diff --git a/Cargo.lock b/Cargo.lock index f74a0941..a42f86ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,15 +12,6 @@ dependencies = [ "regex", ] -[[package]] -name = "addr2line" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" -dependencies = [ - "gimli", -] - [[package]] name = "adler2" version = "2.0.1" @@ -65,23 +56,51 @@ dependencies = [ [[package]] name = "agave-feature-set" -version = "2.3.10" +version = "2.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a2c365c0245cbb8959de725fc2b44c754b673fdf34c9a7f9d4a25c35a7bf1" +dependencies = [ + "ahash 0.8.12", + "solana-epoch-schedule 2.2.1", + "solana-hash 2.3.0", + "solana-pubkey 2.4.0", + "solana-sha256-hasher 2.3.0", + "solana-svm-feature-set 2.3.13", +] + +[[package]] +name = "agave-feature-set" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98b7122392ed81e9b4569c3c960a557afb9f735719e0bcc9b2c19d0345568f5f" +checksum = "0684f4e5500a461664d83fb42cddd10b66cd9dfca611271306d617c322b7827a" dependencies = [ "ahash 0.8.12", - "solana-epoch-schedule", - "solana-hash", - "solana-pubkey", - "solana-sha256-hasher", - "solana-svm-feature-set", + "solana-epoch-schedule 3.0.0", + "solana-hash 3.1.0", + "solana-pubkey 3.0.0", + "solana-sha256-hasher 3.1.0", + "solana-svm-feature-set 3.1.3", +] + +[[package]] +name = "agave-fs" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eec5c4629a3456f4ec3d2652177c1595ba80927d0a0a1e4e17c7858963674f0" +dependencies = [ + "agave-io-uring", + "io-uring", + "libc", + "log", + "slab", + "smallvec", ] [[package]] name = "agave-io-uring" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9a7a05ffb5fb07af5b5ce53c8206f881b118ac3d7aee52d6a3e0329b6d861a" +checksum = "258c297190e6da4ec3c334bbf04732749692660d3b93f20930e592d7b811993d" dependencies = [ "io-uring", "libc", @@ -90,53 +109,163 @@ dependencies = [ "smallvec", ] +[[package]] +name = "agave-logger" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e65de0fcc4e60bfc95caeabae773c4082a4cf768a47326e2ad9f07532e8cea1d" +dependencies = [ + "env_logger", + "libc", + "log", + "signal-hook", +] + [[package]] name = "agave-precompiles" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3566178d1d98fbd1a053422e3c5c6c4154cbe03ca090425b84f7deaecca985" +checksum = "28701885014b411b29369a0061b8af72eab5bd2280e40f399ceb33e52a1b0d68" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", "bincode", "digest 0.10.7", - "ed25519-dalek", + "ed25519-dalek 1.0.1", "libsecp256k1", "openssl", "sha3", "solana-ed25519-program", - "solana-message", + "solana-message 3.0.1", "solana-precompile-error", - "solana-pubkey", - "solana-sdk-ids", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", "solana-secp256k1-program", "solana-secp256r1-program", ] [[package]] name = "agave-reserved-account-keys" -version = "2.3.10" +version = "2.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8289c8a8a2ef5aa10ce49a070f360f4e035ee3410b8d8f3580fb39d8cf042581" +dependencies = [ + "agave-feature-set 2.3.13", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", +] + +[[package]] +name = "agave-reserved-account-keys" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25afbc01a53fa48ef788618d924ff403bceac3740c186257eec76bf5ffdf17cd" +dependencies = [ + "agave-feature-set 3.1.3", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", +] + +[[package]] +name = "agave-snapshots" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb9e9323670f5f83063fb645f133404c57d1eeebef35eea029d23ec745987083" +dependencies = [ + "agave-fs", + "bincode", + "bzip2", + "crossbeam-channel", + "log", + "lz4", + "rand 0.8.5", + "regex", + "semver", + "solana-accounts-db", + "solana-clock 3.0.0", + "solana-genesis-config", + "solana-hash 3.1.0", + "solana-lattice-hash", + "solana-measure", + "solana-metrics", + "strum 0.24.1", + "symlink", + "tar", + "tempfile", + "thiserror 2.0.17", + "zstd", +] + +[[package]] +name = "agave-syscalls" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44941ddf7f11f385b8a10a95bdbe8026909938a4932f23ccd2c78fc2a480a8d7" +checksum = "776409f32d798250aa57e4a0e8e19cc3b5c477fbce2c3ae309f69160470f3e2b" dependencies = [ - "agave-feature-set", - "solana-pubkey", - "solana-sdk-ids", + "bincode", + "libsecp256k1", + "num-traits", + "solana-account 3.2.0", + "solana-account-info 3.1.0", + "solana-big-mod-exp 3.0.0", + "solana-blake3-hasher 3.1.0", + "solana-bn254", + "solana-clock 3.0.0", + "solana-cpi 3.1.0", + "solana-curve25519 3.1.3", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-keccak-hasher 3.1.0", + "solana-loader-v3-interface 6.1.0", + "solana-poseidon", + "solana-program-entrypoint 3.1.1", + "solana-program-runtime", + "solana-pubkey 3.0.0", + "solana-sbpf", + "solana-sdk-ids 3.1.0", + "solana-secp256k1-recover 3.1.0", + "solana-sha256-hasher 3.1.0", + "solana-stable-layout 3.0.0", + "solana-stake-interface 2.0.1", + "solana-svm-callback", + "solana-svm-feature-set 3.1.3", + "solana-svm-log-collector", + "solana-svm-measure", + "solana-svm-timings", + "solana-svm-type-overrides", + "solana-sysvar 3.1.1", + "solana-sysvar-id 3.1.0", + "solana-transaction-context 3.1.3", + "thiserror 2.0.17", ] [[package]] name = "agave-transaction-view" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439207b160be5f9e60382a4988edf85cff360af3d3437127258a5aa40d7e9dc1" +checksum = "92e9045a5df9d3c4d2b653edc5a90217614a74c9b461cf01e1759ab3d99225c4" dependencies = [ - "solana-hash", - "solana-message", + "solana-hash 3.1.0", + "solana-message 3.0.1", "solana-packet", - "solana-pubkey", - "solana-sdk-ids", - "solana-short-vec", - "solana-signature", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-short-vec 3.1.0", + "solana-signature 3.1.0", "solana-svm-transaction", + "solana-transaction-context 3.1.3", +] + +[[package]] +name = "agave-votor-messages" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06742ec361aac1cff6dd1133b218f0edf60462de4b5b1a0cacf3f831ff1c726" +dependencies = [ + "agave-logger", + "serde", + "solana-bls-signatures", + "solana-clock 3.0.0", + "solana-hash 3.1.0", ] [[package]] @@ -157,7 +286,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom 0.3.3", + "getrandom 0.3.4", "once_cell", "version_check", "zerocopy", @@ -165,9 +294,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] @@ -204,9 +333,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" dependencies = [ "anstyle", "anstyle-parse", @@ -219,9 +348,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" [[package]] name = "anstyle-parse" @@ -234,22 +363,22 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.10" +version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -269,7 +398,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -284,9 +413,20 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" dependencies = [ - "ark-ec", - "ark-ff", - "ark-std", + "ark-ec 0.4.2", + "ark-ff 0.4.2", + "ark-std 0.4.0", +] + +[[package]] +name = "ark-bn254" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d69eab57e8d2663efa5c63135b2af4f396d66424f88954c21104125ab6b3e6bc" +dependencies = [ + "ark-ec 0.5.0", + "ark-ff 0.5.0", + "ark-std 0.5.0", ] [[package]] @@ -295,10 +435,10 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" dependencies = [ - "ark-ff", - "ark-poly", - "ark-serialize", - "ark-std", + "ark-ff 0.4.2", + "ark-poly 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", "derivative", "hashbrown 0.13.2", "itertools 0.10.5", @@ -306,16 +446,37 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ark-ec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d68f2d516162846c1238e755a7c4d131b892b70cc70c471a8e3ca3ed818fce" +dependencies = [ + "ahash 0.8.12", + "ark-ff 0.5.0", + "ark-poly 0.5.0", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "educe", + "fnv", + "hashbrown 0.15.2", + "itertools 0.13.0", + "num-bigint 0.4.6", + "num-integer", + "num-traits", + "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", - "ark-ff-macros", - "ark-serialize", - "ark-std", + "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", @@ -326,6 +487,26 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ark-ff" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a177aba0ed1e0fbb62aa9f6d0502e9b46dad8c2eab04c14258a1212d2557ea70" +dependencies = [ + "ark-ff-asm 0.5.0", + "ark-ff-macros 0.5.0", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "arrayvec", + "digest 0.10.7", + "educe", + "itertools 0.13.0", + "num-bigint 0.4.6", + "num-traits", + "paste", + "zeroize", +] + [[package]] name = "ark-ff-asm" version = "0.4.2" @@ -336,6 +517,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-ff-asm" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" +dependencies = [ + "quote", + "syn 2.0.111", +] + [[package]] name = "ark-ff-macros" version = "0.4.2" @@ -349,27 +540,68 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-ff-macros" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3" +dependencies = [ + "num-bigint 0.4.6", + "num-traits", + "proc-macro2", + "quote", + "syn 2.0.111", +] + [[package]] name = "ark-poly" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" dependencies = [ - "ark-ff", - "ark-serialize", - "ark-std", + "ark-ff 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", "derivative", "hashbrown 0.13.2", ] +[[package]] +name = "ark-poly" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579305839da207f02b89cd1679e50e67b4331e2f9294a57693e5051b7703fe27" +dependencies = [ + "ahash 0.8.12", + "ark-ff 0.5.0", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "educe", + "fnv", + "hashbrown 0.15.2", +] + [[package]] name = "ark-serialize" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ - "ark-serialize-derive", - "ark-std", + "ark-serialize-derive 0.4.2", + "ark-std 0.4.0", + "digest 0.10.7", + "num-bigint 0.4.6", +] + +[[package]] +name = "ark-serialize" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f4d068aaf107ebcd7dfb52bc748f8030e0fc930ac8e360146ca54c1203088f7" +dependencies = [ + "ark-serialize-derive 0.5.0", + "ark-std 0.5.0", + "arrayvec", "digest 0.10.7", "num-bigint 0.4.6", ] @@ -385,6 +617,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-serialize-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", +] + [[package]] name = "ark-std" version = "0.4.0" @@ -395,6 +638,16 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "ark-std" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246a225cc6131e9ee4f24619af0f19d67761fff15d7ccc22e42b80846e69449a" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + [[package]] name = "arrayref" version = "0.3.9" @@ -458,22 +711,11 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener 2.5.3", - "futures-core", -] - [[package]] name = "async-compression" -version = "0.4.32" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a89bce6054c720275ac2432fbba080a66a2106a44a1b804553930ca6909f4e0" +checksum = "0e86f6d3dc9dc4352edeea6b8e499e13e3f5dc3b964d7ca5fd411415a3498473" dependencies = [ "compression-codecs", "compression-core", @@ -488,7 +730,7 @@ version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fd03604047cee9b6ce9de9f70c6cd540a0520c813cbd49bae61f33ab80ed1dc" dependencies = [ - "event-listener 5.4.1", + "event-listener", "event-listener-strategy", "pin-project-lite", ] @@ -512,7 +754,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -523,7 +765,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -532,17 +774,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.5.0" @@ -560,9 +791,9 @@ dependencies = [ [[package]] name = "aws-lc-rs" -version = "1.14.1" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879b6c89592deb404ba4dc0ae6b58ffd1795c78991cbb5b8bc441c48a070440d" +checksum = "6b5ce75405893cd713f9ab8e297d8e438f624dde7d706108285f7e17a25a180f" dependencies = [ "aws-lc-sys", "zeroize", @@ -570,16 +801,14 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.32.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee74396bee4da70c2e27cf94762714c911725efe69d9e2672f998512a67a4ce4" +checksum = "179c3777a8b5e70e90ea426114ffc565b2c1a9f82f6c4a0c5a34aa6ef5e781b6" dependencies = [ - "bindgen", "cc", "cmake", "dunce", "fs_extra", - "libloading", ] [[package]] @@ -620,7 +849,7 @@ dependencies = [ "axum-core 0.4.5", "bytes", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", "itoa", @@ -639,14 +868,14 @@ dependencies = [ [[package]] name = "axum" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" +checksum = "5b098575ebe77cb6d14fc7f32749631a6e44edbef6b796f89b020e99ba20d425" dependencies = [ - "axum-core 0.5.2", + "axum-core 0.5.5", "bytes", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", "itoa", @@ -655,8 +884,7 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", - "rustversion", - "serde", + "serde_core", "sync_wrapper 1.0.2", "tower 0.5.2", "tower-layer", @@ -689,7 +917,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", "mime", @@ -702,18 +930,17 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.5.2" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" +checksum = "59446ce19cd142f8833f856eb31f3eb097812d1479ab224f54d72428ca21ea22" dependencies = [ "bytes", "futures-core", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", "mime", "pin-project-lite", - "rustversion", "sync_wrapper 1.0.2", "tower-layer", "tower-service", @@ -734,19 +961,10 @@ dependencies = [ ] [[package]] -name = "backtrace" -version = "0.3.76" +name = "base16ct" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-link 0.2.0", -] +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" @@ -772,6 +990,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" + [[package]] name = "bincode" version = "1.3.3" @@ -787,18 +1011,16 @@ version = "0.72.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "cexpr", "clang-sys", "itertools 0.13.0", - "log", - "prettyplease 0.2.37", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -809,11 +1031,11 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.4" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" dependencies = [ - "serde", + "serde_core", ] [[package]] @@ -825,6 +1047,18 @@ dependencies = [ "typenum", ] +[[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" @@ -857,6 +1091,34 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blst" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcdb4c7013139a150f9fc55d123186dbfaba0d912817466282c73ac49e71fb45" +dependencies = [ + "cc", + "glob", + "threadpool", + "zeroize", +] + +[[package]] +name = "blstrs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a8a8ed6fefbeef4a8c7b460e4110e12c5e22a5b7cf32621aae6ad650c4dcf29" +dependencies = [ + "blst", + "byte-slice-cast", + "ff", + "group", + "pairing", + "rand_core 0.6.4", + "serde", + "subtle", +] + [[package]] name = "borsh" version = "0.10.4" @@ -869,11 +1131,11 @@ dependencies = [ [[package]] name = "borsh" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8646f98db542e39fc66e68a20b2144f6a732636df7c2354e74645faaa433ce" +checksum = "d1da5ab77c1437701eeff7c88d968729e7766172279eab0676857b3d63af7a6f" dependencies = [ - "borsh-derive 1.5.7", + "borsh-derive 1.6.0", "cfg_aliases", ] @@ -892,15 +1154,15 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd1d3c0c2f5833f22386f252fe8ed005c7f59fdcddeef025c01b4c3b9fd9ac3" +checksum = "0686c856aa6aac0c4498f936d7d6a02df690f614c03e4d906d1018062b5c5e2c" dependencies = [ "once_cell", "proc-macro-crate 3.4.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -971,24 +1233,30 @@ 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.2" +version = "1.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3995eaeebcdf32f91f980d360f78732ddc061097ab4e39991ae7a6ace9194677" +checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.10.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f154e572231cb6ba2bd1176980827e3d5dc04cc183a75dea38109fbdd672d29" +checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -999,18 +1267,18 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" dependencies = [ "serde", ] [[package]] name = "bytesize" -version = "2.1.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5c434ae3cf0089ca203e9019ebe529c47ff45cefe8af7c85ecb734ef541822f" +checksum = "6bd91ee7b2422bcb158d90ef4d14f75ef67f340943fc4149891dcce8f8b972a3" dependencies = [ "serde_core", ] @@ -1037,12 +1305,11 @@ dependencies = [ [[package]] name = "caps" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190baaad529bcfbde9e1a19022c42781bdb6ff9de25721abdb8fd98c0807730b" +checksum = "fd1ddba47aba30b6a889298ad0109c3b8dcb0e8fc993b459daa7067d46f865e0" dependencies = [ "libc", - "thiserror 1.0.69", ] [[package]] @@ -1057,9 +1324,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.39" +version = "1.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1354349954c6fc9cb0deab020f27f783cf0b604e8bb754dc4658ecf0d29c35f" +checksum = "c481bdbf0ed3b892f6f806287d72acd515b352a4ec27a208489b8c1bc839633a" dependencies = [ "find-msvc-tools", "jobserver", @@ -1084,9 +1351,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" @@ -1102,7 +1369,7 @@ checksum = "45565fc9416b9896014f5732ac776f810ee53a66730c17e4020c3ec064a8f88f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -1116,7 +1383,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link 0.2.0", + "windows-link", ] [[package]] @@ -1146,14 +1413,13 @@ checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", - "libloading", ] [[package]] name = "clap" -version = "4.5.48" +version = "4.5.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae" +checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" dependencies = [ "clap_builder", "clap_derive", @@ -1161,9 +1427,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.48" +version = "4.5.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9" +checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" dependencies = [ "anstream", "anstyle", @@ -1174,21 +1440,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.47" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] name = "clap_lex" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cmake" @@ -1201,22 +1467,22 @@ dependencies = [ [[package]] name = "codama-errors" -version = "0.6.1" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69a7b7b16f9b57be0ca6ea44b40f5e6b4aeedcd30bfd33d2998721dd9c2d807f" +checksum = "c3e7948cb55c07d184959bd3f74689b91e9c756e7b6cb0ae49292e701517607f" dependencies = [ "cargo_toml", "proc-macro2", "serde_json", - "syn 2.0.106", - "thiserror 2.0.16", + "syn 2.0.111", + "thiserror 2.0.17", ] [[package]] name = "codama-nodes" -version = "0.6.1" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3194539453ecd51fb72c8440e3aa4a84352a41d61dea8f37d1d5f2428d0419" +checksum = "3cc5c97c1cd85a08ae0b3e262544f406f134578c26e4ebef29e6f99ee3fee1b1" dependencies = [ "codama-errors", "codama-nodes-derive", @@ -1227,29 +1493,29 @@ dependencies = [ [[package]] name = "codama-nodes-derive" -version = "0.6.1" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c138c3a7ed16bdcea33cb7b708a650b575464d86077a558c3b6ce091d4ec7455" +checksum = "f1dc6bf1ad55332c331151cc849986fbc26bd7c01c3e0b190b422e4432a46dc6" dependencies = [ "codama-errors", "codama-syn-helpers", "derive_more", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] name = "codama-syn-helpers" -version = "0.6.1" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ce2a27f09caf6476c857c809718fac9213ce4124ad0002f1f12f2964681ccc" +checksum = "4b48abf111be2d4bdc3d2294234d1a307b4111e69945779824d3bd20ba22f100" dependencies = [ "codama-errors", "derive_more", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -1283,9 +1549,9 @@ dependencies = [ [[package]] name = "compression-codecs" -version = "0.4.31" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8a506ec4b81c460798f572caead636d57d3d7e940f998160f52bd254bf2d23" +checksum = "302266479cb963552d11bd042013a58ef1adc56768016c8b82b4199488f2d4ad" dependencies = [ "brotli", "compression-core", @@ -1295,9 +1561,9 @@ dependencies = [ [[package]] name = "compression-core" -version = "0.4.29" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e47641d3deaf41fb1538ac1f54735925e275eaf3bf4d55c81b137fba797e5cbb" +checksum = "75984efb6ed102a0d42db99afb6c1948f0380d1d91808d5529916e6c08b49d8d" [[package]] name = "concurrent-queue" @@ -1321,6 +1587,19 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "console" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b430743a6eb14e9764d4260d4c0d8123087d504eeb9c48f2b2a5e810dd369df4" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "unicode-width", + "windows-sys 0.61.2", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -1341,6 +1620,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "constant_time_eq" version = "0.3.1" @@ -1453,11 +1738,23 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "rand_core 0.6.4", @@ -1522,7 +1819,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -1546,7 +1843,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -1557,7 +1854,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -1570,8 +1867,9 @@ dependencies = [ "hashbrown 0.14.5", "lock_api", "once_cell", - "parking_lot_core 0.9.11", + "parking_lot_core 0.9.12", "rayon", + "serde", ] [[package]] @@ -1580,6 +1878,16 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "der-parser" version = "8.2.0" @@ -1596,9 +1904,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071" +checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" dependencies = [ "powerfmt", "serde_core", @@ -1638,7 +1946,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -1663,6 +1971,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] @@ -1684,7 +1993,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -1704,7 +2013,7 @@ checksum = "c32e3e8ab1b6ee2e06418f40f94f315d82b35157eb1d2322a6e20a4b15106b84" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -1727,7 +2036,7 @@ checksum = "a6cbae11b3de8fce2a456e8ea3dada226b35fe791f0dc1d360c0941f0bb681f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -1754,13 +2063,37 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abe71d579d1812060163dff96056261deb5bf6729b100fa2e36a68b9649ba3d3" +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature 2.2.0", + "spki", +] + [[package]] name = "ed25519" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature", + "signature 1.6.4", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature 2.2.0", ] [[package]] @@ -1770,31 +2103,77 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek 3.2.0", - "ed25519", + "ed25519 1.5.3", "rand 0.7.3", "serde", "sha2 0.9.9", "zeroize", ] +[[package]] +name = "ed25519-dalek" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" +dependencies = [ + "curve25519-dalek 4.1.3", + "ed25519 2.2.3", + "rand_core 0.6.4", + "serde", + "sha2 0.10.9", + "subtle", + "zeroize", +] + [[package]] name = "ed25519-dalek-bip32" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d2be62a4061b872c8c0873ee4fc6f101ce7b889d039f019c5fa2af471a59908" +checksum = "6b49a684b133c4980d7ee783936af771516011c8cd15f429dbda77245e282f03" dependencies = [ "derivation-path", - "ed25519-dalek", + "ed25519-dalek 2.2.0", "hmac 0.12.1", "sha2 0.10.9", ] +[[package]] +name = "educe" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 2.0.111", +] + [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "encode_unicode" version = "1.0.0" @@ -1827,20 +2206,50 @@ checksum = "685adfa4d6f3d765a26bc5dbc936577de9abf756c1feeb3089b01dd395034842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] -name = "env_logger" -version = "0.9.3" +name = "enum-ordinalize" +version = "4.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a1091a7bb1f8f2c4b28f1fe2cef4980ca2d410a3d727d67ecc3178c9b0800f0" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca9601fb2d62598ee17836250842873a413586e5d7ed88b356e38ddbb0ec631" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "env_filter" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" dependencies = [ - "atty", - "humantime", "log", "regex", - "termcolor", +] + +[[package]] +name = "env_logger" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", ] [[package]] @@ -1856,15 +2265,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - [[package]] name = "event-listener" version = "5.4.1" @@ -1882,7 +2285,7 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" dependencies = [ - "event-listener 5.4.1", + "event-listener", "pin-project-lite", ] @@ -1901,7 +2304,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18c1ddb9231d8554c2d6bdf4cfaabf0c59251658c68b6c95cd52dd0c513a912a" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", "libm", "rand 0.9.2", "siphasher 1.0.1", @@ -1919,6 +2322,17 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" +[[package]] +name = "ff" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +dependencies = [ + "bitvec", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "fiat-crypto" version = "0.2.9" @@ -1939,9 +2353,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "five8" @@ -1949,7 +2363,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75b8549488b4715defcb0d8a8a1c1c76a80661b5fa106b4ca0e7fce59d7d875" dependencies = [ - "five8_core", + "five8_core 0.1.2", +] + +[[package]] +name = "five8" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f76610e969fa1784327ded240f1e28a3fd9520c9cec93b636fcf62dd37f772" +dependencies = [ + "five8_core 1.0.0", ] [[package]] @@ -1958,7 +2381,16 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26dec3da8bc3ef08f2c04f61eab298c3ab334523e55f076354d6d6f613799a7b" dependencies = [ - "five8_core", + "five8_core 0.1.2", +] + +[[package]] +name = "five8_const" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a0f1728185f277989ca573a402716ae0beaaea3f76a8ff87ef9dd8fb19436c5" +dependencies = [ + "five8_core 1.0.0", ] [[package]] @@ -1967,6 +2399,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2551bf44bc5f776c15044b9b94153a00198be06743e262afaaa61f11ac7523a5" +[[package]] +name = "five8_core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "059c31d7d36c43fe39d89e55711858b4da8be7eb6dabac23c7289b1a19489406" + [[package]] name = "fixedbitset" version = "0.4.2" @@ -1981,9 +2419,9 @@ checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "flate2" -version = "1.1.2" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb" dependencies = [ "crc32fast", "miniz_oxide", @@ -2046,6 +2484,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures" version = "0.3.31" @@ -2102,7 +2546,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -2158,6 +2602,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -2177,10 +2622,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -2198,24 +2641,18 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", "js-sys", "libc", "r-efi", - "wasi 0.14.7+wasi-0.2.4", + "wasip2", "wasm-bindgen", ] -[[package]] -name = "gimli" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" - [[package]] name = "glob" version = "0.3.3" @@ -2253,7 +2690,7 @@ dependencies = [ "futures-timer", "no-std-compat", "nonzero_ext", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "portable-atomic", "quanta", "rand 0.8.5", @@ -2261,6 +2698,19 @@ dependencies = [ "spinning_top", ] +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand 0.8.5", + "rand_core 0.6.4", + "rand_xorshift", + "subtle", +] + [[package]] name = "h2" version = "0.3.27" @@ -2273,7 +2723,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.11.4", + "indexmap 2.12.1", "slab", "tokio", "tokio-util", @@ -2291,8 +2741,8 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.3.1", - "indexmap 2.11.4", + "http 1.4.0", + "indexmap 2.12.1", "slab", "tokio", "tokio-util", @@ -2334,9 +2784,9 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "equivalent", @@ -2345,9 +2795,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" [[package]] name = "headers" @@ -2385,15 +2835,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.5.2" @@ -2448,7 +2889,7 @@ version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" dependencies = [ - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -2464,12 +2905,11 @@ dependencies = [ [[package]] name = "http" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" dependencies = [ "bytes", - "fnv", "itoa", ] @@ -2491,7 +2931,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.3.1", + "http 1.4.0", ] [[package]] @@ -2502,7 +2942,7 @@ checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", "futures-core", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "pin-project-lite", ] @@ -2519,12 +2959,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424" - [[package]] name = "hyper" version = "0.14.32" @@ -2551,16 +2985,16 @@ dependencies = [ [[package]] name = "hyper" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" dependencies = [ "atomic-waker", "bytes", "futures-channel", "futures-core", "h2 0.4.12", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "httparse", "httpdate", @@ -2590,21 +3024,35 @@ dependencies = [ "tower-service", ] +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper 0.14.32", + "rustls 0.21.12", + "tokio", + "tokio-rustls 0.24.1", +] + [[package]] name = "hyper-rustls" version = "0.27.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" dependencies = [ - "http 1.3.1", - "hyper 1.7.0", + "http 1.4.0", + "hyper 1.8.1", "hyper-util", - "rustls 0.23.32", + "rustls 0.23.35", "rustls-pki-types", "tokio", "tokio-rustls 0.26.4", "tower-service", - "webpki-roots 1.0.2", + "webpki-roots 1.0.4", ] [[package]] @@ -2625,7 +3073,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.7.0", + "hyper 1.8.1", "hyper-util", "pin-project-lite", "tokio", @@ -2653,7 +3101,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.7.0", + "hyper 1.8.1", "hyper-util", "native-tls", "tokio", @@ -2663,23 +3111,23 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" +checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56" dependencies = [ "base64 0.22.1", "bytes", "futures-channel", "futures-core", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", - "hyper 1.7.0", + "hyper 1.8.1", "ipnet", "libc", "percent-encoding", "pin-project-lite", - "socket2 0.6.0", + "socket2 0.6.1", "system-configuration 0.6.1", "tokio", "tower-service", @@ -2713,9 +3161,9 @@ dependencies = [ [[package]] name = "icu_collections" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" dependencies = [ "displaydoc", "potential_utf", @@ -2726,9 +3174,9 @@ dependencies = [ [[package]] name = "icu_locale_core" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" dependencies = [ "displaydoc", "litemap", @@ -2739,11 +3187,10 @@ dependencies = [ [[package]] name = "icu_normalizer" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" dependencies = [ - "displaydoc", "icu_collections", "icu_normalizer_data", "icu_properties", @@ -2754,42 +3201,38 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" [[package]] name = "icu_properties" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" dependencies = [ - "displaydoc", "icu_collections", "icu_locale_core", "icu_properties_data", "icu_provider", - "potential_utf", "zerotrie", "zerovec", ] [[package]] name = "icu_properties_data" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" +checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" [[package]] name = "icu_provider" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" dependencies = [ "displaydoc", "icu_locale_core", - "stable_deref_trait", - "tinystr", "writeable", "yoke", "zerofrom", @@ -2878,12 +3321,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.11.4" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" +checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "serde", "serde_core", ] @@ -2894,13 +3337,26 @@ version = "0.17.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" dependencies = [ - "console", + "console 0.15.11", "number_prefix", "portable-atomic", "unicode-width", "web-time", ] +[[package]] +name = "indicatif" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9375e112e4b463ec1b1c6c011953545c65a30164fbab5b581df32b3abf0dcb88" +dependencies = [ + "console 0.16.1", + "portable-atomic", + "unicode-width", + "unit-prefix", + "web-time", +] + [[package]] name = "inout" version = "0.1.4" @@ -2921,11 +3377,11 @@ dependencies = [ [[package]] name = "io-uring" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b" +checksum = "fdd7bddefd0a8833b88a4b68f90dae22c7450d11b354198baee3874fd811b344" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "cfg-if", "libc", ] @@ -2938,9 +3394,9 @@ checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "iri-string" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +checksum = "4f867b9d1d896b67beb18518eda36fdb77a32ea590de864f1325b294a6d14397" dependencies = [ "memchr", "serde", @@ -2948,9 +3404,9 @@ dependencies = [ [[package]] name = "is_terminal_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "itertools" @@ -2994,6 +3450,30 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jiff" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", +] + [[package]] name = "jni" version = "0.21.1" @@ -3022,15 +3502,15 @@ version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", "libc", ] [[package]] name = "js-sys" -version = "0.3.81" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" dependencies = [ "once_cell", "wasm-bindgen", @@ -3051,6 +3531,20 @@ dependencies = [ "serde_json", ] +[[package]] +name = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.9", + "signature 2.2.0", +] + [[package]] name = "kaigan" version = "0.2.6" @@ -3076,7 +3570,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a35523c6dfa972e1fd19132ef647eff4360a6546c6271807e1327ca6e8797f96" dependencies = [ - "hashbrown 0.15.5", + "hashbrown 0.15.2", ] [[package]] @@ -3087,19 +3581,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.176" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" - -[[package]] -name = "libloading" -version = "0.8.8" +version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" -dependencies = [ - "cfg-if", - "windows-targets 0.53.4", -] +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libm" @@ -3113,9 +3597,9 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "libc", - "redox_syscall 0.5.17", + "redox_syscall 0.5.18", ] [[package]] @@ -3197,8 +3681,20 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c9a85a9752c549ceb7578064b4ed891179d20acd85f27318573b64d2d7ee7ee" dependencies = [ - "ark-bn254", - "ark-ff", + "ark-bn254 0.4.0", + "ark-ff 0.4.2", + "num-bigint 0.4.6", + "thiserror 1.0.69", +] + +[[package]] +name = "light-poseidon" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47a1ccadd0bb5a32c196da536fd72c59183de24a055f6bf0513bf845fefab862" +dependencies = [ + "ark-bn254 0.5.0", + "ark-ff 0.5.0", "num-bigint 0.4.6", "thiserror 1.0.69", ] @@ -3217,17 +3713,16 @@ checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] name = "litemap" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" [[package]] name = "lock_api" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] @@ -3309,9 +3804,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843a98750cd611cc2965a8213b53b43e715f13c37a9e096c6408e69990961db7" +checksum = "744133e4a0e0a658e1374cf3bf8e415c4052a15a111acd372764c55b4177d490" dependencies = [ "libc", ] @@ -3356,17 +3851,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", + "simd-adler32", ] [[package]] name = "mio" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" dependencies = [ "libc", "wasi 0.11.1+wasi-snapshot-preview1", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3398,9 +3894,9 @@ dependencies = [ [[package]] name = "modular-bitfield" -version = "0.11.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a53d79ba8304ac1c4f9eb3b9d281f21f7be9d4626f72ce7df4ad8fbde4f38a74" +checksum = "47a586be3f2f7e70a9d302c621447dba612d42069f3901258b2cf8ce96d855b1" dependencies = [ "modular-bitfield-impl", "static_assertions", @@ -3408,13 +3904,13 @@ dependencies = [ [[package]] name = "modular-bitfield-impl" -version = "0.11.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a7d5f7076603ebc68de2dc6a650ec331a062a13abaa346975be747bbfa4b789" +checksum = "8462d3cc74eaf4194f6c0bd7b18c6f3fa6293297f4bdb60fe4c4b022ea366e12" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.111", ] [[package]] @@ -3452,7 +3948,7 @@ version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "cfg-if", "cfg_aliases", "libc", @@ -3489,11 +3985,11 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "nu-ansi-term" -version = "0.50.1" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -3555,7 +4051,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -3605,15 +4101,15 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ - "hermit-abi 0.5.2", + "hermit-abi", "libc", ] [[package]] name = "num_enum" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a" +checksum = "b1207a7e20ad57b847bbddc6776b968420d38292bbfe2089accff5e19e82454c" dependencies = [ "num_enum_derive", "rustversion", @@ -3621,14 +4117,14 @@ dependencies = [ [[package]] name = "num_enum_derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" +checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7" dependencies = [ "proc-macro-crate 3.4.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -3637,15 +4133,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" -[[package]] -name = "object" -version = "0.37.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" -dependencies = [ - "memchr", -] - [[package]] name = "oid-registry" version = "0.6.1" @@ -3663,9 +4150,9 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "once_cell_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "opaque-debug" @@ -3675,11 +4162,11 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.73" +version = "0.10.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "cfg-if", "foreign-types", "libc", @@ -3696,7 +4183,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -3716,9 +4203,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.109" +version = "0.9.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" dependencies = [ "cc", "libc", @@ -3751,7 +4238,7 @@ dependencies = [ "futures-sink", "js-sys", "pin-project-lite", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", ] @@ -3775,9 +4262,9 @@ checksum = "46d7ab32b827b5b495bd90fa95a6cb65ccc293555dcc3199ae2937d2d237c8ed" dependencies = [ "async-trait", "bytes", - "http 1.3.1", + "http 1.4.0", "opentelemetry 0.29.1", - "reqwest 0.12.23", + "reqwest 0.12.24", "tracing", ] @@ -3788,14 +4275,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d899720fe06916ccba71c01d04ecd77312734e2de3467fd30d9d580c8ce85656" dependencies = [ "futures-core", - "http 1.3.1", + "http 1.4.0", "opentelemetry 0.29.1", "opentelemetry-http", "opentelemetry-proto", "opentelemetry_sdk", "prost 0.13.5", - "reqwest 0.12.23", - "thiserror 2.0.16", + "reqwest 0.12.24", + "thiserror 2.0.17", "tokio", "tonic 0.12.3", "tracing", @@ -3839,12 +4326,21 @@ dependencies = [ "percent-encoding", "rand 0.9.2", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tokio-stream", "tracing", ] +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group", +] + [[package]] name = "parking" version = "2.2.1" @@ -3864,12 +4360,12 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", - "parking_lot_core 0.9.11", + "parking_lot_core 0.9.12", ] [[package]] @@ -3888,15 +4384,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.17", + "redox_syscall 0.5.18", "smallvec", - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -3945,7 +4441,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset 0.4.2", - "indexmap 2.11.4", + "indexmap 2.12.1", ] [[package]] @@ -3955,7 +4451,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" dependencies = [ "fixedbitset 0.5.7", - "indexmap 2.11.4", + "indexmap 2.12.1", ] [[package]] @@ -3975,7 +4471,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -3990,6 +4486,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.32" @@ -4014,11 +4520,20 @@ version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "potential_utf" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84df19adbe5b5a0782edcab45899906947ab039ccf4573713735ee7de1e6b08a" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" dependencies = [ "zerovec", ] @@ -4085,7 +4600,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -4103,7 +4618,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "toml_edit 0.23.6", + "toml_edit 0.23.7", ] [[package]] @@ -4129,9 +4644,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] @@ -4147,10 +4662,10 @@ dependencies = [ "lazy_static", "libc", "memchr", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "protobuf", - "reqwest 0.12.23", - "thiserror 2.0.16", + "reqwest 0.12.24", + "thiserror 2.0.17", ] [[package]] @@ -4221,7 +4736,7 @@ dependencies = [ "prost 0.13.5", "prost-types 0.13.5", "regex", - "syn 2.0.106", + "syn 2.0.111", "tempfile", ] @@ -4243,7 +4758,7 @@ dependencies = [ "pulldown-cmark", "pulldown-cmark-to-cmark", "regex", - "syn 2.0.106", + "syn 2.0.111", "tempfile", ] @@ -4270,7 +4785,7 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -4283,7 +4798,7 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -4348,16 +4863,16 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e8bbe1a966bd2f362681a44f6edce3c2310ac21e4d5067a6e7ec396297a6ea0" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "memchr", "unicase", ] [[package]] name = "pulldown-cmark-to-cmark" -version = "21.0.0" +version = "21.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5b6a0769a491a08b31ea5c62494a8f144ee0987d86d670a8af4df1e1b7cde75" +checksum = "8246feae3db61428fd0bb94285c690b460e4517d83152377543ca802357785f1" dependencies = [ "pulldown-cmark", ] @@ -4379,7 +4894,7 @@ checksum = "9e2e25ee72f5b24d773cae88422baddefff7714f97aab68d96fe2b6fc4a28fb2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -4409,9 +4924,9 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.32", - "socket2 0.6.0", - "thiserror 2.0.16", + "rustls 0.23.35", + "socket2 0.6.1", + "thiserror 2.0.17", "tokio", "tracing", "web-time", @@ -4425,16 +4940,16 @@ checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" dependencies = [ "bytes", "fastbloom", - "getrandom 0.3.3", + "getrandom 0.3.4", "lru-slab", "rand 0.9.2", "ring", "rustc-hash", - "rustls 0.23.32", + "rustls 0.23.35", "rustls-pki-types", "rustls-platform-verifier", "slab", - "thiserror 2.0.16", + "thiserror 2.0.17", "tinyvec", "tracing", "web-time", @@ -4449,16 +4964,16 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.6.0", + "socket2 0.6.1", "tracing", "windows-sys 0.60.2", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] @@ -4469,6 +4984,12 @@ 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" @@ -4557,7 +5078,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", ] [[package]] @@ -4569,6 +5090,15 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "rand_xoshiro" version = "0.6.0" @@ -4584,7 +5114,7 @@ version = "11.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", ] [[package]] @@ -4618,11 +5148,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", ] [[package]] @@ -4642,29 +5172,29 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] name = "regex" -version = "1.11.3" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b5288124840bee7b386bc413c487869b360b2b4ec421ea56425128692f2a82c" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", @@ -4674,9 +5204,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.11" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833eb9ce86d40ef33cb1306d8accf7bc8ec2bfea4355cbdebb3df68b40925cad" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", @@ -4685,9 +5215,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "reqwest" @@ -4695,6 +5225,7 @@ version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ + "async-compression", "base64 0.21.7", "bytes", "encoding_rs", @@ -4704,6 +5235,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.32", + "hyper-rustls 0.24.2", "hyper-tls 0.5.0", "ipnet", "js-sys", @@ -4713,6 +5245,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls 0.21.12", "rustls-pemfile", "serde", "serde_json", @@ -4721,19 +5254,22 @@ dependencies = [ "system-configuration 0.5.1", "tokio", "tokio-native-tls", + "tokio-rustls 0.24.1", + "tokio-util", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 0.25.4", "winreg", ] [[package]] name = "reqwest" -version = "0.12.23" +version = "0.12.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d429f34c8092b2d42c7c93cec323bb4adeb7c67698f70839adec842ec10c7ceb" +checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" dependencies = [ "async-compression", "base64 0.22.1", @@ -4743,11 +5279,11 @@ dependencies = [ "futures-core", "futures-util", "h2 0.4.12", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", - "hyper 1.7.0", - "hyper-rustls", + "hyper 1.8.1", + "hyper-rustls 0.27.7", "hyper-tls 0.6.0", "hyper-util", "js-sys", @@ -4757,7 +5293,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.32", + "rustls 0.23.35", "rustls-pki-types", "serde", "serde_json", @@ -4774,7 +5310,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 1.0.2", + "webpki-roots 1.0.4", ] [[package]] @@ -4785,13 +5321,23 @@ checksum = "57f17d28a6e6acfe1733fe24bcd30774d13bffa4b8a22535b4c8c98423088d4e" dependencies = [ "anyhow", "async-trait", - "http 1.3.1", - "reqwest 0.12.23", + "http 1.4.0", + "reqwest 0.12.24", "serde", "thiserror 1.0.69", "tower-service", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac 0.12.1", + "subtle", +] + [[package]] name = "ring" version = "0.17.14" @@ -4852,7 +5398,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "errno", "libc", "linux-raw-sys 0.4.15", @@ -4865,11 +5411,11 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "errno", "libc", "linux-raw-sys 0.11.0", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -4886,30 +5432,30 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.32" +version = "0.23.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3c25631629d034ce7cd9940adc9d45762d46de2b0f57193c4443b92c6d4d40" +checksum = "533f54bc6a7d4f647e46ad909549eda97bf5afc1585190ef692b4286b198bd8f" dependencies = [ "aws-lc-rs", "log", "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.103.6", + "rustls-webpki 0.103.8", "subtle", "zeroize", ] [[package]] name = "rustls-native-certs" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" +checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923" dependencies = [ "openssl-probe", "rustls-pki-types", "schannel", - "security-framework 3.5.0", + "security-framework 3.5.1", ] [[package]] @@ -4923,9 +5469,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.12.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +checksum = "708c0f9d5f54ba0272468c1d306a52c495b31fa155e91bc25371e6df7996908c" dependencies = [ "web-time", "zeroize", @@ -4933,23 +5479,23 @@ dependencies = [ [[package]] name = "rustls-platform-verifier" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be59af91596cac372a6942530653ad0c3a246cdd491aaa9dcaee47f88d67d5a0" +checksum = "1d99feebc72bae7ab76ba994bb5e121b8d83d910ca40b36e0921f53becc41784" dependencies = [ "core-foundation 0.10.1", "core-foundation-sys", "jni", "log", "once_cell", - "rustls 0.23.32", + "rustls 0.23.35", "rustls-native-certs", "rustls-platform-verifier-android", - "rustls-webpki 0.103.6", - "security-framework 3.5.0", + "rustls-webpki 0.103.8", + "security-framework 3.5.1", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -4970,9 +5516,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.6" +version = "0.103.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8572f3c2cb9934231157b45499fc41e1f58c589fdfb81a844ba873265e80f8eb" +checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" dependencies = [ "aws-lc-rs", "ring", @@ -5007,7 +5553,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -5024,9 +5570,9 @@ dependencies = [ [[package]] name = "schemars" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +checksum = "9558e172d4e8533736ba97870c4b2cd63f84b382a3d6eb063da41b91cce17289" dependencies = [ "dyn-clone", "ref-cast", @@ -5050,13 +5596,27 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + [[package]] name = "security-framework" version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -5065,11 +5625,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.5.0" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc198e42d9b7510827939c9a15f5062a0c913f3371d765977e586d2fe6c16f4a" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "core-foundation 0.10.1", "core-foundation-sys", "libc", @@ -5098,14 +5658,14 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5c67b6f14ecc5b86c66fa63d76b5092352678545a8a3cdae80aef5128371910" dependencies = [ - "parking_lot 0.12.4", + "parking_lot 0.12.5", ] [[package]] name = "serde" -version = "1.0.227" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80ece43fc6fbed4eb5392ab50c07334d3e577cbf40997ee896fe7af40bba4245" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ "serde_core", "serde_derive", @@ -5132,22 +5692,22 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.227" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a576275b607a2c86ea29e410193df32bc680303c82f31e275bbfcafe8b33be5" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.227" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e694923b8824cf0e9b382adf0f60d4e05f348f357b38833a3fa5ed7c2ede04" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -5186,19 +5746,18 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.14.1" +version = "3.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c522100790450cf78eeac1507263d0a350d4d5b30df0c8e1fe051a10c22b376e" +checksum = "4fa237f2807440d238e0364a218270b98f767a00d3dada77b1c53ae88940e2e7" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.11.4", + "indexmap 2.12.1", "schemars 0.9.0", - "schemars 1.0.4", - "serde", - "serde_derive", + "schemars 1.1.0", + "serde_core", "serde_json", "serde_with_macros", "time", @@ -5206,14 +5765,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.14.1" +version = "3.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327ada00f7d64abaac1e55a6911e90cf665aa051b9a561c7006c157f4633135e" +checksum = "52a8e3ca0ca629121f70ab50f95249e5a6f925cc0f6ffe8256c45b728875706c" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -5222,7 +5781,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.11.4", + "indexmap 2.12.1", "itoa", "ryu", "serde", @@ -5301,9 +5860,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.6" +version = "1.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad" dependencies = [ "libc", ] @@ -5314,6 +5873,22 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "simpl" version = "0.1.0" @@ -5382,12 +5957,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -5400,19 +5975,37 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-account-info", - "solana-clock", - "solana-instruction", - "solana-pubkey", - "solana-sdk-ids", - "solana-sysvar", + "solana-account-info 2.3.0", + "solana-clock 2.2.2", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", + "solana-sysvar 2.3.0", +] + +[[package]] +name = "solana-account" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "014dcb9293341241dd153b35f89ea906e4170914f4a347a95e7fb07ade47cd6f" +dependencies = [ + "bincode", + "serde", + "serde_bytes", + "serde_derive", + "solana-account-info 3.1.0", + "solana-clock 3.0.0", + "solana-instruction-error", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-sysvar 3.1.1", ] [[package]] name = "solana-account-decoder" -version = "2.3.10" +version = "2.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "902c42492c67e2cb78e839b1af063ed672b3d1ff22311ce07aa073804ca40e53" +checksum = "ba71c97fa4d85ce4a1e0e79044ad0406c419382be598c800202903a7688ce71a" dependencies = [ "Inflector", "base64 0.22.1", @@ -5422,48 +6015,105 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "solana-account", - "solana-account-decoder-client-types", - "solana-address-lookup-table-interface", - "solana-clock", + "solana-account 2.2.1", + "solana-account-decoder-client-types 2.3.13", + "solana-address-lookup-table-interface 2.2.2", + "solana-clock 2.2.2", "solana-config-program-client", - "solana-epoch-schedule", - "solana-fee-calculator", - "solana-instruction", - "solana-loader-v3-interface", - "solana-nonce", - "solana-program-option", - "solana-program-pack", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", - "solana-slot-hashes", - "solana-slot-history", - "solana-stake-interface", - "solana-sysvar", - "solana-vote-interface", - "spl-generic-token", + "solana-epoch-schedule 2.2.1", + "solana-fee-calculator 2.2.1", + "solana-instruction 2.3.3", + "solana-loader-v3-interface 5.0.0", + "solana-nonce 2.2.1", + "solana-program-option 2.2.1", + "solana-program-pack 2.2.1", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-slot-hashes 2.2.1", + "solana-slot-history 2.2.1", + "solana-stake-interface 1.2.1", + "solana-sysvar 2.3.0", + "solana-vote-interface 2.2.6", + "spl-generic-token 1.0.1", "spl-token 8.0.0", "spl-token-2022 8.0.1", - "spl-token-group-interface", + "spl-token-group-interface 0.6.0", "spl-token-metadata-interface 0.7.0", - "thiserror 2.0.16", + "thiserror 2.0.17", + "zstd", +] + +[[package]] +name = "solana-account-decoder" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd3308940576fd279b73156e29ed398ad1c5424fea9e42cca38b2e6bf98d6a2" +dependencies = [ + "Inflector", + "base64 0.22.1", + "bincode", + "bs58", + "bv", + "serde", + "serde_json", + "solana-account 3.2.0", + "solana-account-decoder-client-types 3.1.3", + "solana-address-lookup-table-interface 3.0.0", + "solana-clock 3.0.0", + "solana-config-interface", + "solana-epoch-schedule 3.0.0", + "solana-fee-calculator 3.0.0", + "solana-instruction 3.1.0", + "solana-loader-v3-interface 6.1.0", + "solana-nonce 3.0.0", + "solana-program-option 3.0.0", + "solana-program-pack 3.0.0", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-slot-hashes 3.0.0", + "solana-slot-history 3.0.0", + "solana-stake-interface 2.0.1", + "solana-sysvar 3.1.1", + "solana-vote-interface 4.0.4", + "spl-generic-token 2.0.1", + "spl-token-2022-interface", + "spl-token-group-interface 0.7.1", + "spl-token-interface", + "spl-token-metadata-interface 0.8.0", + "thiserror 2.0.17", "zstd", ] [[package]] name = "solana-account-decoder-client-types" -version = "2.3.10" +version = "2.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39260da5bed46e52afe17c8dc2fd41b7d23a946c18605154033631a334e882ec" +checksum = "5519e8343325b707f17fbed54fcefb325131b692506d0af9e08a539d15e4f8cf" dependencies = [ "base64 0.22.1", "bs58", "serde", "serde_derive", "serde_json", - "solana-account", - "solana-pubkey", + "solana-account 2.2.1", + "solana-pubkey 2.4.0", + "zstd", +] + +[[package]] +name = "solana-account-decoder-client-types" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e57eff73a653c056ac3131926e1072265d7509f90276ea30412ced57e7628f2" +dependencies = [ + "base64 0.22.1", + "bs58", + "serde", + "serde_json", + "solana-account 3.2.0", + "solana-pubkey 3.0.0", "zstd", ] @@ -5475,33 +6125,44 @@ checksum = "c8f5152a288ef1912300fc6efa6c2d1f9bb55d9398eb6c72326360b8063987da" dependencies = [ "bincode", "serde", - "solana-program-error", - "solana-program-memory", - "solana-pubkey", + "solana-program-error 2.2.2", + "solana-program-memory 2.3.1", + "solana-pubkey 2.4.0", +] + +[[package]] +name = "solana-account-info" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc3397241392f5756925029acaa8515dc70fcbe3d8059d4885d7d6533baf64fd" +dependencies = [ + "bincode", + "serde_core", + "solana-address 2.0.0", + "solana-program-error 3.0.0", + "solana-program-memory 3.1.0", ] [[package]] name = "solana-accounts-db" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97bb9be7b256b2295c443e054229942a34b40a2c032631d6e1c5a063ee1ed9e5" +checksum = "d7f54a3079b6d1c270c4b3c4ced2f4c218f7e71521411839ba83db3a1826a7fd" dependencies = [ - "agave-io-uring", + "agave-fs", "ahash 0.8.12", "bincode", "blake3", "bv", "bytemuck", "bytemuck_derive", - "bzip2", "crossbeam-channel", "dashmap", - "indexmap 2.11.4", - "io-uring", + "indexmap 2.12.1", "itertools 0.12.1", "log", "lz4", - "memmap2 0.9.8", + "memmap2 0.9.9", "modular-bitfield", "num_cpus", "num_enum", @@ -5509,40 +6170,67 @@ dependencies = [ "rayon", "seqlock", "serde", - "serde_derive", - "slab", "smallvec", - "solana-account", - "solana-address-lookup-table-interface", + "solana-account 3.2.0", + "solana-address-lookup-table-interface 3.0.0", "solana-bucket-map", - "solana-clock", - "solana-epoch-schedule", - "solana-fee-calculator", + "solana-clock 3.0.0", + "solana-epoch-schedule 3.0.0", + "solana-fee-calculator 3.0.0", "solana-genesis-config", - "solana-hash", + "solana-hash 3.1.0", "solana-lattice-hash", "solana-measure", - "solana-message", + "solana-message 3.0.1", "solana-metrics", "solana-nohash-hasher", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-rayon-threadlimit", - "solana-rent-collector", - "solana-reward-info", - "solana-sha256-hasher", - "solana-slot-hashes", + "solana-reward-info 3.0.0", + "solana-sha256-hasher 3.1.0", + "solana-slot-hashes 3.0.0", "solana-svm-transaction", - "solana-system-interface", - "solana-sysvar", + "solana-system-interface 2.0.0", + "solana-sysvar 3.1.1", "solana-time-utils", - "solana-transaction", - "solana-transaction-context", - "solana-transaction-error", - "spl-generic-token", + "solana-transaction 3.0.2", + "solana-transaction-context 3.1.3", + "solana-transaction-error 3.0.0", + "spl-generic-token 2.0.1", "static_assertions", - "tar", "tempfile", - "thiserror 2.0.16", + "thiserror 2.0.17", +] + +[[package]] +name = "solana-address" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2ecac8e1b7f74c2baa9e774c42817e3e75b20787134b76cc4d45e8a604488f5" +dependencies = [ + "solana-address 2.0.0", +] + +[[package]] +name = "solana-address" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e37320fd2945c5d654b2c6210624a52d66c3f1f73b653ed211ab91a703b35bdd" +dependencies = [ + "borsh 1.6.0", + "bytemuck", + "bytemuck_derive", + "curve25519-dalek 4.1.3", + "five8 1.0.0", + "five8_const 1.0.0", + "rand 0.8.5", + "serde", + "serde_derive", + "solana-atomic-u64 3.0.0", + "solana-define-syscall 4.0.1", + "solana-program-error 3.0.0", + "solana-sanitize 3.0.1", + "solana-sha256-hasher 3.1.0", ] [[package]] @@ -5555,11 +6243,29 @@ dependencies = [ "bytemuck", "serde", "serde_derive", - "solana-clock", - "solana-instruction", - "solana-pubkey", - "solana-sdk-ids", - "solana-slot-hashes", + "solana-clock 2.2.2", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", + "solana-slot-hashes 2.2.1", +] + +[[package]] +name = "solana-address-lookup-table-interface" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2f56cac5e70517a2f27d05e5100b20de7182473ffd0035b23ea273307905987" +dependencies = [ + "bincode", + "bytemuck", + "serde", + "serde_derive", + "solana-clock 3.0.0", + "solana-instruction 3.1.0", + "solana-instruction-error", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-slot-hashes 3.0.0", ] [[package]] @@ -5568,7 +6274,16 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d52e52720efe60465b052b9e7445a01c17550666beec855cce66f44766697bc2" dependencies = [ - "parking_lot 0.12.4", + "parking_lot 0.12.5", +] + +[[package]] +name = "solana-atomic-u64" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a933ff1e50aff72d02173cfcd7511bd8540b027ee720b75f353f594f834216d0" +dependencies = [ + "parking_lot 0.12.5", ] [[package]] @@ -5579,7 +6294,18 @@ checksum = "75db7f2bbac3e62cfd139065d15bcda9e2428883ba61fc8d27ccb251081e7567" dependencies = [ "num-bigint 0.4.6", "num-traits", - "solana-define-syscall", + "solana-define-syscall 2.3.0", +] + +[[package]] +name = "solana-big-mod-exp" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30c80fb6d791b3925d5ec4bf23a7c169ef5090c013059ec3ed7d0b2c04efa085" +dependencies = [ + "num-bigint 0.4.6", + "num-traits", + "solana-define-syscall 3.0.0", ] [[package]] @@ -5590,7 +6316,18 @@ checksum = "19a3787b8cf9c9fe3dd360800e8b70982b9e5a8af9e11c354b6665dd4a003adc" dependencies = [ "bincode", "serde", - "solana-instruction", + "solana-instruction 2.3.3", +] + +[[package]] +name = "solana-bincode" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "278a1a5bad62cd9da89ac8d4b7ec444e83caa8ae96aa656dfc27684b28d49a5d" +dependencies = [ + "bincode", + "serde_core", + "solana-instruction-error", ] [[package]] @@ -5600,24 +6337,59 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a0801e25a1b31a14494fc80882a036be0ffd290efc4c2d640bfcca120a4672" dependencies = [ "blake3", - "solana-define-syscall", - "solana-hash", - "solana-sanitize", + "solana-define-syscall 2.3.0", + "solana-hash 2.3.0", + "solana-sanitize 2.2.1", +] + +[[package]] +name = "solana-blake3-hasher" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7116e1d942a2432ca3f514625104757ab8a56233787e95144c93950029e31176" +dependencies = [ + "blake3", + "solana-define-syscall 4.0.1", + "solana-hash 4.0.1", +] + +[[package]] +name = "solana-bls-signatures" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c75573697bbb148afa8209aa3ce228ca0754584c9a8a91e818db0f706ae4fb" +dependencies = [ + "base64 0.22.1", + "blst", + "blstrs", + "bytemuck", + "cfg_eval", + "ff", + "group", + "pairing", + "rand 0.8.5", + "serde", + "serde_json", + "serde_with", + "solana-signature 3.1.0", + "solana-signer 3.0.0", + "subtle", + "thiserror 2.0.17", ] [[package]] name = "solana-bn254" -version = "2.2.2" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4420f125118732833f36facf96a27e7b78314b2d642ba07fa9ffdacd8d79e243" +checksum = "8d08583be08d2d5f19aa21efbb6fbdb968ba7fd0de74562441437a7d776772bf" dependencies = [ - "ark-bn254", - "ark-ec", - "ark-ff", - "ark-serialize", + "ark-bn254 0.4.0", + "ark-ec 0.4.2", + "ark-ff 0.4.2", + "ark-serialize 0.4.2", "bytemuck", - "solana-define-syscall", - "thiserror 2.0.16", + "solana-define-syscall 3.0.0", + "thiserror 2.0.17", ] [[package]] @@ -5627,90 +6399,80 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "718333bcd0a1a7aed6655aa66bef8d7fb047944922b2d3a18f49cbc13e73d004" dependencies = [ "borsh 0.10.4", - "borsh 1.5.7", + "borsh 1.6.0", +] + +[[package]] +name = "solana-borsh" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc402b16657abbfa9991cd5cbfac5a11d809f7e7d28d3bb291baeb088b39060e" +dependencies = [ + "borsh 1.6.0", ] [[package]] name = "solana-bpf-loader-program" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0f48b9eaa1e61b369133372e77ba94d4bd6907e7b7be701a9b9c811dabee1e" +checksum = "0e7cb75c221b02918427762bcebdbfd34c831bd1c66442d2df928fa13f6b73fe" dependencies = [ + "agave-syscalls", "bincode", - "libsecp256k1", - "num-traits", "qualifier_attr", - "scopeguard", - "solana-account", - "solana-account-info", - "solana-big-mod-exp", - "solana-bincode", - "solana-blake3-hasher", - "solana-bn254", - "solana-clock", - "solana-cpi", - "solana-curve25519", - "solana-hash", - "solana-instruction", - "solana-keccak-hasher", - "solana-loader-v3-interface", - "solana-loader-v4-interface", - "solana-log-collector", - "solana-measure", + "solana-account 3.2.0", + "solana-bincode 3.1.0", + "solana-clock 3.0.0", + "solana-instruction 3.1.0", + "solana-loader-v3-interface 6.1.0", + "solana-loader-v4-interface 3.1.0", "solana-packet", - "solana-poseidon", - "solana-program-entrypoint", + "solana-program-entrypoint 3.1.1", "solana-program-runtime", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-sbpf", - "solana-sdk-ids", - "solana-secp256k1-recover", - "solana-sha256-hasher", - "solana-stable-layout", - "solana-svm-feature-set", - "solana-system-interface", - "solana-sysvar", - "solana-sysvar-id", - "solana-timings", - "solana-transaction-context", - "solana-type-overrides", - "thiserror 2.0.16", + "solana-sdk-ids 3.1.0", + "solana-svm-feature-set 3.1.3", + "solana-svm-log-collector", + "solana-svm-measure", + "solana-svm-type-overrides", + "solana-system-interface 2.0.0", + "solana-transaction-context 3.1.3", ] [[package]] name = "solana-bucket-map" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b84bb788088bc23e48ae3edbaf22195d8affea8c1158ba4a8e716975e17ddf" +checksum = "1db4efaf4c56ec0ef3a47c1cf17a356e2544aecd8f82a69285612081c07bc859" dependencies = [ "bv", "bytemuck", "bytemuck_derive", - "memmap2 0.9.8", + "memmap2 0.9.9", "modular-bitfield", "num_enum", "rand 0.8.5", - "solana-clock", + "solana-clock 3.0.0", "solana-measure", - "solana-pubkey", + "solana-pubkey 3.0.0", "tempfile", ] [[package]] name = "solana-builtins" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d8c85cdac5340db4f67ef173517efbc20e2b677a356b7a432b12407719fe52b" +checksum = "f22e573564f9ad10b7c716d153efcdaa5f039e1a82cf74fa561beb8e4baa4738" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", "solana-bpf-loader-program", "solana-compute-budget-program", - "solana-hash", + "solana-hash 3.1.0", "solana-loader-v4-program", "solana-program-runtime", - "solana-pubkey", - "solana-sdk-ids", - "solana-stake-program", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", "solana-system-program", "solana-vote-program", "solana-zk-elgamal-proof-program", @@ -5719,88 +6481,89 @@ dependencies = [ [[package]] name = "solana-builtins-default-costs" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63863ef4f611446cedf794957a502f000184c0b9aaa4f2229c198515a7aa4abf" +checksum = "52eb50c3aafcaf5c6666b3fbe80f2d889f75ee6b0c7fb5b20c1349d9a597b5ee" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", "ahash 0.8.12", "log", "solana-bpf-loader-program", "solana-compute-budget-program", "solana-loader-v4-program", - "solana-pubkey", - "solana-sdk-ids", - "solana-stake-program", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", "solana-system-program", "solana-vote-program", ] [[package]] name = "solana-client" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a035d424d5a44a3c16506378fd1e6133c73bc5016ffc40f8983d5373e426522" +checksum = "b459e5f9ab10d2ae6959b96db5b1a56310e762e023102159bf9645f2097ecbbf" dependencies = [ "async-trait", "bincode", "dashmap", "futures", "futures-util", - "indexmap 2.11.4", - "indicatif", + "indexmap 2.12.1", + "indicatif 0.18.3", "log", "quinn", "rayon", - "solana-account", + "solana-account 3.2.0", "solana-client-traits", - "solana-commitment-config", + "solana-commitment-config 3.1.0", "solana-connection-cache", "solana-epoch-info", - "solana-hash", - "solana-instruction", - "solana-keypair", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-keypair 3.1.0", "solana-measure", - "solana-message", - "solana-pubkey", + "solana-message 3.0.1", + "solana-net-utils", + "solana-pubkey 3.0.0", "solana-pubsub-client", "solana-quic-client", "solana-quic-definitions", "solana-rpc-client", "solana-rpc-client-api", "solana-rpc-client-nonce-utils", - "solana-signature", - "solana-signer", + "solana-signature 3.1.0", + "solana-signer 3.0.0", "solana-streamer", - "solana-thin-client", "solana-time-utils", "solana-tpu-client", - "solana-transaction", - "solana-transaction-error", + "solana-transaction 3.0.2", + "solana-transaction-error 3.0.0", + "solana-transaction-status-client-types 3.1.3", "solana-udp-client", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", + "tokio-util", ] [[package]] name = "solana-client-traits" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83f0071874e629f29e0eb3dab8a863e98502ac7aba55b7e0df1803fc5cac72a7" +checksum = "08618ed587e128105510c54ae3e456b9a06d674d8640db75afe66dad65cb4e02" dependencies = [ - "solana-account", - "solana-commitment-config", + "solana-account 3.2.0", + "solana-commitment-config 3.1.0", "solana-epoch-info", - "solana-hash", - "solana-instruction", - "solana-keypair", - "solana-message", - "solana-pubkey", - "solana-signature", - "solana-signer", - "solana-system-interface", - "solana-transaction", - "solana-transaction-error", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-keypair 3.1.0", + "solana-message 3.0.1", + "solana-pubkey 3.0.0", + "solana-signature 3.1.0", + "solana-signer 3.0.0", + "solana-system-interface 2.0.0", + "solana-transaction 3.0.2", + "solana-transaction-error 3.0.0", ] [[package]] @@ -5811,20 +6574,33 @@ checksum = "1bb482ab70fced82ad3d7d3d87be33d466a3498eb8aa856434ff3c0dfc2e2e31" dependencies = [ "serde", "serde_derive", - "solana-sdk-ids", - "solana-sdk-macro", - "solana-sysvar-id", + "solana-sdk-ids 2.2.1", + "solana-sdk-macro 2.2.1", + "solana-sysvar-id 2.2.1", +] + +[[package]] +name = "solana-clock" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb62e9381182459a4520b5fe7fb22d423cae736239a6427fc398a88743d0ed59" +dependencies = [ + "serde", + "serde_derive", + "solana-sdk-ids 3.1.0", + "solana-sdk-macro 3.0.0", + "solana-sysvar-id 3.1.0", ] [[package]] name = "solana-cluster-type" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ace9fea2daa28354d107ea879cff107181d85cd4e0f78a2bedb10e1a428c97e" +checksum = "eb7692fa6bf10a1a86b450c4775526f56d7e0e2116a53313f2533b5694abea64" dependencies = [ "serde", "serde_derive", - "solana-hash", + "solana-hash 3.1.0", ] [[package]] @@ -5832,6 +6608,12 @@ name = "solana-commitment-config" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac49c4dde3edfa832de1697e9bcdb7c3b3f7cb7a1981b7c62526c8bb6700fb73" + +[[package]] +name = "solana-commitment-config" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e41a3917076a8b5375809078ae3a6fb76a53e364b596ef8c4265e7f410876f3" dependencies = [ "serde", "serde_derive", @@ -5839,9 +6621,9 @@ dependencies = [ [[package]] name = "solana-compute-budget" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce8b624a1087dbb8658cc8f94f5871fe417dea53bb1c926550fcb048057af918" +checksum = "686a3d655c6ae8f2ed7ed123e501369d763f733ce566f22703d9e4e34b9eee32" dependencies = [ "solana-fee-structure", "solana-program-runtime", @@ -5849,47 +6631,62 @@ dependencies = [ [[package]] name = "solana-compute-budget-instruction" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "014c843f45832d9c71fe81247b8620f13cb93d4202d802f7d94ce5b613dbf33f" +checksum = "ab5c6e1f2a89248ac1f1f0e27364b7b0a30e33922d8ff3ad7cb0567f07e62580" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", "log", - "solana-borsh", + "solana-borsh 3.0.0", "solana-builtins-default-costs", "solana-compute-budget", "solana-compute-budget-interface", - "solana-instruction", + "solana-instruction 3.1.0", "solana-packet", - "solana-pubkey", - "solana-sdk-ids", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", "solana-svm-transaction", - "solana-transaction-error", - "thiserror 2.0.16", + "solana-transaction-error 3.0.0", + "thiserror 2.0.17", ] [[package]] name = "solana-compute-budget-interface" -version = "2.2.2" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8432d2c4c22d0499aa06d62e4f7e333f81777b3d7c96050ae9e5cb71a8c3aee4" +checksum = "8292c436b269ad23cecc8b24f7da3ab07ca111661e25e00ce0e1d22771951ab9" dependencies = [ - "borsh 1.5.7", - "serde", - "serde_derive", - "solana-instruction", - "solana-sdk-ids", + "borsh 1.6.0", + "solana-instruction 3.1.0", + "solana-sdk-ids 3.1.0", ] [[package]] name = "solana-compute-budget-program" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbcbc0e3c977b0a0c9036c54004ddcf8eb120770fe3a276bd024b3e8877cb1e" +checksum = "2af44adad2ae3b34082349310362cb8d6df9d60c6722b95e486d80f3781644fe" dependencies = [ "solana-program-runtime", ] +[[package]] +name = "solana-config-interface" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e401ae56aed512821cc7a0adaa412ff97fecd2dff4602be7b1330d2daec0c4" +dependencies = [ + "bincode", + "serde", + "serde_derive", + "solana-account 3.2.0", + "solana-instruction 3.1.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-short-vec 3.1.0", + "solana-system-interface 2.0.0", +] + [[package]] name = "solana-config-program-client" version = "0.0.2" @@ -5900,57 +6697,57 @@ dependencies = [ "borsh 0.10.4", "kaigan", "serde", - "solana-program", + "solana-program 2.3.0", ] [[package]] name = "solana-connection-cache" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46de0f0ec7ea94dfbc81268020c7af10999bab279d37b71f94a35f27c1c4af2" +checksum = "0748f2086e095d357408944ba8db6a8c8ba49376cb9f911f3fe2c44c055604f5" dependencies = [ "async-trait", "bincode", "crossbeam-channel", "futures-util", - "indexmap 2.11.4", + "indexmap 2.12.1", "log", "rand 0.8.5", "rayon", - "solana-keypair", + "solana-keypair 3.1.0", "solana-measure", "solana-metrics", "solana-time-utils", - "solana-transaction-error", - "thiserror 2.0.16", + "solana-transaction-error 3.0.0", + "thiserror 2.0.17", "tokio", ] [[package]] name = "solana-cost-model" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea1bd25ccdb7c5fce2b2eb8471aa2c0336d8304491669b63a067332f8d98b84" +checksum = "06f4bdb9c5727e9f5e55c5cde53d000365c1eb00eb4de63ab4cb007dc8af7f32" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", "ahash 0.8.12", "log", - "solana-bincode", - "solana-borsh", + "solana-bincode 3.1.0", + "solana-borsh 3.0.0", "solana-builtins-default-costs", - "solana-clock", + "solana-clock 3.0.0", "solana-compute-budget", "solana-compute-budget-instruction", "solana-compute-budget-interface", "solana-fee-structure", "solana-metrics", "solana-packet", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-runtime-transaction", - "solana-sdk-ids", + "solana-sdk-ids 3.1.0", "solana-svm-transaction", - "solana-system-interface", - "solana-transaction-error", + "solana-system-interface 2.0.0", + "solana-transaction-error 3.0.0", "solana-vote-program", ] @@ -5960,26 +6757,54 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dc71126edddc2ba014622fc32d0f5e2e78ec6c5a1e0eb511b85618c09e9ea11" dependencies = [ - "solana-account-info", - "solana-define-syscall", - "solana-instruction", - "solana-program-error", - "solana-pubkey", - "solana-stable-layout", + "solana-account-info 2.3.0", + "solana-define-syscall 2.3.0", + "solana-instruction 2.3.3", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", + "solana-stable-layout 2.2.1", +] + +[[package]] +name = "solana-cpi" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dea26709d867aada85d0d3617db0944215c8bb28d3745b912de7db13a23280c" +dependencies = [ + "solana-account-info 3.1.0", + "solana-define-syscall 4.0.1", + "solana-instruction 3.1.0", + "solana-program-error 3.0.0", + "solana-pubkey 4.0.0", + "solana-stable-layout 3.0.0", +] + +[[package]] +name = "solana-curve25519" +version = "2.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae4261b9a8613d10e77ac831a8fa60b6fa52b9b103df46d641deff9f9812a23" +dependencies = [ + "bytemuck", + "bytemuck_derive", + "curve25519-dalek 4.1.3", + "solana-define-syscall 2.3.0", + "subtle", + "thiserror 2.0.17", ] [[package]] name = "solana-curve25519" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "946ba468216b901ecfc9476497aeaa985745652bf312dbdc7d72dbe702916b9b" +checksum = "c7123212926bb5957229c6736956eff0a05a73d0924b5d2ef898d43fb67befe9" dependencies = [ "bytemuck", "bytemuck_derive", "curve25519-dalek 4.1.3", - "solana-define-syscall", + "solana-define-syscall 3.0.0", "subtle", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -5997,6 +6822,18 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ae3e2abcf541c8122eafe9a625d4d194b4023c20adde1e251f94e056bb1aee2" +[[package]] +name = "solana-define-syscall" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9697086a4e102d28a156b8d6b521730335d6951bd39a5e766512bbe09007cee" + +[[package]] +name = "solana-define-syscall" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57e5b1c0bc1d4a4d10c88a4100499d954c09d3fecfae4912c1a074dff68b1738" + [[package]] name = "solana-derivation-path" version = "2.2.1" @@ -6008,52 +6845,79 @@ dependencies = [ "uriparse", ] +[[package]] +name = "solana-derivation-path" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff71743072690fdbdfcdc37700ae1cb77485aaad49019473a81aee099b1e0b8c" +dependencies = [ + "derivation-path", + "qstring", + "uriparse", +] + +[[package]] +name = "solana-download-utils" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e84682e864d20eb7032a7e4798f5bfa812da2d0435d6bdc88676d219f1139f" +dependencies = [ + "agave-snapshots", + "log", + "solana-clock 3.0.0", + "solana-file-download", + "solana-genesis-config", + "solana-runtime", +] + [[package]] name = "solana-ed25519-program" -version = "2.2.3" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feafa1691ea3ae588f99056f4bdd1293212c7ece28243d7da257c443e84753" +checksum = "e1419197f1c06abf760043f6d64ba9d79a03ad5a43f18c7586471937122094da" dependencies = [ "bytemuck", "bytemuck_derive", - "ed25519-dalek", - "solana-feature-set", - "solana-instruction", - "solana-precompile-error", - "solana-sdk-ids", + "solana-instruction 3.1.0", + "solana-sdk-ids 3.1.0", ] [[package]] name = "solana-entry" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7717198db94ead000d5b26e6855ea74256a03e1a01d97d1a5bfc8179ed0f1211" +checksum = "0b32ff86ab80b1e349377536073b50653a489a8767bf6993323f5b1e61ee07c7" dependencies = [ "bincode", "crossbeam-channel", "dlopen2", "log", + "num_cpus", "rand 0.8.5", "rayon", "serde", - "solana-hash", + "solana-address 1.1.0", + "solana-hash 3.1.0", "solana-measure", "solana-merkle-tree", + "solana-message 3.0.1", "solana-metrics", "solana-packet", "solana-perf", - "solana-rayon-threadlimit", "solana-runtime-transaction", - "solana-sha256-hasher", - "solana-transaction", - "solana-transaction-error", + "solana-sha256-hasher 3.1.0", + "solana-short-vec 3.1.0", + "solana-signature 3.1.0", + "solana-transaction 3.0.2", + "solana-transaction-error 3.0.0", + "wincode", ] [[package]] name = "solana-epoch-info" -version = "2.2.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ef6f0b449290b0b9f32973eefd95af35b01c5c0c34c569f936c34c5b20d77b" +checksum = "e093c84f6ece620a6b10cd036574b0cd51944231ab32d81f80f76d54aba833e6" dependencies = [ "serde", "serde_derive", @@ -6067,21 +6931,35 @@ checksum = "86b575d3dd323b9ea10bb6fe89bf6bf93e249b215ba8ed7f68f1a3633f384db7" dependencies = [ "serde", "serde_derive", - "solana-hash", - "solana-sdk-ids", - "solana-sdk-macro", - "solana-sysvar-id", + "solana-hash 2.3.0", + "solana-sdk-ids 2.2.1", + "solana-sdk-macro 2.2.1", + "solana-sysvar-id 2.2.1", +] + +[[package]] +name = "solana-epoch-rewards" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b319a4ed70390af911090c020571f0ff1f4ec432522d05ab89f5c08080381995" +dependencies = [ + "serde", + "serde_derive", + "solana-hash 3.1.0", + "solana-sdk-ids 3.1.0", + "solana-sdk-macro 3.0.0", + "solana-sysvar-id 3.1.0", ] [[package]] name = "solana-epoch-rewards-hasher" -version = "2.2.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c5fd2662ae7574810904585fd443545ed2b568dbd304b25a31e79ccc76e81b" +checksum = "1ee8beac9bff4db9225e57d532d169b0be5e447f1e6601a2f50f27a01bf5518f" dependencies = [ "siphasher 0.3.11", - "solana-hash", - "solana-pubkey", + "solana-address 2.0.0", + "solana-hash 4.0.1", ] [[package]] @@ -6092,9 +6970,32 @@ checksum = "3fce071fbddecc55d727b1d7ed16a629afe4f6e4c217bc8d00af3b785f6f67ed" dependencies = [ "serde", "serde_derive", - "solana-sdk-ids", - "solana-sdk-macro", - "solana-sysvar-id", + "solana-sdk-ids 2.2.1", + "solana-sdk-macro 2.2.1", + "solana-sysvar-id 2.2.1", +] + +[[package]] +name = "solana-epoch-schedule" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e5481e72cc4d52c169db73e4c0cd16de8bc943078aac587ec4817a75cc6388f" +dependencies = [ + "serde", + "serde_derive", + "solana-sdk-ids 3.1.0", + "solana-sdk-macro 3.0.0", + "solana-sysvar-id 3.1.0", +] + +[[package]] +name = "solana-epoch-stake" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc6693d0ea833b880514b9b88d95afb80b42762dca98b0712465d1fcbbcb89e" +dependencies = [ + "solana-define-syscall 3.0.0", + "solana-pubkey 3.0.0", ] [[package]] @@ -6105,17 +7006,38 @@ checksum = "84461d56cbb8bb8d539347151e0525b53910102e4bced875d49d5139708e39d3" dependencies = [ "serde", "serde_derive", - "solana-address-lookup-table-interface", - "solana-clock", - "solana-hash", - "solana-instruction", - "solana-keccak-hasher", - "solana-message", - "solana-nonce", - "solana-pubkey", - "solana-sdk-ids", - "solana-system-interface", - "thiserror 2.0.16", + "solana-address-lookup-table-interface 2.2.2", + "solana-clock 2.2.2", + "solana-hash 2.3.0", + "solana-instruction 2.3.3", + "solana-keccak-hasher 2.2.1", + "solana-message 2.4.0", + "solana-nonce 2.2.1", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", + "solana-system-interface 1.0.0", + "thiserror 2.0.17", +] + +[[package]] +name = "solana-example-mocks" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978855d164845c1b0235d4b4d101cadc55373fffaf0b5b6cfa2194d25b2ed658" +dependencies = [ + "serde", + "serde_derive", + "solana-address-lookup-table-interface 3.0.0", + "solana-clock 3.0.0", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-keccak-hasher 3.1.0", + "solana-message 3.0.1", + "solana-nonce 3.0.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-system-interface 2.0.0", + "thiserror 2.0.17", ] [[package]] @@ -6127,37 +7049,42 @@ dependencies = [ "bincode", "serde", "serde_derive", - "solana-account", - "solana-account-info", - "solana-instruction", - "solana-program-error", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", - "solana-system-interface", + "solana-account 2.2.1", + "solana-account-info 2.3.0", + "solana-instruction 2.3.3", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-system-interface 1.0.0", ] [[package]] -name = "solana-feature-set" -version = "2.2.5" +name = "solana-feature-gate-interface" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93b93971e289d6425f88e6e3cb6668c4b05df78b3c518c249be55ced8efd6b6d" +checksum = "7347ab62e6d47a82e340c865133795b394feea7c2b2771d293f57691c6544c3f" dependencies = [ - "ahash 0.8.12", - "lazy_static", - "solana-epoch-schedule", - "solana-hash", - "solana-pubkey", - "solana-sha256-hasher", + "bincode", + "serde", + "serde_derive", + "solana-account 3.2.0", + "solana-account-info 3.1.0", + "solana-instruction 3.1.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-system-interface 2.0.0", ] [[package]] name = "solana-fee" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854f60fe891cb47295b67448c3ee60b674ce3c028b7e780adc4cb388770bca97" +checksum = "b44d71a15c79306d888dfeeaeb5514ba3c167ef1dc8dd6f6380ade15a2e9f118" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", "solana-fee-structure", "solana-svm-transaction", ] @@ -6173,53 +7100,88 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "solana-fee-calculator" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a73cc03ca4bed871ca174558108835f8323e85917bb38b9c81c7af2ab853efe" +dependencies = [ + "log", + "serde", + "serde_derive", +] + [[package]] name = "solana-fee-structure" -version = "2.3.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33adf673581c38e810bf618f745bf31b683a0a4a4377682e6aaac5d9a058dd4e" +checksum = "5e2abdb1223eea8ec64136f39cb1ffcf257e00f915c957c35c0dd9e3f4e700b0" dependencies = [ "serde", "serde_derive", - "solana-message", - "solana-native-token", +] + +[[package]] +name = "solana-file-download" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6884e13cc98f58e609a9b73e3d53f728f0f743b8c15c6768cad6f6382c336c1" +dependencies = [ + "console 0.15.11", + "indicatif 0.17.11", + "log", + "reqwest 0.11.27", ] [[package]] name = "solana-genesis-config" -version = "2.3.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3725085d47b96d37fef07a29d78d2787fc89a0b9004c66eed7753d1e554989f" +checksum = "749eccc960e85c9b33608450093d256006253e1cb436b8380e71777840a3f675" dependencies = [ "bincode", "chrono", "memmap2 0.5.10", "serde", "serde_derive", - "solana-account", - "solana-clock", + "solana-account 3.2.0", + "solana-clock 3.0.0", "solana-cluster-type", - "solana-epoch-schedule", - "solana-fee-calculator", - "solana-hash", + "solana-epoch-schedule 3.0.0", + "solana-fee-calculator 3.0.0", + "solana-hash 3.1.0", "solana-inflation", - "solana-keypair", - "solana-logger", + "solana-keypair 3.1.0", "solana-poh-config", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", - "solana-sha256-hasher", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-sha256-hasher 3.1.0", "solana-shred-version", - "solana-signer", + "solana-signer 3.0.0", "solana-time-utils", ] +[[package]] +name = "solana-genesis-utils" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "697117775e90fde3fbb5a3529f1ba36013f684ecbd768cebd41490ce5dfa8c1b" +dependencies = [ + "agave-snapshots", + "log", + "solana-download-utils", + "solana-genesis-config", + "solana-hash 3.1.0", + "solana-rpc-client", + "thiserror 2.0.17", +] + [[package]] name = "solana-hard-forks" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c28371f878e2ead55611d8ba1b5fb879847156d04edea13693700ad1a28baf" +checksum = "0abacc4b66ce471f135f48f22facf75cbbb0f8a252fbe2c1e0aa59d5b203f519" dependencies = [ "serde", "serde_derive", @@ -6231,23 +7193,48 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b96e9f0300fa287b545613f007dfe20043d7812bee255f418c1eb649c93b63" dependencies = [ - "borsh 1.5.7", + "borsh 1.6.0", "bytemuck", "bytemuck_derive", - "five8", + "five8 0.2.1", "js-sys", "serde", "serde_derive", - "solana-atomic-u64", - "solana-sanitize", + "solana-atomic-u64 2.2.1", + "solana-sanitize 2.2.1", "wasm-bindgen", ] +[[package]] +name = "solana-hash" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "337c246447142f660f778cf6cb582beba8e28deb05b3b24bfb9ffd7c562e5f41" +dependencies = [ + "solana-hash 4.0.1", +] + +[[package]] +name = "solana-hash" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a5d48a6ee7b91fc7b998944ab026ed7b3e2fc8ee3bc58452644a86c2648152f" +dependencies = [ + "borsh 1.6.0", + "bytemuck", + "bytemuck_derive", + "five8 1.0.0", + "serde", + "serde_derive", + "solana-atomic-u64 3.0.0", + "solana-sanitize 3.0.1", +] + [[package]] name = "solana-inflation" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23eef6a09eb8e568ce6839573e4966850e85e9ce71e6ae1a6c930c1c43947de3" +checksum = "e92f37a14e7c660628752833250dd3dcd8e95309876aee751d7f8769a27947c6" dependencies = [ "serde", "serde_derive", @@ -6255,37 +7242,83 @@ dependencies = [ [[package]] name = "solana-instruction" -version = "2.3.0" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47298e2ce82876b64f71e9d13a46bc4b9056194e7f9937ad3084385befa50885" +checksum = "bab5682934bd1f65f8d2c16f21cb532526fcc1a09f796e2cacdb091eee5774ad" dependencies = [ "bincode", - "borsh 1.5.7", + "borsh 1.6.0", "getrandom 0.2.16", "js-sys", "num-traits", "serde", "serde_derive", - "solana-define-syscall", - "solana-pubkey", + "serde_json", + "solana-define-syscall 2.3.0", + "solana-pubkey 2.4.0", "wasm-bindgen", ] +[[package]] +name = "solana-instruction" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee1b699a2c1518028a9982e255e0eca10c44d90006542d9d7f9f40dbce3f7c78" +dependencies = [ + "bincode", + "borsh 1.6.0", + "serde", + "serde_derive", + "solana-define-syscall 4.0.1", + "solana-instruction-error", + "solana-pubkey 4.0.0", +] + +[[package]] +name = "solana-instruction-error" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b04259e03c05faf38a8c24217b5cfe4c90572ae6184ab49cddb1584fdd756d3f" +dependencies = [ + "num-traits", + "serde", + "serde_derive", + "solana-program-error 3.0.0", +] + [[package]] name = "solana-instructions-sysvar" version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0e85a6fad5c2d0c4f5b91d34b8ca47118fc593af706e523cdbedf846a954f57" dependencies = [ - "bitflags 2.9.4", - "solana-account-info", - "solana-instruction", - "solana-program-error", - "solana-pubkey", - "solana-sanitize", - "solana-sdk-ids", - "solana-serialize-utils", - "solana-sysvar-id", + "bitflags 2.10.0", + "solana-account-info 2.3.0", + "solana-instruction 2.3.3", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", + "solana-sanitize 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-serialize-utils 2.2.1", + "solana-sysvar-id 2.2.1", +] + +[[package]] +name = "solana-instructions-sysvar" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ddf67876c541aa1e21ee1acae35c95c6fbc61119814bfef70579317a5e26955" +dependencies = [ + "bitflags 2.10.0", + "solana-account-info 3.1.0", + "solana-instruction 3.1.0", + "solana-instruction-error", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", + "solana-sanitize 3.0.1", + "solana-sdk-ids 3.1.0", + "solana-serialize-utils 3.1.0", + "solana-sysvar-id 3.1.0", ] [[package]] @@ -6295,9 +7328,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7aeb957fbd42a451b99235df4942d96db7ef678e8d5061ef34c9b34cae12f79" dependencies = [ "sha3", - "solana-define-syscall", - "solana-hash", - "solana-sanitize", + "solana-define-syscall 2.3.0", + "solana-hash 2.3.0", + "solana-sanitize 2.2.1", +] + +[[package]] +name = "solana-keccak-hasher" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed1c0d16d6fdeba12291a1f068cdf0d479d9bff1141bf44afd7aa9d485f65ef8" +dependencies = [ + "sha3", + "solana-define-syscall 4.0.1", + "solana-hash 4.0.1", ] [[package]] @@ -6306,19 +7350,34 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd3f04aa1a05c535e93e121a95f66e7dcccf57e007282e8255535d24bf1e98bb" dependencies = [ - "ed25519-dalek", - "ed25519-dalek-bip32", - "five8", + "ed25519-dalek 1.0.1", + "five8 0.2.1", "rand 0.7.3", - "solana-derivation-path", - "solana-pubkey", - "solana-seed-derivable", - "solana-seed-phrase", - "solana-signature", - "solana-signer", + "solana-pubkey 2.4.0", + "solana-seed-phrase 2.2.1", + "solana-signature 2.3.0", + "solana-signer 2.2.1", "wasm-bindgen", ] +[[package]] +name = "solana-keypair" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ac8be597c9e231b0cab2928ce3bc3e4ee77d9c0ad92977b9d901f3879f25a7a" +dependencies = [ + "ed25519-dalek 2.2.0", + "ed25519-dalek-bip32", + "five8 1.0.0", + "rand 0.8.5", + "solana-address 2.0.0", + "solana-derivation-path 3.0.0", + "solana-seed-derivable 3.0.0", + "solana-seed-phrase 3.0.0", + "solana-signature 3.1.0", + "solana-signer 3.0.0", +] + [[package]] name = "solana-last-restart-slot" version = "2.2.1" @@ -6327,16 +7386,29 @@ checksum = "4a6360ac2fdc72e7463565cd256eedcf10d7ef0c28a1249d261ec168c1b55cdd" dependencies = [ "serde", "serde_derive", - "solana-sdk-ids", - "solana-sdk-macro", - "solana-sysvar-id", + "solana-sdk-ids 2.2.1", + "solana-sdk-macro 2.2.1", + "solana-sysvar-id 2.2.1", +] + +[[package]] +name = "solana-last-restart-slot" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcda154ec827f5fc1e4da0af3417951b7e9b8157540f81f936c4a8b1156134d0" +dependencies = [ + "serde", + "serde_derive", + "solana-sdk-ids 3.1.0", + "solana-sdk-macro 3.0.0", + "solana-sysvar-id 3.1.0", ] [[package]] name = "solana-lattice-hash" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaefcdee3e943d6cf6499df8b988f49a525920fa520f5f5418f06ad4b0448ca1" +checksum = "2da94c0f51ae89816dfc479e0ccece6c138bf6af9e50bf930e2027f041328895" dependencies = [ "base64 0.22.1", "blake3", @@ -6346,16 +7418,18 @@ dependencies = [ [[package]] name = "solana-ledger" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0bbe8a1516faef4fe4826b16c0976198b6caa73b680c653b720063428d681f1" +checksum = "b092b339535f266108cb997b13126e0ba4c367bccd538f1c94faa9acec382d70" dependencies = [ - "agave-feature-set", - "agave-reserved-account-keys", + "agave-feature-set 3.1.3", + "agave-reserved-account-keys 3.1.3", + "agave-snapshots", "anyhow", "assert_matches", "bincode", - "bitflags 2.9.4", + "bitflags 2.10.0", + "bytes", "bzip2", "chrono", "chrono-humanize", @@ -6366,7 +7440,6 @@ dependencies = [ "futures", "itertools 0.12.1", "lazy-lru", - "libc", "log", "lru", "mockall", @@ -6383,51 +7456,52 @@ dependencies = [ "serde", "serde_bytes", "sha2 0.10.9", - "solana-account", - "solana-account-decoder", + "solana-account 3.2.0", + "solana-account-decoder 3.1.3", "solana-accounts-db", - "solana-address-lookup-table-interface", + "solana-address-lookup-table-interface 3.0.0", "solana-bpf-loader-program", - "solana-clock", + "solana-clock 3.0.0", "solana-cost-model", "solana-entry", - "solana-epoch-schedule", + "solana-epoch-schedule 3.0.0", "solana-genesis-config", - "solana-hash", - "solana-instruction", - "solana-keypair", + "solana-genesis-utils", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-keypair 3.1.0", "solana-measure", - "solana-message", + "solana-message 3.0.1", "solana-metrics", - "solana-native-token", + "solana-native-token 3.0.0", "solana-net-utils", + "solana-nohash-hasher", "solana-packet", "solana-perf", "solana-program-runtime", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-rayon-threadlimit", "solana-runtime", "solana-runtime-transaction", - "solana-seed-derivable", - "solana-sha256-hasher", + "solana-seed-derivable 3.0.0", + "solana-sha256-hasher 3.1.0", "solana-shred-version", - "solana-signature", - "solana-signer", - "solana-stake-interface", - "solana-stake-program", + "solana-signature 3.1.0", + "solana-signer 3.0.0", + "solana-stake-interface 2.0.1", "solana-storage-bigtable", "solana-storage-proto", "solana-streamer", "solana-svm", + "solana-svm-timings", "solana-svm-transaction", - "solana-system-interface", + "solana-system-interface 2.0.0", "solana-system-transaction", "solana-time-utils", - "solana-timings", - "solana-transaction", - "solana-transaction-context", - "solana-transaction-error", - "solana-transaction-status", + "solana-transaction 3.0.2", + "solana-transaction-context 3.1.3", + "solana-transaction-error 3.0.0", + "solana-transaction-status 3.1.3", "solana-vote", "solana-vote-program", "static_assertions", @@ -6435,10 +7509,11 @@ dependencies = [ "strum_macros 0.24.3", "tar", "tempfile", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tokio-stream", "trees", + "wincode", ] [[package]] @@ -6450,9 +7525,23 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-instruction", - "solana-pubkey", - "solana-sdk-ids", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", +] + +[[package]] +name = "solana-loader-v2-interface" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4a6f0ad4fd9c30679bfee2ce3ea6a449cac38049f210480b751f65676dfe82" +dependencies = [ + "serde", + "serde_bytes", + "serde_derive", + "solana-instruction 3.1.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", ] [[package]] @@ -6464,10 +7553,25 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-instruction", - "solana-pubkey", - "solana-sdk-ids", - "solana-system-interface", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", + "solana-system-interface 1.0.0", +] + +[[package]] +name = "solana-loader-v3-interface" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee44c9b1328c5c712c68966fb8de07b47f3e7bac006e74ddd1bb053d3e46e5d" +dependencies = [ + "serde", + "serde_bytes", + "serde_derive", + "solana-instruction 3.1.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-system-interface 2.0.0", ] [[package]] @@ -6479,74 +7583,66 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-instruction", - "solana-pubkey", - "solana-sdk-ids", - "solana-system-interface", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", + "solana-system-interface 1.0.0", +] + +[[package]] +name = "solana-loader-v4-interface" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c948b33ff81fa89699911b207059e493defdba9647eaf18f23abdf3674e0fb" +dependencies = [ + "serde", + "serde_bytes", + "serde_derive", + "solana-instruction 3.1.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-system-interface 2.0.0", ] [[package]] name = "solana-loader-v4-program" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efa9a00889dd1d9c0e048549a4cd7e0aabd323711414df8cf2d449a807c47bcf" +checksum = "8b3721017c1ca803f8571df2a1909c8353c11a56a8eaac3f7d96d751d0a779ec" dependencies = [ "log", - "qualifier_attr", - "solana-account", - "solana-bincode", + "solana-account 3.2.0", + "solana-bincode 3.1.0", "solana-bpf-loader-program", - "solana-instruction", - "solana-loader-v3-interface", - "solana-loader-v4-interface", - "solana-log-collector", - "solana-measure", + "solana-instruction 3.1.0", + "solana-loader-v3-interface 6.1.0", + "solana-loader-v4-interface 3.1.0", "solana-packet", "solana-program-runtime", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-sbpf", - "solana-sdk-ids", - "solana-transaction-context", - "solana-type-overrides", + "solana-sdk-ids 3.1.0", + "solana-svm-log-collector", + "solana-svm-measure", + "solana-svm-type-overrides", + "solana-transaction-context 3.1.3", ] [[package]] -name = "solana-log-collector" -version = "2.3.10" +name = "solana-measure" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069f37aa0ba25d4c6ac42fb78d651ce626c64676c3178b99c8edf129ff3035f3" -dependencies = [ - "log", -] - -[[package]] -name = "solana-logger" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8e777ec1afd733939b532a42492d888ec7c88d8b4127a5d867eb45c6eb5cd5" -dependencies = [ - "env_logger", - "lazy_static", - "libc", - "log", - "signal-hook", -] - -[[package]] -name = "solana-measure" -version = "2.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "776bf2178d04969492949d3b1b8d0885160d2436b9e90b55fd22ab816d6b0539" +checksum = "c48d639f9c87b48437b3feab27cfc50ea4d471de2d18b2afc84aa69df1201fb5" [[package]] name = "solana-merkle-tree" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435aa8f5f4ec99489170ea06e2842a3519e1d5516d66b0605a4804db1403729a" +checksum = "783fcc9d760727f5c7cf2539a25fc23002cd297671985950a6306a90750bf6d0" dependencies = [ "fast-math", - "solana-hash", - "solana-sha256-hasher", + "solana-hash 3.1.0", + "solana-sha256-hasher 3.1.0", ] [[package]] @@ -6560,32 +7656,52 @@ dependencies = [ "lazy_static", "serde", "serde_derive", - "solana-bincode", - "solana-hash", - "solana-instruction", - "solana-pubkey", - "solana-sanitize", - "solana-sdk-ids", - "solana-short-vec", - "solana-system-interface", - "solana-transaction-error", + "solana-bincode 2.2.1", + "solana-hash 2.3.0", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-sanitize 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-short-vec 2.2.1", + "solana-system-interface 1.0.0", + "solana-transaction-error 2.2.1", "wasm-bindgen", ] +[[package]] +name = "solana-message" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85666605c9fd727f865ed381665db0a8fc29f984a030ecc1e40f43bfb2541623" +dependencies = [ + "bincode", + "blake3", + "lazy_static", + "serde", + "serde_derive", + "solana-address 1.1.0", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-sanitize 3.0.1", + "solana-sdk-ids 3.1.0", + "solana-short-vec 3.1.0", + "solana-transaction-error 3.0.0", +] + [[package]] name = "solana-metrics" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e208835e05d7017d78619a441e30399c762fcce499d1d20577c553774680f66f" +checksum = "f8c46308f901be3b6b55e54bf8277fd6b6001361dbe583e5b033f88bc031197d" dependencies = [ "crossbeam-channel", "gethostname", "log", - "reqwest 0.12.23", + "reqwest 0.12.24", "solana-cluster-type", - "solana-sha256-hasher", + "solana-sha256-hasher 3.1.0", "solana-time-utils", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -6594,7 +7710,16 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36a1a14399afaabc2781a1db09cb14ee4cc4ee5c7a5a3cfcc601811379a8092" dependencies = [ - "solana-define-syscall", + "solana-define-syscall 2.3.0", +] + +[[package]] +name = "solana-msg" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "264275c556ea7e22b9d3f87d56305546a38d4eee8ec884f3b126236cb7dcbbb4" +dependencies = [ + "solana-define-syscall 3.0.0", ] [[package]] @@ -6603,23 +7728,31 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61515b880c36974053dd499c0510066783f0cc6ac17def0c7ef2a244874cf4a9" +[[package]] +name = "solana-native-token" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8dd4c280dca9d046139eb5b7a5ac9ad10403fbd64964c7d7571214950d758f" + [[package]] name = "solana-net-utils" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f42a434c8bf97ed2ae5080f66016abf25023a7fd8a26fd8d88e808446c7500" +checksum = "d2edb6edf83fa8b3d71135cda15d650062120e26021b41683bbbd94f527ed683" dependencies = [ "anyhow", "bincode", "bytes", + "cfg-if", + "dashmap", "itertools 0.12.1", "log", "nix", "rand 0.8.5", "serde", - "serde_derive", - "socket2 0.5.10", + "socket2 0.6.1", "solana-serde", + "solana-svm-type-overrides", "tokio", "url", ] @@ -6638,48 +7771,62 @@ checksum = "703e22eb185537e06204a5bd9d509b948f0066f2d1d814a6f475dafb3ddf1325" dependencies = [ "serde", "serde_derive", - "solana-fee-calculator", - "solana-hash", - "solana-pubkey", - "solana-sha256-hasher", + "solana-fee-calculator 2.2.1", + "solana-hash 2.3.0", + "solana-pubkey 2.4.0", + "solana-sha256-hasher 2.3.0", +] + +[[package]] +name = "solana-nonce" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abbdc6c8caf1c08db9f36a50967539d0f72b9f1d4aea04fec5430f532e5afadc" +dependencies = [ + "serde", + "serde_derive", + "solana-fee-calculator 3.0.0", + "solana-hash 3.1.0", + "solana-pubkey 3.0.0", + "solana-sha256-hasher 3.1.0", ] [[package]] name = "solana-nonce-account" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde971a20b8dbf60144d6a84439dda86b5466e00e2843091fe731083cda614da" +checksum = "805fd25b29e5a1a0e6c3dd6320c9da80f275fbe4ff6e392617c303a2085c435e" dependencies = [ - "solana-account", - "solana-hash", - "solana-nonce", - "solana-sdk-ids", + "solana-account 3.2.0", + "solana-hash 3.1.0", + "solana-nonce 3.0.0", + "solana-sdk-ids 3.1.0", ] [[package]] name = "solana-offchain-message" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b526398ade5dea37f1f147ce55dae49aa017a5d7326606359b0445ca8d946581" +checksum = "f6e2a1141a673f72a05cf406b99e4b2b8a457792b7c01afa07b3f00d4e2de393" dependencies = [ "num_enum", - "solana-hash", + "solana-hash 3.1.0", "solana-packet", - "solana-pubkey", - "solana-sanitize", - "solana-sha256-hasher", - "solana-signature", - "solana-signer", + "solana-pubkey 3.0.0", + "solana-sanitize 3.0.1", + "solana-sha256-hasher 3.1.0", + "solana-signature 3.1.0", + "solana-signer 3.0.0", ] [[package]] name = "solana-packet" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "004f2d2daf407b3ec1a1ca5ec34b3ccdfd6866dd2d3c7d0715004a96e4b6d127" +checksum = "6edf2f25743c95229ac0fdc32f8f5893ef738dbf332c669e9861d33ddb0f469d" dependencies = [ "bincode", - "bitflags 2.9.4", + "bitflags 2.10.0", "cfg_eval", "serde", "serde_derive", @@ -6688,9 +7835,9 @@ dependencies = [ [[package]] name = "solana-perf" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aed1dfb7f2c51b6b948531fd0127f8c10c71a9640c9804f106b41e6435adc768" +checksum = "60c681205a42c004c5a66d90bebe30f646936041894f20acd941667a412a4a5f" dependencies = [ "ahash 0.8.12", "bincode", @@ -6706,23 +7853,24 @@ dependencies = [ "rand 0.8.5", "rayon", "serde", - "solana-hash", - "solana-message", + "solana-hash 3.1.0", + "solana-message 3.0.1", "solana-metrics", "solana-packet", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-rayon-threadlimit", - "solana-sdk-ids", - "solana-short-vec", - "solana-signature", + "solana-sdk-ids 3.1.0", + "solana-short-vec 3.1.0", + "solana-signature 3.1.0", "solana-time-utils", + "solana-transaction-context 3.1.3", ] [[package]] name = "solana-poh-config" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d650c3b4b9060082ac6b0efbbb66865089c58405bfb45de449f3f2b91eccee75" +checksum = "2f1fef1f2ff2480fdbcc64bef5e3c47bec6e1647270db88b43f23e3a55f8d9cf" dependencies = [ "serde", "serde_derive", @@ -6730,52 +7878,36 @@ dependencies = [ [[package]] name = "solana-poseidon" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97889a27e92d1cee1b4b02edfc23b0ee3241765b79e6aea66e0a4d8a226e7bff" +checksum = "6e51c9ffecacac7691711b91e15f557af5ee652d0e8d66477f6c919b1ca4ed18" dependencies = [ - "ark-bn254", - "light-poseidon", - "solana-define-syscall", - "thiserror 2.0.16", + "ark-bn254 0.4.0", + "ark-bn254 0.5.0", + "light-poseidon 0.2.0", + "light-poseidon 0.4.0", + "solana-define-syscall 3.0.0", + "thiserror 2.0.17", ] [[package]] name = "solana-precompile-error" -version = "2.2.2" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d87b2c1f5de77dfe2b175ee8dd318d196aaca4d0f66f02842f80c852811f9f8" +checksum = "cafcd950de74c6c39d55dc8ca108bbb007799842ab370ef26cf45a34453c31e1" dependencies = [ "num-traits", - "solana-decode-error", -] - -[[package]] -name = "solana-precompiles" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36e92768a57c652edb0f5d1b30a7d0bc64192139c517967c18600debe9ae3832" -dependencies = [ - "lazy_static", - "solana-ed25519-program", - "solana-feature-set", - "solana-message", - "solana-precompile-error", - "solana-pubkey", - "solana-sdk-ids", - "solana-secp256k1-program", - "solana-secp256r1-program", ] [[package]] name = "solana-presigner" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a57a24e6a4125fc69510b6774cd93402b943191b6cddad05de7281491c90fe" +checksum = "0f704eaf825be3180832445b9e4983b875340696e8e7239bf2d535b0f86c14a2" dependencies = [ - "solana-pubkey", - "solana-signature", - "solana-signer", + "solana-pubkey 3.0.0", + "solana-signature 3.1.0", + "solana-signer 3.0.0", ] [[package]] @@ -6787,7 +7919,7 @@ dependencies = [ "bincode", "blake3", "borsh 0.10.4", - "borsh 1.5.7", + "borsh 1.6.0", "bs58", "bytemuck", "console_error_panic_hook", @@ -6803,71 +7935,130 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-account-info", - "solana-address-lookup-table-interface", - "solana-atomic-u64", - "solana-big-mod-exp", - "solana-bincode", - "solana-blake3-hasher", - "solana-borsh", - "solana-clock", - "solana-cpi", + "solana-account-info 2.3.0", + "solana-address-lookup-table-interface 2.2.2", + "solana-atomic-u64 2.2.1", + "solana-big-mod-exp 2.2.1", + "solana-bincode 2.2.1", + "solana-blake3-hasher 2.2.1", + "solana-borsh 2.2.1", + "solana-clock 2.2.2", + "solana-cpi 2.2.1", "solana-decode-error", - "solana-define-syscall", - "solana-epoch-rewards", - "solana-epoch-schedule", - "solana-example-mocks", - "solana-feature-gate-interface", - "solana-fee-calculator", - "solana-hash", - "solana-instruction", - "solana-instructions-sysvar", - "solana-keccak-hasher", - "solana-last-restart-slot", - "solana-loader-v2-interface", - "solana-loader-v3-interface", - "solana-loader-v4-interface", - "solana-message", - "solana-msg", - "solana-native-token", - "solana-nonce", - "solana-program-entrypoint", - "solana-program-error", - "solana-program-memory", - "solana-program-option", - "solana-program-pack", - "solana-pubkey", - "solana-rent", - "solana-sanitize", - "solana-sdk-ids", - "solana-sdk-macro", - "solana-secp256k1-recover", - "solana-serde-varint", - "solana-serialize-utils", - "solana-sha256-hasher", - "solana-short-vec", - "solana-slot-hashes", - "solana-slot-history", - "solana-stable-layout", - "solana-stake-interface", - "solana-system-interface", - "solana-sysvar", - "solana-sysvar-id", - "solana-vote-interface", - "thiserror 2.0.16", + "solana-define-syscall 2.3.0", + "solana-epoch-rewards 2.2.1", + "solana-epoch-schedule 2.2.1", + "solana-example-mocks 2.2.1", + "solana-feature-gate-interface 2.2.2", + "solana-fee-calculator 2.2.1", + "solana-hash 2.3.0", + "solana-instruction 2.3.3", + "solana-instructions-sysvar 2.2.2", + "solana-keccak-hasher 2.2.1", + "solana-last-restart-slot 2.2.1", + "solana-loader-v2-interface 2.2.1", + "solana-loader-v3-interface 5.0.0", + "solana-loader-v4-interface 2.2.1", + "solana-message 2.4.0", + "solana-msg 2.2.1", + "solana-native-token 2.3.0", + "solana-nonce 2.2.1", + "solana-program-entrypoint 2.3.0", + "solana-program-error 2.2.2", + "solana-program-memory 2.3.1", + "solana-program-option 2.2.1", + "solana-program-pack 2.2.1", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sanitize 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-sdk-macro 2.2.1", + "solana-secp256k1-recover 2.2.1", + "solana-serde-varint 2.2.2", + "solana-serialize-utils 2.2.1", + "solana-sha256-hasher 2.3.0", + "solana-short-vec 2.2.1", + "solana-slot-hashes 2.2.1", + "solana-slot-history 2.2.1", + "solana-stable-layout 2.2.1", + "solana-stake-interface 1.2.1", + "solana-system-interface 1.0.0", + "solana-sysvar 2.3.0", + "solana-sysvar-id 2.2.1", + "solana-vote-interface 2.2.6", + "thiserror 2.0.17", "wasm-bindgen", ] +[[package]] +name = "solana-program" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91b12305dd81045d705f427acd0435a2e46444b65367d7179d7bdcfc3bc5f5eb" +dependencies = [ + "memoffset", + "solana-account-info 3.1.0", + "solana-big-mod-exp 3.0.0", + "solana-blake3-hasher 3.1.0", + "solana-borsh 3.0.0", + "solana-clock 3.0.0", + "solana-cpi 3.1.0", + "solana-define-syscall 3.0.0", + "solana-epoch-rewards 3.0.0", + "solana-epoch-schedule 3.0.0", + "solana-epoch-stake", + "solana-example-mocks 3.0.0", + "solana-fee-calculator 3.0.0", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-instruction-error", + "solana-instructions-sysvar 3.0.0", + "solana-keccak-hasher 3.1.0", + "solana-last-restart-slot 3.0.0", + "solana-msg 3.0.0", + "solana-native-token 3.0.0", + "solana-program-entrypoint 3.1.1", + "solana-program-error 3.0.0", + "solana-program-memory 3.1.0", + "solana-program-option 3.0.0", + "solana-program-pack 3.0.0", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-secp256k1-recover 3.1.0", + "solana-serde-varint 3.0.0", + "solana-serialize-utils 3.1.0", + "solana-sha256-hasher 3.1.0", + "solana-short-vec 3.1.0", + "solana-slot-hashes 3.0.0", + "solana-slot-history 3.0.0", + "solana-stable-layout 3.0.0", + "solana-sysvar 3.1.1", + "solana-sysvar-id 3.1.0", +] + [[package]] name = "solana-program-entrypoint" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32ce041b1a0ed275290a5008ee1a4a6c48f5054c8a3d78d313c08958a06aedbd" dependencies = [ - "solana-account-info", - "solana-msg", - "solana-program-error", - "solana-pubkey", + "solana-account-info 2.3.0", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", +] + +[[package]] +name = "solana-program-entrypoint" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c9b0a1ff494e05f503a08b3d51150b73aa639544631e510279d6375f290997" +dependencies = [ + "solana-account-info 3.1.0", + "solana-define-syscall 4.0.1", + "solana-program-error 3.0.0", + "solana-pubkey 4.0.0", ] [[package]] @@ -6876,14 +8067,25 @@ version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ee2e0217d642e2ea4bee237f37bd61bb02aec60da3647c48ff88f6556ade775" dependencies = [ - "borsh 1.5.7", + "borsh 1.6.0", "num-traits", "serde", "serde_derive", "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-pubkey", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-pubkey 2.4.0", +] + +[[package]] +name = "solana-program-error" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1af32c995a7b692a915bb7414d5f8e838450cf7c70414e763d8abcae7b51f28" +dependencies = [ + "borsh 1.6.0", + "serde", + "serde_derive", ] [[package]] @@ -6892,7 +8094,16 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a5426090c6f3fd6cfdc10685322fede9ca8e5af43cd6a59e98bfe4e91671712" dependencies = [ - "solana-define-syscall", + "solana-define-syscall 2.3.0", +] + +[[package]] +name = "solana-program-memory" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4068648649653c2c50546e9a7fb761791b5ab0cda054c771bb5808d3a4b9eb52" +dependencies = [ + "solana-define-syscall 4.0.1", ] [[package]] @@ -6901,56 +8112,73 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc677a2e9bc616eda6dbdab834d463372b92848b2bfe4a1ed4e4b4adba3397d0" +[[package]] +name = "solana-program-option" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e7b4ddb464f274deb4a497712664c3b612e3f5f82471d4e47710fc4ab1c3095" + [[package]] name = "solana-program-pack" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "319f0ef15e6e12dc37c597faccb7d62525a509fec5f6975ecb9419efddeb277b" dependencies = [ - "solana-program-error", + "solana-program-error 2.2.2", +] + +[[package]] +name = "solana-program-pack" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c169359de21f6034a63ebf96d6b380980307df17a8d371344ff04a883ec4e9d0" +dependencies = [ + "solana-program-error 3.0.0", ] [[package]] name = "solana-program-runtime" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b1d11968572f776906505e2b794fbae01904da79598b338d4b3113a38ab10a6" +checksum = "1946dc97d7666617c6eb9231d07ffdfd36841ebef3b08e04e2dd2249c56843a1" dependencies = [ "base64 0.22.1", "bincode", - "enum-iterator", "itertools 0.12.1", "log", "percentage", "rand 0.8.5", "serde", - "solana-account", - "solana-clock", - "solana-epoch-rewards", - "solana-epoch-schedule", + "solana-account 3.2.0", + "solana-account-info 3.1.0", + "solana-clock 3.0.0", + "solana-epoch-rewards 3.0.0", + "solana-epoch-schedule 3.0.0", "solana-fee-structure", - "solana-hash", - "solana-instruction", - "solana-last-restart-slot", - "solana-log-collector", - "solana-measure", - "solana-metrics", - "solana-program-entrypoint", - "solana-pubkey", - "solana-rent", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-last-restart-slot 3.0.0", + "solana-loader-v3-interface 6.1.0", + "solana-program-entrypoint 3.1.1", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", "solana-sbpf", - "solana-sdk-ids", - "solana-slot-hashes", - "solana-stable-layout", + "solana-sdk-ids 3.1.0", + "solana-slot-hashes 3.0.0", + "solana-stable-layout 3.0.0", + "solana-stake-interface 2.0.1", "solana-svm-callback", - "solana-svm-feature-set", - "solana-system-interface", - "solana-sysvar", - "solana-sysvar-id", - "solana-timings", - "solana-transaction-context", - "solana-type-overrides", - "thiserror 2.0.16", + "solana-svm-feature-set 3.1.3", + "solana-svm-log-collector", + "solana-svm-measure", + "solana-svm-timings", + "solana-svm-transaction", + "solana-svm-type-overrides", + "solana-system-interface 2.0.0", + "solana-sysvar 3.1.1", + "solana-sysvar-id 3.1.0", + "solana-transaction-context 3.1.3", + "thiserror 2.0.17", ] [[package]] @@ -6960,31 +8188,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b62adb9c3261a052ca1f999398c388f1daf558a1b492f60a6d9e64857db4ff1" dependencies = [ "borsh 0.10.4", - "borsh 1.5.7", + "borsh 1.6.0", "bytemuck", "bytemuck_derive", "curve25519-dalek 4.1.3", - "five8", - "five8_const", + "five8 0.2.1", + "five8_const 0.1.4", "getrandom 0.2.16", "js-sys", "num-traits", - "rand 0.8.5", "serde", "serde_derive", - "solana-atomic-u64", + "solana-atomic-u64 2.2.1", "solana-decode-error", - "solana-define-syscall", - "solana-sanitize", - "solana-sha256-hasher", + "solana-define-syscall 2.3.0", + "solana-sanitize 2.2.1", + "solana-sha256-hasher 2.3.0", "wasm-bindgen", ] +[[package]] +name = "solana-pubkey" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8909d399deb0851aa524420beeb5646b115fd253ef446e35fe4504c904da3941" +dependencies = [ + "rand 0.8.5", + "solana-address 1.1.0", +] + +[[package]] +name = "solana-pubkey" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6f7104d456b58e1418c21a8581e89810278d1190f70f27ece7fc0b2c9282a57" +dependencies = [ + "solana-address 2.0.0", +] + [[package]] name = "solana-pubsub-client" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df314b22923b112c7bd90629b42af3881222b8955e3a1d4cf2b21f5ab794a0bb" +checksum = "27b1fd9238ec0868382d1405a18d1d9dbf78fd8bfb1bc33c199d856400c4129b" dependencies = [ "crossbeam-channel", "futures-util", @@ -6992,14 +8238,13 @@ dependencies = [ "log", "semver", "serde", - "serde_derive", "serde_json", - "solana-account-decoder-client-types", - "solana-clock", - "solana-pubkey", + "solana-account-decoder-client-types 3.1.3", + "solana-clock 3.0.0", + "solana-pubkey 3.0.0", "solana-rpc-client-types", - "solana-signature", - "thiserror 2.0.16", + "solana-signature 3.1.0", + "thiserror 2.0.17", "tokio", "tokio-stream", "tokio-tungstenite", @@ -7009,9 +8254,9 @@ dependencies = [ [[package]] name = "solana-quic-client" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "022865e50402d978b90cc3090d6d2a098ed9af549ce69a7deed92cf203f3a4a3" +checksum = "de5985d8dab9b47d28f81773afb3d3b96df9e4b785baf824628e5ff22c6d82b2" dependencies = [ "async-lock", "async-trait", @@ -7020,38 +8265,39 @@ dependencies = [ "log", "quinn", "quinn-proto", - "rustls 0.23.32", + "rustls 0.23.35", "solana-connection-cache", - "solana-keypair", + "solana-keypair 3.1.0", "solana-measure", "solana-metrics", "solana-net-utils", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-quic-definitions", "solana-rpc-client-api", - "solana-signer", + "solana-signer 3.0.0", "solana-streamer", "solana-tls-utils", - "solana-transaction-error", - "thiserror 2.0.16", + "solana-transaction-error 3.0.0", + "thiserror 2.0.17", "tokio", ] [[package]] name = "solana-quic-definitions" -version = "2.3.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf0d4d5b049eb1d0c35f7b18f305a27c8986fc5c0c9b383e97adaa35334379e" +checksum = "15319accf7d3afd845817aeffa6edd8cc185f135cefbc6b985df29cfd8c09609" dependencies = [ - "solana-keypair", + "solana-keypair 3.1.0", ] [[package]] name = "solana-rayon-threadlimit" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99a753bb24fd7f697d92343a6f6b50cd1e9e1e5e6267b9224821ab3972939e8" +checksum = "4e4bc48c5884744db48e7c394cc563985828b869e3c49c6eb8d95d78777ffd35" dependencies = [ + "log", "num_cpus", ] @@ -7063,55 +8309,39 @@ checksum = "d1aea8fdea9de98ca6e8c2da5827707fb3842833521b528a713810ca685d2480" dependencies = [ "serde", "serde_derive", - "solana-sdk-ids", - "solana-sdk-macro", - "solana-sysvar-id", + "solana-sdk-ids 2.2.1", + "solana-sdk-macro 2.2.1", + "solana-sysvar-id 2.2.1", ] [[package]] -name = "solana-rent-collector" -version = "2.3.0" +name = "solana-rent" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "127e6dfa51e8c8ae3aa646d8b2672bc4ac901972a338a9e1cd249e030564fb9d" +checksum = "b702d8c43711e3c8a9284a4f1bbc6a3de2553deb25b0c8142f9a44ef0ce5ddc1" dependencies = [ "serde", "serde_derive", - "solana-account", - "solana-clock", - "solana-epoch-schedule", - "solana-genesis-config", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", + "solana-sdk-ids 3.1.0", + "solana-sdk-macro 3.0.0", + "solana-sysvar-id 3.1.0", ] [[package]] -name = "solana-rent-debits" +name = "solana-reward-info" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f6f9113c6003492e74438d1288e30cffa8ccfdc2ef7b49b9e816d8034da18cd" -dependencies = [ - "solana-pubkey", - "solana-reward-info", -] - -[[package]] -name = "solana-reserved-account-keys" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4b22ea19ca2a3f28af7cd047c914abf833486bf7a7c4a10fc652fff09b385b1" +checksum = "18205b69139b1ae0ab8f6e11cdcb627328c0814422ad2482000fa2ca54ae4a2f" dependencies = [ - "lazy_static", - "solana-feature-set", - "solana-pubkey", - "solana-sdk-ids", + "serde", + "serde_derive", ] [[package]] name = "solana-reward-info" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18205b69139b1ae0ab8f6e11cdcb627328c0814422ad2482000fa2ca54ae4a2f" +checksum = "82be7946105c2ee6be9f9ee7bd18a068b558389221d29efa92b906476102bfcc" dependencies = [ "serde", "serde_derive", @@ -7119,120 +8349,125 @@ dependencies = [ [[package]] name = "solana-rpc-client" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9238867c44e246ddd0427b8e8e21de1b98c6e63a243ae36c7d8429d2e0b29390" +checksum = "695f5c9e9afbb79269d173db59ec79993720b817212addc0367fc447e12eb0da" dependencies = [ "async-trait", "base64 0.22.1", "bincode", "bs58", "futures", - "indicatif", + "indicatif 0.18.3", "log", - "reqwest 0.12.23", + "reqwest 0.12.24", "reqwest-middleware", "semver", "serde", - "serde_derive", "serde_json", - "solana-account", - "solana-account-decoder-client-types", - "solana-clock", - "solana-commitment-config", + "solana-account 3.2.0", + "solana-account-decoder 3.1.3", + "solana-account-decoder-client-types 3.1.3", + "solana-clock 3.0.0", + "solana-commitment-config 3.1.0", "solana-epoch-info", - "solana-epoch-schedule", - "solana-feature-gate-interface", - "solana-hash", - "solana-instruction", - "solana-message", - "solana-pubkey", + "solana-epoch-schedule 3.0.0", + "solana-feature-gate-interface 3.0.0", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-message 3.0.1", + "solana-pubkey 3.0.0", "solana-rpc-client-api", - "solana-signature", - "solana-transaction", - "solana-transaction-error", - "solana-transaction-status-client-types", + "solana-signature 3.1.0", + "solana-transaction 3.0.2", + "solana-transaction-error 3.0.0", + "solana-transaction-status-client-types 3.1.3", "solana-version", - "solana-vote-interface", + "solana-vote-interface 4.0.4", "tokio", ] [[package]] name = "solana-rpc-client-api" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "735b5dc6f2ec3cfb1a39f1327e5855c741edaa8aa7eb1613e6d918cda4cf3c29" +checksum = "e6eeb20b0d1b0d4daaf2e2f8d5e2c008d8809282b2ccc1451c68d427d6662d78" dependencies = [ "anyhow", "jsonrpc-core", - "reqwest 0.12.23", + "reqwest 0.12.24", "reqwest-middleware", "serde", - "serde_derive", "serde_json", - "solana-account-decoder-client-types", - "solana-clock", + "solana-account-decoder-client-types 3.1.3", + "solana-clock 3.0.0", "solana-rpc-client-types", - "solana-signer", - "solana-transaction-error", - "solana-transaction-status-client-types", - "thiserror 2.0.16", + "solana-signer 3.0.0", + "solana-transaction-error 3.0.0", + "solana-transaction-status-client-types 3.1.3", + "thiserror 2.0.17", ] [[package]] name = "solana-rpc-client-nonce-utils" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32cbcb994c698ffaea792ec0dba3ae84259c53e7dc464cc6b2321a3d593c7f61" +checksum = "694ee738ae2981a584f3ae984e53f4ea1deaca400147867ef030c42891e8de74" dependencies = [ - "solana-account", - "solana-commitment-config", - "solana-hash", - "solana-message", - "solana-nonce", - "solana-pubkey", + "solana-account 3.2.0", + "solana-commitment-config 3.1.0", + "solana-hash 3.1.0", + "solana-message 3.0.1", + "solana-nonce 3.0.0", + "solana-pubkey 3.0.0", "solana-rpc-client", - "solana-sdk-ids", - "thiserror 2.0.16", + "solana-sdk-ids 3.1.0", + "thiserror 2.0.17", ] [[package]] name = "solana-rpc-client-types" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b96eeec383718c1a4dbbebc4039029ae779d7e6ec5586b6a330803132d04f4f" +checksum = "151719868cc3fece2d268795951f732d74423ac64e6832e33aba00a76713d1e8" dependencies = [ "base64 0.22.1", "bs58", "semver", "serde", - "serde_derive", "serde_json", - "solana-account", - "solana-account-decoder-client-types", - "solana-clock", - "solana-commitment-config", - "solana-fee-calculator", + "solana-account 3.2.0", + "solana-account-decoder-client-types 3.1.3", + "solana-address 1.1.0", + "solana-clock 3.0.0", + "solana-commitment-config 3.1.0", + "solana-fee-calculator 3.0.0", "solana-inflation", - "solana-pubkey", - "solana-transaction-error", - "solana-transaction-status-client-types", + "solana-reward-info 3.0.0", + "solana-transaction 3.0.2", + "solana-transaction-error 3.0.0", + "solana-transaction-status-client-types 3.1.3", "solana-version", - "spl-generic-token", - "thiserror 2.0.16", + "spl-generic-token 2.0.1", + "thiserror 2.0.17", ] [[package]] name = "solana-runtime" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "437c883f83cb4f43f616c035c3c4d0810ab183105f2c200e841a2b9278dc5055" +checksum = "6a778afa6c1fde03f12759fb6a3116c8a4d6c38d1b909dc2baa64a0528ead25a" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", + "agave-fs", "agave-precompiles", - "agave-reserved-account-keys", + "agave-reserved-account-keys 3.1.3", + "agave-snapshots", + "agave-syscalls", + "agave-votor-messages", "ahash 0.8.12", "aquamarine", + "arc-swap", "arrayref", "assert_matches", "base64 0.22.1", @@ -7240,18 +8475,16 @@ dependencies = [ "blake3", "bv", "bytemuck", - "bzip2", "crossbeam-channel", "dashmap", "dir-diff", - "flate2", "fnv", "im", "itertools 0.12.1", "libc", "log", "lz4", - "memmap2 0.9.8", + "memmap2 0.9.9", "mockall", "modular-bitfield", "num-derive", @@ -7263,121 +8496,119 @@ dependencies = [ "rand 0.8.5", "rayon", "regex", + "semver", "serde", - "serde_derive", "serde_json", "serde_with", - "solana-account", - "solana-account-info", + "solana-account 3.2.0", + "solana-account-info 3.1.0", "solana-accounts-db", - "solana-address-lookup-table-interface", + "solana-address-lookup-table-interface 3.0.0", + "solana-bls-signatures", "solana-bpf-loader-program", "solana-bucket-map", "solana-builtins", "solana-client-traits", - "solana-clock", - "solana-commitment-config", + "solana-clock 3.0.0", + "solana-cluster-type", + "solana-commitment-config 3.1.0", "solana-compute-budget", "solana-compute-budget-instruction", "solana-compute-budget-interface", + "solana-config-interface", "solana-cost-model", - "solana-cpi", + "solana-cpi 3.1.0", "solana-ed25519-program", "solana-epoch-info", "solana-epoch-rewards-hasher", - "solana-epoch-schedule", - "solana-feature-gate-interface", + "solana-epoch-schedule 3.0.0", + "solana-feature-gate-interface 3.0.0", "solana-fee", - "solana-fee-calculator", + "solana-fee-calculator 3.0.0", "solana-fee-structure", "solana-genesis-config", "solana-hard-forks", - "solana-hash", + "solana-hash 3.1.0", "solana-inflation", - "solana-instruction", - "solana-keypair", + "solana-instruction 3.1.0", + "solana-keypair 3.1.0", "solana-lattice-hash", - "solana-loader-v3-interface", - "solana-loader-v4-interface", + "solana-loader-v3-interface 6.1.0", + "solana-loader-v4-interface 3.1.0", "solana-measure", - "solana-message", + "solana-message 3.0.1", "solana-metrics", - "solana-native-token", + "solana-native-token 3.0.0", "solana-nohash-hasher", - "solana-nonce", + "solana-nonce 3.0.0", "solana-nonce-account", "solana-packet", "solana-perf", "solana-poh-config", "solana-precompile-error", "solana-program-runtime", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-rayon-threadlimit", - "solana-rent", - "solana-rent-collector", - "solana-rent-debits", - "solana-reward-info", + "solana-rent 3.0.0", + "solana-reward-info 3.0.0", "solana-runtime-transaction", - "solana-sdk-ids", + "solana-sdk-ids 3.1.0", "solana-secp256k1-program", - "solana-seed-derivable", + "solana-seed-derivable 3.0.0", "solana-serde", - "solana-sha256-hasher", - "solana-signature", - "solana-signer", - "solana-slot-hashes", - "solana-slot-history", - "solana-stake-interface", - "solana-stake-program", + "solana-sha256-hasher 3.1.0", + "solana-signature 3.1.0", + "solana-signer 3.0.0", + "solana-slot-hashes 3.0.0", + "solana-slot-history 3.0.0", + "solana-stake-interface 2.0.1", "solana-svm", "solana-svm-callback", - "solana-svm-rent-collector", + "solana-svm-timings", "solana-svm-transaction", - "solana-system-interface", + "solana-system-interface 2.0.0", "solana-system-transaction", - "solana-sysvar", - "solana-sysvar-id", + "solana-sysvar 3.1.1", + "solana-sysvar-id 3.1.0", "solana-time-utils", - "solana-timings", - "solana-transaction", - "solana-transaction-context", - "solana-transaction-error", - "solana-transaction-status-client-types", + "solana-transaction 3.0.2", + "solana-transaction-context 3.1.3", + "solana-transaction-error 3.0.0", + "solana-transaction-status-client-types 3.1.3", "solana-unified-scheduler-logic", "solana-version", "solana-vote", - "solana-vote-interface", + "solana-vote-interface 4.0.4", "solana-vote-program", - "spl-generic-token", + "spl-generic-token 2.0.1", "static_assertions", "strum 0.24.1", "strum_macros 0.24.3", "symlink", - "tar", "tempfile", - "thiserror 2.0.16", - "zstd", + "thiserror 2.0.17", ] [[package]] name = "solana-runtime-transaction" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7395e29f0fcc035cf4926b830c4330ecb1c450fa8e95ed29b5447876763eb5f2" +checksum = "21d6fc87b6eed4b29530501d65c14bdac6c96cd8812deb81df66be4cc49b06bf" dependencies = [ "agave-transaction-view", "log", "solana-compute-budget", "solana-compute-budget-instruction", - "solana-hash", - "solana-message", - "solana-pubkey", - "solana-sdk-ids", - "solana-signature", + "solana-hash 3.1.0", + "solana-message 3.0.1", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-signature 3.1.0", "solana-svm-transaction", - "solana-transaction", - "solana-transaction-error", - "thiserror 2.0.16", + "solana-transaction 3.0.2", + "solana-transaction-context 3.1.3", + "solana-transaction-error 3.0.0", + "thiserror 2.0.17", ] [[package]] @@ -7386,11 +8617,17 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61f1bc1357b8188d9c4a3af3fc55276e56987265eb7ad073ae6f8180ee54cecf" +[[package]] +name = "solana-sanitize" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf09694a0fc14e5ffb18f9b7b7c0f15ecb6eac5b5610bf76a1853459d19daf9" + [[package]] name = "solana-sbpf" -version = "0.11.1" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "474a2d95dc819898ded08d24f29642d02189d3e1497bbb442a92a3997b7eb55f" +checksum = "b15b079e08471a9dbfe1e48b2c7439c85aa2a055cbd54eddd8bd257b0a7dbb29" dependencies = [ "byteorder", "combine 3.8.1", @@ -7399,79 +8636,46 @@ dependencies = [ "log", "rand 0.8.5", "rustc-demangle", - "thiserror 2.0.16", + "thiserror 2.0.17", "winapi", ] [[package]] name = "solana-sdk" -version = "2.3.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cc0e4a7635b902791c44b6581bfb82f3ada32c5bc0929a64f39fe4bb384c86a" +checksum = "3f03df7969f5e723ad31b6c9eadccc209037ac4caa34d8dc259316b05c11e82b" dependencies = [ "bincode", "bs58", - "getrandom 0.1.16", - "js-sys", "serde", - "serde_json", - "solana-account", - "solana-bn254", - "solana-client-traits", - "solana-cluster-type", - "solana-commitment-config", - "solana-compute-budget-interface", - "solana-decode-error", - "solana-derivation-path", - "solana-ed25519-program", + "solana-account 3.2.0", "solana-epoch-info", "solana-epoch-rewards-hasher", - "solana-feature-set", "solana-fee-structure", - "solana-genesis-config", - "solana-hard-forks", "solana-inflation", - "solana-instruction", - "solana-keypair", - "solana-message", - "solana-native-token", - "solana-nonce-account", + "solana-keypair 3.1.0", + "solana-message 3.0.1", "solana-offchain-message", - "solana-packet", - "solana-poh-config", - "solana-precompile-error", - "solana-precompiles", "solana-presigner", - "solana-program", - "solana-program-memory", - "solana-pubkey", - "solana-quic-definitions", - "solana-rent-collector", - "solana-rent-debits", - "solana-reserved-account-keys", - "solana-reward-info", - "solana-sanitize", - "solana-sdk-ids", - "solana-sdk-macro", - "solana-secp256k1-program", - "solana-secp256k1-recover", - "solana-secp256r1-program", - "solana-seed-derivable", - "solana-seed-phrase", + "solana-program 3.0.0", + "solana-program-memory 3.1.0", + "solana-pubkey 3.0.0", + "solana-sanitize 3.0.1", + "solana-sdk-ids 3.1.0", + "solana-sdk-macro 3.0.0", + "solana-seed-derivable 3.0.0", + "solana-seed-phrase 3.0.0", "solana-serde", - "solana-serde-varint", - "solana-short-vec", + "solana-serde-varint 3.0.0", + "solana-short-vec 3.1.0", "solana-shred-version", - "solana-signature", - "solana-signer", - "solana-system-transaction", + "solana-signature 3.1.0", + "solana-signer 3.0.0", "solana-time-utils", - "solana-transaction", - "solana-transaction-context", - "solana-transaction-error", - "solana-validator-exit", - "thiserror 2.0.16", - "wasm-bindgen", + "solana-transaction 3.0.2", + "solana-transaction-error 3.0.0", + "thiserror 2.0.17", ] [[package]] @@ -7480,7 +8684,16 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c5d8b9cc68d5c88b062a33e23a6466722467dde0035152d8fb1afbcdf350a5f" dependencies = [ - "solana-pubkey", + "solana-pubkey 2.4.0", +] + +[[package]] +name = "solana-sdk-ids" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def234c1956ff616d46c9dd953f251fa7096ddbaa6d52b165218de97882b7280" +dependencies = [ + "solana-address 2.0.0", ] [[package]] @@ -7492,26 +8705,33 @@ dependencies = [ "bs58", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", +] + +[[package]] +name = "solana-sdk-macro" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6430000e97083460b71d9fbadc52a2ab2f88f53b3a4c5e58c5ae3640a0e8c00" +dependencies = [ + "bs58", + "proc-macro2", + "quote", + "syn 2.0.111", ] [[package]] name = "solana-secp256k1-program" -version = "2.2.3" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f19833e4bc21558fe9ec61f239553abe7d05224347b57d65c2218aeeb82d6149" +checksum = "8efa767b0188f577edae7080e8bf080e5db9458e2b6ee5beaa73e2e6bb54e99d" dependencies = [ - "bincode", "digest 0.10.7", - "libsecp256k1", + "k256", "serde", "serde_derive", "sha3", - "solana-feature-set", - "solana-instruction", - "solana-precompile-error", - "solana-sdk-ids", - "solana-signature", + "solana-signature 3.1.0", ] [[package]] @@ -7520,31 +8740,42 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baa3120b6cdaa270f39444f5093a90a7b03d296d362878f7a6991d6de3bbe496" dependencies = [ - "borsh 1.5.7", "libsecp256k1", - "solana-define-syscall", - "thiserror 2.0.16", + "solana-define-syscall 2.3.0", + "thiserror 2.0.17", +] + +[[package]] +name = "solana-secp256k1-recover" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9de18cfdab99eeb940fbedd8c981fa130c0d76252da75d05446f22fae8b51932" +dependencies = [ + "k256", + "solana-define-syscall 4.0.1", + "thiserror 2.0.17", ] [[package]] name = "solana-secp256r1-program" -version = "2.2.4" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce0ae46da3071a900f02d367d99b2f3058fe2e90c5062ac50c4f20cfedad8f0f" +checksum = "445d8e12592631d76fc4dc57858bae66c9fd7cc838c306c62a472547fc9d0ce6" dependencies = [ "bytemuck", "openssl", - "solana-feature-set", - "solana-instruction", - "solana-precompile-error", - "solana-sdk-ids", + "solana-instruction 3.1.0", + "solana-sdk-ids 3.1.0", ] [[package]] name = "solana-security-txt" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "468aa43b7edb1f9b7b7b686d5c3aeb6630dc1708e86e31343499dd5c4d775183" +checksum = "156bb61a96c605fa124e052d630dba2f6fb57e08c7d15b757e1e958b3ed7b3fe" +dependencies = [ + "hashbrown 0.15.2", +] [[package]] name = "solana-seed-derivable" @@ -7552,7 +8783,16 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3beb82b5adb266c6ea90e5cf3967235644848eac476c5a1f2f9283a143b7c97f" dependencies = [ - "solana-derivation-path", + "solana-derivation-path 2.2.1", +] + +[[package]] +name = "solana-seed-derivable" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff7bdb72758e3bec33ed0e2658a920f1f35dfb9ed576b951d20d63cb61ecd95c" +dependencies = [ + "solana-derivation-path 3.0.0", ] [[package]] @@ -7566,11 +8806,22 @@ dependencies = [ "sha2 0.10.9", ] +[[package]] +name = "solana-seed-phrase" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc905b200a95f2ea9146e43f2a7181e3aeb55de6bc12afb36462d00a3c7310de" +dependencies = [ + "hmac 0.12.1", + "pbkdf2", + "sha2 0.10.9", +] + [[package]] name = "solana-serde" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1931484a408af466e14171556a47adaa215953c7f48b24e5f6b0282763818b04" +checksum = "709a93cab694c70f40b279d497639788fc2ccbcf9b4aa32273d4b361322c02dd" dependencies = [ "serde", ] @@ -7585,14 +8836,34 @@ dependencies = [ ] [[package]] -name = "solana-serialize-utils" -version = "2.2.1" +name = "solana-serde-varint" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "817a284b63197d2b27afdba829c5ab34231da4a9b4e763466a003c40ca4f535e" +checksum = "3e5174c57d5ff3c1995f274d17156964664566e2cde18a07bba1586d35a70d3b" dependencies = [ - "solana-instruction", - "solana-pubkey", - "solana-sanitize", + "serde", +] + +[[package]] +name = "solana-serialize-utils" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "817a284b63197d2b27afdba829c5ab34231da4a9b4e763466a003c40ca4f535e" +dependencies = [ + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-sanitize 2.2.1", +] + +[[package]] +name = "solana-serialize-utils" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e41dd8feea239516c623a02f0a81c2367f4b604d7965237fed0751aeec33ed" +dependencies = [ + "solana-instruction-error", + "solana-pubkey 3.0.0", + "solana-sanitize 3.0.1", ] [[package]] @@ -7602,8 +8873,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aa3feb32c28765f6aa1ce8f3feac30936f16c5c3f7eb73d63a5b8f6f8ecdc44" dependencies = [ "sha2 0.10.9", - "solana-define-syscall", - "solana-hash", + "solana-define-syscall 2.3.0", + "solana-hash 2.3.0", +] + +[[package]] +name = "solana-sha256-hasher" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db7dc3011ea4c0334aaaa7e7128cb390ecf546b28d412e9bf2064680f57f588f" +dependencies = [ + "sha2 0.10.9", + "solana-define-syscall 4.0.1", + "solana-hash 4.0.1", ] [[package]] @@ -7615,15 +8897,24 @@ dependencies = [ "serde", ] +[[package]] +name = "solana-short-vec" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79fb1809a32cfcf7d9c47b7070a92fa17cdb620ab5829e9a8a9ff9d138a7a175" +dependencies = [ + "serde_core", +] + [[package]] name = "solana-shred-version" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afd3db0461089d1ad1a78d9ba3f15b563899ca2386351d38428faa5350c60a98" +checksum = "94953e22ca28fe4541a3447d6baeaf519cc4ddc063253bfa673b721f34c136bb" dependencies = [ "solana-hard-forks", - "solana-hash", - "solana-sha256-hasher", + "solana-hash 3.1.0", + "solana-sha256-hasher 3.1.0", ] [[package]] @@ -7632,13 +8923,27 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64c8ec8e657aecfc187522fc67495142c12f35e55ddeca8698edbb738b8dbd8c" dependencies = [ - "ed25519-dalek", - "five8", + "ed25519-dalek 1.0.1", + "five8 0.2.1", + "serde", + "serde-big-array", + "serde_derive", + "solana-sanitize 2.2.1", +] + +[[package]] +name = "solana-signature" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bb8057cc0e9f7b5e89883d49de6f407df655bb6f3a71d0b7baf9986a2218fd9" +dependencies = [ + "ed25519-dalek 2.2.0", + "five8 0.2.1", "rand 0.8.5", "serde", "serde-big-array", "serde_derive", - "solana-sanitize", + "solana-sanitize 3.0.1", ] [[package]] @@ -7647,9 +8952,20 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c41991508a4b02f021c1342ba00bcfa098630b213726ceadc7cb032e051975b" dependencies = [ - "solana-pubkey", - "solana-signature", - "solana-transaction-error", + "solana-pubkey 2.4.0", + "solana-signature 2.3.0", + "solana-transaction-error 2.2.1", +] + +[[package]] +name = "solana-signer" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bfea97951fee8bae0d6038f39a5efcb6230ecdfe33425ac75196d1a1e3e3235" +dependencies = [ + "solana-pubkey 3.0.0", + "solana-signature 3.1.0", + "solana-transaction-error 3.0.0", ] [[package]] @@ -7660,9 +8976,22 @@ checksum = "0c8691982114513763e88d04094c9caa0376b867a29577939011331134c301ce" dependencies = [ "serde", "serde_derive", - "solana-hash", - "solana-sdk-ids", - "solana-sysvar-id", + "solana-hash 2.3.0", + "solana-sdk-ids 2.2.1", + "solana-sysvar-id 2.2.1", +] + +[[package]] +name = "solana-slot-hashes" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80a293f952293281443c04f4d96afd9d547721923d596e92b4377ed2360f1746" +dependencies = [ + "serde", + "serde_derive", + "solana-hash 3.1.0", + "solana-sdk-ids 3.1.0", + "solana-sysvar-id 3.1.0", ] [[package]] @@ -7674,8 +9003,21 @@ dependencies = [ "bv", "serde", "serde_derive", - "solana-sdk-ids", - "solana-sysvar-id", + "solana-sdk-ids 2.2.1", + "solana-sysvar-id 2.2.1", +] + +[[package]] +name = "solana-slot-history" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f914f6b108f5bba14a280b458d023e3621c9973f27f015a4d755b50e88d89e97" +dependencies = [ + "bv", + "serde", + "serde_derive", + "solana-sdk-ids 3.1.0", + "solana-sysvar-id 3.1.0", ] [[package]] @@ -7684,8 +9026,18 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f14f7d02af8f2bc1b5efeeae71bc1c2b7f0f65cd75bcc7d8180f2c762a57f54" dependencies = [ - "solana-instruction", - "solana-pubkey", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", +] + +[[package]] +name = "solana-stable-layout" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1da74507795b6e8fb60b7c7306c0c36e2c315805d16eaaf479452661234685ac" +dependencies = [ + "solana-instruction 3.1.0", + "solana-pubkey 3.0.0", ] [[package]] @@ -7695,56 +9047,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5269e89fde216b4d7e1d1739cf5303f8398a1ff372a81232abbee80e554a838c" dependencies = [ "borsh 0.10.4", - "borsh 1.5.7", + "borsh 1.6.0", "num-traits", "serde", "serde_derive", - "solana-clock", - "solana-cpi", + "solana-clock 2.2.2", + "solana-cpi 2.2.1", "solana-decode-error", - "solana-instruction", - "solana-program-error", - "solana-pubkey", - "solana-system-interface", - "solana-sysvar-id", + "solana-instruction 2.3.3", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", + "solana-system-interface 1.0.0", + "solana-sysvar-id 2.2.1", ] [[package]] -name = "solana-stake-program" -version = "2.3.10" +name = "solana-stake-interface" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde8d700ff79abd00fd17f69090908c2185cc8c5e2554f6f788b40bab9be2d8e" +checksum = "f6f912ae679b683365348dea482dbd9468d22ff258b554fd36e3d3683c2122e3" dependencies = [ - "agave-feature-set", - "bincode", - "log", - "solana-account", - "solana-bincode", - "solana-clock", - "solana-config-program-client", - "solana-genesis-config", - "solana-instruction", - "solana-log-collector", - "solana-native-token", - "solana-packet", - "solana-program-runtime", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", - "solana-stake-interface", - "solana-sysvar", - "solana-transaction-context", - "solana-type-overrides", - "solana-vote-interface", + "num-traits", + "serde", + "serde_derive", + "solana-clock 3.0.0", + "solana-cpi 3.1.0", + "solana-instruction 3.1.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", + "solana-system-interface 2.0.0", + "solana-sysvar 3.1.1", + "solana-sysvar-id 3.1.0", ] [[package]] name = "solana-storage-bigtable" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "853f9462e2fdbe0513d071a83fa4e04440bf0ab7100b3f0cef1df7c9bfd9565e" +checksum = "0ca57335e89774043dbf8f41d1bd300f81e6a61f13cad688eabae1c7b24f0729" dependencies = [ - "agave-reserved-account-keys", + "agave-reserved-account-keys 3.1.3", "backoff", "bincode", "bytes", @@ -7761,20 +9103,19 @@ dependencies = [ "prost 0.11.9", "prost-types 0.11.9", "serde", - "serde_derive", "smpl_jwt", - "solana-clock", - "solana-message", + "solana-clock 3.0.0", + "solana-message 3.0.1", "solana-metrics", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-serde", - "solana-signature", + "solana-signature 3.1.0", "solana-storage-proto", "solana-time-utils", - "solana-transaction", - "solana-transaction-error", - "solana-transaction-status", - "thiserror 2.0.16", + "solana-transaction 3.0.2", + "solana-transaction-error 3.0.0", + "solana-transaction-status 3.1.3", + "thiserror 2.0.17", "tokio", "tonic 0.9.2", "zstd", @@ -7782,36 +9123,36 @@ dependencies = [ [[package]] name = "solana-storage-proto" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4fee13c4b2c5368852b43d876becef279471f7d84036347e9c97bed1302c2f" +checksum = "f59231870d0ddabf9860c0a22ecdef8ff8f778aa4105d7ad8a4ac18bc1efd428" dependencies = [ "bincode", "bs58", "prost 0.11.9", "protobuf-src", "serde", - "solana-account-decoder", - "solana-hash", - "solana-instruction", - "solana-message", - "solana-pubkey", + "solana-account-decoder 3.1.3", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-message 3.0.1", + "solana-pubkey 3.0.0", "solana-serde", - "solana-signature", - "solana-transaction", - "solana-transaction-context", - "solana-transaction-error", - "solana-transaction-status", + "solana-signature 3.1.0", + "solana-transaction 3.0.2", + "solana-transaction-context 3.1.3", + "solana-transaction-error 3.0.0", + "solana-transaction-status 3.1.3", "tonic-build 0.9.2", ] [[package]] name = "solana-streamer" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1faa9bfb0bc556b77d836cacf347c4e1754a0334e8b9946dbed49ead4e1c0eb2" +checksum = "899889e499eaa2faed76e271c52d867ea69ddc22b40274df837a89b8ab6c1e89" dependencies = [ - "async-channel", + "arc-swap", "bytes", "crossbeam-channel", "dashmap", @@ -7819,34 +9160,35 @@ dependencies = [ "futures-util", "governor", "histogram", - "indexmap 2.11.4", + "indexmap 2.12.1", "itertools 0.12.1", "libc", "log", "nix", + "num_cpus", "pem", "percentage", "quinn", "quinn-proto", "rand 0.8.5", - "rustls 0.23.32", + "rustls 0.23.35", "smallvec", - "socket2 0.5.10", - "solana-keypair", + "socket2 0.6.1", + "solana-keypair 3.1.0", "solana-measure", "solana-metrics", "solana-net-utils", "solana-packet", "solana-perf", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-quic-definitions", - "solana-signature", - "solana-signer", + "solana-signature 3.1.0", + "solana-signer 3.0.0", "solana-time-utils", "solana-tls-utils", - "solana-transaction-error", + "solana-transaction-error 3.0.0", "solana-transaction-metrics-tracker", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tokio-util", "x509-parser", @@ -7854,96 +9196,118 @@ dependencies = [ [[package]] name = "solana-svm" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b9039c65a27023105fe902949557f86922570156015d8b76cf05e193faa9d64" +checksum = "95e4f9b2f74565d69ec3041f6540e0a4b4a4f654648f54f3e04c9c3f28477277" dependencies = [ "ahash 0.8.12", "log", "percentage", "serde", - "serde_derive", - "solana-account", - "solana-clock", + "solana-account 3.2.0", + "solana-clock 3.0.0", "solana-fee-structure", - "solana-hash", - "solana-instruction", - "solana-instructions-sysvar", - "solana-loader-v3-interface", - "solana-loader-v4-interface", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-instructions-sysvar 3.0.0", + "solana-loader-v3-interface 6.1.0", + "solana-loader-v4-interface 3.1.0", "solana-loader-v4-program", - "solana-log-collector", - "solana-measure", - "solana-message", - "solana-nonce", + "solana-message 3.0.1", + "solana-nonce 3.0.0", "solana-nonce-account", - "solana-program-entrypoint", - "solana-program-pack", + "solana-program-entrypoint 3.1.1", + "solana-program-pack 3.0.0", "solana-program-runtime", - "solana-pubkey", - "solana-rent", - "solana-rent-collector", - "solana-rent-debits", - "solana-sdk-ids", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.1.0", "solana-svm-callback", - "solana-svm-feature-set", - "solana-svm-rent-collector", + "solana-svm-feature-set 3.1.3", + "solana-svm-log-collector", + "solana-svm-measure", + "solana-svm-timings", "solana-svm-transaction", - "solana-system-interface", - "solana-sysvar-id", - "solana-timings", - "solana-transaction-context", - "solana-transaction-error", - "solana-type-overrides", - "spl-generic-token", - "thiserror 2.0.16", + "solana-svm-type-overrides", + "solana-system-interface 2.0.0", + "solana-sysvar-id 3.1.0", + "solana-transaction-context 3.1.3", + "solana-transaction-error 3.0.0", + "spl-generic-token 2.0.1", + "thiserror 2.0.17", ] [[package]] name = "solana-svm-callback" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab8d6c0a248e3cd4adb7c65792096ea79305f9633904be30da773f38bd21b67" +checksum = "e2a3d780b1ab2f2cfb55f41e192b78c2e80e3224cf0c6de77343552bcbd7bc57" dependencies = [ - "solana-account", + "solana-account 3.2.0", + "solana-clock 3.0.0", "solana-precompile-error", - "solana-pubkey", + "solana-pubkey 3.0.0", ] [[package]] name = "solana-svm-feature-set" -version = "2.3.10" +version = "2.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f24b836eb4d74ec255217bdbe0f24f64a07adeac31aca61f334f91cd4a3b1d5" + +[[package]] +name = "solana-svm-feature-set" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4639fc59e29da44c4010fb672db9980c26d8073892f07aad568be32e00acf9d4" + +[[package]] +name = "solana-svm-log-collector" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93afa0242ccc1ec642845f75773ba5aaf63a3cd0953dd2d09d47beb2ca4e8fe2" +dependencies = [ + "log", +] + +[[package]] +name = "solana-svm-measure" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c343731bf4a594a615c2aa32a63a0f42f39581e7975114ed825133e30ab68346" +checksum = "69ff602eec3e6df1cac6693da4aec76e66c2fc1ee8420635995352df0d3bfc6b" [[package]] -name = "solana-svm-rent-collector" -version = "2.3.10" +name = "solana-svm-timings" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ffd2b9a602fe29a9f43867a6edd9f0c8b99bb1367adb513c12dfcfd0e1148a" +checksum = "60a9d32decdf9487b8d5bed7f1a4eb3d80cfa95e108b69272d91a0d6be918b82" dependencies = [ - "solana-account", - "solana-clock", - "solana-pubkey", - "solana-rent", - "solana-rent-collector", - "solana-sdk-ids", - "solana-transaction-context", - "solana-transaction-error", + "eager", + "enum-iterator", + "solana-pubkey 3.0.0", ] [[package]] name = "solana-svm-transaction" -version = "2.3.10" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b071f7ae92dedb3e947af983ff4e6e9f721bca431e336ab2ed2d2a90fdb8cd" +dependencies = [ + "solana-hash 3.1.0", + "solana-message 3.0.1", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-signature 3.1.0", + "solana-transaction 3.0.2", +] + +[[package]] +name = "solana-svm-type-overrides" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c423922c429cc1ec011f7c92c44ab540dc1dc769fb3361599498a55cfd9c7a8" +checksum = "0e1ace47d2d211d9a43655a76866b4c8cfcdd751d9f4c3fa0f6a46e049d04218" dependencies = [ - "solana-hash", - "solana-message", - "solana-pubkey", - "solana-sdk-ids", - "solana-signature", - "solana-transaction", + "rand 0.8.5", ] [[package]] @@ -7957,51 +9321,65 @@ dependencies = [ "serde", "serde_derive", "solana-decode-error", - "solana-instruction", - "solana-pubkey", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", "wasm-bindgen", ] +[[package]] +name = "solana-system-interface" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e1790547bfc3061f1ee68ea9d8dc6c973c02a163697b24263a8e9f2e6d4afa2" +dependencies = [ + "num-traits", + "serde", + "serde_derive", + "solana-instruction 3.1.0", + "solana-msg 3.0.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", +] + [[package]] name = "solana-system-program" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ab16ed883b20e809ee79f8678aeeefc9fac06933fa57c8ca582a63179e281c" +checksum = "a6a7a47efcfe3ada26f190077a0d90dfcffa7e08fc0174a5fce75b0159761b59" dependencies = [ "bincode", "log", "serde", - "serde_derive", - "solana-account", - "solana-bincode", - "solana-fee-calculator", - "solana-instruction", - "solana-log-collector", - "solana-nonce", + "solana-account 3.2.0", + "solana-bincode 3.1.0", + "solana-fee-calculator 3.0.0", + "solana-instruction 3.1.0", + "solana-nonce 3.0.0", "solana-nonce-account", "solana-packet", "solana-program-runtime", - "solana-pubkey", - "solana-sdk-ids", - "solana-system-interface", - "solana-sysvar", - "solana-transaction-context", - "solana-type-overrides", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-svm-log-collector", + "solana-svm-type-overrides", + "solana-system-interface 2.0.0", + "solana-sysvar 3.1.1", + "solana-transaction-context 3.1.3", ] [[package]] name = "solana-system-transaction" -version = "2.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd98a25e5bcba8b6be8bcbb7b84b24c2a6a8178d7fb0e3077a916855ceba91a" +checksum = "a31b5699ec533621515e714f1533ee6b3b0e71c463301d919eb59b8c1e249d30" dependencies = [ - "solana-hash", - "solana-keypair", - "solana-message", - "solana-pubkey", - "solana-signer", - "solana-system-interface", - "solana-transaction", + "solana-hash 3.1.0", + "solana-keypair 3.1.0", + "solana-message 3.0.1", + "solana-pubkey 3.0.0", + "solana-signer 3.0.0", + "solana-system-interface 2.0.0", + "solana-transaction 3.0.2", ] [[package]] @@ -8017,28 +9395,62 @@ dependencies = [ "lazy_static", "serde", "serde_derive", - "solana-account-info", - "solana-clock", - "solana-define-syscall", - "solana-epoch-rewards", - "solana-epoch-schedule", - "solana-fee-calculator", - "solana-hash", - "solana-instruction", - "solana-instructions-sysvar", - "solana-last-restart-slot", - "solana-program-entrypoint", - "solana-program-error", - "solana-program-memory", - "solana-pubkey", - "solana-rent", - "solana-sanitize", - "solana-sdk-ids", - "solana-sdk-macro", - "solana-slot-hashes", - "solana-slot-history", - "solana-stake-interface", - "solana-sysvar-id", + "solana-account-info 2.3.0", + "solana-clock 2.2.2", + "solana-define-syscall 2.3.0", + "solana-epoch-rewards 2.2.1", + "solana-epoch-schedule 2.2.1", + "solana-fee-calculator 2.2.1", + "solana-hash 2.3.0", + "solana-instruction 2.3.3", + "solana-instructions-sysvar 2.2.2", + "solana-last-restart-slot 2.2.1", + "solana-program-entrypoint 2.3.0", + "solana-program-error 2.2.2", + "solana-program-memory 2.3.1", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sanitize 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-sdk-macro 2.2.1", + "solana-slot-hashes 2.2.1", + "solana-slot-history 2.2.1", + "solana-stake-interface 1.2.1", + "solana-sysvar-id 2.2.1", +] + +[[package]] +name = "solana-sysvar" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6690d3dd88f15c21edff68eb391ef8800df7a1f5cec84ee3e8d1abf05affdf74" +dependencies = [ + "base64 0.22.1", + "bincode", + "bytemuck", + "bytemuck_derive", + "lazy_static", + "serde", + "serde_derive", + "solana-account-info 3.1.0", + "solana-clock 3.0.0", + "solana-define-syscall 4.0.1", + "solana-epoch-rewards 3.0.0", + "solana-epoch-schedule 3.0.0", + "solana-fee-calculator 3.0.0", + "solana-hash 4.0.1", + "solana-instruction 3.1.0", + "solana-last-restart-slot 3.0.0", + "solana-program-entrypoint 3.1.1", + "solana-program-error 3.0.0", + "solana-program-memory 3.1.0", + "solana-pubkey 4.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-sdk-macro 3.0.0", + "solana-slot-hashes 3.0.0", + "solana-slot-history 3.0.0", + "solana-sysvar-id 3.1.0", ] [[package]] @@ -8047,100 +9459,70 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5762b273d3325b047cfda250787f8d796d781746860d5d0a746ee29f3e8812c1" dependencies = [ - "solana-pubkey", - "solana-sdk-ids", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", ] [[package]] -name = "solana-thin-client" -version = "2.3.10" +name = "solana-sysvar-id" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc60d1502f5eeb2e5f3286b34f567d3c076e6da5a753a002ef8889fda670ecf" +checksum = "17358d1e9a13e5b9c2264d301102126cf11a47fd394cdf3dec174fe7bc96e1de" dependencies = [ - "bincode", - "log", - "rayon", - "solana-account", - "solana-client-traits", - "solana-clock", - "solana-commitment-config", - "solana-connection-cache", - "solana-epoch-info", - "solana-hash", - "solana-instruction", - "solana-keypair", - "solana-message", - "solana-pubkey", - "solana-rpc-client", - "solana-rpc-client-api", - "solana-signature", - "solana-signer", - "solana-system-interface", - "solana-transaction", - "solana-transaction-error", + "solana-address 2.0.0", + "solana-sdk-ids 3.1.0", ] [[package]] name = "solana-time-utils" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af261afb0e8c39252a04d026e3ea9c405342b08c871a2ad8aa5448e068c784c" - -[[package]] -name = "solana-timings" -version = "2.3.10" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f256ace5303af279db4de8be635e98b907da6705ce50262f8dcfd05f3925b62c" -dependencies = [ - "eager", - "enum-iterator", - "solana-pubkey", -] +checksum = "0ced92c60aa76ec4780a9d93f3bd64dfa916e1b998eacc6f1c110f3f444f02c9" [[package]] name = "solana-tls-utils" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5629f315f8e64b7336e5c8e10ff48d350ca1ce321f4132238705f0acbeeaf843" +checksum = "39ecf07b047c05d08d234ad99b90050e043c5024b484ba82cf25b1f9517baa01" dependencies = [ - "rustls 0.23.32", - "solana-keypair", - "solana-pubkey", - "solana-signer", + "rustls 0.23.35", + "solana-keypair 3.1.0", + "solana-pubkey 3.0.0", + "solana-signer 3.0.0", "x509-parser", ] [[package]] name = "solana-tpu-client" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "268c9aaf276cc863b1f683ab0e7d97aee2d52502ddf9fd02d8564fc8fb9f2ba8" +checksum = "73b148fd0833086cb75a8d38d341752f5c1f082d73d3150cc45b47032e5d0fe8" dependencies = [ "async-trait", "bincode", "futures-util", - "indexmap 2.11.4", - "indicatif", + "indexmap 2.12.1", + "indicatif 0.18.3", "log", "rayon", "solana-client-traits", - "solana-clock", - "solana-commitment-config", + "solana-clock 3.0.0", + "solana-commitment-config 3.1.0", "solana-connection-cache", - "solana-epoch-schedule", + "solana-epoch-schedule 3.0.0", "solana-measure", - "solana-message", + "solana-message 3.0.1", "solana-net-utils", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-pubsub-client", "solana-quic-definitions", "solana-rpc-client", "solana-rpc-client-api", - "solana-signature", - "solana-signer", - "solana-transaction", - "solana-transaction-error", - "thiserror 2.0.16", + "solana-signature 3.1.0", + "solana-signer 3.0.0", + "solana-transaction 3.0.2", + "solana-transaction-error 3.0.0", + "thiserror 2.0.17", "tokio", ] @@ -8150,42 +9532,75 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80657d6088f721148f5d889c828ca60c7daeedac9a8679f9ec215e0c42bcbf41" dependencies = [ - "bincode", "serde", "serde_derive", - "solana-bincode", - "solana-feature-set", - "solana-hash", - "solana-instruction", - "solana-keypair", - "solana-message", - "solana-precompiles", - "solana-pubkey", - "solana-sanitize", - "solana-sdk-ids", - "solana-short-vec", - "solana-signature", - "solana-signer", - "solana-system-interface", - "solana-transaction-error", + "solana-hash 2.3.0", + "solana-instruction 2.3.3", + "solana-keypair 2.2.3", + "solana-message 2.4.0", + "solana-pubkey 2.4.0", + "solana-sanitize 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-short-vec 2.2.1", + "solana-signature 2.3.0", + "solana-transaction-error 2.2.1", "wasm-bindgen", ] +[[package]] +name = "solana-transaction" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ceb2efbf427a91b884709ffac4dac29117752ce1e37e9ae04977e450aa0bb76" +dependencies = [ + "bincode", + "serde", + "serde_derive", + "solana-address 2.0.0", + "solana-hash 4.0.1", + "solana-instruction 3.1.0", + "solana-instruction-error", + "solana-message 3.0.1", + "solana-sanitize 3.0.1", + "solana-sdk-ids 3.1.0", + "solana-short-vec 3.1.0", + "solana-signature 3.1.0", + "solana-signer 3.0.0", + "solana-transaction-error 3.0.0", +] + [[package]] name = "solana-transaction-context" -version = "2.3.10" +version = "2.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a816015e792c953f755a333c1ae3a1c3b1e5cde52a5f98015ed26d5adea70e63" +checksum = "54a312304361987a85b2ef2293920558e6612876a639dd1309daf6d0d59ef2fe" dependencies = [ "bincode", "serde", "serde_derive", - "solana-account", - "solana-instruction", - "solana-instructions-sysvar", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", + "solana-account 2.2.1", + "solana-instruction 2.3.3", + "solana-instructions-sysvar 2.2.2", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sdk-ids 2.2.1", +] + +[[package]] +name = "solana-transaction-context" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd9a056caa8b6bc1f47db81e6b92da836b2aa3cf20553ab49a1a2b2ab8fde31e" +dependencies = [ + "bincode", + "serde", + "solana-account 3.2.0", + "solana-instruction 3.1.0", + "solana-instructions-sysvar 3.0.0", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sbpf", + "solana-sdk-ids 3.1.0", ] [[package]] @@ -8196,15 +9611,27 @@ checksum = "222a9dc8fdb61c6088baab34fc3a8b8473a03a7a5fd404ed8dd502fa79b67cb1" dependencies = [ "serde", "serde_derive", - "solana-instruction", - "solana-sanitize", + "solana-instruction 2.3.3", + "solana-sanitize 2.2.1", +] + +[[package]] +name = "solana-transaction-error" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4222065402340d7e6aec9dc3e54d22992ddcf923d91edcd815443c2bfca3144a" +dependencies = [ + "serde", + "serde_derive", + "solana-instruction-error", + "solana-sanitize 3.0.1", ] [[package]] name = "solana-transaction-metrics-tracker" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63e77b3b3f4790dcf6cb945cfce4210cb8a22ccf74cfdff84b726650b698bf62" +checksum = "a34f0be8c181093704032287650a52d2a884eba81614aa4c404a7ec43bca7b7c" dependencies = [ "base64 0.22.1", "bincode", @@ -8212,59 +9639,102 @@ dependencies = [ "rand 0.8.5", "solana-packet", "solana-perf", - "solana-short-vec", - "solana-signature", + "solana-short-vec 3.1.0", + "solana-signature 3.1.0", ] [[package]] name = "solana-transaction-status" -version = "2.3.10" +version = "2.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4b8faaef81300575139ce1ab8fd0fa0ad5f8adfbafb5bf0f684e32e9298e87" +checksum = "135f92f4192cc68900c665becf97fc0a6500ae5a67ff347bf2cbc20ecfefa821" dependencies = [ "Inflector", - "agave-reserved-account-keys", + "agave-reserved-account-keys 2.3.13", "base64 0.22.1", "bincode", - "borsh 1.5.7", + "borsh 1.6.0", "bs58", "log", "serde", "serde_derive", "serde_json", - "solana-account-decoder", - "solana-address-lookup-table-interface", - "solana-clock", - "solana-hash", - "solana-instruction", - "solana-loader-v2-interface", - "solana-loader-v3-interface", - "solana-message", - "solana-program-option", - "solana-pubkey", - "solana-reward-info", - "solana-sdk-ids", - "solana-signature", - "solana-stake-interface", - "solana-system-interface", - "solana-transaction", - "solana-transaction-error", - "solana-transaction-status-client-types", - "solana-vote-interface", + "solana-account-decoder 2.3.13", + "solana-address-lookup-table-interface 2.2.2", + "solana-clock 2.2.2", + "solana-hash 2.3.0", + "solana-instruction 2.3.3", + "solana-loader-v2-interface 2.2.1", + "solana-loader-v3-interface 5.0.0", + "solana-message 2.4.0", + "solana-program-option 2.2.1", + "solana-pubkey 2.4.0", + "solana-reward-info 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-signature 2.3.0", + "solana-stake-interface 1.2.1", + "solana-system-interface 1.0.0", + "solana-transaction 2.2.3", + "solana-transaction-error 2.2.1", + "solana-transaction-status-client-types 2.3.13", + "solana-vote-interface 2.2.6", "spl-associated-token-account", "spl-memo", "spl-token 8.0.0", "spl-token-2022 8.0.1", - "spl-token-group-interface", + "spl-token-group-interface 0.6.0", "spl-token-metadata-interface 0.7.0", - "thiserror 2.0.16", + "thiserror 2.0.17", +] + +[[package]] +name = "solana-transaction-status" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a414f013ef35e6f00da9f227303d4e41b7c4eacd9f38cfcea8103299b5a1bbd" +dependencies = [ + "Inflector", + "agave-reserved-account-keys 3.1.3", + "base64 0.22.1", + "bincode", + "borsh 1.6.0", + "bs58", + "log", + "serde", + "serde_json", + "solana-account-decoder 3.1.3", + "solana-address-lookup-table-interface 3.0.0", + "solana-clock 3.0.0", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-loader-v2-interface 3.0.0", + "solana-loader-v3-interface 6.1.0", + "solana-message 3.0.1", + "solana-program-option 3.0.0", + "solana-pubkey 3.0.0", + "solana-reward-info 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-signature 3.1.0", + "solana-stake-interface 2.0.1", + "solana-system-interface 2.0.0", + "solana-transaction 3.0.2", + "solana-transaction-error 3.0.0", + "solana-transaction-status-client-types 3.1.3", + "solana-vote-interface 4.0.4", + "spl-associated-token-account-interface", + "spl-memo-interface", + "spl-token-2022-interface", + "spl-token-group-interface 0.7.1", + "spl-token-interface", + "spl-token-metadata-interface 0.8.0", + "thiserror 2.0.17", ] [[package]] name = "solana-transaction-status-client-types" -version = "2.3.10" +version = "2.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24dfa59c12442f2283eb07d3c2fefff5862d4200579093b0a990b0c262bc003e" +checksum = "51f1d7c2387c35850848212244d2b225847666cb52d3bd59a5c409d2c300303d" dependencies = [ "base64 0.22.1", "bincode", @@ -8272,103 +9742,110 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "solana-account-decoder-client-types", - "solana-commitment-config", - "solana-message", - "solana-reward-info", - "solana-signature", - "solana-transaction", - "solana-transaction-context", - "solana-transaction-error", - "thiserror 2.0.16", + "solana-account-decoder-client-types 2.3.13", + "solana-commitment-config 2.2.1", + "solana-message 2.4.0", + "solana-reward-info 2.2.1", + "solana-signature 2.3.0", + "solana-transaction 2.2.3", + "solana-transaction-context 2.3.13", + "solana-transaction-error 2.2.1", + "thiserror 2.0.17", ] [[package]] -name = "solana-type-overrides" -version = "2.3.10" +name = "solana-transaction-status-client-types" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9086d01acf627f85d6d0213540dcb437497b71323b580469218f7f683eca4d74" +checksum = "5b68112658f8ed0901054d3d1e7fcce3bedab88f190ca1b00ac5f121384cdb3b" dependencies = [ - "rand 0.8.5", + "base64 0.22.1", + "bincode", + "bs58", + "serde", + "serde_json", + "solana-account-decoder-client-types 3.1.3", + "solana-commitment-config 3.1.0", + "solana-instruction 3.1.0", + "solana-message 3.0.1", + "solana-pubkey 3.0.0", + "solana-reward-info 3.0.0", + "solana-signature 3.1.0", + "solana-transaction 3.0.2", + "solana-transaction-context 3.1.3", + "solana-transaction-error 3.0.0", + "thiserror 2.0.17", ] [[package]] name = "solana-udp-client" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a11eb463af8c3de38b6452a51c885231188462647eb8e95ca8344c18aceaf47" +checksum = "b1ccd63a4899f45e080d061de4da2cf60c3bf4d61397d6b211e7be4b9190efd3" dependencies = [ "async-trait", "solana-connection-cache", - "solana-keypair", + "solana-keypair 3.1.0", "solana-net-utils", "solana-streamer", - "solana-transaction-error", - "thiserror 2.0.16", + "solana-transaction-error 3.0.0", + "thiserror 2.0.17", "tokio", ] [[package]] name = "solana-unified-scheduler-logic" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99061c7a8314ddbfb09de914f0c8d07f0d4e0a4b4bc2e221d4469462b4e79653" +checksum = "5d0693e556093104277518e1832b1b1d9fb3e6d991620bfba238327e501d030a" dependencies = [ "assert_matches", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-runtime-transaction", - "solana-transaction", + "solana-transaction 3.0.2", "static_assertions", "unwrap_none", ] -[[package]] -name = "solana-validator-exit" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bbf6d7a3c0b28dd5335c52c0e9eae49d0ae489a8f324917faf0ded65a812c1d" - [[package]] name = "solana-version" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb7e1261069a748647abc07f611a5ced461390447aa1fe083eb733796e038b" +checksum = "3e04d8d5ea770807f8cd6ef57bd493a9856085127045d241509be0790b3de7fb" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", "rand 0.8.5", "semver", "serde", - "serde_derive", - "solana-sanitize", - "solana-serde-varint", + "solana-sanitize 3.0.1", + "solana-serde-varint 3.0.0", ] [[package]] name = "solana-vote" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94366c00babcca27f1e953aab097889c02f102ce4aabf0db8fdefbd2f6951895" +checksum = "2222b5be4809768448faf3313f07ef743250aa2a710ea28853c010134cfd6db6" dependencies = [ "itertools 0.12.1", "log", "serde", - "serde_derive", - "solana-account", - "solana-bincode", - "solana-clock", - "solana-hash", - "solana-instruction", - "solana-keypair", + "solana-account 3.2.0", + "solana-bincode 3.1.0", + "solana-clock 3.0.0", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-keypair 3.1.0", "solana-packet", - "solana-pubkey", - "solana-sdk-ids", - "solana-serialize-utils", - "solana-signature", - "solana-signer", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-serialize-utils 3.1.0", + "solana-signature 3.1.0", + "solana-signer 3.0.0", "solana-svm-transaction", - "solana-transaction", - "solana-vote-interface", - "thiserror 2.0.16", + "solana-transaction 3.0.2", + "solana-vote-interface 4.0.4", + "thiserror 2.0.17", ] [[package]] @@ -8382,74 +9859,135 @@ dependencies = [ "num-traits", "serde", "serde_derive", - "solana-clock", + "solana-clock 2.2.2", "solana-decode-error", - "solana-hash", - "solana-instruction", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", - "solana-serde-varint", - "solana-serialize-utils", - "solana-short-vec", - "solana-system-interface", + "solana-hash 2.3.0", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-serde-varint 2.2.2", + "solana-serialize-utils 2.2.1", + "solana-short-vec 2.2.1", + "solana-system-interface 1.0.0", +] + +[[package]] +name = "solana-vote-interface" +version = "4.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6e123e16bfdd7a81d71b4c4699e0b29580b619f4cd2ef5b6aae1eb85e8979f" +dependencies = [ + "bincode", + "cfg_eval", + "num-derive", + "num-traits", + "serde", + "serde_derive", + "serde_with", + "solana-clock 3.0.0", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-instruction-error", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-serde-varint 3.0.0", + "solana-serialize-utils 3.1.0", + "solana-short-vec 3.1.0", + "solana-system-interface 2.0.0", ] [[package]] name = "solana-vote-program" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4cede31c71a6857315ef37b54f9f6a04bdd4183fd05ccb8d4631ab2c5fd2ba7" +checksum = "e25b1cebb26a3e4cce242612beb2bb2ada3a51e99d76a1cbece67591769273e7" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", "bincode", "log", "num-derive", "num-traits", "serde", - "serde_derive", - "solana-account", - "solana-bincode", - "solana-clock", - "solana-epoch-schedule", - "solana-hash", - "solana-instruction", - "solana-keypair", + "solana-account 3.2.0", + "solana-bincode 3.1.0", + "solana-clock 3.0.0", + "solana-epoch-schedule 3.0.0", + "solana-hash 3.1.0", + "solana-instruction 3.1.0", + "solana-keypair 3.1.0", "solana-packet", "solana-program-runtime", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", - "solana-signer", - "solana-slot-hashes", - "solana-transaction", - "solana-transaction-context", - "solana-vote-interface", - "thiserror 2.0.16", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-signer 3.0.0", + "solana-slot-hashes 3.0.0", + "solana-transaction 3.0.2", + "solana-transaction-context 3.1.3", + "solana-vote-interface 4.0.4", + "thiserror 2.0.17", ] [[package]] name = "solana-zk-elgamal-proof-program" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5bd32a19e9970aef95d657f45d8a678cf378bc9a6fdf527ec30d5f1ec4767c" +checksum = "98159849b2040a4815ce02e30590a43bb6866fcaeb7ec46e62e6fc11fd8738dc" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", "bytemuck", "num-derive", "num-traits", - "solana-instruction", - "solana-log-collector", + "solana-instruction 3.1.0", "solana-program-runtime", - "solana-sdk-ids", - "solana-zk-sdk", + "solana-sdk-ids 3.1.0", + "solana-svm-log-collector", + "solana-zk-sdk 4.0.0", +] + +[[package]] +name = "solana-zk-sdk" +version = "2.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b9fc6ec37d16d0dccff708ed1dd6ea9ba61796700c3bb7c3b401973f10f63b" +dependencies = [ + "aes-gcm-siv", + "base64 0.22.1", + "bincode", + "bytemuck", + "bytemuck_derive", + "curve25519-dalek 4.1.3", + "itertools 0.12.1", + "js-sys", + "merlin", + "num-derive", + "num-traits", + "rand 0.8.5", + "serde", + "serde_derive", + "serde_json", + "sha3", + "solana-derivation-path 2.2.1", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", + "solana-seed-derivable 2.2.1", + "solana-seed-phrase 2.2.1", + "solana-signature 2.3.0", + "solana-signer 2.2.1", + "subtle", + "thiserror 2.0.17", + "wasm-bindgen", + "zeroize", ] [[package]] name = "solana-zk-sdk" -version = "2.3.10" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fbc771177d65034eaa27dd66f809ca1c52beebaa92eefd23d560c394dd006f2" +checksum = "9602bcb1f7af15caef92b91132ec2347e1c51a72ecdbefdaefa3eac4b8711475" dependencies = [ "aes-gcm-siv", "base64 0.22.1", @@ -8457,6 +9995,7 @@ dependencies = [ "bytemuck", "bytemuck_derive", "curve25519-dalek 4.1.3", + "getrandom 0.2.16", "itertools 0.12.1", "js-sys", "merlin", @@ -8467,42 +10006,42 @@ dependencies = [ "serde_derive", "serde_json", "sha3", - "solana-derivation-path", - "solana-instruction", - "solana-pubkey", - "solana-sdk-ids", - "solana-seed-derivable", - "solana-seed-phrase", - "solana-signature", - "solana-signer", + "solana-derivation-path 3.0.0", + "solana-instruction 3.1.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-seed-derivable 3.0.0", + "solana-seed-phrase 3.0.0", + "solana-signature 3.1.0", + "solana-signer 3.0.0", "subtle", - "thiserror 2.0.16", + "thiserror 2.0.17", "wasm-bindgen", "zeroize", ] [[package]] name = "solana-zk-token-proof-program" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8150e17f5fdb826ca7a3a6aca3512cb3ae68d4bee863ac22714eee0b5e483068" +checksum = "cbfe01c829b6797939034c5524eed46fc558c8ff1dac6e86d9b21681f2cbbb09" dependencies = [ - "agave-feature-set", + "agave-feature-set 3.1.3", "bytemuck", "num-derive", "num-traits", - "solana-instruction", - "solana-log-collector", + "solana-instruction 3.1.0", "solana-program-runtime", - "solana-sdk-ids", + "solana-sdk-ids 3.1.0", + "solana-svm-log-collector", "solana-zk-token-sdk", ] [[package]] name = "solana-zk-token-sdk" -version = "2.3.10" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2f5e4be8646cd77786cf8cdbde4ef0a9f36d95dc3b754c296dd2d47149b2552" +checksum = "5cae28b0bffeeb4431c12fb3b95f7afe748d81f7b3862a8a8770a84aff9b8282" dependencies = [ "aes-gcm-siv", "base64 0.22.1", @@ -8516,20 +10055,19 @@ dependencies = [ "num-traits", "rand 0.8.5", "serde", - "serde_derive", "serde_json", "sha3", - "solana-curve25519", - "solana-derivation-path", - "solana-instruction", - "solana-pubkey", - "solana-sdk-ids", - "solana-seed-derivable", - "solana-seed-phrase", - "solana-signature", - "solana-signer", + "solana-curve25519 3.1.3", + "solana-derivation-path 3.0.0", + "solana-instruction 3.1.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-seed-derivable 3.0.0", + "solana-seed-phrase 3.0.0", + "solana-signature 3.1.0", + "solana-signer 3.0.0", "subtle", - "thiserror 2.0.16", + "thiserror 2.0.17", "zeroize", ] @@ -8548,20 +10086,30 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "spl-associated-token-account" version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae179d4a26b3c7a20c839898e6aed84cb4477adf108a366c95532f058aea041b" dependencies = [ - "borsh 1.5.7", + "borsh 1.6.0", "num-derive", "num-traits", - "solana-program", + "solana-program 2.3.0", "spl-associated-token-account-client", "spl-token 8.0.0", "spl-token-2022 8.0.1", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -8570,30 +10118,42 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6f8349dbcbe575f354f9a533a21f272f3eb3808a49e2fdc1c34393b88ba76cb" dependencies = [ - "solana-instruction", - "solana-pubkey", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", +] + +[[package]] +name = "spl-associated-token-account-interface" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6433917b60441d68d99a17e121d9db0ea15a9a69c0e5afa34649cf5ba12612f" +dependencies = [ + "borsh 1.6.0", + "solana-instruction 3.1.0", + "solana-pubkey 3.0.0", ] [[package]] name = "spl-discriminator" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38ea8b6dedb7065887f12d62ed62c1743aa70749e8558f963609793f6fb12bc" +checksum = "a7398da23554a31660f17718164e31d31900956054f54f52d5ec1be51cb4f4b3" dependencies = [ "bytemuck", - "solana-program", + "solana-program-error 2.2.2", + "solana-sha256-hasher 2.3.0", "spl-discriminator-derive", ] [[package]] name = "spl-discriminator" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7398da23554a31660f17718164e31d31900956054f54f52d5ec1be51cb4f4b3" +checksum = "d48cc11459e265d5b501534144266620289720b4c44522a47bc6b63cd295d2f3" dependencies = [ "bytemuck", - "solana-program-error", - "solana-sha256-hasher", + "solana-program-error 3.0.0", + "solana-sha256-hasher 3.1.0", "spl-discriminator-derive", ] @@ -8605,7 +10165,7 @@ checksum = "d9e8418ea6269dcfb01c712f0444d2c75542c04448b480e87de59d2865edc750" dependencies = [ "quote", "spl-discriminator-syn", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -8617,7 +10177,7 @@ dependencies = [ "proc-macro2", "quote", "sha2 0.10.9", - "syn 2.0.106", + "syn 2.0.111", "thiserror 1.0.69", ] @@ -8628,18 +10188,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65edfeed09cd4231e595616aa96022214f9c9d2be02dea62c2b30d5695a6833a" dependencies = [ "bytemuck", - "solana-account-info", - "solana-cpi", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", - "solana-system-interface", - "solana-sysvar", - "solana-zk-sdk", + "solana-account-info 2.3.0", + "solana-cpi 2.2.1", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-entrypoint 2.3.0", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-system-interface 1.0.0", + "solana-sysvar 2.3.0", + "solana-zk-sdk 2.3.13", "spl-pod 0.5.1", "spl-token-confidential-transfer-proof-extraction 0.3.0", ] @@ -8651,23 +10211,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56cc66fe64651a48c8deb4793d8a5deec8f8faf19f355b9df294387bc5a36b5f" dependencies = [ "bytemuck", - "solana-account-info", - "solana-cpi", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", + "solana-account-info 2.3.0", + "solana-cpi 2.2.1", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-entrypoint 2.3.0", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sdk-ids 2.2.1", "solana-security-txt", - "solana-system-interface", - "solana-sysvar", - "solana-zk-sdk", + "solana-system-interface 1.0.0", + "solana-sysvar 2.3.0", + "solana-zk-sdk 2.3.13", "spl-pod 0.5.1", "spl-token-confidential-transfer-proof-extraction 0.4.1", ] +[[package]] +name = "spl-elgamal-registry-interface" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065f54100d118d24036283e03120b2f60cb5b7d597d3db649e13690e22d41398" +dependencies = [ + "bytemuck", + "solana-instruction 3.1.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-zk-sdk 4.0.0", + "spl-token-confidential-transfer-proof-extraction 0.5.1", +] + [[package]] name = "spl-generic-token" version = "1.0.1" @@ -8675,7 +10250,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "741a62a566d97c58d33f9ed32337ceedd4e35109a686e31b1866c5dfa56abddc" dependencies = [ "bytemuck", - "solana-pubkey", + "solana-pubkey 2.4.0", +] + +[[package]] +name = "spl-generic-token" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233df81b75ab99b42f002b5cdd6e65a7505ffa930624f7096a7580a56765e9cf" +dependencies = [ + "bytemuck", + "solana-pubkey 3.0.0", ] [[package]] @@ -8684,26 +10269,22 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f09647c0974e33366efeb83b8e2daebb329f0420149e74d3a4bd2c08cf9f7cb" dependencies = [ - "solana-account-info", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", + "solana-account-info 2.3.0", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-entrypoint 2.3.0", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", ] [[package]] -name = "spl-pod" -version = "0.3.1" +name = "spl-memo-interface" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c704c88fc457fa649ba3aabe195c79d885c3f26709efaddc453c8de352c90b87" +checksum = "3d4e2aedd58f858337fa609af5ad7100d4a243fdaf6a40d6eb4c28c5f19505d3" dependencies = [ - "borsh 1.5.7", - "bytemuck", - "bytemuck_derive", - "solana-program", - "solana-zk-token-sdk", - "spl-program-error 0.5.0", + "solana-instruction 3.1.0", + "solana-pubkey 3.0.0", ] [[package]] @@ -8712,31 +10293,37 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d994afaf86b779104b4a95ba9ca75b8ced3fdb17ee934e38cb69e72afbe17799" dependencies = [ - "borsh 1.5.7", + "borsh 1.6.0", "bytemuck", "bytemuck_derive", "num-derive", "num-traits", "solana-decode-error", - "solana-msg", - "solana-program-error", - "solana-program-option", - "solana-pubkey", - "solana-zk-sdk", - "thiserror 2.0.16", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-program-option 2.2.1", + "solana-pubkey 2.4.0", + "solana-zk-sdk 2.3.13", + "thiserror 2.0.17", ] [[package]] -name = "spl-program-error" -version = "0.5.0" +name = "spl-pod" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7b28bed65356558133751cc32b48a7a5ddfc59ac4e941314630bbed1ac10532" +checksum = "b1233fdecd7461611d69bb87bc2e95af742df47291975d21232a0be8217da9de" dependencies = [ + "borsh 1.6.0", + "bytemuck", + "bytemuck_derive", "num-derive", "num-traits", - "solana-program", - "spl-program-error-derive 0.4.1", - "thiserror 1.0.69", + "num_enum", + "solana-program-error 3.0.0", + "solana-program-option 3.0.0", + "solana-pubkey 3.0.0", + "solana-zk-sdk 4.0.0", + "thiserror 2.0.17", ] [[package]] @@ -8748,34 +10335,49 @@ dependencies = [ "num-derive", "num-traits", "solana-decode-error", - "solana-msg", - "solana-program-error", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", "spl-program-error-derive 0.5.0", - "thiserror 2.0.16", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-program-error" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c4f6cf26cb6768110bf024bc7224326c720d711f7ad25d16f40f6cee40edb2d" +dependencies = [ + "num-derive", + "num-traits", + "num_enum", + "solana-msg 3.0.0", + "solana-program-error 3.0.0", + "spl-program-error-derive 0.6.0", + "thiserror 2.0.17", ] [[package]] name = "spl-program-error-derive" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d375dd76c517836353e093c2dbb490938ff72821ab568b545fd30ab3256b3e" +checksum = "2a2539e259c66910d78593475540e8072f0b10f0f61d7607bbf7593899ed52d0" dependencies = [ "proc-macro2", "quote", "sha2 0.10.9", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] name = "spl-program-error-derive" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2539e259c66910d78593475540e8072f0b10f0f61d7607bbf7593899ed52d0" +checksum = "9ec8965aa4dc6c74701cbb48b9cad5af35b9a394514934949edbb357b78f840d" dependencies = [ "proc-macro2", "quote", "sha2 0.10.9", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -8786,20 +10388,20 @@ checksum = "6f0db03f091f43b5766296e80088718491b50949cd3eb4cce3e0cfed58fe2c18" dependencies = [ "arrayref", "bincode", - "borsh 1.5.7", + "borsh 1.6.0", "bytemuck", "num-derive", "num-traits", "num_enum", "serde", "serde_derive", - "solana-program", + "solana-program 2.3.0", "solana-security-txt", - "solana-stake-interface", - "solana-system-interface", + "solana-stake-interface 1.2.1", + "solana-system-interface 1.0.0", "spl-pod 0.5.1", "spl-token-2022 9.0.0", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -8811,32 +10413,38 @@ dependencies = [ "bytemuck", "num-derive", "num-traits", - "solana-account-info", + "solana-account-info 2.3.0", "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-error", - "solana-pubkey", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", "spl-discriminator 0.4.1", "spl-pod 0.5.1", "spl-program-error 0.7.0", "spl-type-length-value 0.8.0", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] -name = "spl-token" -version = "6.0.0" +name = "spl-tlv-account-resolution" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a0f06ac7f23dc0984931b1fe309468f14ea58e32660439c1cef19456f5d0e3" +checksum = "6927f613c9d7ce20835d3cefb602137cab2518e383a047c0eaa58054a60644c8" dependencies = [ - "arrayref", "bytemuck", "num-derive", "num-traits", "num_enum", - "solana-program", - "thiserror 1.0.69", + "solana-account-info 3.1.0", + "solana-instruction 3.1.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", + "spl-discriminator 0.5.1", + "spl-pod 0.7.1", + "spl-program-error 0.8.0", + "spl-type-length-value 0.9.0", + "thiserror 2.0.17", ] [[package]] @@ -8850,21 +10458,49 @@ dependencies = [ "num-derive", "num-traits", "num_enum", - "solana-account-info", - "solana-cpi", + "solana-account-info 2.3.0", + "solana-cpi 2.2.1", "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-program-memory", - "solana-program-option", - "solana-program-pack", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", - "solana-sysvar", - "thiserror 2.0.16", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-entrypoint 2.3.0", + "solana-program-error 2.2.2", + "solana-program-memory 2.3.1", + "solana-program-option 2.2.1", + "solana-program-pack 2.2.1", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sdk-ids 2.2.1", + "solana-sysvar 2.3.0", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-token" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "878b0183d51fcd8a53e1604f4c13321894cf53227e6773c529b0d03d499a8dfd" +dependencies = [ + "arrayref", + "bytemuck", + "num-derive", + "num-traits", + "num_enum", + "solana-account-info 3.1.0", + "solana-cpi 3.1.0", + "solana-instruction 3.1.0", + "solana-msg 3.0.0", + "solana-program-entrypoint 3.1.1", + "solana-program-error 3.0.0", + "solana-program-memory 3.1.0", + "solana-program-option 3.0.0", + "solana-program-pack 3.0.0", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-sysvar 3.1.1", + "spl-token-interface", + "thiserror 2.0.17", ] [[package]] @@ -8878,37 +10514,37 @@ dependencies = [ "num-derive", "num-traits", "num_enum", - "solana-account-info", - "solana-clock", - "solana-cpi", + "solana-account-info 2.3.0", + "solana-clock 2.2.2", + "solana-cpi 2.2.1", "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-native-token", - "solana-program-entrypoint", - "solana-program-error", - "solana-program-memory", - "solana-program-option", - "solana-program-pack", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-native-token 2.3.0", + "solana-program-entrypoint 2.3.0", + "solana-program-error 2.2.2", + "solana-program-memory 2.3.1", + "solana-program-option 2.2.1", + "solana-program-pack 2.2.1", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sdk-ids 2.2.1", "solana-security-txt", - "solana-system-interface", - "solana-sysvar", - "solana-zk-sdk", + "solana-system-interface 1.0.0", + "solana-sysvar 2.3.0", + "solana-zk-sdk 2.3.13", "spl-elgamal-registry 0.2.0", "spl-memo", "spl-pod 0.5.1", "spl-token 8.0.0", - "spl-token-confidential-transfer-ciphertext-arithmetic", + "spl-token-confidential-transfer-ciphertext-arithmetic 0.3.1", "spl-token-confidential-transfer-proof-extraction 0.3.0", - "spl-token-confidential-transfer-proof-generation", - "spl-token-group-interface", + "spl-token-confidential-transfer-proof-generation 0.4.1", + "spl-token-group-interface 0.6.0", "spl-token-metadata-interface 0.7.0", - "spl-transfer-hook-interface", + "spl-transfer-hook-interface 0.10.0", "spl-type-length-value 0.8.0", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -8922,37 +10558,106 @@ dependencies = [ "num-derive", "num-traits", "num_enum", - "solana-account-info", - "solana-clock", - "solana-cpi", + "solana-account-info 2.3.0", + "solana-clock 2.2.2", + "solana-cpi 2.2.1", "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-native-token", - "solana-program-entrypoint", - "solana-program-error", - "solana-program-memory", - "solana-program-option", - "solana-program-pack", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-native-token 2.3.0", + "solana-program-entrypoint 2.3.0", + "solana-program-error 2.2.2", + "solana-program-memory 2.3.1", + "solana-program-option 2.2.1", + "solana-program-pack 2.2.1", + "solana-pubkey 2.4.0", + "solana-rent 2.2.1", + "solana-sdk-ids 2.2.1", "solana-security-txt", - "solana-system-interface", - "solana-sysvar", - "solana-zk-sdk", + "solana-system-interface 1.0.0", + "solana-sysvar 2.3.0", + "solana-zk-sdk 2.3.13", "spl-elgamal-registry 0.3.0", "spl-memo", "spl-pod 0.5.1", "spl-token 8.0.0", - "spl-token-confidential-transfer-ciphertext-arithmetic", + "spl-token-confidential-transfer-ciphertext-arithmetic 0.3.1", "spl-token-confidential-transfer-proof-extraction 0.4.1", - "spl-token-confidential-transfer-proof-generation", - "spl-token-group-interface", + "spl-token-confidential-transfer-proof-generation 0.4.1", + "spl-token-group-interface 0.6.0", "spl-token-metadata-interface 0.7.0", - "spl-transfer-hook-interface", + "spl-transfer-hook-interface 0.10.0", "spl-type-length-value 0.8.0", - "thiserror 2.0.16", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-token-2022" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552427d9117528d037daa0e70416d51322c8a33241317210f230304d852be61e" +dependencies = [ + "arrayref", + "bytemuck", + "num-derive", + "num-traits", + "num_enum", + "solana-account-info 3.1.0", + "solana-clock 3.0.0", + "solana-cpi 3.1.0", + "solana-instruction 3.1.0", + "solana-msg 3.0.0", + "solana-program-entrypoint 3.1.1", + "solana-program-error 3.0.0", + "solana-program-memory 3.1.0", + "solana-program-option 3.0.0", + "solana-program-pack 3.0.0", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-security-txt", + "solana-system-interface 2.0.0", + "solana-sysvar 3.1.1", + "solana-zk-sdk 4.0.0", + "spl-elgamal-registry-interface", + "spl-memo-interface", + "spl-pod 0.7.1", + "spl-token-2022-interface", + "spl-token-confidential-transfer-ciphertext-arithmetic 0.4.1", + "spl-token-confidential-transfer-proof-extraction 0.5.1", + "spl-token-confidential-transfer-proof-generation 0.5.1", + "spl-token-group-interface 0.7.1", + "spl-token-metadata-interface 0.8.0", + "spl-transfer-hook-interface 2.1.0", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-token-2022-interface" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fcd81188211f4b3c8a5eba7fd534c7142f9dd026123b3472492782cc72f4dc6" +dependencies = [ + "arrayref", + "bytemuck", + "num-derive", + "num-traits", + "num_enum", + "solana-account-info 3.1.0", + "solana-instruction 3.1.0", + "solana-program-error 3.0.0", + "solana-program-option 3.0.0", + "solana-program-pack 3.0.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-zk-sdk 4.0.0", + "spl-pod 0.7.1", + "spl-token-confidential-transfer-proof-extraction 0.5.1", + "spl-token-confidential-transfer-proof-generation 0.5.1", + "spl-token-group-interface 0.7.1", + "spl-token-metadata-interface 0.8.0", + "spl-type-length-value 0.9.0", + "thiserror 2.0.17", ] [[package]] @@ -8963,8 +10668,20 @@ checksum = "cddd52bfc0f1c677b41493dafa3f2dbbb4b47cf0990f08905429e19dc8289b35" dependencies = [ "base64 0.22.1", "bytemuck", - "solana-curve25519", - "solana-zk-sdk", + "solana-curve25519 2.3.13", + "solana-zk-sdk 2.3.13", +] + +[[package]] +name = "spl-token-confidential-transfer-ciphertext-arithmetic" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afbeb07f737d868f145512a4bcf9f59da275b7a3483df0add3f71eb812b689fb" +dependencies = [ + "base64 0.22.1", + "bytemuck", + "solana-curve25519 3.1.3", + "solana-zk-sdk 4.0.0", ] [[package]] @@ -8974,17 +10691,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe2629860ff04c17bafa9ba4bed8850a404ecac81074113e1f840dbd0ebb7bd6" dependencies = [ "bytemuck", - "solana-account-info", - "solana-curve25519", - "solana-instruction", - "solana-instructions-sysvar", - "solana-msg", - "solana-program-error", - "solana-pubkey", - "solana-sdk-ids", - "solana-zk-sdk", + "solana-account-info 2.3.0", + "solana-curve25519 2.3.13", + "solana-instruction 2.3.3", + "solana-instructions-sysvar 2.2.2", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", + "solana-zk-sdk 2.3.13", "spl-pod 0.5.1", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -8994,17 +10711,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512c85bdbbb4cbcc2038849a9e164c958b16541f252b53ea1a3933191c0a4a1a" dependencies = [ "bytemuck", - "solana-account-info", - "solana-curve25519", - "solana-instruction", - "solana-instructions-sysvar", - "solana-msg", - "solana-program-error", - "solana-pubkey", - "solana-sdk-ids", - "solana-zk-sdk", + "solana-account-info 2.3.0", + "solana-curve25519 2.3.13", + "solana-instruction 2.3.3", + "solana-instructions-sysvar 2.2.2", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", + "solana-zk-sdk 2.3.13", "spl-pod 0.5.1", - "thiserror 2.0.16", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-token-confidential-transfer-proof-extraction" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879a9ebad0d77383d3ea71e7de50503554961ff0f4ef6cbca39ad126e6f6da3a" +dependencies = [ + "bytemuck", + "solana-account-info 3.1.0", + "solana-curve25519 3.1.3", + "solana-instruction 3.1.0", + "solana-instructions-sysvar 3.0.0", + "solana-msg 3.0.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-zk-sdk 4.0.0", + "spl-pod 0.7.1", + "thiserror 2.0.17", ] [[package]] @@ -9014,8 +10751,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa27b9174bea869a7ebf31e0be6890bce90b1a4288bc2bbf24bd413f80ae3fde" dependencies = [ "curve25519-dalek 4.1.3", - "solana-zk-sdk", - "thiserror 2.0.16", + "solana-zk-sdk 2.3.13", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-token-confidential-transfer-proof-generation" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0cd59fce3dc00f563c6fa364d67c3f200d278eae681f4dc250240afcfe044b1" +dependencies = [ + "curve25519-dalek 4.1.3", + "solana-zk-sdk 4.0.0", + "thiserror 2.0.17", ] [[package]] @@ -9028,27 +10776,51 @@ dependencies = [ "num-derive", "num-traits", "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-error", - "solana-pubkey", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", "spl-discriminator 0.4.1", "spl-pod 0.5.1", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] -name = "spl-token-metadata-interface" -version = "0.4.0" +name = "spl-token-group-interface" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "452d0f758af20caaa10d9a6f7608232e000d4c74462f248540b3d2ddfa419776" +dependencies = [ + "bytemuck", + "num-derive", + "num-traits", + "num_enum", + "solana-instruction 3.1.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", + "spl-discriminator 0.5.1", + "spl-pod 0.7.1", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-token-interface" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c2318ddff97e006ed9b1291ebec0750a78547f870f62a69c56fe3b46a5d8fc" +checksum = "8c564ac05a7c8d8b12e988a37d82695b5ba4db376d07ea98bc4882c81f96c7f3" dependencies = [ - "borsh 1.5.7", - "solana-program", - "spl-discriminator 0.3.0", - "spl-pod 0.3.1", - "spl-program-error 0.5.0", - "spl-type-length-value 0.5.0", + "arrayref", + "bytemuck", + "num-derive", + "num-traits", + "num_enum", + "solana-instruction 3.1.0", + "solana-program-error 3.0.0", + "solana-program-option 3.0.0", + "solana-program-pack 3.0.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "thiserror 2.0.17", ] [[package]] @@ -9057,19 +10829,38 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "304d6e06f0de0c13a621464b1fd5d4b1bebf60d15ca71a44d3839958e0da16ee" dependencies = [ - "borsh 1.5.7", + "borsh 1.6.0", "num-derive", "num-traits", - "solana-borsh", + "solana-borsh 2.2.1", "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-error", - "solana-pubkey", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", "spl-discriminator 0.4.1", "spl-pod 0.5.1", "spl-type-length-value 0.8.0", - "thiserror 2.0.16", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-token-metadata-interface" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c467c7c3bd056f8fe60119e7ec34ddd6f23052c2fa8f1f51999098063b72676" +dependencies = [ + "borsh 1.6.0", + "num-derive", + "num-traits", + "solana-borsh 3.0.0", + "solana-instruction 3.1.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", + "spl-discriminator 0.5.1", + "spl-pod 0.7.1", + "spl-type-length-value 0.9.0", + "thiserror 2.0.17", ] [[package]] @@ -9082,32 +10873,45 @@ dependencies = [ "bytemuck", "num-derive", "num-traits", - "solana-account-info", - "solana-cpi", + "solana-account-info 2.3.0", + "solana-cpi 2.2.1", "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-error", - "solana-pubkey", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", "spl-discriminator 0.4.1", "spl-pod 0.5.1", "spl-program-error 0.7.0", - "spl-tlv-account-resolution", + "spl-tlv-account-resolution 0.10.0", "spl-type-length-value 0.8.0", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] -name = "spl-type-length-value" -version = "0.5.0" +name = "spl-transfer-hook-interface" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdcd73ec187bc409464c60759232e309f83b52a18a9c5610bf281c9c6432918c" +checksum = "c34b46b8f39bc64a9ab177a0ea8e9a58826db76f8d9d154a2400ee60baef7b1e" dependencies = [ + "arrayref", "bytemuck", - "solana-program", - "spl-discriminator 0.3.0", - "spl-pod 0.3.1", - "spl-program-error 0.5.0", + "num-derive", + "num-traits", + "solana-account-info 3.1.0", + "solana-cpi 3.1.0", + "solana-instruction 3.1.0", + "solana-msg 3.0.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.1.0", + "solana-system-interface 2.0.0", + "spl-discriminator 0.5.1", + "spl-pod 0.7.1", + "spl-program-error 0.8.0", + "spl-tlv-account-resolution 0.11.1", + "spl-type-length-value 0.9.0", + "thiserror 2.0.17", ] [[package]] @@ -9119,20 +10923,38 @@ dependencies = [ "bytemuck", "num-derive", "num-traits", - "solana-account-info", + "solana-account-info 2.3.0", "solana-decode-error", - "solana-msg", - "solana-program-error", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", "spl-discriminator 0.4.1", "spl-pod 0.5.1", - "thiserror 2.0.16", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-type-length-value" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca20a1a19f4507a98ca4b28ff5ed54cac9b9d34ed27863e2bde50a3238f9a6ac" +dependencies = [ + "bytemuck", + "num-derive", + "num-traits", + "num_enum", + "solana-account-info 3.1.0", + "solana-msg 3.0.0", + "solana-program-error 3.0.0", + "spl-discriminator 0.5.1", + "spl-pod 0.7.1", + "thiserror 2.0.17", ] [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "static_assertions" @@ -9183,7 +11005,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -9211,9 +11033,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.106" +version = "2.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" dependencies = [ "proc-macro2", "quote", @@ -9255,7 +11077,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -9275,7 +11097,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "core-foundation 0.9.4", "system-configuration-sys 0.6.0", ] @@ -9300,6 +11122,12 @@ dependencies = [ "libc", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tar" version = "0.4.44" @@ -9318,19 +11146,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" dependencies = [ "fastrand", - "getrandom 0.3.3", + "getrandom 0.3.4", "once_cell", "rustix 1.1.2", - "windows-sys 0.61.1", -] - -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", + "windows-sys 0.61.2", ] [[package]] @@ -9360,11 +11179,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl 2.0.16", + "thiserror-impl 2.0.17", ] [[package]] @@ -9375,18 +11194,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] name = "thiserror-impl" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -9398,6 +11217,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "time" version = "0.3.44" @@ -9431,9 +11259,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" dependencies = [ "displaydoc", "zerovec", @@ -9456,22 +11284,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.47.1" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ - "backtrace", "bytes", - "io-uring", "libc", "mio", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project-lite", "signal-hook-registry", - "slab", - "socket2 0.6.0", + "socket2 0.6.1", "tokio-macros", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -9486,13 +11311,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -9521,7 +11346,7 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" dependencies = [ - "rustls 0.23.32", + "rustls 0.23.35", "tokio", ] @@ -9539,28 +11364,30 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.20.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +checksum = "d25a406cddcc431a75d3d9afc6a7c0f7428d4891dd973e4d54c56b46127bf857" dependencies = [ "futures-util", "log", - "rustls 0.21.12", + "rustls 0.23.35", + "rustls-pki-types", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls 0.26.4", "tungstenite", - "webpki-roots 0.25.4", + "webpki-roots 0.26.11", ] [[package]] name = "tokio-util" -version = "0.7.16" +version = "0.7.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" +checksum = "2efa149fe76073d6e8fd97ef4f4eca7b67f599660115591483572e406e165594" dependencies = [ "bytes", "futures-core", "futures-sink", + "futures-util", "pin-project-lite", "tokio", ] @@ -9597,9 +11424,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" dependencies = [ "serde_core", ] @@ -9610,7 +11437,7 @@ version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.11.4", + "indexmap 2.12.1", "serde", "serde_spanned", "toml_datetime 0.6.11", @@ -9620,21 +11447,21 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.23.6" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3effe7c0e86fdff4f69cdd2ccc1b96f933e24811c5441d44904e8683e27184b" +checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" dependencies = [ - "indexmap 2.11.4", - "toml_datetime 0.7.2", + "indexmap 2.12.1", + "toml_datetime 0.7.3", "toml_parser", "winnow", ] [[package]] name = "toml_parser" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627" +checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" dependencies = [ "winnow", ] @@ -9689,10 +11516,10 @@ dependencies = [ "bytes", "flate2", "h2 0.4.12", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", - "hyper 1.7.0", + "hyper 1.8.1", "hyper-timeout 0.5.2", "hyper-util", "percent-encoding", @@ -9715,21 +11542,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb7613188ce9f7df5bfe185db26c5814347d110db17920415cf2fbcad85e7203" dependencies = [ "async-trait", - "axum 0.8.4", + "axum 0.8.7", "base64 0.22.1", "bytes", "flate2", "h2 0.4.12", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", - "hyper 1.7.0", + "hyper 1.8.1", "hyper-timeout 0.5.2", "hyper-util", "percent-encoding", "pin-project", "rustls-native-certs", - "socket2 0.6.0", + "socket2 0.6.1", "sync_wrapper 1.0.2", "tokio", "tokio-rustls 0.26.4", @@ -9765,7 +11592,7 @@ dependencies = [ "prost-build 0.13.5", "prost-types 0.13.5", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -9777,7 +11604,7 @@ dependencies = [ "prettyplease 0.2.37", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -9815,7 +11642,7 @@ dependencies = [ "prost-build 0.14.1", "prost-types 0.14.1", "quote", - "syn 2.0.106", + "syn 2.0.111", "tempfile", "tonic-build 0.14.2", ] @@ -9878,7 +11705,7 @@ checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", - "indexmap 2.11.4", + "indexmap 2.12.1", "pin-project-lite", "slab", "sync_wrapper 1.0.2", @@ -9891,14 +11718,14 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +checksum = "9cf146f99d442e8e68e585f5d798ccd3cad9a7835b917e09728880a862706456" dependencies = [ - "bitflags 2.9.4", + "bitflags 2.10.0", "bytes", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "iri-string", "pin-project-lite", @@ -9921,9 +11748,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" dependencies = [ "log", "pin-project-lite", @@ -9933,20 +11760,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] name = "tracing-core" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" dependencies = [ "once_cell", "valuable", @@ -9983,9 +11810,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.20" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ "matchers", "nu-ansi-term", @@ -10013,30 +11840,29 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" -version = "0.20.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +checksum = "8628dcc84e5a09eb3d8423d6cb682965dea9133204e8fb3efee74c2a0c259442" dependencies = [ - "byteorder", "bytes", "data-encoding", - "http 0.2.12", + "http 1.4.0", "httparse", "log", - "rand 0.8.5", - "rustls 0.21.12", + "rand 0.9.2", + "rustls 0.23.35", + "rustls-pki-types", "sha1", - "thiserror 1.0.69", - "url", + "thiserror 2.0.17", "utf-8", - "webpki-roots 0.24.0", + "webpki-roots 0.26.11", ] [[package]] name = "typenum" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" [[package]] name = "unicase" @@ -10046,15 +11872,15 @@ checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" [[package]] name = "unicode-ident" -version = "1.0.19" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "unicode-width" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "unicode-xid" @@ -10062,6 +11888,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "unit-prefix" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" + [[package]] name = "universal-hash" version = "0.5.1" @@ -10145,7 +11977,7 @@ version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", "js-sys", "wasm-bindgen", ] @@ -10205,15 +12037,6 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "wasi" -version = "0.14.7+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" -dependencies = [ - "wasip2", -] - [[package]] name = "wasip2" version = "1.0.1+wasi-0.2.4" @@ -10225,9 +12048,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.104" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" dependencies = [ "cfg-if", "once_cell", @@ -10236,25 +12059,11 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn 2.0.106", - "wasm-bindgen-shared", -] - [[package]] name = "wasm-bindgen-futures" -version = "0.4.54" +version = "0.4.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e038d41e478cc73bae0ff9b36c60cff1c98b8f38f8d7e8061e79ee63608ac5c" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" dependencies = [ "cfg-if", "js-sys", @@ -10265,9 +12074,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.104" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -10275,31 +12084,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.104" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" dependencies = [ + "bumpalo", "proc-macro2", "quote", - "syn 2.0.106", - "wasm-bindgen-backend", + "syn 2.0.111", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.104" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" dependencies = [ "unicode-ident", ] [[package]] name = "web-sys" -version = "0.3.81" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9367c417a924a74cae129e6a2ae3b47fabb1f8995595ab474029da749a8be120" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" dependencies = [ "js-sys", "wasm-bindgen", @@ -10317,33 +12126,33 @@ dependencies = [ [[package]] name = "webpki-root-certs" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4ffd8df1c57e87c325000a3d6ef93db75279dc3a231125aac571650f22b12a" +checksum = "ee3e3b5f5e80bc89f30ce8d0343bf4e5f12341c51f3e26cbeecbc7c85443e85b" dependencies = [ "rustls-pki-types", ] [[package]] name = "webpki-roots" -version = "0.24.0" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" -dependencies = [ - "rustls-webpki 0.101.7", -] +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.25.4" +version = "0.26.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.4", +] [[package]] name = "webpki-roots" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" +checksum = "b2878ef029c47c6e8cf779119f20fcf52bde7ad42a731b2a304bc221df17571e" dependencies = [ "rustls-pki-types", ] @@ -10382,7 +12191,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -10392,97 +12201,98 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows-core" -version = "0.62.1" +name = "wincode" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6844ee5416b285084d3d3fffd743b925a6c9385455f64f6d4fa3031c4c2749a9" +checksum = "d5067322fecd19471f7980888bff95cedf08b19829c83418f51410ff9ccc4193" dependencies = [ - "windows-implement", - "windows-interface", - "windows-link 0.2.0", - "windows-result 0.4.0", - "windows-strings 0.5.0", + "proc-macro2", + "quote", + "solana-short-vec 3.1.0", + "thiserror 2.0.17", + "wincode-derive", ] [[package]] -name = "windows-implement" -version = "0.60.1" +name = "wincode-derive" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb307e42a74fb6de9bf3a02d9712678b22399c87e6fa869d6dfcd8c1b7754e0" +checksum = "a144d1576a6d65f9c80df1d531e12b197057c6f69a6e9d4a183fe61e9f135568" dependencies = [ + "darling", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] -name = "windows-interface" -version = "0.59.2" +name = "windows-core" +version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0abd1ddbc6964ac14db11c7213d6532ef34bd9aa042c2e5935f59d7908b46a5" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", ] [[package]] -name = "windows-link" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" - -[[package]] -name = "windows-link" -version = "0.2.0" +name = "windows-implement" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", +] [[package]] -name = "windows-registry" -version = "0.5.3" +name = "windows-interface" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ - "windows-link 0.1.3", - "windows-result 0.3.4", - "windows-strings 0.4.2", + "proc-macro2", + "quote", + "syn 2.0.111", ] [[package]] -name = "windows-result" -version = "0.3.4" +name = "windows-link" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" -dependencies = [ - "windows-link 0.1.3", -] +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] -name = "windows-result" -version = "0.4.0" +name = "windows-registry" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" dependencies = [ - "windows-link 0.2.0", + "windows-link", + "windows-result", + "windows-strings", ] [[package]] -name = "windows-strings" -version = "0.4.2" +name = "windows-result" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-link 0.1.3", + "windows-link", ] [[package]] name = "windows-strings" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-link 0.2.0", + "windows-link", ] [[package]] @@ -10527,16 +12337,16 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.4", + "windows-targets 0.53.5", ] [[package]] name = "windows-sys" -version = "0.61.1" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f109e41dd4a3c848907eb83d5a42ea98b3769495597450cf6d153507b166f0f" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link 0.2.0", + "windows-link", ] [[package]] @@ -10587,19 +12397,19 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.4" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d42b7b7f66d2a06854650af09cfdf8713e427a439c97ad65a6375318033ac4b" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows-link 0.2.0", - "windows_aarch64_gnullvm 0.53.0", - "windows_aarch64_msvc 0.53.0", - "windows_i686_gnu 0.53.0", - "windows_i686_gnullvm 0.53.0", - "windows_i686_msvc 0.53.0", - "windows_x86_64_gnu 0.53.0", - "windows_x86_64_gnullvm 0.53.0", - "windows_x86_64_msvc 0.53.0", + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] @@ -10622,9 +12432,9 @@ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" @@ -10646,9 +12456,9 @@ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" [[package]] name = "windows_i686_gnu" @@ -10670,9 +12480,9 @@ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" [[package]] name = "windows_i686_gnullvm" @@ -10682,9 +12492,9 @@ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" [[package]] name = "windows_i686_msvc" @@ -10706,9 +12516,9 @@ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" @@ -10730,9 +12540,9 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" [[package]] name = "windows_x86_64_gnullvm" @@ -10754,9 +12564,9 @@ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" @@ -10778,15 +12588,15 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winnow" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" dependencies = [ "memchr", ] @@ -10809,9 +12619,18 @@ checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "writeable" -version = "0.6.1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "wyz" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] [[package]] name = "x509-parser" @@ -10843,16 +12662,16 @@ dependencies = [ [[package]] name = "yellowstone-fumarole-client" -version = "0.2.1+solana.2" +version = "0.2.2+solana.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf20746db350fa8f563eb2700ee7a449c892381419e8e9f6b703c44b86abf50" +checksum = "7f5421e45188ca4e379fe3297dd4b5484a5152942f006064293393b050780fe7" dependencies = [ "async-trait", "bytesize", "futures", "fxhash", - "http 1.3.1", - "hyper 1.7.0", + "http 1.4.0", + "hyper 1.8.1", "lazy_static", "prometheus", "prost 0.14.1", @@ -10861,7 +12680,7 @@ dependencies = [ "serde_json", "serde_with", "serde_yaml", - "solana-clock", + "solana-clock 2.2.2", "thiserror 1.0.69", "tokio", "tokio-stream", @@ -10877,9 +12696,9 @@ dependencies = [ [[package]] name = "yellowstone-grpc-client" -version = "9.0.0" +version = "9.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa1f12f04366aff925c567f87909ddaa4e9d557fc9fe71d8d61b09a6549eb4bb" +checksum = "38a9ba079420757406d603cd5f27b8c6f6e94c415c30a43b19ef4a0c4a5ff0d1" dependencies = [ "bytes", "futures", @@ -10891,26 +12710,26 @@ dependencies = [ [[package]] name = "yellowstone-grpc-proto" -version = "9.0.0" +version = "9.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dab1296ca56ab02ead0fa60ca085f89ac95cba5b6ff2680c9946a0320efe2b64" +checksum = "dbba21b6046eff1c9be2366a70d7264763b10004306e874b54409503a39e5f1e" dependencies = [ "anyhow", "bincode", "prost 0.14.1", "prost-types 0.14.1", "protobuf-src", - "solana-account", - "solana-account-decoder", - "solana-clock", - "solana-hash", - "solana-message", - "solana-pubkey", - "solana-signature", - "solana-transaction", - "solana-transaction-context", - "solana-transaction-error", - "solana-transaction-status", + "solana-account 2.2.1", + "solana-account-decoder 2.3.13", + "solana-clock 2.2.2", + "solana-hash 2.3.0", + "solana-message 2.4.0", + "solana-pubkey 2.4.0", + "solana-signature 2.3.0", + "solana-transaction 2.2.3", + "solana-transaction-context 2.3.13", + "solana-transaction-error 2.2.1", + "solana-transaction-status 2.3.13", "tonic 0.14.2", "tonic-build 0.14.2", "tonic-prost", @@ -10927,7 +12746,6 @@ dependencies = [ "futures-util", "opentelemetry 0.24.0", "prometheus", - "rustls 0.23.32", "serde", "smallvec", "thiserror 1.0.69", @@ -10940,35 +12758,20 @@ dependencies = [ ] [[package]] -name = "yellowstone-vixen-boop-parser" +name = "yellowstone-vixen-block-meta-parser" version = "0.6.0" dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", + "tokio", + "yellowstone-grpc-proto", "yellowstone-vixen-core", + "yellowstone-vixen-mock", ] [[package]] name = "yellowstone-vixen-core" version = "0.6.0" dependencies = [ - "borsh 1.5.7", + "borsh 1.6.0", "bs58", "clap", "serde", @@ -10982,12 +12785,12 @@ name = "yellowstone-vixen-example-filtered-pipeline" version = "0.0.0" dependencies = [ "clap", + "rustls 0.23.35", "toml 0.8.23", "tracing", "yellowstone-vixen", - "yellowstone-vixen-meteora-amm-parser", - "yellowstone-vixen-raydium-amm-v4-parser", "yellowstone-vixen-solana-rpc-source", + "yellowstone-vixen-spl-token-parser", "yellowstone-vixen-yellowstone-grpc-source", ] @@ -10995,40 +12798,19 @@ dependencies = [ name = "yellowstone-vixen-example-prometheus" version = "0.0.0" dependencies = [ + "borsh 1.6.0", "clap", "prometheus", + "prost 0.13.5", + "rustls 0.23.35", "tokio", "toml 0.8.23", "tracing", "yellowstone-vixen", "yellowstone-vixen-parser", - "yellowstone-vixen-yellowstone-grpc-source", -] - -[[package]] -name = "yellowstone-vixen-example-stream" -version = "0.0.0" -dependencies = [ - "clap", - "prost-build 0.13.5", - "toml 0.8.23", - "tracing", - "tracing-subscriber", - "yellowstone-vixen", - "yellowstone-vixen-jupiter-swap-parser", - "yellowstone-vixen-kamino-limit-orders-parser", - "yellowstone-vixen-meteora-amm-parser", - "yellowstone-vixen-meteora-parser", - "yellowstone-vixen-moonshot-parser", - "yellowstone-vixen-orca-whirlpool-parser", - "yellowstone-vixen-parser", - "yellowstone-vixen-proto", - "yellowstone-vixen-pump-swaps-parser", - "yellowstone-vixen-pumpfun-parser", - "yellowstone-vixen-raydium-amm-v4-parser", - "yellowstone-vixen-raydium-clmm-parser", - "yellowstone-vixen-raydium-cpmm-parser", - "yellowstone-vixen-stream", + "yellowstone-vixen-proc-macro", + "yellowstone-vixen-spl-token-extensions-parser", + "yellowstone-vixen-spl-token-parser", "yellowstone-vixen-yellowstone-grpc-source", ] @@ -11043,198 +12825,17 @@ dependencies = [ "opentelemetry-stdout", "opentelemetry_sdk", "prost-build 0.13.5", + "rustls 0.23.35", "tokio", "toml 0.8.23", "tracing", "tracing-opentelemetry", "tracing-subscriber", "yellowstone-vixen", - "yellowstone-vixen-parser", + "yellowstone-vixen-spl-token-parser", "yellowstone-vixen-yellowstone-grpc-source", ] -[[package]] -name = "yellowstone-vixen-jupiter-swap-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-kamino-limit-orders-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-meteora-amm-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-meteora-dbc-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-meteora-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-meteora-pools-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-meteora-vault-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - [[package]] name = "yellowstone-vixen-mock" version = "0.6.0" @@ -11246,83 +12847,20 @@ dependencies = [ "solana-client", "solana-rpc-client-api", "solana-sdk", - "solana-transaction-status", + "solana-transaction-status 3.1.3", "yellowstone-grpc-proto", "yellowstone-vixen-core", ] -[[package]] -name = "yellowstone-vixen-moonshot-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-orca-whirlpool-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - [[package]] name = "yellowstone-vixen-parser" version = "0.6.0" dependencies = [ "bs58", - "bytemuck", - "solana-program-error", - "solana-pubkey", - "spl-pod 0.3.1", - "spl-token 6.0.0", - "spl-token-2022 9.0.0", - "spl-token-group-interface", - "spl-token-metadata-interface 0.7.0", - "spl-type-length-value 0.8.0", - "strum 0.27.2", - "strum_macros 0.27.2", + "solana-program-option 3.0.0", + "solana-pubkey 3.0.0", "thiserror 1.0.69", "tokio", - "tracing", - "yellowstone-grpc-proto", "yellowstone-vixen-core", "yellowstone-vixen-mock", "yellowstone-vixen-proto", @@ -11341,7 +12879,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -11358,159 +12896,12 @@ dependencies = [ ] [[package]] -name = "yellowstone-vixen-pump-swaps-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-pumpfun-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-raydium-amm-v4-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-raydium-clmm-parser" +name = "yellowstone-vixen-slot-parser" version = "0.6.0" dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-raydium-cpmm-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - -[[package]] -name = "yellowstone-vixen-raydium-launchpad-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "protobuf-src", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", + "tokio", "yellowstone-vixen-core", + "yellowstone-vixen-mock", ] [[package]] @@ -11520,10 +12911,10 @@ dependencies = [ "async-trait", "clap", "serde", - "solana-account-decoder-client-types", + "solana-account-decoder-client-types 3.1.3", "solana-client", - "solana-commitment-config", - "solana-pubkey", + "solana-commitment-config 3.1.0", + "solana-pubkey 3.0.0", "tokio", "tracing", "yellowstone-grpc-proto", @@ -11535,14 +12926,16 @@ dependencies = [ name = "yellowstone-vixen-solana-snapshot-source" version = "0.6.0" dependencies = [ + "agave-snapshots", "async-trait", "clap", "futures-util", "serde", - "solana-account", + "solana-account 3.2.0", "solana-accounts-db", + "solana-genesis-utils", "solana-ledger", - "solana-pubkey", + "solana-pubkey 3.0.0", "solana-runtime", "tar", "tempfile", @@ -11556,24 +12949,63 @@ dependencies = [ "zstd", ] +[[package]] +name = "yellowstone-vixen-spl-token-extensions-parser" +version = "0.6.0" +dependencies = [ + "bs58", + "bytemuck", + "solana-program-error 3.0.0", + "solana-program-pack 3.0.0", + "spl-pod 0.7.1", + "spl-token-2022 10.0.0", + "spl-token-group-interface 0.7.1", + "spl-token-metadata-interface 0.8.0", + "spl-type-length-value 0.9.0", + "thiserror 1.0.69", + "tokio", + "yellowstone-grpc-proto", + "yellowstone-vixen-core", + "yellowstone-vixen-mock", + "yellowstone-vixen-parser", + "yellowstone-vixen-spl-token-parser", +] + +[[package]] +name = "yellowstone-vixen-spl-token-parser" +version = "0.6.0" +dependencies = [ + "bs58", + "bytemuck", + "solana-program-error 3.0.0", + "spl-pod 0.7.1", + "spl-token 9.0.0", + "strum 0.27.2", + "strum_macros 0.27.2", + "thiserror 1.0.69", + "tokio", + "tracing", + "yellowstone-grpc-proto", + "yellowstone-vixen-core", + "yellowstone-vixen-mock", + "yellowstone-vixen-parser", + "yellowstone-vixen-proto", +] + [[package]] name = "yellowstone-vixen-stake-pool-parser" version = "0.6.0" dependencies = [ - "borsh 1.5.7", + "borsh 1.6.0", "bs58", - "spl-pod 0.3.1", + "spl-pod 0.7.1", "spl-stake-pool", - "spl-token 6.0.0", - "spl-token-2022 9.0.0", - "spl-token-group-interface", - "spl-token-metadata-interface 0.4.0", - "spl-type-length-value 0.8.0", "thiserror 1.0.69", "tokio", "yellowstone-grpc-proto", "yellowstone-vixen-core", "yellowstone-vixen-mock", + "yellowstone-vixen-parser", "yellowstone-vixen-proto", ] @@ -11602,31 +13034,6 @@ dependencies = [ "yellowstone-vixen-yellowstone-grpc-source", ] -[[package]] -name = "yellowstone-vixen-virtuals-parser" -version = "0.6.0" -dependencies = [ - "borsh 1.5.7", - "num-derive", - "num-traits", - "prost 0.13.5", - "prost-build 0.13.5", - "solana-account-info", - "solana-cpi", - "solana-decode-error", - "solana-instruction", - "solana-msg", - "solana-program-entrypoint", - "solana-program-error", - "solana-pubkey", - "strum 0.27.2", - "strum_macros 0.27.2", - "thiserror 1.0.69", - "tonic 0.12.3", - "tracing", - "yellowstone-vixen-core", -] - [[package]] name = "yellowstone-vixen-yellowstone-fumarole-source" version = "0.6.0" @@ -11664,11 +13071,10 @@ dependencies = [ [[package]] name = "yoke" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" dependencies = [ - "serde", "stable_deref_trait", "yoke-derive", "zerofrom", @@ -11676,34 +13082,34 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", "synstructure 0.13.2", ] [[package]] name = "zerocopy" -version = "0.8.27" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +checksum = "4ea879c944afe8a2b25fef16bb4ba234f47c694565e97383b36f3a878219065c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.27" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +checksum = "cf955aa904d6040f70dc8e9384444cb1030aed272ba3cb09bbc4ab9e7c1f34f5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] @@ -11723,15 +13129,15 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", "synstructure 0.13.2", ] [[package]] name = "zeroize" -version = "1.8.1" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" dependencies = [ "zeroize_derive", ] @@ -11744,14 +13150,14 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] name = "zerotrie" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" dependencies = [ "displaydoc", "yoke", @@ -11760,9 +13166,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" dependencies = [ "yoke", "zerofrom", @@ -11771,13 +13177,13 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.111", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 9d2a8017..83e76d45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ resolver = "2" [workspace.package] authors = ["Triton One", "ABK-Labs"] -edition = "2021" +edition = "2024" license = "MIT" version = "0.6.0" repository = "https://github.com/rpcpool/yellowstone-vixen" @@ -13,8 +13,9 @@ publish = false [workspace.dependencies] +agave-snapshots = "^3.0.0" async-trait = "^0.1" -borsh = "1.5.5" +borsh = "1.5.7" bs58 = "^0.5.1" hex = "^0.4.3" bytesize = "^2.0.0" @@ -36,35 +37,38 @@ prost-build = "^0.13.1" prost-types = "^0.13.1" protobuf-src = "^1.0.0" regex = "^1.11.0" -rustls = "^0.23.0" serde = "^1.0.198" serde_json = "^1.0.0" smallvec = "^1.14.0" -solana-account = "^2.2.0" -solana-accounts-db = "^2.2.0" -solana-account-decoder-client-types = "^2.2.0" -solana-client = "^2.2.0" -solana-commitment-config = "^2.2.0" -solana-sdk = "^2.2.0" -solana-rpc-client-api = "^2.2.0" -solana-account-info = "^2.2.0" -solana-cpi = "^2.2.0" -solana-decode-error = "^2.2.0" -solana-pubkey = "^2.2.0" -solana-instruction = "^2.2.0" -solana-msg = "^2.2.0" -solana-program-entrypoint = "^2.2.0" -solana-program-error = "^2.2.0" -solana-transaction-status = "^2.2.0" -solana-ledger = "^2.2.0" -solana-runtime = "^2.2.0" -spl-pod = "^0.3.0" +solana-genesis-utils = "^3.0.0" +solana-account = "^3.0.0" +solana-accounts-db = "^3.0.0" +solana-program-option = "^3.0.0" +solana-account-decoder-client-types = "^3.0.0" +solana-client = "^3.0.0" +solana-commitment-config = "^3.0.0" +solana-sdk = "^3.0.0" +solana-rpc-client-api = "^3.0.0" +solana-account-info = "^3.0.0" +solana-cpi = "^3.0.0" +solana-decode-error = "^3.0.0" +solana-pubkey = "^3.0.0" +solana-instruction = "^3.0.0" +solana-msg = "^3.0.0" +solana-program-entrypoint = "^3.0.0" +solana-program-pack = "^3.0.0" +solana-program-error = "^3.0.0" +solana-transaction-status = "^3.0.0" +solana-ledger = "^3.0.0" +solana-runtime = "^3.0.0" +spl-pod = "^0.7.0" spl-stake-pool = "^2.0.0" -spl-token = "^6.0.0" -spl-token-2022 = "^9.0.0" -spl-type-length-value = "^0.8.0" -spl-token-group-interface = "^0.6.0" -spl-token-metadata-interface = "^0.7.0" +spl-token = "^9.0.0" +spl-token-2022 = "^10.0.0" +spl-type-length-value = "^0.9.0" +spl-token-group-interface = "^0.7.0" +spl-token-metadata-interface = "^0.8.0" +rustls = "^0.23" strum = "^0.27" strum_macros = "^0.27" syn = { version = "2", default-features = false } @@ -76,7 +80,7 @@ tonic-reflection = "^0.12.1" tonic-build = "^0.12.1" toml = "^0.8.0" topograph = "^0.4.0" -tokio = "^1.37.0" +tokio = "^1.48.0" tracing = "^0.1.40" quote = "1" zstd = "^0.13.0" @@ -85,6 +89,7 @@ bytemuck = "^1" yellowstone-fumarole-client = "^0.2.0" yellowstone-grpc-client = { version = "9" } yellowstone-grpc-proto = { version = "9", default-features = false } + yellowstone-vixen = { path = "crates/runtime", version = "0.6.0" } yellowstone-vixen-proc-macro = { path = "crates/proc-macro", version = "0.6.0" } yellowstone-vixen-stream = { path = "crates/stream", version = "0.6.0" } @@ -93,23 +98,11 @@ yellowstone-vixen-mock = { path = "crates/mock", version = "0.6.0" } yellowstone-vixen-parser = { path = "crates/parser", version = "0.6.0" } yellowstone-vixen-proto = { path = "crates/proto", version = "0.6.0" } -yellowstone-vixen-boop-parser = { path = "crates/boop-parser", version = "0.6.0" } -yellowstone-vixen-meteora-parser = { path = "crates/meteora-parser", version = "0.6.0" } -yellowstone-vixen-pumpfun-parser = { path = "crates/pumpfun-parser", version = "0.6.0" } -yellowstone-vixen-jupiter-swap-parser = { path = "crates/jupiter-swap-parser", version = "0.6.0" } -yellowstone-vixen-meteora-amm-parser = { path = "crates/meteora-amm-parser", version = "0.6.0" } -yellowstone-vixen-meteora-dbc-parser = { path = "crates/meteora-dbc-parser", version = "0.6.0" } -yellowstone-vixen-meteora-pools-parser = { path = "crates/meteora-pools-parser", version = "0.6.0" } -yellowstone-vixen-meteora-vault-parser = { path = "crates/meteora-vault-parser", version = "0.6.0" } -yellowstone-vixen-moonshot-parser = { path = "crates/moonshot-parser", version = "0.6.0" } -yellowstone-vixen-orca-whirlpool-parser = { path = "crates/orca-whirlpool-parser", version = "0.6.0" } -yellowstone-vixen-raydium-cpmm-parser = { path = "crates/raydium-cpmm-parser", version = "0.6.0" } -yellowstone-vixen-pump-swaps-parser = { path = "crates/pump-swaps-parser", version = "0.6.0" } -yellowstone-vixen-raydium-clmm-parser = { path = "crates/raydium-clmm-parser", version = "0.6.0" } -yellowstone-vixen-raydium-amm-v4-parser = { path = "crates/raydium-amm-v4-parser", version = "0.6.0" } -yellowstone-vixen-kamino-limit-orders-parser = { path = "crates/kamino-limit-orders-parser", version = "0.6.0" } -yellowstone-vixen-raydium-launchpad-parser = { path = "crates/raydium-launchpad-parser", version = "0.6.0" } -yellowstone-vixen-virtuals-parser = { path = "crates/virtuals-parser", version = "0.6.0" } +# Parsers +yellowstone-vixen-spl-token-extensions-parser = { path = "crates/spl-token-extensions-parser", version = "0.6.0" } +yellowstone-vixen-spl-token-parser = { path = "crates/spl-token-parser", version = "0.6.0" } +yellowstone-vixen-block-meta-parser = { path = "crates/block-meta-parser", version = "0.6.0" } +yellowstone-vixen-slot-parser = { path = "crates/slot-parser", version = "0.6.0" } # Sources yellowstone-vixen-solana-rpc-source = { path = "crates/solana-rpc-source", version = "0.6.0" } diff --git a/README.md b/README.md index f78417b8..fb08cd91 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Solana change events, following the Yellowstone gRPC specification, are received - [Problem Solving](#problem-solving) - [Features](#features) - [Quick Start](#quick-start) - - [Official Parsers](#official-parsers) + - [Parsers](#parsers) - [Official Sources](#official-sources) - [Developer Resources](#developer-resources) - [Maintainers](#maintainers) @@ -29,7 +29,8 @@ Yellowstone Vixen solves core challenges for Solana dApp developers: - **🛠 Parser + Handler Architecture**: Build pipelines that transform raw Solana events into structured models and trigger custom logic. - **🔥 Flexible Source Integration**: Register custom data sources or use existing ones like Dragon's Mouth for Solana Geyser streams. -- **📈 Metrics Support**: Prometheus /metrics endpoint available out-of-the-box. +- **✨ IDL-Based Code Generation**: Generate type-safe parsers directly from your Solana program's IDL using a procedural macro, eliminating manual deserialization and improving maintainability. +- **📈 Metrics Support**: Register your own Prometheus registry for unified metrics reporting. - **🧪 Offline Testing with Fixtures**: Test parsers without connecting to live Solana nodes using devnet fixtures. - **🔄 gRPC Streaming API**: Serve parsed program events directly to external systems or clients. @@ -43,7 +44,7 @@ use std::path::PathBuf; use clap::Parser; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use yellowstone_vixen::Pipeline; -use yellowstone_vixen_parser::token_program::{AccountParser, InstructionParser}; +use yellowstone_vixen_spl_token_parser::{AccountParser, InstructionParser}; use yellowstone_vixen_yellowstone_grpc_source::YellowstoneGrpcSource; #[derive(clap::Parser)] @@ -57,13 +58,17 @@ pub struct Opts { pub struct Logger; impl vixen::Handler for Logger { - async fn handle(&self, _value: &V, _raw: &R) -> vixen::HandlerResult<()> { + async fn handle(&self, value: &V, _raw: &R) -> vixen::HandlerResult<()> { tracing::info!(?value); Ok(()) } } fn main() { + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .expect("Fialed to install rustls crypto provider"); + tracing_subscriber::registry() .with(tracing_subscriber::EnvFilter::from_default_env()) .with(tracing_subscriber::fmt::layer()) @@ -93,27 +98,37 @@ To run prometheus, you need to have docker and docker-compose installed on your sudo docker-compose up ``` -## Supported Programs - -| Address | Public Name | Parser | -| ---------------------------------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | -| `boop8hVGQGqehUK2iVEMEnMrL5RbjywRzHKBmBE7ry4` | **Boop.fun** | [yellowstone-vixen-boop-parser](https://github.com/rpcpool/yellowstone-vixen/tree/main/crates/boop-parser) | -| `JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4` | **Jupiter Aggregator v6** | [yellowstone-vixen-jupiter-swap-parser](https://github.com/rpcpool/yellowstone-vixen/tree/main/crates/jupiter-swap-parser) | -| `LiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF` | **Kamino Limit Order** | [yellowstone-vixen-kamino-limit-orders-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/kamino-limit-orders-parser) | -| `cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG` | **Meteora DAMM v2** | [yellowstone-vixen-meteora-amm-parser](https://github.com/rpcpool/yellowstone-vixen/tree/main/crates/meteora-amm-parser) | -| `dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN` | **Meteora Dynamic Bonding Curve** | [yellowstone-vixen-meteora-dbc-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/meteora-dbc-parser) | -| `LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo` | **Meteora DLMM** | [yellowstone-vixen-meteora-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/meteora-parser) | -| `Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB` | **Meteora Pools** | [yellowstone-vixen-meteora-pools-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/meteora-pools-parser) | -| `24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi` | **Meteora Vault** | [yellowstone-vixen-meteora-vault-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/meteora-vault-parser) | -| `MoonCVVNZFSYkqNXP6bxHLPL6QQJiMagDL3qcqUQTrG` | **Moonshot** | [yellowstone-vixen-moonshot-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/moonshot-parser) | -| `whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc` | **Whirlpools** | [yellowstone-vixen-orca-whirlpool-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/orca-whirlpool-parser) | -| `pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA` | **Pump.fun AMM** | [yellowstone-vixen-pump-swaps-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/pump-swaps-parser) | -| `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P` | **Pump.fun** | [yellowstone-vixen-pumpfun-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/pumpfun-parser) | -| `675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8` | **Raydium Liquidity Pool V4** | [yellowstone-vixen-raydium-amm-v4-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/raydium-amm-v4-parser) | -| `CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK` | **Raydium Concentrated Liquidity** | [yellowstone-vixen-raydium-clmm-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/raydium-clmm-parser) | -| `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C` | **Raydium CPMM** | [yellowstone-vixen-raydium-cpmm-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/raydium-cpmm-parser) | -| `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` | **Raydium Launchpad** | [yellowstone-vixen-raydium-launchpad-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/raydium-launchpad-parser) | -| `5U3EU2ubXtK84QcRjWVmYt9RaDyA8gKxdUrPFXmZyaki` | **Virtuals** | [yellowstone-vixen-virtuals-parser](https://github.com/rpcpool/yellowstone-vixen/blob/main/crates/virtuals-parser) | +## Parsers + +### Built-in + +| Address | Public Name | Parser | +| --------------------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | +| `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA` | **Token Program** | [yellowstone-vixen-spl-token-parser](https://github.com/rpcpool/yellowstone-vixen/tree/main/crates/spl-token-parser) | +| `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb` | **Token Extensions** | [yellowstone-vixen-spl-token-extensions-parser](https://github.com/rpcpool/yellowstone-vixen/tree/main/crates/spl-token-extensions-program) | + +### Codegen Macro + +The `yellowstone-vixen-proc-macro` crate provides the `include_vixen_parser!` procedural macro, which generates a Vixen parser from a Codama JSON IDL file. + +To use it, add the following dependencies to your `Cargo.toml`: + +```toml +[dependencies] +borsh = "^1.0.0" +yellowstone-vixen-parser = { version = "0.6.0" } +yellowstone-vixen-proc-macro = { version = "0.6.0" } +``` + +Then, import and invoke the macro in your code. Specify the path to your Codama JSON IDL file relative to your crate root: + +```rust +use yellowstone_vixen_proc_macro::include_vixen_parser; + +include_vixen_parser!("path/to/idl.json"); +``` + +The generated account and instruction parsers will be available under a module named after the program. ## Official Sources diff --git a/crates/block-meta-parser/Cargo.toml b/crates/block-meta-parser/Cargo.toml new file mode 100644 index 00000000..7bfb8812 --- /dev/null +++ b/crates/block-meta-parser/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "yellowstone-vixen-block-meta-parser" +description = "Vixen block meta parser." +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +authors.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +yellowstone-grpc-proto = { workspace = true } +yellowstone-vixen-core = { workspace = true } + +[dev-dependencies] +yellowstone-vixen-mock = { workspace = true } +tokio.workspace = true + +[features] +default = [] diff --git a/crates/parser/src/block_meta.rs b/crates/block-meta-parser/src/block_meta.rs similarity index 100% rename from crates/parser/src/block_meta.rs rename to crates/block-meta-parser/src/block_meta.rs diff --git a/crates/block-meta-parser/src/lib.rs b/crates/block-meta-parser/src/lib.rs new file mode 100644 index 00000000..7a5daa65 --- /dev/null +++ b/crates/block-meta-parser/src/lib.rs @@ -0,0 +1,3 @@ +mod block_meta; + +pub use block_meta::*; diff --git a/crates/boop-parser/Cargo.toml b/crates/boop-parser/Cargo.toml deleted file mode 100644 index 50d3ce90..00000000 --- a/crates/boop-parser/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "yellowstone-vixen-boop-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Boop program" -license.workspace = true -repository.workspace = true -authors.workspace = true - - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info.workspace = true -solana-cpi.workspace = true -solana-decode-error.workspace = true -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction = { workspace = true, features = ["serde", "borsh"] } -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh = { workspace = true, features = ["derive"] } -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build = { workspace = true } diff --git a/crates/boop-parser/build.rs b/crates/boop-parser/build.rs deleted file mode 100644 index dd98fcfb..00000000 --- a/crates/boop-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/boop.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/boop-parser/idl.json b/crates/boop-parser/idl.json deleted file mode 100644 index e98de136..00000000 --- a/crates/boop-parser/idl.json +++ /dev/null @@ -1,7804 +0,0 @@ -{ - "address": "boop8hVGQGqehUK2iVEMEnMrL5RbjywRzHKBmBE7ry4", - "metadata": { - "name": "boop", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Boop is a token launcher with fee sharing" - }, - "instructions": [ - { - "name": "add_operators", - "discriminator": [ - 165, - 199, - 62, - 214, - 81, - 54, - 4, - 150 - ], - "accounts": [ - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "authority", - "writable": true, - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "operators", - "type": { - "vec": "pubkey" - } - } - ] - }, - { - "name": "buy_token", - "discriminator": [ - 138, - 127, - 14, - 91, - 38, - 87, - 115, - 105 - ], - "accounts": [ - { - "name": "mint" - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "trading_fees_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 114, - 97, - 100, - 105, - 110, - 103, - 95, - 102, - 101, - 101, - 115, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_sol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "recipient_token_account" - }, - { - "name": "buyer", - "writable": true, - "signer": true - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "wsol", - "address": "So11111111111111111111111111111111111111112" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - } - ], - "args": [ - { - "name": "buy_amount", - "type": "u64" - }, - { - "name": "amount_out_min", - "type": "u64" - } - ] - }, - { - "name": "cancel_authority_transfer", - "discriminator": [ - 94, - 131, - 125, - 184, - 183, - 24, - 125, - 229 - ], - "accounts": [ - { - "name": "authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "close_bonding_curve_vault", - "discriminator": [ - 189, - 71, - 189, - 239, - 113, - 66, - 59, - 189 - ], - "accounts": [ - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "operator", - "writable": true, - "signer": true - }, - { - "name": "vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "mint" - }, - { - "name": "recipient_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "recipient" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "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": "recipient", - "writable": true - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "docs": [ - "System program for creating associated token if needed" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "collect_trading_fees", - "discriminator": [ - 189, - 38, - 205, - 234, - 81, - 77, - 25, - 1 - ], - "accounts": [ - { - "name": "operator", - "writable": true, - "signer": true - }, - { - "name": "protocol_fee_recipient", - "relations": [ - "config" - ] - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "lock_program", - "address": "LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE" - }, - { - "name": "vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 107, - 95, - 99, - 112, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "const", - "value": "LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE" - } - } - }, - { - "name": "fee_nft_account", - "docs": [ - "Fee token account" - ] - }, - { - "name": "locked_liquidity", - "docs": [ - "Store the locked the information of liquidity" - ], - "writable": true - }, - { - "name": "cpmm_program", - "address": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - }, - { - "name": "cp_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 110, - 100, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "pool_state", - "writable": true - }, - { - "name": "lp_mint", - "docs": [ - "lp mint", - "address = pool_state.lp_mint" - ], - "writable": true - }, - { - "name": "recipient_token_0_account", - "docs": [ - "The token account for receive token_0" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "protocol_fee_recipient" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "vault_0_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": "recipient_token_1_account", - "docs": [ - "The token account for receive token_1" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 114, - 97, - 100, - 105, - 110, - 103, - 95, - 102, - 101, - 101, - 115, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_0_vault.mint" - } - ] - } - }, - { - "name": "token_0_vault", - "docs": [ - "The address that holds pool tokens for token_0" - ], - "writable": true - }, - { - "name": "token_1_vault", - "docs": [ - "The address that holds pool tokens for token_1" - ], - "writable": true - }, - { - "name": "vault_0_mint", - "docs": [ - "The mint of token_0 vault" - ] - }, - { - "name": "vault_1_mint", - "docs": [ - "The mint of token_1 vault" - ] - }, - { - "name": "locked_lp_vault", - "docs": [ - "locked lp token account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "authority" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "lp_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "system_program", - "docs": [ - "System program" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "associated_token_program", - "docs": [ - "Associated token program" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "token_program", - "docs": [ - "token Program" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_program_2022", - "docs": [ - "Token program 2022" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "memo_program", - "docs": [ - "memo program" - ], - "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" - } - ], - "args": [] - }, - { - "name": "complete_authority_transfer", - "discriminator": [ - 81, - 233, - 91, - 132, - 175, - 31, - 151, - 141 - ], - "accounts": [ - { - "name": "pending_authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "create_raydium_pool", - "discriminator": [ - 65, - 45, - 119, - 77, - 204, - 178, - 84, - 2 - ], - "accounts": [ - { - "name": "cpmm_program", - "address": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - }, - { - "name": "amm_config", - "docs": [ - "Which config the pool belongs to." - ] - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 110, - 100, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "pool_state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "amm_config" - }, - { - "kind": "account", - "path": "token_0_mint" - }, - { - "kind": "account", - "path": "token_1_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "token_0_mint", - "writable": true - }, - { - "name": "token_1_mint", - "docs": [ - "Token_1 mint, the key must be greater than token_0 mint." - ], - "address": "So11111111111111111111111111111111111111112" - }, - { - "name": "lp_mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "vault_authority", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "bonding_curve_wsol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 119, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "creator_lp_token", - "writable": true - }, - { - "name": "token_0_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "token_0_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "token_1_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "token_1_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "create_pool_fee", - "docs": [ - "create pool fee account" - ], - "writable": true, - "address": "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8" - }, - { - "name": "observation_state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 111, - 98, - 115, - 101, - 114, - 118, - 97, - 116, - 105, - 111, - 110 - ] - }, - { - "kind": "account", - "path": "pool_state" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "operator", - "writable": true, - "signer": true - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "token_program", - "docs": [ - "Program to create mint account and mint tokens" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "docs": [ - "Program to create an ATA for receiving position NFT" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "docs": [ - "To create a new program account" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "rent", - "docs": [ - "Sysvar for program account" - ], - "address": "SysvarRent111111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "create_raydium_random_pool", - "discriminator": [ - 78, - 44, - 173, - 29, - 132, - 180, - 4, - 172 - ], - "accounts": [ - { - "name": "cpmm_program", - "address": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - }, - { - "name": "amm_config", - "docs": [ - "Which config the pool belongs to." - ] - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 110, - 100, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "pool_state", - "writable": true, - "signer": true - }, - { - "name": "token_0_mint", - "writable": true - }, - { - "name": "token_1_mint", - "docs": [ - "Token_1 mint, the key must be greater than token_0 mint." - ], - "address": "So11111111111111111111111111111111111111112" - }, - { - "name": "lp_mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "vault_authority", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "bonding_curve_wsol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 119, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "creator_lp_token", - "writable": true - }, - { - "name": "token_0_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "token_0_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "token_1_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "token_1_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "create_pool_fee", - "docs": [ - "create pool fee account" - ], - "writable": true, - "address": "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8" - }, - { - "name": "observation_state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 111, - 98, - 115, - 101, - 114, - 118, - 97, - 116, - 105, - 111, - 110 - ] - }, - { - "kind": "account", - "path": "pool_state" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "operator", - "writable": true, - "signer": true - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "token_program", - "docs": [ - "Program to create mint account and mint tokens" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "docs": [ - "Program to create an ATA for receiving position NFT" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "docs": [ - "To create a new program account" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "rent", - "docs": [ - "Sysvar for program account" - ], - "address": "SysvarRent111111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "create_token", - "discriminator": [ - 84, - 52, - 204, - 228, - 24, - 140, - 234, - 75 - ], - "accounts": [ - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "const", - "value": [ - 11, - 112, - 101, - 177, - 227, - 209, - 124, - 69, - 56, - 157, - 82, - 127, - 107, - 4, - 195, - 205, - 88, - 184, - 108, - 115, - 26, - 160, - 253, - 181, - 73, - 182, - 209, - 188, - 3, - 248, - 41, - 70 - ] - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 11, - 112, - 101, - 177, - 227, - 209, - 124, - 69, - 56, - 157, - 82, - 127, - 107, - 4, - 195, - 205, - 88, - 184, - 108, - 115, - 26, - 160, - 253, - 181, - 73, - 182, - 209, - 188, - 3, - 248, - 41, - 70 - ] - } - } - }, - { - "name": "mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 105, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "payer" - }, - { - "kind": "arg", - "path": "salt" - } - ] - } - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_metadata_program", - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - } - ], - "args": [ - { - "name": "salt", - "type": "u64" - }, - { - "name": "name", - "type": "string" - }, - { - "name": "symbol", - "type": "string" - }, - { - "name": "uri", - "type": "string" - } - ] - }, - { - "name": "create_token_fallback", - "discriminator": [ - 253, - 184, - 126, - 199, - 235, - 232, - 172, - 162 - ], - "accounts": [ - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "const", - "value": [ - 11, - 112, - 101, - 177, - 227, - 209, - 124, - 69, - 56, - 157, - 82, - 127, - 107, - 4, - 195, - 205, - 88, - 184, - 108, - 115, - 26, - 160, - 253, - 181, - 73, - 182, - 209, - 188, - 3, - 248, - 41, - 70 - ] - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 11, - 112, - 101, - 177, - 227, - 209, - 124, - 69, - 56, - 157, - 82, - 127, - 107, - 4, - 195, - 205, - 88, - 184, - 108, - 115, - 26, - 160, - 253, - 181, - 73, - 182, - 209, - 188, - 3, - 248, - 41, - 70 - ] - } - } - }, - { - "name": "mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 105, - 110, - 116 - ] - }, - { - "kind": "arg", - "path": "salt" - } - ] - } - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_metadata_program", - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - } - ], - "args": [ - { - "name": "salt", - "type": "u64" - }, - { - "name": "name", - "type": "string" - }, - { - "name": "symbol", - "type": "string" - }, - { - "name": "uri", - "type": "string" - } - ] - }, - { - "name": "deploy_bonding_curve", - "discriminator": [ - 180, - 89, - 199, - 76, - 168, - 236, - 217, - 138 - ], - "accounts": [ - { - "name": "mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 105, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "payer" - }, - { - "kind": "arg", - "path": "salt" - } - ] - } - }, - { - "name": "vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_sol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - } - ], - "args": [ - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "salt", - "type": "u64" - } - ] - }, - { - "name": "deploy_bonding_curve_fallback", - "discriminator": [ - 53, - 230, - 172, - 84, - 77, - 174, - 22, - 61 - ], - "accounts": [ - { - "name": "mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 105, - 110, - 116 - ] - }, - { - "kind": "arg", - "path": "salt" - } - ] - } - }, - { - "name": "vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_sol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - } - ], - "args": [ - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "salt", - "type": "u64" - } - ] - }, - { - "name": "deposit_into_raydium", - "discriminator": [ - 168, - 89, - 99, - 30, - 117, - 49, - 88, - 224 - ], - "accounts": [ - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "amm_config", - "docs": [ - "Which config the pool belongs to." - ] - }, - { - "name": "operator", - "writable": true, - "signer": true - }, - { - "name": "operator_wsol_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "operator" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "token_1_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": "vault_authority", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 110, - 100, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "pool_state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "amm_config" - }, - { - "kind": "account", - "path": "token_0_mint" - }, - { - "kind": "account", - "path": "token_1_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "token_0_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "token_0_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "token_1_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "token_1_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "bonding_curve_wsol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 119, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "token_program", - "docs": [ - "token Program" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_program_2022", - "docs": [ - "Token program 2022" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "system_program", - "docs": [ - "System program" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "associated_token_program", - "docs": [ - "Program to create an ATA for the operator to recoup any potential remaining WSOL" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "lp_mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "cpmm_program", - "address": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - }, - { - "name": "owner_lp_token", - "writable": true - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "token_0_mint", - "writable": true - }, - { - "name": "token_1_mint", - "docs": [ - "token_1 mint, the key must greater than token_0 mint" - ], - "address": "So11111111111111111111111111111111111111112" - } - ], - "args": [ - { - "name": "lp_token_amount", - "type": "u64" - }, - { - "name": "maximum_token_0_amount", - "type": "u64" - }, - { - "name": "maximum_token_1_amount", - "type": "u64" - } - ] - }, - { - "name": "graduate", - "discriminator": [ - 45, - 235, - 225, - 181, - 17, - 218, - 64, - 130 - ], - "accounts": [ - { - "name": "mint" - }, - { - "name": "wsol", - "address": "So11111111111111111111111111111111111111112" - }, - { - "name": "protocol_fee_recipient", - "writable": true - }, - { - "name": "token_distributor" - }, - { - "name": "token_distributor_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "token_distributor" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "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": "vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "bonding_curve_sol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_wsol_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 119, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "operator", - "writable": true, - "signer": true - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - } - ], - "args": [] - }, - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "protocol_fee_recipient", - "type": "pubkey" - }, - { - "name": "token_distributor", - "type": "pubkey" - } - ] - }, - { - "name": "initiate_authority_transfer", - "discriminator": [ - 210, - 43, - 101, - 215, - 119, - 140, - 106, - 218 - ], - "accounts": [ - { - "name": "authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "new_authority", - "type": "pubkey" - } - ] - }, - { - "name": "lock_raydium_liquidity", - "discriminator": [ - 173, - 255, - 148, - 6, - 122, - 99, - 140, - 22 - ], - "accounts": [ - { - "name": "lock_program", - "address": "LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE" - }, - { - "name": "vault_authority", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 107, - 95, - 99, - 112, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "const", - "value": "LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE" - } - } - }, - { - "name": "fee_nft_owner" - }, - { - "name": "fee_nft_mint", - "writable": true, - "signer": true - }, - { - "name": "fee_nft_account", - "writable": true - }, - { - "name": "pool_state", - "writable": true - }, - { - "name": "locked_liquidity", - "docs": [ - "Store the locked information of liquidity" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 107, - 101, - 100, - 95, - 108, - 105, - 113, - 117, - 105, - 100, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "fee_nft_mint" - } - ], - "program": { - "kind": "const", - "value": "LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE" - } - } - }, - { - "name": "lp_mint", - "docs": [ - "The mint of liquidity token" - ], - "writable": true - }, - { - "name": "liquidity_owner_lp", - "docs": [ - "liquidity owner lp token account" - ], - "writable": true - }, - { - "name": "locked_lp_vault", - "writable": true - }, - { - "name": "token_0_vault", - "docs": [ - "The address that holds pool tokens for token_0" - ], - "writable": true - }, - { - "name": "token_1_vault", - "docs": [ - "The address that holds pool tokens for token_1" - ], - "writable": true - }, - { - "name": "operator", - "writable": true, - "signer": true - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "token_0_vault.mint" - } - ] - } - }, - { - "name": "metadata_account", - "docs": [ - "To store metaplex metadata" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "const", - "value": [ - 11, - 112, - 101, - 177, - 227, - 209, - 124, - 69, - 56, - 157, - 82, - 127, - 107, - 4, - 195, - 205, - 88, - 184, - 108, - 115, - 26, - 160, - 253, - 181, - 73, - 182, - 209, - 188, - 3, - 248, - 41, - 70 - ] - }, - { - "kind": "account", - "path": "fee_nft_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 11, - 112, - 101, - 177, - 227, - 209, - 124, - 69, - 56, - 157, - 82, - 127, - 107, - 4, - 195, - 205, - 88, - 184, - 108, - 115, - 26, - 160, - 253, - 181, - 73, - 182, - 209, - 188, - 3, - 248, - 41, - 70 - ] - } - } - }, - { - "name": "rent", - "docs": [ - "Sysvar for token mint and ATA creation" - ], - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "system_program", - "docs": [ - "Program to create the new account" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "docs": [ - "Program to create/transfer mint/token account" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "docs": [ - "Program to create an ATA for receiving fee NFT" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "metadata_program", - "docs": [ - "Program to create NFT metadata accunt" - ], - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - } - ], - "args": [] - }, - { - "name": "remove_operators", - "discriminator": [ - 42, - 20, - 89, - 83, - 222, - 37, - 4, - 109 - ], - "accounts": [ - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "authority", - "writable": true, - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "operators", - "type": { - "vec": "pubkey" - } - } - ] - }, - { - "name": "sell_token", - "discriminator": [ - 109, - 61, - 40, - 187, - 230, - 176, - 135, - 174 - ], - "accounts": [ - { - "name": "mint" - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "trading_fees_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 114, - 97, - 100, - 105, - 110, - 103, - 95, - 102, - 101, - 101, - 115, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "bonding_curve_sol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "seller_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "seller" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "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": "seller", - "writable": true, - "signer": true - }, - { - "name": "recipient", - "writable": true - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - } - ], - "args": [ - { - "name": "sell_amount", - "type": "u64" - }, - { - "name": "amount_out_min", - "type": "u64" - } - ] - }, - { - "name": "split_trading_fees", - "discriminator": [ - 96, - 126, - 225, - 47, - 185, - 213, - 50, - 58 - ], - "accounts": [ - { - "name": "operator", - "writable": true, - "signer": true - }, - { - "name": "mint" - }, - { - "name": "wsol", - "address": "So11111111111111111111111111111111111111112" - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "trading_fees_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 114, - 97, - 100, - 105, - 110, - 103, - 95, - 102, - 101, - 101, - 115, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "fee_splitter_program", - "address": "boopEYztaEYSnajfMtjcRysyzyRcchgKsPboRZEbnJi" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "fee_splitter_config" - }, - { - "name": "fee_splitter_creator_vault", - "writable": true - }, - { - "name": "fee_splitter_vault_authority", - "writable": true - }, - { - "name": "fee_splitter_creator_vault_authority", - "writable": true - }, - { - "name": "fee_splitter_staking_mint" - }, - { - "name": "fee_splitter_wsol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "fee_splitter_vault_authority" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "wsol" - } - ], - "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": "fee_splitter_creator_vault_authority_wsol_vault", - "writable": true - }, - { - "name": "fee_splitter_treasury_wsol_vault", - "writable": true - }, - { - "name": "fee_splitter_team_wsol_vault", - "writable": true - }, - { - "name": "fee_splitter_reward_pool", - "writable": true - }, - { - "name": "fee_splitter_reward_pool_staking_vault", - "writable": true - }, - { - "name": "fee_splitter_reward_pool_reward_vault", - "writable": true - }, - { - "name": "fee_splitter_reward_pool_program" - } - ], - "args": [] - }, - { - "name": "swap_sol_for_tokens_on_raydium", - "discriminator": [ - 107, - 248, - 131, - 239, - 152, - 234, - 54, - 35 - ], - "accounts": [ - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "output_token_mint" - } - ] - } - }, - { - "name": "amm_config", - "docs": [ - "Which config the pool belongs to." - ] - }, - { - "name": "operator", - "writable": true, - "signer": true - }, - { - "name": "vault_authority", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 110, - 100, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "pool_state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "amm_config" - }, - { - "kind": "account", - "path": "output_token_mint" - }, - { - "kind": "account", - "path": "input_token_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "input_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "input_token_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "output_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "output_token_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "output_token_mint" - } - ] - } - }, - { - "name": "bonding_curve_wsol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 119, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "output_token_mint" - } - ] - } - }, - { - "name": "output_token_mint", - "docs": [ - "token_0 mint, the key must smaller than token_1 mint" - ] - }, - { - "name": "input_token_mint", - "docs": [ - "token_1 mint, the key must greater than token_0 mint" - ], - "address": "So11111111111111111111111111111111111111112" - }, - { - "name": "token_program", - "docs": [ - "input_token_mint and output_token_mint have the same token program" - ] - }, - { - "name": "cp_swap_program", - "address": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - }, - { - "name": "observation_state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 111, - 98, - 115, - 101, - 114, - 118, - 97, - 116, - 105, - 111, - 110 - ] - }, - { - "kind": "account", - "path": "pool_state" - } - ], - "program": { - "kind": "const", - "value": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - } - } - } - ], - "args": [ - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "minimum_amount_out", - "type": "u64" - } - ] - }, - { - "name": "swap_tokens_for_sol_on_raydium", - "discriminator": [ - 216, - 172, - 130, - 148, - 34, - 98, - 215, - 163 - ], - "accounts": [ - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101 - ] - }, - { - "kind": "account", - "path": "input_token_mint" - } - ] - } - }, - { - "name": "amm_config", - "docs": [ - "Which config the pool belongs to." - ] - }, - { - "name": "operator", - "writable": true, - "signer": true - }, - { - "name": "vault_authority", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 110, - 100, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "pool_state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "amm_config" - }, - { - "kind": "account", - "path": "input_token_mint" - }, - { - "kind": "account", - "path": "output_token_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "input_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "input_token_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "output_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "output_token_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 169, - 42, - 90, - 139, - 79, - 41, - 89, - 82, - 132, - 37, - 80, - 170, - 147, - 253, - 91, - 149, - 181, - 172, - 230, - 168, - 235, - 146, - 12, - 147, - 148, - 46, - 67, - 105, - 12, - 32, - 236, - 115 - ] - } - } - }, - { - "name": "bonding_curve_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "input_token_mint" - } - ] - } - }, - { - "name": "bonding_curve_wsol_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 95, - 99, - 117, - 114, - 118, - 101, - 95, - 119, - 115, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "input_token_mint" - } - ] - } - }, - { - "name": "input_token_mint", - "docs": [ - "token_0 mint, the key must smaller than token_1 mint" - ] - }, - { - "name": "output_token_mint", - "docs": [ - "token_1 mint, the key must greater than token_0 mint" - ], - "address": "So11111111111111111111111111111111111111112" - }, - { - "name": "token_program", - "docs": [ - "input_token_mint and output_token_mint have the same token program" - ] - }, - { - "name": "cp_swap_program", - "address": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - }, - { - "name": "observation_state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 111, - 98, - 115, - 101, - 114, - 118, - 97, - 116, - 105, - 111, - 110 - ] - }, - { - "kind": "account", - "path": "pool_state" - } - ], - "program": { - "kind": "const", - "value": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - } - } - } - ], - "args": [ - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "minimum_amount_out", - "type": "u64" - } - ] - }, - { - "name": "toggle_paused", - "discriminator": [ - 54, - 83, - 147, - 198, - 123, - 97, - 218, - 72 - ], - "accounts": [ - { - "name": "authority", - "writable": true, - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "update_config", - "discriminator": [ - 29, - 158, - 252, - 191, - 10, - 83, - 219, - 99 - ], - "accounts": [ - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "new_protocol_fee_recipient", - "type": "pubkey" - }, - { - "name": "new_virtual_sol_reserves", - "type": "u64" - }, - { - "name": "new_virtual_token_reserves", - "type": "u64" - }, - { - "name": "new_graduation_target", - "type": "u64" - }, - { - "name": "new_graduation_fee", - "type": "u64" - }, - { - "name": "new_damping_term", - "type": "u8" - }, - { - "name": "new_swap_fee_basis_points", - "type": "u8" - }, - { - "name": "new_token_for_stakers_basis_points", - "type": "u16" - }, - { - "name": "new_token_amount_for_raydium_liquidity", - "type": "u64" - }, - { - "name": "new_max_graduation_price_deviation_basis_points", - "type": "u16" - }, - { - "name": "new_max_swap_amount_for_pool_price_correction_basis_points", - "type": "u16" - } - ] - } - ], - "accounts": [ - { - "name": "AmmConfig", - "discriminator": [ - 218, - 244, - 33, - 104, - 203, - 203, - 43, - 111 - ] - }, - { - "name": "BondingCurve", - "discriminator": [ - 23, - 183, - 248, - 55, - 96, - 216, - 172, - 96 - ] - }, - { - "name": "Config", - "discriminator": [ - 155, - 12, - 170, - 224, - 30, - 250, - 204, - 130 - ] - }, - { - "name": "LockedCpLiquidityState", - "discriminator": [ - 25, - 10, - 238, - 197, - 207, - 234, - 73, - 22 - ] - } - ], - "events": [ - { - "name": "AuthorityTransferCancelledEvent", - "discriminator": [ - 192, - 121, - 140, - 224, - 229, - 96, - 13, - 143 - ] - }, - { - "name": "AuthorityTransferCompletedEvent", - "discriminator": [ - 163, - 132, - 217, - 128, - 243, - 92, - 90, - 249 - ] - }, - { - "name": "AuthorityTransferInitiatedEvent", - "discriminator": [ - 121, - 246, - 95, - 155, - 229, - 109, - 148, - 205 - ] - }, - { - "name": "BondingCurveDeployedEvent", - "discriminator": [ - 225, - 80, - 178, - 34, - 217, - 39, - 184, - 148 - ] - }, - { - "name": "BondingCurveDeployedFallbackEvent", - "discriminator": [ - 106, - 252, - 243, - 115, - 199, - 159, - 247, - 31 - ] - }, - { - "name": "BondingCurveVaultClosedEvent", - "discriminator": [ - 185, - 36, - 156, - 82, - 189, - 164, - 207, - 79 - ] - }, - { - "name": "ConfigUpdatedEvent", - "discriminator": [ - 245, - 158, - 129, - 99, - 60, - 100, - 214, - 220 - ] - }, - { - "name": "LiquidityDepositedIntoRaydiumEvent", - "discriminator": [ - 236, - 50, - 97, - 27, - 198, - 101, - 248, - 20 - ] - }, - { - "name": "OperatorsAddedEvent", - "discriminator": [ - 247, - 58, - 112, - 56, - 203, - 186, - 112, - 152 - ] - }, - { - "name": "OperatorsRemovedEvent", - "discriminator": [ - 44, - 72, - 75, - 70, - 151, - 42, - 53, - 89 - ] - }, - { - "name": "PausedToggledEvent", - "discriminator": [ - 143, - 222, - 228, - 224, - 6, - 230, - 64, - 176 - ] - }, - { - "name": "RaydiumLiquidityLockedEvent", - "discriminator": [ - 172, - 189, - 8, - 241, - 137, - 175, - 59, - 100 - ] - }, - { - "name": "RaydiumPoolCreatedEvent", - "discriminator": [ - 170, - 178, - 21, - 215, - 84, - 222, - 34, - 101 - ] - }, - { - "name": "RaydiumRandomPoolCreatedEvent", - "discriminator": [ - 152, - 251, - 128, - 152, - 158, - 235, - 83, - 53 - ] - }, - { - "name": "SwapSolForTokensOnRaydiumEvent", - "discriminator": [ - 247, - 1, - 8, - 166, - 221, - 116, - 113, - 98 - ] - }, - { - "name": "SwapTokensForSolOnRaydiumEvent", - "discriminator": [ - 76, - 249, - 221, - 162, - 65, - 70, - 118, - 32 - ] - }, - { - "name": "TokenBoughtEvent", - "discriminator": [ - 71, - 89, - 222, - 124, - 215, - 192, - 230, - 138 - ] - }, - { - "name": "TokenCreatedEvent", - "discriminator": [ - 96, - 122, - 113, - 138, - 50, - 227, - 149, - 57 - ] - }, - { - "name": "TokenCreatedFallbackEvent", - "discriminator": [ - 157, - 202, - 35, - 92, - 165, - 163, - 39, - 56 - ] - }, - { - "name": "TokenGraduatedEvent", - "discriminator": [ - 73, - 116, - 111, - 26, - 92, - 217, - 146, - 141 - ] - }, - { - "name": "TokenSoldEvent", - "discriminator": [ - 204, - 239, - 182, - 77, - 241, - 51, - 77, - 66 - ] - }, - { - "name": "TradingFeesCollectedEvent", - "discriminator": [ - 225, - 63, - 26, - 55, - 134, - 243, - 210, - 203 - ] - }, - { - "name": "TradingFeesSplitEvent", - "discriminator": [ - 113, - 60, - 159, - 17, - 253, - 174, - 135, - 122 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "AmountInTooLow", - "msg": "Amount in too low" - }, - { - "code": 6001, - "name": "AmountOutTooLow", - "msg": "Amount out too low" - }, - { - "code": 6002, - "name": "ConfigNotInitialized", - "msg": "Config not initialized" - }, - { - "code": 6003, - "name": "CreatorIsNotProvided", - "msg": "Creator is not provided" - }, - { - "code": 6004, - "name": "DampingTermTooLow", - "msg": "Damping term too low" - }, - { - "code": 6005, - "name": "FirstBuyMustBeAtMost50PercentOfTotalSupply", - "msg": "First buy must be at most 50% of the total supply" - }, - { - "code": 6006, - "name": "GraduationFeeRelativeToTargetIsTooHigh", - "msg": "Graduation fee relative to graduation target is too high" - }, - { - "code": 6007, - "name": "InvalidBondingCurveStatus", - "msg": "Invalid bonding curve status" - }, - { - "code": 6008, - "name": "InsufficientTokensOut", - "msg": "Insufficient tokens to transfer out of the bonding curve" - }, - { - "code": 6009, - "name": "InvalidMint", - "msg": "Invalid mint" - }, - { - "code": 6010, - "name": "InvalidProtocolFeeRecipient", - "msg": "Invalid protocol fee recipient" - }, - { - "code": 6011, - "name": "MaxBasisPointsOffGraduationPriceTooHigh", - "msg": "Max basis points off graduation price too high" - }, - { - "code": 6012, - "name": "MaxGraduationPriceDeviationBasisPointsTooHigh", - "msg": "Max graduation price deviation basis points too high" - }, - { - "code": 6013, - "name": "MaxSwapAmountForPoolPriceCorrectionBasisPointsTooHigh", - "msg": "Max swap amount for pool price correction basis points too high" - }, - { - "code": 6014, - "name": "MintIsLargerThanOrEqualToNativeMint", - "msg": "Mint is larger than or equal to native mint" - }, - { - "code": 6015, - "name": "NoAuthorityTransferInProgress", - "msg": "No authority transfer in progress" - }, - { - "code": 6016, - "name": "NothingToDeposit", - "msg": "LP Token amount is too low" - }, - { - "code": 6017, - "name": "NothingToSplit", - "msg": "Nothing to split" - }, - { - "code": 6018, - "name": "NothingToLock", - "msg": "Nothing to lock" - }, - { - "code": 6019, - "name": "OperatorAlreadyAdded", - "msg": "Operator already added" - }, - { - "code": 6020, - "name": "OperatorDoesNotExist", - "msg": "Operator does not exist" - }, - { - "code": 6021, - "name": "Paused", - "msg": "Paused" - }, - { - "code": 6022, - "name": "PoolPriceOutOfRange", - "msg": "Pool is already created and has a price out of range when attempting to deposit liquidity" - }, - { - "code": 6023, - "name": "SwapFeeBasisPointsTooHigh", - "msg": "Swap fee basis points too high" - }, - { - "code": 6024, - "name": "SwapAmountTooHigh", - "msg": "Swap amount exceeds the reasonable limit to leave as liquidity" - }, - { - "code": 6025, - "name": "TokenAmountForRaydiumLiquidityTooHigh", - "msg": "Token amount for Raydium liquidity too high" - }, - { - "code": 6026, - "name": "TokenForStakersBasisPointsTooHigh", - "msg": "Token for stakers basis points too high" - }, - { - "code": 6027, - "name": "TokenGraduated", - "msg": "Token graduated" - }, - { - "code": 6028, - "name": "TokenNameTooLong", - "msg": "Token name too long" - }, - { - "code": 6029, - "name": "TokenNameTooShort", - "msg": "Token name too short" - }, - { - "code": 6030, - "name": "TokenSymbolTooLong", - "msg": "Token symbol too long" - }, - { - "code": 6031, - "name": "TokenSymbolTooShort", - "msg": "Token symbol too short" - }, - { - "code": 6032, - "name": "Unauthorized", - "msg": "Unauthorized" - } - ], - "types": [ - { - "name": "AmmConfig", - "docs": [ - "Holds the current owner of the factory" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "docs": [ - "Bump to identify PDA" - ], - "type": "u8" - }, - { - "name": "disable_create_pool", - "docs": [ - "Status to control if new pool can be create" - ], - "type": "bool" - }, - { - "name": "index", - "docs": [ - "Config index" - ], - "type": "u16" - }, - { - "name": "trade_fee_rate", - "docs": [ - "The trade fee, denominated in hundredths of a bip (10^-6)" - ], - "type": "u64" - }, - { - "name": "protocol_fee_rate", - "docs": [ - "The protocol fee" - ], - "type": "u64" - }, - { - "name": "fund_fee_rate", - "docs": [ - "The fund fee, denominated in hundredths of a bip (10^-6)" - ], - "type": "u64" - }, - { - "name": "create_pool_fee", - "docs": [ - "Fee for create a new pool" - ], - "type": "u64" - }, - { - "name": "protocol_owner", - "docs": [ - "Address of the protocol fee owner" - ], - "type": "pubkey" - }, - { - "name": "fund_owner", - "docs": [ - "Address of the fund fee owner" - ], - "type": "pubkey" - }, - { - "name": "padding", - "docs": [ - "padding" - ], - "type": { - "array": [ - "u64", - 16 - ] - } - } - ] - } - }, - { - "name": "AuthorityTransferCancelledEvent", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "AuthorityTransferCompletedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "old_authority", - "type": "pubkey" - }, - { - "name": "new_authority", - "type": "pubkey" - } - ] - } - }, - { - "name": "AuthorityTransferInitiatedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "old_authority", - "type": "pubkey" - }, - { - "name": "new_authority", - "type": "pubkey" - } - ] - } - }, - { - "name": "BondingCurve", - "type": { - "kind": "struct", - "fields": [ - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "virtual_sol_reserves", - "type": "u64" - }, - { - "name": "virtual_token_reserves", - "type": "u64" - }, - { - "name": "graduation_target", - "type": "u64" - }, - { - "name": "graduation_fee", - "type": "u64" - }, - { - "name": "sol_reserves", - "type": "u64" - }, - { - "name": "token_reserves", - "type": "u64" - }, - { - "name": "damping_term", - "type": "u8" - }, - { - "name": "swap_fee_basis_points", - "type": "u8" - }, - { - "name": "token_for_stakers_basis_points", - "type": "u16" - }, - { - "name": "status", - "type": { - "defined": { - "name": "BondingCurveStatus" - } - } - } - ] - } - }, - { - "name": "BondingCurveDeployedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "BondingCurveDeployedFallbackEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "BondingCurveStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Trading" - }, - { - "name": "Graduated" - }, - { - "name": "PoolPriceCorrected" - }, - { - "name": "LiquidityProvisioned" - }, - { - "name": "LiquidityLocked" - } - ] - } - }, - { - "name": "BondingCurveVaultClosedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "Config", - "type": { - "kind": "struct", - "fields": [ - { - "name": "is_paused", - "type": "bool" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "pending_authority", - "type": "pubkey" - }, - { - "name": "operators", - "type": { - "vec": "pubkey" - } - }, - { - "name": "protocol_fee_recipient", - "type": "pubkey" - }, - { - "name": "token_distributor", - "type": "pubkey" - }, - { - "name": "virtual_sol_reserves", - "type": "u64" - }, - { - "name": "virtual_token_reserves", - "type": "u64" - }, - { - "name": "graduation_target", - "type": "u64" - }, - { - "name": "graduation_fee", - "type": "u64" - }, - { - "name": "damping_term", - "type": "u8" - }, - { - "name": "token_for_stakers_basis_points", - "type": "u16" - }, - { - "name": "swap_fee_basis_points", - "type": "u8" - }, - { - "name": "token_amount_for_raydium_liquidity", - "type": "u64" - }, - { - "name": "max_graduation_price_deviation_basis_points", - "type": "u16" - }, - { - "name": "max_swap_amount_for_pool_price_correction_basis_points", - "type": "u16" - } - ] - } - }, - { - "name": "ConfigUpdatedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "protocol_fee_recipient", - "type": "pubkey" - }, - { - "name": "virtual_sol_reserves", - "type": "u64" - }, - { - "name": "virtual_token_reserves", - "type": "u64" - }, - { - "name": "graduation_target", - "type": "u64" - }, - { - "name": "graduation_fee", - "type": "u64" - }, - { - "name": "damping_term", - "type": "u8" - }, - { - "name": "swap_fee_basis_points", - "type": "u8" - }, - { - "name": "token_for_stakers_basis_points", - "type": "u16" - }, - { - "name": "token_amount_for_raydium_liquidity", - "type": "u64" - }, - { - "name": "max_graduation_price_deviation_basis_points", - "type": "u16" - }, - { - "name": "max_swap_amount_for_pool_price_correction_basis_points", - "type": "u16" - } - ] - } - }, - { - "name": "LiquidityDepositedIntoRaydiumEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_state", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "lp_token_amount", - "type": "u64" - }, - { - "name": "tokens_deposited", - "type": "u64" - }, - { - "name": "wsol_deposited", - "type": "u64" - } - ] - } - }, - { - "name": "LockedCpLiquidityState", - "type": { - "kind": "struct", - "fields": [ - { - "name": "locked_lp_amount", - "docs": [ - "The Locked liquidity amount without claimed lp fee" - ], - "type": "u64" - }, - { - "name": "claimed_lp_amount", - "docs": [ - "Claimed lp fee amount" - ], - "type": "u64" - }, - { - "name": "unclaimed_lp_amount", - "docs": [ - "Unclaimed lp fee amount" - ], - "type": "u64" - }, - { - "name": "last_lp", - "docs": [ - "Last updated cp pool lp total supply" - ], - "type": "u64" - }, - { - "name": "last_k", - "docs": [ - "Last updated cp pool k" - ], - "type": "u128" - }, - { - "name": "recent_epoch", - "docs": [ - "Account update recent epoch" - ], - "type": "u64" - }, - { - "name": "pool_id", - "docs": [ - "The ID of the pool with which this record is connected" - ], - "type": "pubkey" - }, - { - "name": "fee_nft_mint", - "docs": [ - "nft mint to check who has authority to collect fee" - ], - "type": "pubkey" - }, - { - "name": "locked_owner", - "docs": [ - "The owner who has locked liquidity" - ], - "type": "pubkey" - }, - { - "name": "locked_lp_mint", - "docs": [ - "The mint of locked lp token" - ], - "type": "pubkey" - }, - { - "name": "padding", - "docs": [ - "Unused bytes for future upgrades." - ], - "type": { - "array": [ - "u64", - 8 - ] - } - } - ] - } - }, - { - "name": "OperatorsAddedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "operators", - "type": { - "vec": "pubkey" - } - } - ] - } - }, - { - "name": "OperatorsRemovedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "operators", - "type": { - "vec": "pubkey" - } - } - ] - } - }, - { - "name": "PausedToggledEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "is_paused", - "type": "bool" - } - ] - } - }, - { - "name": "RaydiumLiquidityLockedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_state", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "lp_amount", - "type": "u64" - } - ] - } - }, - { - "name": "RaydiumPoolCreatedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_state", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "RaydiumRandomPoolCreatedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_state", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "SwapSolForTokensOnRaydiumEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "amount_out", - "type": "u64" - } - ] - } - }, - { - "name": "SwapTokensForSolOnRaydiumEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "amount_out", - "type": "u64" - } - ] - } - }, - { - "name": "TokenBoughtEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "amount_out", - "type": "u64" - }, - { - "name": "swap_fee", - "type": "u64" - }, - { - "name": "buyer", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "TokenCreatedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "name", - "type": "string" - }, - { - "name": "symbol", - "type": "string" - }, - { - "name": "uri", - "type": "string" - } - ] - } - }, - { - "name": "TokenCreatedFallbackEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "name", - "type": "string" - }, - { - "name": "symbol", - "type": "string" - }, - { - "name": "uri", - "type": "string" - } - ] - } - }, - { - "name": "TokenGraduatedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "sol_for_liquidity", - "type": "u64" - }, - { - "name": "graduation_fee", - "type": "u64" - }, - { - "name": "token_for_distributor", - "type": "u64" - } - ] - } - }, - { - "name": "TokenSoldEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "amount_out", - "type": "u64" - }, - { - "name": "swap_fee", - "type": "u64" - }, - { - "name": "seller", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "TradingFeesCollectedEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_state", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "TradingFeesSplitEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "creator", - "type": "pubkey" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/crates/boop-parser/proto/boop.proto b/crates/boop-parser/proto/boop.proto deleted file mode 100644 index f67c9c71..00000000 --- a/crates/boop-parser/proto/boop.proto +++ /dev/null @@ -1,811 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.boop; - -message AddOperatorsIx { - AddOperatorsIxAccounts accounts = 1; - AddOperatorsIxData data = 2; -} - -message BuyTokenIx { - BuyTokenIxAccounts accounts = 1; - BuyTokenIxData data = 2; -} - -message CancelAuthorityTransferIx { - CancelAuthorityTransferIxAccounts accounts = 1; -} - -message CloseBondingCurveVaultIx { - CloseBondingCurveVaultIxAccounts accounts = 1; -} - -message CollectTradingFeesIx { - CollectTradingFeesIxAccounts accounts = 1; -} - -message CompleteAuthorityTransferIx { - CompleteAuthorityTransferIxAccounts accounts = 1; -} - -message CreateRaydiumPoolIx { - CreateRaydiumPoolIxAccounts accounts = 1; -} - -message CreateRaydiumRandomPoolIx { - CreateRaydiumRandomPoolIxAccounts accounts = 1; -} - -message CreateTokenIx { - CreateTokenIxAccounts accounts = 1; - CreateTokenIxData data = 2; -} - -message CreateTokenFallbackIx { - CreateTokenFallbackIxAccounts accounts = 1; - CreateTokenFallbackIxData data = 2; -} - -message DeployBondingCurveIx { - DeployBondingCurveIxAccounts accounts = 1; - DeployBondingCurveIxData data = 2; -} - -message DeployBondingCurveFallbackIx { - DeployBondingCurveFallbackIxAccounts accounts = 1; - DeployBondingCurveFallbackIxData data = 2; -} - -message DepositIntoRaydiumIx { - DepositIntoRaydiumIxAccounts accounts = 1; - DepositIntoRaydiumIxData data = 2; -} - -message GraduateIx { - GraduateIxAccounts accounts = 1; -} - -message InitializeIx { - InitializeIxAccounts accounts = 1; - InitializeIxData data = 2; -} - -message InitiateAuthorityTransferIx { - InitiateAuthorityTransferIxAccounts accounts = 1; - InitiateAuthorityTransferIxData data = 2; -} - -message LockRaydiumLiquidityIx { - LockRaydiumLiquidityIxAccounts accounts = 1; -} - -message RemoveOperatorsIx { - RemoveOperatorsIxAccounts accounts = 1; - RemoveOperatorsIxData data = 2; -} - -message SellTokenIx { - SellTokenIxAccounts accounts = 1; - SellTokenIxData data = 2; -} - -message SplitTradingFeesIx { - SplitTradingFeesIxAccounts accounts = 1; -} - -message SwapSolForTokensOnRaydiumIx { - SwapSolForTokensOnRaydiumIxAccounts accounts = 1; - SwapSolForTokensOnRaydiumIxData data = 2; -} - -message SwapTokensForSolOnRaydiumIx { - SwapTokensForSolOnRaydiumIxAccounts accounts = 1; - SwapTokensForSolOnRaydiumIxData data = 2; -} - -message TogglePausedIx { - TogglePausedIxAccounts accounts = 1; -} - -message UpdateConfigIx { - UpdateConfigIxAccounts accounts = 1; - UpdateConfigIxData data = 2; -} - - -message AuthorityTransferCancelledEvent { - -} - -message AuthorityTransferCompletedEvent { - string old_authority = 1; - string new_authority = 2; -} - -message AuthorityTransferInitiatedEvent { - string old_authority = 1; - string new_authority = 2; -} - -message BondingCurveDeployedEvent { - string mint = 1; - string creator = 2; -} - -message BondingCurveDeployedFallbackEvent { - string mint = 1; - string creator = 2; -} - -enum BondingCurveStatus { - BondingCurveStatusTrading = 0; - BondingCurveStatusGraduated = 1; - BondingCurveStatusPoolPriceCorrected = 2; - BondingCurveStatusLiquidityProvisioned = 3; - BondingCurveStatusLiquidityLocked = 4; -} - -message BondingCurveVaultClosedEvent { - string mint = 1; - string recipient = 2; - uint64 amount = 3; -} - -message ConfigUpdatedEvent { - string protocol_fee_recipient = 1; - uint64 virtual_sol_reserves = 2; - uint64 virtual_token_reserves = 3; - uint64 graduation_target = 4; - uint64 graduation_fee = 5; - uint32 damping_term = 6; - uint32 swap_fee_basis_points = 7; - uint32 token_for_stakers_basis_points = 8; - uint64 token_amount_for_raydium_liquidity = 9; - uint32 max_graduation_price_deviation_basis_points = 10; - uint32 max_swap_amount_for_pool_price_correction_basis_points = 11; -} - -message LiquidityDepositedIntoRaydiumEvent { - string pool_state = 1; - string mint = 2; - uint64 lp_token_amount = 3; - uint64 tokens_deposited = 4; - uint64 wsol_deposited = 5; -} - -message OperatorsAddedEvent { - repeated string operators = 1; -} - -message OperatorsRemovedEvent { - repeated string operators = 1; -} - -message PausedToggledEvent { - bool is_paused = 1; -} - -message RaydiumLiquidityLockedEvent { - string pool_state = 1; - string mint = 2; - uint64 lp_amount = 3; -} - -message RaydiumPoolCreatedEvent { - string pool_state = 1; - string mint = 2; -} - -message RaydiumRandomPoolCreatedEvent { - string pool_state = 1; - string mint = 2; -} - -message SwapSolForTokensOnRaydiumEvent { - string mint = 1; - uint64 amount_in = 2; - uint64 amount_out = 3; -} - -message SwapTokensForSolOnRaydiumEvent { - string mint = 1; - uint64 amount_in = 2; - uint64 amount_out = 3; -} - -message TokenBoughtEvent { - string mint = 1; - uint64 amount_in = 2; - uint64 amount_out = 3; - uint64 swap_fee = 4; - string buyer = 5; - string recipient = 6; -} - -message TokenCreatedEvent { - string name = 1; - string symbol = 2; - string uri = 3; -} - -message TokenCreatedFallbackEvent { - string name = 1; - string symbol = 2; - string uri = 3; -} - -message TokenGraduatedEvent { - string mint = 1; - uint64 sol_for_liquidity = 2; - uint64 graduation_fee = 3; - uint64 token_for_distributor = 4; -} - -message TokenSoldEvent { - string mint = 1; - uint64 amount_in = 2; - uint64 amount_out = 3; - uint64 swap_fee = 4; - string seller = 5; - string recipient = 6; -} - -message TradingFeesCollectedEvent { - string pool_state = 1; - string mint = 2; -} - -message TradingFeesSplitEvent { - uint64 amount = 1; - string creator = 2; -} - - -message AmmConfig { - uint32 bump = 1; - bool disable_create_pool = 2; - uint32 index = 3; - uint64 trade_fee_rate = 4; - uint64 protocol_fee_rate = 5; - uint64 fund_fee_rate = 6; - uint64 create_pool_fee = 7; - string protocol_owner = 8; - string fund_owner = 9; - repeated uint64 padding = 10; -} - -message BondingCurve { - string creator = 1; - string mint = 2; - uint64 virtual_sol_reserves = 3; - uint64 virtual_token_reserves = 4; - uint64 graduation_target = 5; - uint64 graduation_fee = 6; - uint64 sol_reserves = 7; - uint64 token_reserves = 8; - uint32 damping_term = 9; - uint32 swap_fee_basis_points = 10; - uint32 token_for_stakers_basis_points = 11; - BondingCurveStatus status = 12; -} - -message Config { - bool is_paused = 1; - string authority = 2; - string pending_authority = 3; - repeated string operators = 4; - string protocol_fee_recipient = 5; - string token_distributor = 6; - uint64 virtual_sol_reserves = 7; - uint64 virtual_token_reserves = 8; - uint64 graduation_target = 9; - uint64 graduation_fee = 10; - uint32 damping_term = 11; - uint32 token_for_stakers_basis_points = 12; - uint32 swap_fee_basis_points = 13; - uint64 token_amount_for_raydium_liquidity = 14; - uint32 max_graduation_price_deviation_basis_points = 15; - uint32 max_swap_amount_for_pool_price_correction_basis_points = 16; -} - -message LockedCpLiquidityState { - uint64 locked_lp_amount = 1; - uint64 claimed_lp_amount = 2; - uint64 unclaimed_lp_amount = 3; - uint64 last_lp = 4; - string last_k = 5; - uint64 recent_epoch = 6; - string pool_id = 7; - string fee_nft_mint = 8; - string locked_owner = 9; - string locked_lp_mint = 10; - repeated uint64 padding = 11; -} - - -message AddOperatorsIxAccounts { - string config = 1; - string authority = 2; - string system_program = 3; -} - -message AddOperatorsIxData { - repeated string operators = 1; -} - -message BuyTokenIxAccounts { - string mint = 1; - string bonding_curve = 2; - string trading_fees_vault = 3; - string bonding_curve_vault = 4; - string bonding_curve_sol_vault = 5; - string recipient_token_account = 6; - string buyer = 7; - string config = 8; - string vault_authority = 9; - string wsol = 10; - string system_program = 11; - string token_program = 12; - string associated_token_program = 13; -} - -message BuyTokenIxData { - uint64 buy_amount = 1; - uint64 amount_out_min = 2; -} - -message CancelAuthorityTransferIxAccounts { - string authority = 1; - string config = 2; - string system_program = 3; -} - - -message CloseBondingCurveVaultIxAccounts { - string config = 1; - string operator = 2; - string vault_authority = 3; - string bonding_curve = 4; - string bonding_curve_vault = 5; - string mint = 6; - string recipient_token_account = 7; - string recipient = 8; - string token_program = 9; - string system_program = 10; - string associated_token_program = 11; - string rent = 12; -} - - -message CollectTradingFeesIxAccounts { - string operator = 1; - string protocol_fee_recipient = 2; - string config = 3; - string lock_program = 4; - string vault_authority = 5; - string authority = 6; - string fee_nft_account = 7; - string locked_liquidity = 8; - string cpmm_program = 9; - string cp_authority = 10; - string pool_state = 11; - string lp_mint = 12; - string recipient_token0_account = 13; - string recipient_token1_account = 14; - string token0_vault = 15; - string token1_vault = 16; - string vault0_mint = 17; - string vault1_mint = 18; - string locked_lp_vault = 19; - string system_program = 20; - string associated_token_program = 21; - string token_program = 22; - string token_program2022 = 23; - string memo_program = 24; -} - - -message CompleteAuthorityTransferIxAccounts { - string pending_authority = 1; - string config = 2; - string system_program = 3; -} - - -message CreateRaydiumPoolIxAccounts { - string cpmm_program = 1; - string amm_config = 2; - string authority = 3; - string pool_state = 4; - string token0_mint = 5; - string token1_mint = 6; - string lp_mint = 7; - string vault_authority = 8; - string bonding_curve = 9; - string bonding_curve_vault = 10; - string bonding_curve_wsol_vault = 11; - string creator_lp_token = 12; - string token0_vault = 13; - string token1_vault = 14; - string create_pool_fee = 15; - string observation_state = 16; - string operator = 17; - string config = 18; - string token_program = 19; - string associated_token_program = 20; - string system_program = 21; - string rent = 22; -} - - -message CreateRaydiumRandomPoolIxAccounts { - string cpmm_program = 1; - string amm_config = 2; - string authority = 3; - string pool_state = 4; - string token0_mint = 5; - string token1_mint = 6; - string lp_mint = 7; - string vault_authority = 8; - string bonding_curve = 9; - string bonding_curve_vault = 10; - string bonding_curve_wsol_vault = 11; - string creator_lp_token = 12; - string token0_vault = 13; - string token1_vault = 14; - string create_pool_fee = 15; - string observation_state = 16; - string operator = 17; - string config = 18; - string token_program = 19; - string associated_token_program = 20; - string system_program = 21; - string rent = 22; -} - - -message CreateTokenIxAccounts { - string config = 1; - string metadata = 2; - string mint = 3; - string payer = 4; - string rent = 5; - string system_program = 6; - string token_program = 7; - string token_metadata_program = 8; -} - -message CreateTokenIxData { - uint64 salt = 1; - string name = 2; - string symbol = 3; - string uri = 4; -} - -message CreateTokenFallbackIxAccounts { - string config = 1; - string metadata = 2; - string mint = 3; - string payer = 4; - string rent = 5; - string system_program = 6; - string token_program = 7; - string token_metadata_program = 8; -} - -message CreateTokenFallbackIxData { - uint64 salt = 1; - string name = 2; - string symbol = 3; - string uri = 4; -} - -message DeployBondingCurveIxAccounts { - string mint = 1; - string vault_authority = 2; - string bonding_curve = 3; - string bonding_curve_sol_vault = 4; - string bonding_curve_vault = 5; - string config = 6; - string payer = 7; - string system_program = 8; - string token_program = 9; - string associated_token_program = 10; -} - -message DeployBondingCurveIxData { - string creator = 1; - uint64 salt = 2; -} - -message DeployBondingCurveFallbackIxAccounts { - string mint = 1; - string vault_authority = 2; - string bonding_curve = 3; - string bonding_curve_sol_vault = 4; - string bonding_curve_vault = 5; - string config = 6; - string payer = 7; - string system_program = 8; - string token_program = 9; - string associated_token_program = 10; -} - -message DeployBondingCurveFallbackIxData { - string creator = 1; - uint64 salt = 2; -} - -message DepositIntoRaydiumIxAccounts { - string config = 1; - string amm_config = 2; - string operator = 3; - string operator_wsol_account = 4; - string vault_authority = 5; - string authority = 6; - string pool_state = 7; - string token0_vault = 8; - string token1_vault = 9; - string bonding_curve_vault = 10; - string bonding_curve_wsol_vault = 11; - string token_program = 12; - string token_program2022 = 13; - string system_program = 14; - string associated_token_program = 15; - string lp_mint = 16; - string cpmm_program = 17; - string owner_lp_token = 18; - string bonding_curve = 19; - string token0_mint = 20; - string token1_mint = 21; -} - -message DepositIntoRaydiumIxData { - uint64 lp_token_amount = 1; - uint64 maximum_token0_amount = 2; - uint64 maximum_token1_amount = 3; -} - -message GraduateIxAccounts { - string mint = 1; - string wsol = 2; - string protocol_fee_recipient = 3; - string token_distributor = 4; - string token_distributor_token_account = 5; - string vault_authority = 6; - string bonding_curve_sol_vault = 7; - string bonding_curve = 8; - string bonding_curve_vault = 9; - string bonding_curve_wsol_account = 10; - string operator = 11; - string config = 12; - string system_program = 13; - string token_program = 14; - string associated_token_program = 15; -} - - -message InitializeIxAccounts { - string config = 1; - string authority = 2; - string system_program = 3; -} - -message InitializeIxData { - string protocol_fee_recipient = 1; - string token_distributor = 2; -} - -message InitiateAuthorityTransferIxAccounts { - string authority = 1; - string config = 2; - string system_program = 3; -} - -message InitiateAuthorityTransferIxData { - string new_authority = 1; -} - -message LockRaydiumLiquidityIxAccounts { - string lock_program = 1; - string vault_authority = 2; - string authority = 3; - string fee_nft_owner = 4; - string fee_nft_mint = 5; - string fee_nft_account = 6; - string pool_state = 7; - string locked_liquidity = 8; - string lp_mint = 9; - string liquidity_owner_lp = 10; - string locked_lp_vault = 11; - string token0_vault = 12; - string token1_vault = 13; - string operator = 14; - string config = 15; - string bonding_curve = 16; - string metadata_account = 17; - string rent = 18; - string system_program = 19; - string token_program = 20; - string associated_token_program = 21; - string metadata_program = 22; -} - - -message RemoveOperatorsIxAccounts { - string config = 1; - string authority = 2; - string system_program = 3; -} - -message RemoveOperatorsIxData { - repeated string operators = 1; -} - -message SellTokenIxAccounts { - string mint = 1; - string bonding_curve = 2; - string trading_fees_vault = 3; - string bonding_curve_vault = 4; - string bonding_curve_sol_vault = 5; - string seller_token_account = 6; - string seller = 7; - string recipient = 8; - string config = 9; - string system_program = 10; - string token_program = 11; - string associated_token_program = 12; -} - -message SellTokenIxData { - uint64 sell_amount = 1; - uint64 amount_out_min = 2; -} - -message SplitTradingFeesIxAccounts { - string operator = 1; - string mint = 2; - string wsol = 3; - string config = 4; - string vault_authority = 5; - string bonding_curve = 6; - string trading_fees_vault = 7; - string fee_splitter_program = 8; - string system_program = 9; - string token_program = 10; - string associated_token_program = 11; - string fee_splitter_config = 12; - string fee_splitter_creator_vault = 13; - string fee_splitter_vault_authority = 14; - string fee_splitter_creator_vault_authority = 15; - string fee_splitter_staking_mint = 16; - string fee_splitter_wsol_vault = 17; - string fee_splitter_creator_vault_authority_wsol_vault = 18; - string fee_splitter_treasury_wsol_vault = 19; - string fee_splitter_team_wsol_vault = 20; - string fee_splitter_reward_pool = 21; - string fee_splitter_reward_pool_staking_vault = 22; - string fee_splitter_reward_pool_reward_vault = 23; - string fee_splitter_reward_pool_program = 24; -} - - -message SwapSolForTokensOnRaydiumIxAccounts { - string config = 1; - string bonding_curve = 2; - string amm_config = 3; - string operator = 4; - string vault_authority = 5; - string authority = 6; - string pool_state = 7; - string input_vault = 8; - string output_vault = 9; - string bonding_curve_vault = 10; - string bonding_curve_wsol_vault = 11; - string output_token_mint = 12; - string input_token_mint = 13; - string token_program = 14; - string cp_swap_program = 15; - string observation_state = 16; -} - -message SwapSolForTokensOnRaydiumIxData { - uint64 amount_in = 1; - uint64 minimum_amount_out = 2; -} - -message SwapTokensForSolOnRaydiumIxAccounts { - string config = 1; - string bonding_curve = 2; - string amm_config = 3; - string operator = 4; - string vault_authority = 5; - string authority = 6; - string pool_state = 7; - string input_vault = 8; - string output_vault = 9; - string bonding_curve_vault = 10; - string bonding_curve_wsol_vault = 11; - string input_token_mint = 12; - string output_token_mint = 13; - string token_program = 14; - string cp_swap_program = 15; - string observation_state = 16; -} - -message SwapTokensForSolOnRaydiumIxData { - uint64 amount_in = 1; - uint64 minimum_amount_out = 2; -} - -message TogglePausedIxAccounts { - string authority = 1; - string config = 2; -} - - -message UpdateConfigIxAccounts { - string config = 1; - string authority = 2; - string system_program = 3; -} - -message UpdateConfigIxData { - string new_protocol_fee_recipient = 1; - uint64 new_virtual_sol_reserves = 2; - uint64 new_virtual_token_reserves = 3; - uint64 new_graduation_target = 4; - uint64 new_graduation_fee = 5; - uint32 new_damping_term = 6; - uint32 new_swap_fee_basis_points = 7; - uint32 new_token_for_stakers_basis_points = 8; - uint64 new_token_amount_for_raydium_liquidity = 9; - uint32 new_max_graduation_price_deviation_basis_points = 10; - uint32 new_max_swap_amount_for_pool_price_correction_basis_points = 11; -} - - -message ProgramState { - oneof state_oneof { - AmmConfig amm_config = 1; - BondingCurve bonding_curve = 2; - Config config = 3; - LockedCpLiquidityState locked_cp_liquidity_state = 4; - } -} - -message ProgramIxs { - oneof ix_oneof { - AddOperatorsIx add_operators = 1; - BuyTokenIx buy_token = 2; - CancelAuthorityTransferIx cancel_authority_transfer = 3; - CloseBondingCurveVaultIx close_bonding_curve_vault = 4; - CollectTradingFeesIx collect_trading_fees = 5; - CompleteAuthorityTransferIx complete_authority_transfer = 6; - CreateRaydiumPoolIx create_raydium_pool = 7; - CreateRaydiumRandomPoolIx create_raydium_random_pool = 8; - CreateTokenIx create_token = 9; - CreateTokenFallbackIx create_token_fallback = 10; - DeployBondingCurveIx deploy_bonding_curve = 11; - DeployBondingCurveFallbackIx deploy_bonding_curve_fallback = 12; - DepositIntoRaydiumIx deposit_into_raydium = 13; - GraduateIx graduate = 14; - InitializeIx initialize = 15; - InitiateAuthorityTransferIx initiate_authority_transfer = 16; - LockRaydiumLiquidityIx lock_raydium_liquidity = 17; - RemoveOperatorsIx remove_operators = 18; - SellTokenIx sell_token = 19; - SplitTradingFeesIx split_trading_fees = 20; - SwapSolForTokensOnRaydiumIx swap_sol_for_tokens_on_raydium = 21; - SwapTokensForSolOnRaydiumIx swap_tokens_for_sol_on_raydium = 22; - TogglePausedIx toggle_paused = 23; - UpdateConfigIx update_config = 24; - } -} - diff --git a/crates/boop-parser/src/generated_parser/accounts_parser.rs b/crates/boop-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index 830d70df..00000000 --- a/crates/boop-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,234 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{AmmConfig, BondingCurve, Config, LockedCpLiquidityState}, - deserialize_checked, ID, -}; - -/// Boop Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum BoopProgramState { - AmmConfig(AmmConfig), - BondingCurve(BondingCurve), - Config(Config), - LockedCpLiquidityState(LockedCpLiquidityState), -} - -impl BoopProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [218, 244, 33, 104, 203, 203, 43, 111] => Ok(BoopProgramState::AmmConfig( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [23, 183, 248, 55, 96, 216, 172, 96] => Ok(BoopProgramState::BondingCurve( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [155, 12, 170, 224, 30, 250, 204, 130] => Ok(BoopProgramState::Config( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [25, 10, 238, 197, 207, 234, 73, 22] => Ok(BoopProgramState::LockedCpLiquidityState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = BoopProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "boop::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = BoopProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, AmmConfig, BoopProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for AmmConfig { - fn into_proto(self) -> proto_def::AmmConfig { - proto_def::AmmConfig { - bump: self.bump.into(), - disable_create_pool: self.disable_create_pool, - index: self.index.into(), - trade_fee_rate: self.trade_fee_rate, - protocol_fee_rate: self.protocol_fee_rate, - fund_fee_rate: self.fund_fee_rate, - create_pool_fee: self.create_pool_fee, - protocol_owner: self.protocol_owner.to_string(), - fund_owner: self.fund_owner.to_string(), - padding: self.padding.to_vec(), - } - } - } - use super::BondingCurve; - impl IntoProto for BondingCurve { - fn into_proto(self) -> proto_def::BondingCurve { - proto_def::BondingCurve { - creator: self.creator.to_string(), - mint: self.mint.to_string(), - virtual_sol_reserves: self.virtual_sol_reserves, - virtual_token_reserves: self.virtual_token_reserves, - graduation_target: self.graduation_target, - graduation_fee: self.graduation_fee, - sol_reserves: self.sol_reserves, - token_reserves: self.token_reserves, - damping_term: self.damping_term.into(), - swap_fee_basis_points: self.swap_fee_basis_points.into(), - token_for_stakers_basis_points: self.token_for_stakers_basis_points.into(), - status: self.status as i32, - } - } - } - use super::Config; - impl IntoProto for Config { - fn into_proto(self) -> proto_def::Config { - proto_def::Config { - is_paused: self.is_paused, - authority: self.authority.to_string(), - pending_authority: self.pending_authority.to_string(), - operators: self.operators.into_iter().map(|x| x.to_string()).collect(), - protocol_fee_recipient: self.protocol_fee_recipient.to_string(), - token_distributor: self.token_distributor.to_string(), - virtual_sol_reserves: self.virtual_sol_reserves, - virtual_token_reserves: self.virtual_token_reserves, - graduation_target: self.graduation_target, - graduation_fee: self.graduation_fee, - damping_term: self.damping_term.into(), - token_for_stakers_basis_points: self.token_for_stakers_basis_points.into(), - swap_fee_basis_points: self.swap_fee_basis_points.into(), - token_amount_for_raydium_liquidity: self.token_amount_for_raydium_liquidity, - max_graduation_price_deviation_basis_points: self - .max_graduation_price_deviation_basis_points - .into(), - max_swap_amount_for_pool_price_correction_basis_points: self - .max_swap_amount_for_pool_price_correction_basis_points - .into(), - } - } - } - use super::LockedCpLiquidityState; - impl IntoProto for LockedCpLiquidityState { - fn into_proto(self) -> proto_def::LockedCpLiquidityState { - proto_def::LockedCpLiquidityState { - locked_lp_amount: self.locked_lp_amount, - claimed_lp_amount: self.claimed_lp_amount, - unclaimed_lp_amount: self.unclaimed_lp_amount, - last_lp: self.last_lp, - last_k: self.last_k.to_string(), - recent_epoch: self.recent_epoch, - pool_id: self.pool_id.to_string(), - fee_nft_mint: self.fee_nft_mint.to_string(), - locked_owner: self.locked_owner.to_string(), - locked_lp_mint: self.locked_lp_mint.to_string(), - padding: self.padding.to_vec(), - } - } - } - - impl IntoProto for BoopProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - BoopProgramState::AmmConfig(data) => { - proto_def::program_state::StateOneof::AmmConfig(data.into_proto()) - }, - BoopProgramState::BondingCurve(data) => { - proto_def::program_state::StateOneof::BondingCurve(data.into_proto()) - }, - BoopProgramState::Config(data) => { - proto_def::program_state::StateOneof::Config(data.into_proto()) - }, - BoopProgramState::LockedCpLiquidityState(data) => { - proto_def::program_state::StateOneof::LockedCpLiquidityState(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/boop-parser/src/generated_parser/instructions_parser.rs b/crates/boop-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index defa3931..00000000 --- a/crates/boop-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,1548 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - AddOperators as AddOperatorsIxAccounts, AddOperatorsInstructionArgs as AddOperatorsIxData, - BuyToken as BuyTokenIxAccounts, BuyTokenInstructionArgs as BuyTokenIxData, - CancelAuthorityTransfer as CancelAuthorityTransferIxAccounts, - CloseBondingCurveVault as CloseBondingCurveVaultIxAccounts, - CollectTradingFees as CollectTradingFeesIxAccounts, - CompleteAuthorityTransfer as CompleteAuthorityTransferIxAccounts, - CreateRaydiumPool as CreateRaydiumPoolIxAccounts, - CreateRaydiumRandomPool as CreateRaydiumRandomPoolIxAccounts, - CreateToken as CreateTokenIxAccounts, CreateTokenFallback as CreateTokenFallbackIxAccounts, - CreateTokenFallbackInstructionArgs as CreateTokenFallbackIxData, - CreateTokenInstructionArgs as CreateTokenIxData, - DeployBondingCurve as DeployBondingCurveIxAccounts, - DeployBondingCurveFallback as DeployBondingCurveFallbackIxAccounts, - DeployBondingCurveFallbackInstructionArgs as DeployBondingCurveFallbackIxData, - DeployBondingCurveInstructionArgs as DeployBondingCurveIxData, - DepositIntoRaydium as DepositIntoRaydiumIxAccounts, - DepositIntoRaydiumInstructionArgs as DepositIntoRaydiumIxData, - Graduate as GraduateIxAccounts, Initialize as InitializeIxAccounts, - InitializeInstructionArgs as InitializeIxData, - InitiateAuthorityTransfer as InitiateAuthorityTransferIxAccounts, - InitiateAuthorityTransferInstructionArgs as InitiateAuthorityTransferIxData, - LockRaydiumLiquidity as LockRaydiumLiquidityIxAccounts, - RemoveOperators as RemoveOperatorsIxAccounts, - RemoveOperatorsInstructionArgs as RemoveOperatorsIxData, SellToken as SellTokenIxAccounts, - SellTokenInstructionArgs as SellTokenIxData, - SplitTradingFees as SplitTradingFeesIxAccounts, - SwapSolForTokensOnRaydium as SwapSolForTokensOnRaydiumIxAccounts, - SwapSolForTokensOnRaydiumInstructionArgs as SwapSolForTokensOnRaydiumIxData, - SwapTokensForSolOnRaydium as SwapTokensForSolOnRaydiumIxAccounts, - SwapTokensForSolOnRaydiumInstructionArgs as SwapTokensForSolOnRaydiumIxData, - TogglePaused as TogglePausedIxAccounts, UpdateConfig as UpdateConfigIxAccounts, - UpdateConfigInstructionArgs as UpdateConfigIxData, - }, - ID, -}; - -/// Boop Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum BoopProgramIx { - AddOperators(AddOperatorsIxAccounts, AddOperatorsIxData), - BuyToken(BuyTokenIxAccounts, BuyTokenIxData), - CancelAuthorityTransfer(CancelAuthorityTransferIxAccounts), - CloseBondingCurveVault(CloseBondingCurveVaultIxAccounts), - CollectTradingFees(CollectTradingFeesIxAccounts), - CompleteAuthorityTransfer(CompleteAuthorityTransferIxAccounts), - CreateRaydiumPool(CreateRaydiumPoolIxAccounts), - CreateRaydiumRandomPool(CreateRaydiumRandomPoolIxAccounts), - CreateToken(CreateTokenIxAccounts, CreateTokenIxData), - CreateTokenFallback(CreateTokenFallbackIxAccounts, CreateTokenFallbackIxData), - DeployBondingCurve(DeployBondingCurveIxAccounts, DeployBondingCurveIxData), - DeployBondingCurveFallback( - DeployBondingCurveFallbackIxAccounts, - DeployBondingCurveFallbackIxData, - ), - DepositIntoRaydium(DepositIntoRaydiumIxAccounts, DepositIntoRaydiumIxData), - Graduate(GraduateIxAccounts), - Initialize(InitializeIxAccounts, InitializeIxData), - InitiateAuthorityTransfer( - InitiateAuthorityTransferIxAccounts, - InitiateAuthorityTransferIxData, - ), - LockRaydiumLiquidity(LockRaydiumLiquidityIxAccounts), - RemoveOperators(RemoveOperatorsIxAccounts, RemoveOperatorsIxData), - SellToken(SellTokenIxAccounts, SellTokenIxData), - SplitTradingFees(SplitTradingFeesIxAccounts), - SwapSolForTokensOnRaydium( - SwapSolForTokensOnRaydiumIxAccounts, - SwapSolForTokensOnRaydiumIxData, - ), - SwapTokensForSolOnRaydium( - SwapTokensForSolOnRaydiumIxAccounts, - SwapTokensForSolOnRaydiumIxData, - ), - TogglePaused(TogglePausedIxAccounts), - UpdateConfig(UpdateConfigIxAccounts, UpdateConfigIxData), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = BoopProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "Boop::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [165, 199, 62, 214, 81, 54, 4, 150] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddOperatorsIxAccounts { - config: next_account(accounts)?, - authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: AddOperatorsIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::AddOperators(ix_accounts, de_ix_data)) - }, - [138, 127, 14, 91, 38, 87, 115, 105] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = BuyTokenIxAccounts { - mint: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - trading_fees_vault: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - bonding_curve_sol_vault: next_account(accounts)?, - recipient_token_account: next_account(accounts)?, - buyer: next_account(accounts)?, - config: next_account(accounts)?, - vault_authority: next_account(accounts)?, - wsol: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - let de_ix_data: BuyTokenIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::BuyToken(ix_accounts, de_ix_data)) - }, - [94, 131, 125, 184, 183, 24, 125, 229] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CancelAuthorityTransferIxAccounts { - authority: next_account(accounts)?, - config: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(BoopProgramIx::CancelAuthorityTransfer(ix_accounts)) - }, - [189, 71, 189, 239, 113, 66, 59, 189] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CloseBondingCurveVaultIxAccounts { - config: next_account(accounts)?, - operator: next_account(accounts)?, - vault_authority: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - mint: next_account(accounts)?, - recipient_token_account: next_account(accounts)?, - recipient: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - Ok(BoopProgramIx::CloseBondingCurveVault(ix_accounts)) - }, - [189, 38, 205, 234, 81, 77, 25, 1] => { - let expected_accounts_len = 24; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectTradingFeesIxAccounts { - operator: next_account(accounts)?, - protocol_fee_recipient: next_account(accounts)?, - config: next_account(accounts)?, - lock_program: next_account(accounts)?, - vault_authority: next_account(accounts)?, - authority: next_account(accounts)?, - fee_nft_account: next_account(accounts)?, - locked_liquidity: next_account(accounts)?, - cpmm_program: next_account(accounts)?, - cp_authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - lp_mint: next_account(accounts)?, - recipient_token0_account: next_account(accounts)?, - recipient_token1_account: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - locked_lp_vault: next_account(accounts)?, - system_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - memo_program: next_account(accounts)?, - }; - Ok(BoopProgramIx::CollectTradingFees(ix_accounts)) - }, - [81, 233, 91, 132, 175, 31, 151, 141] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CompleteAuthorityTransferIxAccounts { - pending_authority: next_account(accounts)?, - config: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(BoopProgramIx::CompleteAuthorityTransfer(ix_accounts)) - }, - [65, 45, 119, 77, 204, 178, 84, 2] => { - let expected_accounts_len = 22; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateRaydiumPoolIxAccounts { - cpmm_program: next_account(accounts)?, - amm_config: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - token0_mint: next_account(accounts)?, - token1_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - vault_authority: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - bonding_curve_wsol_vault: next_account(accounts)?, - creator_lp_token: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - create_pool_fee: next_account(accounts)?, - observation_state: next_account(accounts)?, - operator: next_account(accounts)?, - config: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - Ok(BoopProgramIx::CreateRaydiumPool(ix_accounts)) - }, - [78, 44, 173, 29, 132, 180, 4, 172] => { - let expected_accounts_len = 22; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateRaydiumRandomPoolIxAccounts { - cpmm_program: next_account(accounts)?, - amm_config: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - token0_mint: next_account(accounts)?, - token1_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - vault_authority: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - bonding_curve_wsol_vault: next_account(accounts)?, - creator_lp_token: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - create_pool_fee: next_account(accounts)?, - observation_state: next_account(accounts)?, - operator: next_account(accounts)?, - config: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - Ok(BoopProgramIx::CreateRaydiumRandomPool(ix_accounts)) - }, - [84, 52, 204, 228, 24, 140, 234, 75] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateTokenIxAccounts { - config: next_account(accounts)?, - metadata: next_account(accounts)?, - mint: next_account(accounts)?, - payer: next_account(accounts)?, - rent: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - token_metadata_program: next_account(accounts)?, - }; - let de_ix_data: CreateTokenIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::CreateToken(ix_accounts, de_ix_data)) - }, - [253, 184, 126, 199, 235, 232, 172, 162] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateTokenFallbackIxAccounts { - config: next_account(accounts)?, - metadata: next_account(accounts)?, - mint: next_account(accounts)?, - payer: next_account(accounts)?, - rent: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - token_metadata_program: next_account(accounts)?, - }; - let de_ix_data: CreateTokenFallbackIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::CreateTokenFallback(ix_accounts, de_ix_data)) - }, - [180, 89, 199, 76, 168, 236, 217, 138] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DeployBondingCurveIxAccounts { - mint: next_account(accounts)?, - vault_authority: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - bonding_curve_sol_vault: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - config: next_account(accounts)?, - payer: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - let de_ix_data: DeployBondingCurveIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::DeployBondingCurve(ix_accounts, de_ix_data)) - }, - [53, 230, 172, 84, 77, 174, 22, 61] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DeployBondingCurveFallbackIxAccounts { - mint: next_account(accounts)?, - vault_authority: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - bonding_curve_sol_vault: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - config: next_account(accounts)?, - payer: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - let de_ix_data: DeployBondingCurveFallbackIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::DeployBondingCurveFallback( - ix_accounts, - de_ix_data, - )) - }, - [168, 89, 99, 30, 117, 49, 88, 224] => { - let expected_accounts_len = 21; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DepositIntoRaydiumIxAccounts { - config: next_account(accounts)?, - amm_config: next_account(accounts)?, - operator: next_account(accounts)?, - operator_wsol_account: next_account(accounts)?, - vault_authority: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - bonding_curve_wsol_vault: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - system_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - lp_mint: next_account(accounts)?, - cpmm_program: next_account(accounts)?, - owner_lp_token: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - token0_mint: next_account(accounts)?, - token1_mint: next_account(accounts)?, - }; - let de_ix_data: DepositIntoRaydiumIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::DepositIntoRaydium(ix_accounts, de_ix_data)) - }, - [45, 235, 225, 181, 17, 218, 64, 130] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = GraduateIxAccounts { - mint: next_account(accounts)?, - wsol: next_account(accounts)?, - protocol_fee_recipient: next_account(accounts)?, - token_distributor: next_account(accounts)?, - token_distributor_token_account: next_account(accounts)?, - vault_authority: next_account(accounts)?, - bonding_curve_sol_vault: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - bonding_curve_wsol_account: next_account(accounts)?, - operator: next_account(accounts)?, - config: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - Ok(BoopProgramIx::Graduate(ix_accounts)) - }, - [175, 175, 109, 31, 13, 152, 155, 237] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeIxAccounts { - config: next_account(accounts)?, - authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializeIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::Initialize(ix_accounts, de_ix_data)) - }, - [210, 43, 101, 215, 119, 140, 106, 218] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitiateAuthorityTransferIxAccounts { - authority: next_account(accounts)?, - config: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitiateAuthorityTransferIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::InitiateAuthorityTransfer( - ix_accounts, - de_ix_data, - )) - }, - [173, 255, 148, 6, 122, 99, 140, 22] => { - let expected_accounts_len = 22; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = LockRaydiumLiquidityIxAccounts { - lock_program: next_account(accounts)?, - vault_authority: next_account(accounts)?, - authority: next_account(accounts)?, - fee_nft_owner: next_account(accounts)?, - fee_nft_mint: next_account(accounts)?, - fee_nft_account: next_account(accounts)?, - pool_state: next_account(accounts)?, - locked_liquidity: next_account(accounts)?, - lp_mint: next_account(accounts)?, - liquidity_owner_lp: next_account(accounts)?, - locked_lp_vault: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - operator: next_account(accounts)?, - config: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - metadata_account: next_account(accounts)?, - rent: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - metadata_program: next_account(accounts)?, - }; - Ok(BoopProgramIx::LockRaydiumLiquidity(ix_accounts)) - }, - [42, 20, 89, 83, 222, 37, 4, 109] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveOperatorsIxAccounts { - config: next_account(accounts)?, - authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: RemoveOperatorsIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::RemoveOperators(ix_accounts, de_ix_data)) - }, - [109, 61, 40, 187, 230, 176, 135, 174] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SellTokenIxAccounts { - mint: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - trading_fees_vault: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - bonding_curve_sol_vault: next_account(accounts)?, - seller_token_account: next_account(accounts)?, - seller: next_account(accounts)?, - recipient: next_account(accounts)?, - config: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - let de_ix_data: SellTokenIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::SellToken(ix_accounts, de_ix_data)) - }, - [96, 126, 225, 47, 185, 213, 50, 58] => { - let expected_accounts_len = 24; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SplitTradingFeesIxAccounts { - operator: next_account(accounts)?, - mint: next_account(accounts)?, - wsol: next_account(accounts)?, - config: next_account(accounts)?, - vault_authority: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - trading_fees_vault: next_account(accounts)?, - fee_splitter_program: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - fee_splitter_config: next_account(accounts)?, - fee_splitter_creator_vault: next_account(accounts)?, - fee_splitter_vault_authority: next_account(accounts)?, - fee_splitter_creator_vault_authority: next_account(accounts)?, - fee_splitter_staking_mint: next_account(accounts)?, - fee_splitter_wsol_vault: next_account(accounts)?, - fee_splitter_creator_vault_authority_wsol_vault: next_account(accounts)?, - fee_splitter_treasury_wsol_vault: next_account(accounts)?, - fee_splitter_team_wsol_vault: next_account(accounts)?, - fee_splitter_reward_pool: next_account(accounts)?, - fee_splitter_reward_pool_staking_vault: next_account(accounts)?, - fee_splitter_reward_pool_reward_vault: next_account(accounts)?, - fee_splitter_reward_pool_program: next_account(accounts)?, - }; - Ok(BoopProgramIx::SplitTradingFees(ix_accounts)) - }, - [107, 248, 131, 239, 152, 234, 54, 35] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapSolForTokensOnRaydiumIxAccounts { - config: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - amm_config: next_account(accounts)?, - operator: next_account(accounts)?, - vault_authority: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - input_vault: next_account(accounts)?, - output_vault: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - bonding_curve_wsol_vault: next_account(accounts)?, - output_token_mint: next_account(accounts)?, - input_token_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - cp_swap_program: next_account(accounts)?, - observation_state: next_account(accounts)?, - }; - let de_ix_data: SwapSolForTokensOnRaydiumIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::SwapSolForTokensOnRaydium( - ix_accounts, - de_ix_data, - )) - }, - [216, 172, 130, 148, 34, 98, 215, 163] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapTokensForSolOnRaydiumIxAccounts { - config: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - amm_config: next_account(accounts)?, - operator: next_account(accounts)?, - vault_authority: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - input_vault: next_account(accounts)?, - output_vault: next_account(accounts)?, - bonding_curve_vault: next_account(accounts)?, - bonding_curve_wsol_vault: next_account(accounts)?, - input_token_mint: next_account(accounts)?, - output_token_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - cp_swap_program: next_account(accounts)?, - observation_state: next_account(accounts)?, - }; - let de_ix_data: SwapTokensForSolOnRaydiumIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::SwapTokensForSolOnRaydium( - ix_accounts, - de_ix_data, - )) - }, - [54, 83, 147, 198, 123, 97, 218, 72] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = TogglePausedIxAccounts { - authority: next_account(accounts)?, - config: next_account(accounts)?, - }; - Ok(BoopProgramIx::TogglePaused(ix_accounts)) - }, - [29, 158, 252, 191, 10, 83, 219, 99] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateConfigIxAccounts { - config: next_account(accounts)?, - authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: UpdateConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(BoopProgramIx::UpdateConfig(ix_accounts, de_ix_data)) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AddOperatorsIxAccounts, BoopProgramIx, InstructionParser}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for AddOperatorsIxAccounts { - fn into_proto(self) -> proto_def::AddOperatorsIxAccounts { - proto_def::AddOperatorsIxAccounts { - config: self.config.to_string(), - authority: self.authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::AddOperatorsIxData; - impl IntoProto for AddOperatorsIxData { - fn into_proto(self) -> proto_def::AddOperatorsIxData { - proto_def::AddOperatorsIxData { - operators: self.operators.into_iter().map(|x| x.to_string()).collect(), - } - } - } - use super::BuyTokenIxAccounts; - impl IntoProto for BuyTokenIxAccounts { - fn into_proto(self) -> proto_def::BuyTokenIxAccounts { - proto_def::BuyTokenIxAccounts { - mint: self.mint.to_string(), - bonding_curve: self.bonding_curve.to_string(), - trading_fees_vault: self.trading_fees_vault.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - bonding_curve_sol_vault: self.bonding_curve_sol_vault.to_string(), - recipient_token_account: self.recipient_token_account.to_string(), - buyer: self.buyer.to_string(), - config: self.config.to_string(), - vault_authority: self.vault_authority.to_string(), - wsol: self.wsol.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::BuyTokenIxData; - impl IntoProto for BuyTokenIxData { - fn into_proto(self) -> proto_def::BuyTokenIxData { - proto_def::BuyTokenIxData { - buy_amount: self.buy_amount, - amount_out_min: self.amount_out_min, - } - } - } - use super::CancelAuthorityTransferIxAccounts; - impl IntoProto for CancelAuthorityTransferIxAccounts { - fn into_proto(self) -> proto_def::CancelAuthorityTransferIxAccounts { - proto_def::CancelAuthorityTransferIxAccounts { - authority: self.authority.to_string(), - config: self.config.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CloseBondingCurveVaultIxAccounts; - impl IntoProto for CloseBondingCurveVaultIxAccounts { - fn into_proto(self) -> proto_def::CloseBondingCurveVaultIxAccounts { - proto_def::CloseBondingCurveVaultIxAccounts { - config: self.config.to_string(), - operator: self.operator.to_string(), - vault_authority: self.vault_authority.to_string(), - bonding_curve: self.bonding_curve.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - mint: self.mint.to_string(), - recipient_token_account: self.recipient_token_account.to_string(), - recipient: self.recipient.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::CollectTradingFeesIxAccounts; - impl IntoProto for CollectTradingFeesIxAccounts { - fn into_proto(self) -> proto_def::CollectTradingFeesIxAccounts { - proto_def::CollectTradingFeesIxAccounts { - operator: self.operator.to_string(), - protocol_fee_recipient: self.protocol_fee_recipient.to_string(), - config: self.config.to_string(), - lock_program: self.lock_program.to_string(), - vault_authority: self.vault_authority.to_string(), - authority: self.authority.to_string(), - fee_nft_account: self.fee_nft_account.to_string(), - locked_liquidity: self.locked_liquidity.to_string(), - cpmm_program: self.cpmm_program.to_string(), - cp_authority: self.cp_authority.to_string(), - pool_state: self.pool_state.to_string(), - lp_mint: self.lp_mint.to_string(), - recipient_token0_account: self.recipient_token0_account.to_string(), - recipient_token1_account: self.recipient_token1_account.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - locked_lp_vault: self.locked_lp_vault.to_string(), - system_program: self.system_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - memo_program: self.memo_program.to_string(), - } - } - } - use super::CompleteAuthorityTransferIxAccounts; - impl IntoProto - for CompleteAuthorityTransferIxAccounts - { - fn into_proto(self) -> proto_def::CompleteAuthorityTransferIxAccounts { - proto_def::CompleteAuthorityTransferIxAccounts { - pending_authority: self.pending_authority.to_string(), - config: self.config.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreateRaydiumPoolIxAccounts; - impl IntoProto for CreateRaydiumPoolIxAccounts { - fn into_proto(self) -> proto_def::CreateRaydiumPoolIxAccounts { - proto_def::CreateRaydiumPoolIxAccounts { - cpmm_program: self.cpmm_program.to_string(), - amm_config: self.amm_config.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - token0_mint: self.token0_mint.to_string(), - token1_mint: self.token1_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - vault_authority: self.vault_authority.to_string(), - bonding_curve: self.bonding_curve.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - bonding_curve_wsol_vault: self.bonding_curve_wsol_vault.to_string(), - creator_lp_token: self.creator_lp_token.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - create_pool_fee: self.create_pool_fee.to_string(), - observation_state: self.observation_state.to_string(), - operator: self.operator.to_string(), - config: self.config.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::CreateRaydiumRandomPoolIxAccounts; - impl IntoProto for CreateRaydiumRandomPoolIxAccounts { - fn into_proto(self) -> proto_def::CreateRaydiumRandomPoolIxAccounts { - proto_def::CreateRaydiumRandomPoolIxAccounts { - cpmm_program: self.cpmm_program.to_string(), - amm_config: self.amm_config.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - token0_mint: self.token0_mint.to_string(), - token1_mint: self.token1_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - vault_authority: self.vault_authority.to_string(), - bonding_curve: self.bonding_curve.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - bonding_curve_wsol_vault: self.bonding_curve_wsol_vault.to_string(), - creator_lp_token: self.creator_lp_token.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - create_pool_fee: self.create_pool_fee.to_string(), - observation_state: self.observation_state.to_string(), - operator: self.operator.to_string(), - config: self.config.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::CreateTokenIxAccounts; - impl IntoProto for CreateTokenIxAccounts { - fn into_proto(self) -> proto_def::CreateTokenIxAccounts { - proto_def::CreateTokenIxAccounts { - config: self.config.to_string(), - metadata: self.metadata.to_string(), - mint: self.mint.to_string(), - payer: self.payer.to_string(), - rent: self.rent.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - token_metadata_program: self.token_metadata_program.to_string(), - } - } - } - use super::CreateTokenIxData; - impl IntoProto for CreateTokenIxData { - fn into_proto(self) -> proto_def::CreateTokenIxData { - proto_def::CreateTokenIxData { - salt: self.salt, - name: self.name, - symbol: self.symbol, - uri: self.uri, - } - } - } - use super::CreateTokenFallbackIxAccounts; - impl IntoProto for CreateTokenFallbackIxAccounts { - fn into_proto(self) -> proto_def::CreateTokenFallbackIxAccounts { - proto_def::CreateTokenFallbackIxAccounts { - config: self.config.to_string(), - metadata: self.metadata.to_string(), - mint: self.mint.to_string(), - payer: self.payer.to_string(), - rent: self.rent.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - token_metadata_program: self.token_metadata_program.to_string(), - } - } - } - use super::CreateTokenFallbackIxData; - impl IntoProto for CreateTokenFallbackIxData { - fn into_proto(self) -> proto_def::CreateTokenFallbackIxData { - proto_def::CreateTokenFallbackIxData { - salt: self.salt, - name: self.name, - symbol: self.symbol, - uri: self.uri, - } - } - } - use super::DeployBondingCurveIxAccounts; - impl IntoProto for DeployBondingCurveIxAccounts { - fn into_proto(self) -> proto_def::DeployBondingCurveIxAccounts { - proto_def::DeployBondingCurveIxAccounts { - mint: self.mint.to_string(), - vault_authority: self.vault_authority.to_string(), - bonding_curve: self.bonding_curve.to_string(), - bonding_curve_sol_vault: self.bonding_curve_sol_vault.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - config: self.config.to_string(), - payer: self.payer.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::DeployBondingCurveIxData; - impl IntoProto for DeployBondingCurveIxData { - fn into_proto(self) -> proto_def::DeployBondingCurveIxData { - proto_def::DeployBondingCurveIxData { - creator: self.creator.to_string(), - salt: self.salt, - } - } - } - use super::DeployBondingCurveFallbackIxAccounts; - impl IntoProto - for DeployBondingCurveFallbackIxAccounts - { - fn into_proto(self) -> proto_def::DeployBondingCurveFallbackIxAccounts { - proto_def::DeployBondingCurveFallbackIxAccounts { - mint: self.mint.to_string(), - vault_authority: self.vault_authority.to_string(), - bonding_curve: self.bonding_curve.to_string(), - bonding_curve_sol_vault: self.bonding_curve_sol_vault.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - config: self.config.to_string(), - payer: self.payer.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::DeployBondingCurveFallbackIxData; - impl IntoProto for DeployBondingCurveFallbackIxData { - fn into_proto(self) -> proto_def::DeployBondingCurveFallbackIxData { - proto_def::DeployBondingCurveFallbackIxData { - creator: self.creator.to_string(), - salt: self.salt, - } - } - } - use super::DepositIntoRaydiumIxAccounts; - impl IntoProto for DepositIntoRaydiumIxAccounts { - fn into_proto(self) -> proto_def::DepositIntoRaydiumIxAccounts { - proto_def::DepositIntoRaydiumIxAccounts { - config: self.config.to_string(), - amm_config: self.amm_config.to_string(), - operator: self.operator.to_string(), - operator_wsol_account: self.operator_wsol_account.to_string(), - vault_authority: self.vault_authority.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - bonding_curve_wsol_vault: self.bonding_curve_wsol_vault.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - system_program: self.system_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - lp_mint: self.lp_mint.to_string(), - cpmm_program: self.cpmm_program.to_string(), - owner_lp_token: self.owner_lp_token.to_string(), - bonding_curve: self.bonding_curve.to_string(), - token0_mint: self.token0_mint.to_string(), - token1_mint: self.token1_mint.to_string(), - } - } - } - use super::DepositIntoRaydiumIxData; - impl IntoProto for DepositIntoRaydiumIxData { - fn into_proto(self) -> proto_def::DepositIntoRaydiumIxData { - proto_def::DepositIntoRaydiumIxData { - lp_token_amount: self.lp_token_amount, - maximum_token0_amount: self.maximum_token0_amount, - maximum_token1_amount: self.maximum_token1_amount, - } - } - } - use super::GraduateIxAccounts; - impl IntoProto for GraduateIxAccounts { - fn into_proto(self) -> proto_def::GraduateIxAccounts { - proto_def::GraduateIxAccounts { - mint: self.mint.to_string(), - wsol: self.wsol.to_string(), - protocol_fee_recipient: self.protocol_fee_recipient.to_string(), - token_distributor: self.token_distributor.to_string(), - token_distributor_token_account: self.token_distributor_token_account.to_string(), - vault_authority: self.vault_authority.to_string(), - bonding_curve_sol_vault: self.bonding_curve_sol_vault.to_string(), - bonding_curve: self.bonding_curve.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - bonding_curve_wsol_account: self.bonding_curve_wsol_account.to_string(), - operator: self.operator.to_string(), - config: self.config.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::InitializeIxAccounts; - impl IntoProto for InitializeIxAccounts { - fn into_proto(self) -> proto_def::InitializeIxAccounts { - proto_def::InitializeIxAccounts { - config: self.config.to_string(), - authority: self.authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializeIxData; - impl IntoProto for InitializeIxData { - fn into_proto(self) -> proto_def::InitializeIxData { - proto_def::InitializeIxData { - protocol_fee_recipient: self.protocol_fee_recipient.to_string(), - token_distributor: self.token_distributor.to_string(), - } - } - } - use super::InitiateAuthorityTransferIxAccounts; - impl IntoProto - for InitiateAuthorityTransferIxAccounts - { - fn into_proto(self) -> proto_def::InitiateAuthorityTransferIxAccounts { - proto_def::InitiateAuthorityTransferIxAccounts { - authority: self.authority.to_string(), - config: self.config.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitiateAuthorityTransferIxData; - impl IntoProto for InitiateAuthorityTransferIxData { - fn into_proto(self) -> proto_def::InitiateAuthorityTransferIxData { - proto_def::InitiateAuthorityTransferIxData { - new_authority: self.new_authority.to_string(), - } - } - } - use super::LockRaydiumLiquidityIxAccounts; - impl IntoProto for LockRaydiumLiquidityIxAccounts { - fn into_proto(self) -> proto_def::LockRaydiumLiquidityIxAccounts { - proto_def::LockRaydiumLiquidityIxAccounts { - lock_program: self.lock_program.to_string(), - vault_authority: self.vault_authority.to_string(), - authority: self.authority.to_string(), - fee_nft_owner: self.fee_nft_owner.to_string(), - fee_nft_mint: self.fee_nft_mint.to_string(), - fee_nft_account: self.fee_nft_account.to_string(), - pool_state: self.pool_state.to_string(), - locked_liquidity: self.locked_liquidity.to_string(), - lp_mint: self.lp_mint.to_string(), - liquidity_owner_lp: self.liquidity_owner_lp.to_string(), - locked_lp_vault: self.locked_lp_vault.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - operator: self.operator.to_string(), - config: self.config.to_string(), - bonding_curve: self.bonding_curve.to_string(), - metadata_account: self.metadata_account.to_string(), - rent: self.rent.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - metadata_program: self.metadata_program.to_string(), - } - } - } - use super::RemoveOperatorsIxAccounts; - impl IntoProto for RemoveOperatorsIxAccounts { - fn into_proto(self) -> proto_def::RemoveOperatorsIxAccounts { - proto_def::RemoveOperatorsIxAccounts { - config: self.config.to_string(), - authority: self.authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::RemoveOperatorsIxData; - impl IntoProto for RemoveOperatorsIxData { - fn into_proto(self) -> proto_def::RemoveOperatorsIxData { - proto_def::RemoveOperatorsIxData { - operators: self.operators.into_iter().map(|x| x.to_string()).collect(), - } - } - } - use super::SellTokenIxAccounts; - impl IntoProto for SellTokenIxAccounts { - fn into_proto(self) -> proto_def::SellTokenIxAccounts { - proto_def::SellTokenIxAccounts { - mint: self.mint.to_string(), - bonding_curve: self.bonding_curve.to_string(), - trading_fees_vault: self.trading_fees_vault.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - bonding_curve_sol_vault: self.bonding_curve_sol_vault.to_string(), - seller_token_account: self.seller_token_account.to_string(), - seller: self.seller.to_string(), - recipient: self.recipient.to_string(), - config: self.config.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::SellTokenIxData; - impl IntoProto for SellTokenIxData { - fn into_proto(self) -> proto_def::SellTokenIxData { - proto_def::SellTokenIxData { - sell_amount: self.sell_amount, - amount_out_min: self.amount_out_min, - } - } - } - use super::SplitTradingFeesIxAccounts; - impl IntoProto for SplitTradingFeesIxAccounts { - fn into_proto(self) -> proto_def::SplitTradingFeesIxAccounts { - proto_def::SplitTradingFeesIxAccounts { - operator: self.operator.to_string(), - mint: self.mint.to_string(), - wsol: self.wsol.to_string(), - config: self.config.to_string(), - vault_authority: self.vault_authority.to_string(), - bonding_curve: self.bonding_curve.to_string(), - trading_fees_vault: self.trading_fees_vault.to_string(), - fee_splitter_program: self.fee_splitter_program.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - fee_splitter_config: self.fee_splitter_config.to_string(), - fee_splitter_creator_vault: self.fee_splitter_creator_vault.to_string(), - fee_splitter_vault_authority: self.fee_splitter_vault_authority.to_string(), - fee_splitter_creator_vault_authority: self - .fee_splitter_creator_vault_authority - .to_string(), - fee_splitter_staking_mint: self.fee_splitter_staking_mint.to_string(), - fee_splitter_wsol_vault: self.fee_splitter_wsol_vault.to_string(), - fee_splitter_creator_vault_authority_wsol_vault: self - .fee_splitter_creator_vault_authority_wsol_vault - .to_string(), - fee_splitter_treasury_wsol_vault: self.fee_splitter_treasury_wsol_vault.to_string(), - fee_splitter_team_wsol_vault: self.fee_splitter_team_wsol_vault.to_string(), - fee_splitter_reward_pool: self.fee_splitter_reward_pool.to_string(), - fee_splitter_reward_pool_staking_vault: self - .fee_splitter_reward_pool_staking_vault - .to_string(), - fee_splitter_reward_pool_reward_vault: self - .fee_splitter_reward_pool_reward_vault - .to_string(), - fee_splitter_reward_pool_program: self.fee_splitter_reward_pool_program.to_string(), - } - } - } - use super::SwapSolForTokensOnRaydiumIxAccounts; - impl IntoProto - for SwapSolForTokensOnRaydiumIxAccounts - { - fn into_proto(self) -> proto_def::SwapSolForTokensOnRaydiumIxAccounts { - proto_def::SwapSolForTokensOnRaydiumIxAccounts { - config: self.config.to_string(), - bonding_curve: self.bonding_curve.to_string(), - amm_config: self.amm_config.to_string(), - operator: self.operator.to_string(), - vault_authority: self.vault_authority.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - input_vault: self.input_vault.to_string(), - output_vault: self.output_vault.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - bonding_curve_wsol_vault: self.bonding_curve_wsol_vault.to_string(), - output_token_mint: self.output_token_mint.to_string(), - input_token_mint: self.input_token_mint.to_string(), - token_program: self.token_program.to_string(), - cp_swap_program: self.cp_swap_program.to_string(), - observation_state: self.observation_state.to_string(), - } - } - } - use super::SwapSolForTokensOnRaydiumIxData; - impl IntoProto for SwapSolForTokensOnRaydiumIxData { - fn into_proto(self) -> proto_def::SwapSolForTokensOnRaydiumIxData { - proto_def::SwapSolForTokensOnRaydiumIxData { - amount_in: self.amount_in, - minimum_amount_out: self.minimum_amount_out, - } - } - } - use super::SwapTokensForSolOnRaydiumIxAccounts; - impl IntoProto - for SwapTokensForSolOnRaydiumIxAccounts - { - fn into_proto(self) -> proto_def::SwapTokensForSolOnRaydiumIxAccounts { - proto_def::SwapTokensForSolOnRaydiumIxAccounts { - config: self.config.to_string(), - bonding_curve: self.bonding_curve.to_string(), - amm_config: self.amm_config.to_string(), - operator: self.operator.to_string(), - vault_authority: self.vault_authority.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - input_vault: self.input_vault.to_string(), - output_vault: self.output_vault.to_string(), - bonding_curve_vault: self.bonding_curve_vault.to_string(), - bonding_curve_wsol_vault: self.bonding_curve_wsol_vault.to_string(), - input_token_mint: self.input_token_mint.to_string(), - output_token_mint: self.output_token_mint.to_string(), - token_program: self.token_program.to_string(), - cp_swap_program: self.cp_swap_program.to_string(), - observation_state: self.observation_state.to_string(), - } - } - } - use super::SwapTokensForSolOnRaydiumIxData; - impl IntoProto for SwapTokensForSolOnRaydiumIxData { - fn into_proto(self) -> proto_def::SwapTokensForSolOnRaydiumIxData { - proto_def::SwapTokensForSolOnRaydiumIxData { - amount_in: self.amount_in, - minimum_amount_out: self.minimum_amount_out, - } - } - } - use super::TogglePausedIxAccounts; - impl IntoProto for TogglePausedIxAccounts { - fn into_proto(self) -> proto_def::TogglePausedIxAccounts { - proto_def::TogglePausedIxAccounts { - authority: self.authority.to_string(), - config: self.config.to_string(), - } - } - } - use super::UpdateConfigIxAccounts; - impl IntoProto for UpdateConfigIxAccounts { - fn into_proto(self) -> proto_def::UpdateConfigIxAccounts { - proto_def::UpdateConfigIxAccounts { - config: self.config.to_string(), - authority: self.authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::UpdateConfigIxData; - impl IntoProto for UpdateConfigIxData { - fn into_proto(self) -> proto_def::UpdateConfigIxData { - proto_def::UpdateConfigIxData { - new_protocol_fee_recipient: self.new_protocol_fee_recipient.to_string(), - new_virtual_sol_reserves: self.new_virtual_sol_reserves, - new_virtual_token_reserves: self.new_virtual_token_reserves, - new_graduation_target: self.new_graduation_target, - new_graduation_fee: self.new_graduation_fee, - new_damping_term: self.new_damping_term.into(), - new_swap_fee_basis_points: self.new_swap_fee_basis_points.into(), - new_token_for_stakers_basis_points: self.new_token_for_stakers_basis_points.into(), - new_token_amount_for_raydium_liquidity: self.new_token_amount_for_raydium_liquidity, - new_max_graduation_price_deviation_basis_points: self - .new_max_graduation_price_deviation_basis_points - .into(), - new_max_swap_amount_for_pool_price_correction_basis_points: self - .new_max_swap_amount_for_pool_price_correction_basis_points - .into(), - } - } - } - - impl IntoProto for BoopProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - BoopProgramIx::AddOperators(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddOperators( - proto_def::AddOperatorsIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::BuyToken(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::BuyToken( - proto_def::BuyTokenIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::CancelAuthorityTransfer(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CancelAuthorityTransfer( - proto_def::CancelAuthorityTransferIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - BoopProgramIx::CloseBondingCurveVault(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CloseBondingCurveVault( - proto_def::CloseBondingCurveVaultIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - BoopProgramIx::CollectTradingFees(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectTradingFees( - proto_def::CollectTradingFeesIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - BoopProgramIx::CompleteAuthorityTransfer(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CompleteAuthorityTransfer( - proto_def::CompleteAuthorityTransferIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - BoopProgramIx::CreateRaydiumPool(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateRaydiumPool( - proto_def::CreateRaydiumPoolIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - BoopProgramIx::CreateRaydiumRandomPool(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateRaydiumRandomPool( - proto_def::CreateRaydiumRandomPoolIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - BoopProgramIx::CreateToken(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateToken( - proto_def::CreateTokenIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::CreateTokenFallback(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateTokenFallback( - proto_def::CreateTokenFallbackIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::DeployBondingCurve(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::DeployBondingCurve( - proto_def::DeployBondingCurveIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::DeployBondingCurveFallback(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::DeployBondingCurveFallback( - proto_def::DeployBondingCurveFallbackIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::DepositIntoRaydium(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::DepositIntoRaydium( - proto_def::DepositIntoRaydiumIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::Graduate(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Graduate( - proto_def::GraduateIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - BoopProgramIx::Initialize(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Initialize( - proto_def::InitializeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::InitiateAuthorityTransfer(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitiateAuthorityTransfer( - proto_def::InitiateAuthorityTransferIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::LockRaydiumLiquidity(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::LockRaydiumLiquidity( - proto_def::LockRaydiumLiquidityIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - BoopProgramIx::RemoveOperators(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveOperators( - proto_def::RemoveOperatorsIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::SellToken(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SellToken( - proto_def::SellTokenIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::SplitTradingFees(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SplitTradingFees( - proto_def::SplitTradingFeesIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - BoopProgramIx::SwapSolForTokensOnRaydium(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapSolForTokensOnRaydium( - proto_def::SwapSolForTokensOnRaydiumIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::SwapTokensForSolOnRaydium(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapTokensForSolOnRaydium( - proto_def::SwapTokensForSolOnRaydiumIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - BoopProgramIx::TogglePaused(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::TogglePaused( - proto_def::TogglePausedIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - BoopProgramIx::UpdateConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateConfig( - proto_def::UpdateConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/boop-parser/src/generated_parser/mod.rs b/crates/boop-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/boop-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/boop-parser/src/generated_parser/proto_helpers.rs b/crates/boop-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index 513e1bff..00000000 --- a/crates/boop-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,247 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::AuthorityTransferCancelledEvent}; - impl IntoProto for AuthorityTransferCancelledEvent { - fn into_proto(self) -> proto_def::AuthorityTransferCancelledEvent { - proto_def::AuthorityTransferCancelledEvent {} - } - } - use crate::types::AuthorityTransferCompletedEvent; - impl IntoProto for AuthorityTransferCompletedEvent { - fn into_proto(self) -> proto_def::AuthorityTransferCompletedEvent { - proto_def::AuthorityTransferCompletedEvent { - old_authority: self.old_authority.to_string(), - new_authority: self.new_authority.to_string(), - } - } - } - use crate::types::AuthorityTransferInitiatedEvent; - impl IntoProto for AuthorityTransferInitiatedEvent { - fn into_proto(self) -> proto_def::AuthorityTransferInitiatedEvent { - proto_def::AuthorityTransferInitiatedEvent { - old_authority: self.old_authority.to_string(), - new_authority: self.new_authority.to_string(), - } - } - } - use crate::types::BondingCurveDeployedEvent; - impl IntoProto for BondingCurveDeployedEvent { - fn into_proto(self) -> proto_def::BondingCurveDeployedEvent { - proto_def::BondingCurveDeployedEvent { - mint: self.mint.to_string(), - creator: self.creator.to_string(), - } - } - } - use crate::types::BondingCurveDeployedFallbackEvent; - impl IntoProto for BondingCurveDeployedFallbackEvent { - fn into_proto(self) -> proto_def::BondingCurveDeployedFallbackEvent { - proto_def::BondingCurveDeployedFallbackEvent { - mint: self.mint.to_string(), - creator: self.creator.to_string(), - } - } - } - use crate::types::BondingCurveVaultClosedEvent; - impl IntoProto for BondingCurveVaultClosedEvent { - fn into_proto(self) -> proto_def::BondingCurveVaultClosedEvent { - proto_def::BondingCurveVaultClosedEvent { - mint: self.mint.to_string(), - recipient: self.recipient.to_string(), - amount: self.amount, - } - } - } - use crate::types::ConfigUpdatedEvent; - impl IntoProto for ConfigUpdatedEvent { - fn into_proto(self) -> proto_def::ConfigUpdatedEvent { - proto_def::ConfigUpdatedEvent { - protocol_fee_recipient: self.protocol_fee_recipient.to_string(), - virtual_sol_reserves: self.virtual_sol_reserves, - virtual_token_reserves: self.virtual_token_reserves, - graduation_target: self.graduation_target, - graduation_fee: self.graduation_fee, - damping_term: self.damping_term.into(), - swap_fee_basis_points: self.swap_fee_basis_points.into(), - token_for_stakers_basis_points: self.token_for_stakers_basis_points.into(), - token_amount_for_raydium_liquidity: self.token_amount_for_raydium_liquidity, - max_graduation_price_deviation_basis_points: self - .max_graduation_price_deviation_basis_points - .into(), - max_swap_amount_for_pool_price_correction_basis_points: self - .max_swap_amount_for_pool_price_correction_basis_points - .into(), - } - } - } - use crate::types::LiquidityDepositedIntoRaydiumEvent; - impl IntoProto - for LiquidityDepositedIntoRaydiumEvent - { - fn into_proto(self) -> proto_def::LiquidityDepositedIntoRaydiumEvent { - proto_def::LiquidityDepositedIntoRaydiumEvent { - pool_state: self.pool_state.to_string(), - mint: self.mint.to_string(), - lp_token_amount: self.lp_token_amount, - tokens_deposited: self.tokens_deposited, - wsol_deposited: self.wsol_deposited, - } - } - } - use crate::types::OperatorsAddedEvent; - impl IntoProto for OperatorsAddedEvent { - fn into_proto(self) -> proto_def::OperatorsAddedEvent { - proto_def::OperatorsAddedEvent { - operators: self.operators.into_iter().map(|x| x.to_string()).collect(), - } - } - } - use crate::types::OperatorsRemovedEvent; - impl IntoProto for OperatorsRemovedEvent { - fn into_proto(self) -> proto_def::OperatorsRemovedEvent { - proto_def::OperatorsRemovedEvent { - operators: self.operators.into_iter().map(|x| x.to_string()).collect(), - } - } - } - use crate::types::PausedToggledEvent; - impl IntoProto for PausedToggledEvent { - fn into_proto(self) -> proto_def::PausedToggledEvent { - proto_def::PausedToggledEvent { - is_paused: self.is_paused, - } - } - } - use crate::types::RaydiumLiquidityLockedEvent; - impl IntoProto for RaydiumLiquidityLockedEvent { - fn into_proto(self) -> proto_def::RaydiumLiquidityLockedEvent { - proto_def::RaydiumLiquidityLockedEvent { - pool_state: self.pool_state.to_string(), - mint: self.mint.to_string(), - lp_amount: self.lp_amount, - } - } - } - use crate::types::RaydiumPoolCreatedEvent; - impl IntoProto for RaydiumPoolCreatedEvent { - fn into_proto(self) -> proto_def::RaydiumPoolCreatedEvent { - proto_def::RaydiumPoolCreatedEvent { - pool_state: self.pool_state.to_string(), - mint: self.mint.to_string(), - } - } - } - use crate::types::RaydiumRandomPoolCreatedEvent; - impl IntoProto for RaydiumRandomPoolCreatedEvent { - fn into_proto(self) -> proto_def::RaydiumRandomPoolCreatedEvent { - proto_def::RaydiumRandomPoolCreatedEvent { - pool_state: self.pool_state.to_string(), - mint: self.mint.to_string(), - } - } - } - use crate::types::SwapSolForTokensOnRaydiumEvent; - impl IntoProto for SwapSolForTokensOnRaydiumEvent { - fn into_proto(self) -> proto_def::SwapSolForTokensOnRaydiumEvent { - proto_def::SwapSolForTokensOnRaydiumEvent { - mint: self.mint.to_string(), - amount_in: self.amount_in, - amount_out: self.amount_out, - } - } - } - use crate::types::SwapTokensForSolOnRaydiumEvent; - impl IntoProto for SwapTokensForSolOnRaydiumEvent { - fn into_proto(self) -> proto_def::SwapTokensForSolOnRaydiumEvent { - proto_def::SwapTokensForSolOnRaydiumEvent { - mint: self.mint.to_string(), - amount_in: self.amount_in, - amount_out: self.amount_out, - } - } - } - use crate::types::TokenBoughtEvent; - impl IntoProto for TokenBoughtEvent { - fn into_proto(self) -> proto_def::TokenBoughtEvent { - proto_def::TokenBoughtEvent { - mint: self.mint.to_string(), - amount_in: self.amount_in, - amount_out: self.amount_out, - swap_fee: self.swap_fee, - buyer: self.buyer.to_string(), - recipient: self.recipient.to_string(), - } - } - } - use crate::types::TokenCreatedEvent; - impl IntoProto for TokenCreatedEvent { - fn into_proto(self) -> proto_def::TokenCreatedEvent { - proto_def::TokenCreatedEvent { - name: self.name, - symbol: self.symbol, - uri: self.uri, - } - } - } - use crate::types::TokenCreatedFallbackEvent; - impl IntoProto for TokenCreatedFallbackEvent { - fn into_proto(self) -> proto_def::TokenCreatedFallbackEvent { - proto_def::TokenCreatedFallbackEvent { - name: self.name, - symbol: self.symbol, - uri: self.uri, - } - } - } - use crate::types::TokenGraduatedEvent; - impl IntoProto for TokenGraduatedEvent { - fn into_proto(self) -> proto_def::TokenGraduatedEvent { - proto_def::TokenGraduatedEvent { - mint: self.mint.to_string(), - sol_for_liquidity: self.sol_for_liquidity, - graduation_fee: self.graduation_fee, - token_for_distributor: self.token_for_distributor, - } - } - } - use crate::types::TokenSoldEvent; - impl IntoProto for TokenSoldEvent { - fn into_proto(self) -> proto_def::TokenSoldEvent { - proto_def::TokenSoldEvent { - mint: self.mint.to_string(), - amount_in: self.amount_in, - amount_out: self.amount_out, - swap_fee: self.swap_fee, - seller: self.seller.to_string(), - recipient: self.recipient.to_string(), - } - } - } - use crate::types::TradingFeesCollectedEvent; - impl IntoProto for TradingFeesCollectedEvent { - fn into_proto(self) -> proto_def::TradingFeesCollectedEvent { - proto_def::TradingFeesCollectedEvent { - pool_state: self.pool_state.to_string(), - mint: self.mint.to_string(), - } - } - } - use crate::types::TradingFeesSplitEvent; - impl IntoProto for TradingFeesSplitEvent { - fn into_proto(self) -> proto_def::TradingFeesSplitEvent { - proto_def::TradingFeesSplitEvent { - amount: self.amount, - creator: self.creator.to_string(), - } - } - } -} diff --git a/crates/boop-parser/src/generated_sdk/accounts/amm_config.rs b/crates/boop-parser/src/generated_sdk/accounts/amm_config.rs deleted file mode 100644 index 6084227b..00000000 --- a/crates/boop-parser/src/generated_sdk/accounts/amm_config.rs +++ /dev/null @@ -1,155 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AmmConfig { - pub discriminator: [u8; 8], - /// Bump to identify PDA - pub bump: u8, - /// Status to control if new pool can be create - pub disable_create_pool: bool, - /// Config index - pub index: u16, - /// The trade fee, denominated in hundredths of a bip (10^-6) - pub trade_fee_rate: u64, - /// The protocol fee - pub protocol_fee_rate: u64, - /// The fund fee, denominated in hundredths of a bip (10^-6) - pub fund_fee_rate: u64, - /// Fee for create a new pool - pub create_pool_fee: u64, - /// Address of the protocol fee owner - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_owner: Pubkey, - /// Address of the fund fee owner - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fund_owner: Pubkey, - /// padding - pub padding: [u64; 16], -} - -impl AmmConfig { - pub const LEN: usize = 236; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for AmmConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_amm_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = AmmConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_amm_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = AmmConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for AmmConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for AmmConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for AmmConfig { - fn owner() -> Pubkey { crate::BOOP_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for AmmConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for AmmConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/boop-parser/src/generated_sdk/accounts/bonding_curve.rs b/crates/boop-parser/src/generated_sdk/accounts/bonding_curve.rs deleted file mode 100644 index 23c788c8..00000000 --- a/crates/boop-parser/src/generated_sdk/accounts/bonding_curve.rs +++ /dev/null @@ -1,149 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::BondingCurveStatus; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BondingCurve { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub virtual_sol_reserves: u64, - pub virtual_token_reserves: u64, - pub graduation_target: u64, - pub graduation_fee: u64, - pub sol_reserves: u64, - pub token_reserves: u64, - pub damping_term: u8, - pub swap_fee_basis_points: u8, - pub token_for_stakers_basis_points: u16, - pub status: BondingCurveStatus, -} - -impl BondingCurve { - pub const LEN: usize = 125; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for BondingCurve { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_bonding_curve(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = BondingCurve::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_bonding_curve(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = BondingCurve::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for BondingCurve { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for BondingCurve {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for BondingCurve { - fn owner() -> Pubkey { crate::BOOP_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for BondingCurve {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for BondingCurve { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/boop-parser/src/generated_sdk/accounts/config.rs b/crates/boop-parser/src/generated_sdk/accounts/config.rs deleted file mode 100644 index 25e85163..00000000 --- a/crates/boop-parser/src/generated_sdk/accounts/config.rs +++ /dev/null @@ -1,161 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Config { - pub discriminator: [u8; 8], - pub is_paused: bool, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pending_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::>") - )] - pub operators: Vec, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_fee_recipient: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_distributor: Pubkey, - pub virtual_sol_reserves: u64, - pub virtual_token_reserves: u64, - pub graduation_target: u64, - pub graduation_fee: u64, - pub damping_term: u8, - pub token_for_stakers_basis_points: u16, - pub swap_fee_basis_points: u8, - pub token_amount_for_raydium_liquidity: u64, - pub max_graduation_price_deviation_basis_points: u16, - pub max_swap_amount_for_pool_price_correction_basis_points: u16, -} - -impl Config { - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Config { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Config::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Config::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Config { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Config {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Config { - fn owner() -> Pubkey { crate::BOOP_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Config {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Config { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/boop-parser/src/generated_sdk/accounts/locked_cp_liquidity_state.rs b/crates/boop-parser/src/generated_sdk/accounts/locked_cp_liquidity_state.rs deleted file mode 100644 index 20d094a4..00000000 --- a/crates/boop-parser/src/generated_sdk/accounts/locked_cp_liquidity_state.rs +++ /dev/null @@ -1,166 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockedCpLiquidityState { - pub discriminator: [u8; 8], - /// The Locked liquidity amount without claimed lp fee - pub locked_lp_amount: u64, - /// Claimed lp fee amount - pub claimed_lp_amount: u64, - /// Unclaimed lp fee amount - pub unclaimed_lp_amount: u64, - /// Last updated cp pool lp total supply - pub last_lp: u64, - /// Last updated cp pool k - pub last_k: u128, - /// Account update recent epoch - pub recent_epoch: u64, - /// The ID of the pool with which this record is connected - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_id: Pubkey, - /// nft mint to check who has authority to collect fee - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_nft_mint: Pubkey, - /// The owner who has locked liquidity - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub locked_owner: Pubkey, - /// The mint of locked lp token - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub locked_lp_mint: Pubkey, - /// Unused bytes for future upgrades. - pub padding: [u64; 8], -} - -impl LockedCpLiquidityState { - pub const LEN: usize = 256; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for LockedCpLiquidityState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_locked_cp_liquidity_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_locked_cp_liquidity_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_locked_cp_liquidity_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = LockedCpLiquidityState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_locked_cp_liquidity_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_locked_cp_liquidity_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_locked_cp_liquidity_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = LockedCpLiquidityState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for LockedCpLiquidityState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for LockedCpLiquidityState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for LockedCpLiquidityState { - fn owner() -> Pubkey { crate::BOOP_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for LockedCpLiquidityState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for LockedCpLiquidityState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/boop-parser/src/generated_sdk/accounts/mod.rs b/crates/boop-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index fcad90a4..00000000 --- a/crates/boop-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#amm_config; -pub(crate) mod r#bonding_curve; -pub(crate) mod r#config; -pub(crate) mod r#locked_cp_liquidity_state; - -pub use self::{r#amm_config::*, r#bonding_curve::*, r#config::*, r#locked_cp_liquidity_state::*}; diff --git a/crates/boop-parser/src/generated_sdk/errors/boop.rs b/crates/boop-parser/src/generated_sdk/errors/boop.rs deleted file mode 100644 index 698ac073..00000000 --- a/crates/boop-parser/src/generated_sdk/errors/boop.rs +++ /dev/null @@ -1,126 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum BoopError { - /// 6000 - Amount in too low - #[error("Amount in too low")] - AmountInTooLow = 0x1770, - /// 6001 - Amount out too low - #[error("Amount out too low")] - AmountOutTooLow = 0x1771, - /// 6002 - Config not initialized - #[error("Config not initialized")] - ConfigNotInitialized = 0x1772, - /// 6003 - Creator is not provided - #[error("Creator is not provided")] - CreatorIsNotProvided = 0x1773, - /// 6004 - Damping term too low - #[error("Damping term too low")] - DampingTermTooLow = 0x1774, - /// 6005 - First buy must be at most 50% of the total supply - #[error("First buy must be at most 50% of the total supply")] - FirstBuyMustBeAtMost50PercentOfTotalSupply = 0x1775, - /// 6006 - Graduation fee relative to graduation target is too high - #[error("Graduation fee relative to graduation target is too high")] - GraduationFeeRelativeToTargetIsTooHigh = 0x1776, - /// 6007 - Invalid bonding curve status - #[error("Invalid bonding curve status")] - InvalidBondingCurveStatus = 0x1777, - /// 6008 - Insufficient tokens to transfer out of the bonding curve - #[error("Insufficient tokens to transfer out of the bonding curve")] - InsufficientTokensOut = 0x1778, - /// 6009 - Invalid mint - #[error("Invalid mint")] - InvalidMint = 0x1779, - /// 6010 - Invalid protocol fee recipient - #[error("Invalid protocol fee recipient")] - InvalidProtocolFeeRecipient = 0x177a, - /// 6011 - Max basis points off graduation price too high - #[error("Max basis points off graduation price too high")] - MaxBasisPointsOffGraduationPriceTooHigh = 0x177b, - /// 6012 - Max graduation price deviation basis points too high - #[error("Max graduation price deviation basis points too high")] - MaxGraduationPriceDeviationBasisPointsTooHigh = 0x177c, - /// 6013 - Max swap amount for pool price correction basis points too high - #[error("Max swap amount for pool price correction basis points too high")] - MaxSwapAmountForPoolPriceCorrectionBasisPointsTooHigh = 0x177d, - /// 6014 - Mint is larger than or equal to native mint - #[error("Mint is larger than or equal to native mint")] - MintIsLargerThanOrEqualToNativeMint = 0x177e, - /// 6015 - No authority transfer in progress - #[error("No authority transfer in progress")] - NoAuthorityTransferInProgress = 0x177f, - /// 6016 - LP Token amount is too low - #[error("LP Token amount is too low")] - NothingToDeposit = 0x1780, - /// 6017 - Nothing to split - #[error("Nothing to split")] - NothingToSplit = 0x1781, - /// 6018 - Nothing to lock - #[error("Nothing to lock")] - NothingToLock = 0x1782, - /// 6019 - Operator already added - #[error("Operator already added")] - OperatorAlreadyAdded = 0x1783, - /// 6020 - Operator does not exist - #[error("Operator does not exist")] - OperatorDoesNotExist = 0x1784, - /// 6021 - Paused - #[error("Paused")] - Paused = 0x1785, - /// 6022 - Pool is already created and has a price out of range when attempting to deposit liquidity - #[error( - "Pool is already created and has a price out of range when attempting to deposit liquidity" - )] - PoolPriceOutOfRange = 0x1786, - /// 6023 - Swap fee basis points too high - #[error("Swap fee basis points too high")] - SwapFeeBasisPointsTooHigh = 0x1787, - /// 6024 - Swap amount exceeds the reasonable limit to leave as liquidity - #[error("Swap amount exceeds the reasonable limit to leave as liquidity")] - SwapAmountTooHigh = 0x1788, - /// 6025 - Token amount for Raydium liquidity too high - #[error("Token amount for Raydium liquidity too high")] - TokenAmountForRaydiumLiquidityTooHigh = 0x1789, - /// 6026 - Token for stakers basis points too high - #[error("Token for stakers basis points too high")] - TokenForStakersBasisPointsTooHigh = 0x178a, - /// 6027 - Token graduated - #[error("Token graduated")] - TokenGraduated = 0x178b, - /// 6028 - Token name too long - #[error("Token name too long")] - TokenNameTooLong = 0x178c, - /// 6029 - Token name too short - #[error("Token name too short")] - TokenNameTooShort = 0x178d, - /// 6030 - Token symbol too long - #[error("Token symbol too long")] - TokenSymbolTooLong = 0x178e, - /// 6031 - Token symbol too short - #[error("Token symbol too short")] - TokenSymbolTooShort = 0x178f, - /// 6032 - Unauthorized - #[error("Unauthorized")] - Unauthorized = 0x1790, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for BoopError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for BoopError { - fn type_of() -> &'static str { "BoopError" } -} diff --git a/crates/boop-parser/src/generated_sdk/errors/mod.rs b/crates/boop-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 99193457..00000000 --- a/crates/boop-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod boop; - -pub use self::boop::BoopError; diff --git a/crates/boop-parser/src/generated_sdk/instructions/add_operators.rs b/crates/boop-parser/src/generated_sdk/instructions/add_operators.rs deleted file mode 100644 index 4eb0196a..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/add_operators.rs +++ /dev/null @@ -1,397 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct AddOperators { - pub config: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl AddOperators { - pub fn instruction( - &self, - args: AddOperatorsInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddOperatorsInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new(self.authority, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddOperatorsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddOperatorsInstructionData { - discriminator: [u8; 8], -} - -impl AddOperatorsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [165, 199, 62, 214, 81, 54, 4, 150], - } - } -} - -impl Default for AddOperatorsInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddOperatorsInstructionArgs { - pub operators: Vec, -} - -/// Instruction builder for `AddOperators`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` authority -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct AddOperatorsBuilder { - config: Option, - authority: Option, - system_program: Option, - operators: Option>, - __remaining_accounts: Vec, -} - -impl AddOperatorsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn operators(&mut self, operators: Vec) -> &mut Self { - self.operators = Some(operators); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddOperators { - config: self.config.expect("config is not set"), - authority: self.authority.expect("authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = AddOperatorsInstructionArgs { - operators: self.operators.clone().expect("operators is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_operators` CPI accounts. -pub struct AddOperatorsCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_operators` CPI instruction. -pub struct AddOperatorsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddOperatorsInstructionArgs, -} - -impl<'a, 'b> AddOperatorsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddOperatorsCpiAccounts<'a, 'b>, - args: AddOperatorsInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - authority: accounts.authority, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddOperatorsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddOperators` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` authority -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct AddOperatorsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddOperatorsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddOperatorsCpiBuilderInstruction { - __program: program, - config: None, - authority: None, - system_program: None, - operators: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn operators(&mut self, operators: Vec) -> &mut Self { - self.instruction.operators = Some(operators); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddOperatorsInstructionArgs { - operators: self - .instruction - .operators - .clone() - .expect("operators is not set"), - }; - let instruction = AddOperatorsCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddOperatorsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - operators: Option>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/buy_token.rs b/crates/boop-parser/src/generated_sdk/instructions/buy_token.rs deleted file mode 100644 index 640cf7dd..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/buy_token.rs +++ /dev/null @@ -1,850 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct BuyToken { - pub mint: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub trading_fees_vault: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub bonding_curve_sol_vault: solana_pubkey::Pubkey, - - pub recipient_token_account: solana_pubkey::Pubkey, - - pub buyer: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub wsol: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl BuyToken { - pub fn instruction(&self, args: BuyTokenInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: BuyTokenInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.trading_fees_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_sol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.recipient_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.buyer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.wsol, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&BuyTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyTokenInstructionData { - discriminator: [u8; 8], -} - -impl BuyTokenInstructionData { - pub fn new() -> Self { - Self { - discriminator: [138, 127, 14, 91, 38, 87, 115, 105], - } - } -} - -impl Default for BuyTokenInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyTokenInstructionArgs { - pub buy_amount: u64, - pub amount_out_min: u64, -} - -/// Instruction builder for `BuyToken`. -/// -/// ### Accounts: -/// -/// 0. `[]` mint -/// 1. `[writable]` bonding_curve -/// 2. `[writable]` trading_fees_vault -/// 3. `[writable]` bonding_curve_vault -/// 4. `[writable]` bonding_curve_sol_vault -/// 5. `[]` recipient_token_account -/// 6. `[writable, signer]` buyer -/// 7. `[]` config -/// 8. `[]` vault_authority -/// 9. `[optional]` wsol (default to `So11111111111111111111111111111111111111112`) -/// 10. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 12. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -#[derive(Clone, Debug, Default)] -pub struct BuyTokenBuilder { - mint: Option, - bonding_curve: Option, - trading_fees_vault: Option, - bonding_curve_vault: Option, - bonding_curve_sol_vault: Option, - recipient_token_account: Option, - buyer: Option, - config: Option, - vault_authority: Option, - wsol: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - buy_amount: Option, - amount_out_min: Option, - __remaining_accounts: Vec, -} - -impl BuyTokenBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn trading_fees_vault(&mut self, trading_fees_vault: solana_pubkey::Pubkey) -> &mut Self { - self.trading_fees_vault = Some(trading_fees_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_sol_vault( - &mut self, - bonding_curve_sol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_sol_vault = Some(bonding_curve_sol_vault); - self - } - - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account = Some(recipient_token_account); - self - } - - #[inline(always)] - pub fn buyer(&mut self, buyer: solana_pubkey::Pubkey) -> &mut Self { - self.buyer = Some(buyer); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - /// `[optional account, default to 'So11111111111111111111111111111111111111112']` - #[inline(always)] - pub fn wsol(&mut self, wsol: solana_pubkey::Pubkey) -> &mut Self { - self.wsol = Some(wsol); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn buy_amount(&mut self, buy_amount: u64) -> &mut Self { - self.buy_amount = Some(buy_amount); - self - } - - #[inline(always)] - pub fn amount_out_min(&mut self, amount_out_min: u64) -> &mut Self { - self.amount_out_min = Some(amount_out_min); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = BuyToken { - mint: self.mint.expect("mint is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - trading_fees_vault: self - .trading_fees_vault - .expect("trading_fees_vault is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - bonding_curve_sol_vault: self - .bonding_curve_sol_vault - .expect("bonding_curve_sol_vault is not set"), - recipient_token_account: self - .recipient_token_account - .expect("recipient_token_account is not set"), - buyer: self.buyer.expect("buyer is not set"), - config: self.config.expect("config is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - wsol: self.wsol.unwrap_or(solana_pubkey::pubkey!( - "So11111111111111111111111111111111111111112" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - }; - let args = BuyTokenInstructionArgs { - buy_amount: self.buy_amount.clone().expect("buy_amount is not set"), - amount_out_min: self - .amount_out_min - .clone() - .expect("amount_out_min is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `buy_token` CPI accounts. -pub struct BuyTokenCpiAccounts<'a, 'b> { - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub trading_fees_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub buyer: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub wsol: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `buy_token` CPI instruction. -pub struct BuyTokenCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub trading_fees_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub buyer: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub wsol: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: BuyTokenInstructionArgs, -} - -impl<'a, 'b> BuyTokenCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: BuyTokenCpiAccounts<'a, 'b>, - args: BuyTokenInstructionArgs, - ) -> Self { - Self { - __program: program, - mint: accounts.mint, - bonding_curve: accounts.bonding_curve, - trading_fees_vault: accounts.trading_fees_vault, - bonding_curve_vault: accounts.bonding_curve_vault, - bonding_curve_sol_vault: accounts.bonding_curve_sol_vault, - recipient_token_account: accounts.recipient_token_account, - buyer: accounts.buyer, - config: accounts.config, - vault_authority: accounts.vault_authority, - wsol: accounts.wsol, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.trading_fees_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_sol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.recipient_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.buyer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.wsol.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&BuyTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.trading_fees_vault.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.bonding_curve_sol_vault.clone()); - account_infos.push(self.recipient_token_account.clone()); - account_infos.push(self.buyer.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.wsol.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `BuyToken` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` mint -/// 1. `[writable]` bonding_curve -/// 2. `[writable]` trading_fees_vault -/// 3. `[writable]` bonding_curve_vault -/// 4. `[writable]` bonding_curve_sol_vault -/// 5. `[]` recipient_token_account -/// 6. `[writable, signer]` buyer -/// 7. `[]` config -/// 8. `[]` vault_authority -/// 9. `[]` wsol -/// 10. `[]` system_program -/// 11. `[]` token_program -/// 12. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct BuyTokenCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> BuyTokenCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(BuyTokenCpiBuilderInstruction { - __program: program, - mint: None, - bonding_curve: None, - trading_fees_vault: None, - bonding_curve_vault: None, - bonding_curve_sol_vault: None, - recipient_token_account: None, - buyer: None, - config: None, - vault_authority: None, - wsol: None, - system_program: None, - token_program: None, - associated_token_program: None, - buy_amount: None, - amount_out_min: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn trading_fees_vault( - &mut self, - trading_fees_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.trading_fees_vault = Some(trading_fees_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_sol_vault( - &mut self, - bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_sol_vault = Some(bonding_curve_sol_vault); - self - } - - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account = Some(recipient_token_account); - self - } - - #[inline(always)] - pub fn buyer(&mut self, buyer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.buyer = Some(buyer); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn wsol(&mut self, wsol: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.wsol = Some(wsol); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn buy_amount(&mut self, buy_amount: u64) -> &mut Self { - self.instruction.buy_amount = Some(buy_amount); - self - } - - #[inline(always)] - pub fn amount_out_min(&mut self, amount_out_min: u64) -> &mut Self { - self.instruction.amount_out_min = Some(amount_out_min); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = BuyTokenInstructionArgs { - buy_amount: self - .instruction - .buy_amount - .clone() - .expect("buy_amount is not set"), - amount_out_min: self - .instruction - .amount_out_min - .clone() - .expect("amount_out_min is not set"), - }; - let instruction = BuyTokenCpi { - __program: self.instruction.__program, - - mint: self.instruction.mint.expect("mint is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - trading_fees_vault: self - .instruction - .trading_fees_vault - .expect("trading_fees_vault is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - bonding_curve_sol_vault: self - .instruction - .bonding_curve_sol_vault - .expect("bonding_curve_sol_vault is not set"), - - recipient_token_account: self - .instruction - .recipient_token_account - .expect("recipient_token_account is not set"), - - buyer: self.instruction.buyer.expect("buyer is not set"), - - config: self.instruction.config.expect("config is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - wsol: self.instruction.wsol.expect("wsol is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct BuyTokenCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - trading_fees_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_sol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - buyer: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - wsol: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - buy_amount: Option, - amount_out_min: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/cancel_authority_transfer.rs b/crates/boop-parser/src/generated_sdk/instructions/cancel_authority_transfer.rs deleted file mode 100644 index 0098d010..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/cancel_authority_transfer.rs +++ /dev/null @@ -1,355 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CancelAuthorityTransfer { - pub authority: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl CancelAuthorityTransfer { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CancelAuthorityTransferInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CancelAuthorityTransferInstructionData { - discriminator: [u8; 8], -} - -impl CancelAuthorityTransferInstructionData { - pub fn new() -> Self { - Self { - discriminator: [94, 131, 125, 184, 183, 24, 125, 229], - } - } -} - -impl Default for CancelAuthorityTransferInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CancelAuthorityTransfer`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[writable]` config -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CancelAuthorityTransferBuilder { - authority: Option, - config: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl CancelAuthorityTransferBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CancelAuthorityTransfer { - authority: self.authority.expect("authority is not set"), - config: self.config.expect("config is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `cancel_authority_transfer` CPI accounts. -pub struct CancelAuthorityTransferCpiAccounts<'a, 'b> { - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `cancel_authority_transfer` CPI instruction. -pub struct CancelAuthorityTransferCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CancelAuthorityTransferCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CancelAuthorityTransferCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - authority: accounts.authority, - config: accounts.config, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CancelAuthorityTransferInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CancelAuthorityTransfer` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[writable]` config -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct CancelAuthorityTransferCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CancelAuthorityTransferCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CancelAuthorityTransferCpiBuilderInstruction { - __program: program, - authority: None, - config: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CancelAuthorityTransferCpi { - __program: self.instruction.__program, - - authority: self.instruction.authority.expect("authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CancelAuthorityTransferCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/close_bonding_curve_vault.rs b/crates/boop-parser/src/generated_sdk/instructions/close_bonding_curve_vault.rs deleted file mode 100644 index 82e6e08f..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/close_bonding_curve_vault.rs +++ /dev/null @@ -1,731 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CloseBondingCurveVault { - pub config: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub recipient_token_account: solana_pubkey::Pubkey, - - pub recipient: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - /// System program for creating associated token if needed - pub system_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl CloseBondingCurveVault { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.operator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.recipient, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CloseBondingCurveVaultInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseBondingCurveVaultInstructionData { - discriminator: [u8; 8], -} - -impl CloseBondingCurveVaultInstructionData { - pub fn new() -> Self { - Self { - discriminator: [189, 71, 189, 239, 113, 66, 59, 189], - } - } -} - -impl Default for CloseBondingCurveVaultInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CloseBondingCurveVault`. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable, signer]` operator -/// 2. `[]` vault_authority -/// 3. `[writable]` bonding_curve -/// 4. `[writable]` bonding_curve_vault -/// 5. `[]` mint -/// 6. `[writable]` recipient_token_account -/// 7. `[writable]` recipient -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 10. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 11. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CloseBondingCurveVaultBuilder { - config: Option, - operator: Option, - vault_authority: Option, - bonding_curve: Option, - bonding_curve_vault: Option, - mint: Option, - recipient_token_account: Option, - recipient: Option, - token_program: Option, - system_program: Option, - associated_token_program: Option, - rent: Option, - __remaining_accounts: Vec, -} - -impl CloseBondingCurveVaultBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account = Some(recipient_token_account); - self - } - - #[inline(always)] - pub fn recipient(&mut self, recipient: solana_pubkey::Pubkey) -> &mut Self { - self.recipient = Some(recipient); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program for creating associated token if needed - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CloseBondingCurveVault { - config: self.config.expect("config is not set"), - operator: self.operator.expect("operator is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - mint: self.mint.expect("mint is not set"), - recipient_token_account: self - .recipient_token_account - .expect("recipient_token_account is not set"), - recipient: self.recipient.expect("recipient is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_bonding_curve_vault` CPI accounts. -pub struct CloseBondingCurveVaultCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub recipient: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program for creating associated token if needed - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_bonding_curve_vault` CPI instruction. -pub struct CloseBondingCurveVaultCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub recipient: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program for creating associated token if needed - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CloseBondingCurveVaultCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CloseBondingCurveVaultCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - config: accounts.config, - operator: accounts.operator, - vault_authority: accounts.vault_authority, - bonding_curve: accounts.bonding_curve, - bonding_curve_vault: accounts.bonding_curve_vault, - mint: accounts.mint, - recipient_token_account: accounts.recipient_token_account, - recipient: accounts.recipient, - token_program: accounts.token_program, - system_program: accounts.system_program, - associated_token_program: accounts.associated_token_program, - rent: accounts.rent, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CloseBondingCurveVaultInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.recipient_token_account.clone()); - account_infos.push(self.recipient.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CloseBondingCurveVault` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable, signer]` operator -/// 2. `[]` vault_authority -/// 3. `[writable]` bonding_curve -/// 4. `[writable]` bonding_curve_vault -/// 5. `[]` mint -/// 6. `[writable]` recipient_token_account -/// 7. `[writable]` recipient -/// 8. `[]` token_program -/// 9. `[]` system_program -/// 10. `[]` associated_token_program -/// 11. `[]` rent -#[derive(Clone, Debug)] -pub struct CloseBondingCurveVaultCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CloseBondingCurveVaultCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CloseBondingCurveVaultCpiBuilderInstruction { - __program: program, - config: None, - operator: None, - vault_authority: None, - bonding_curve: None, - bonding_curve_vault: None, - mint: None, - recipient_token_account: None, - recipient: None, - token_program: None, - system_program: None, - associated_token_program: None, - rent: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account = Some(recipient_token_account); - self - } - - #[inline(always)] - pub fn recipient(&mut self, recipient: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.recipient = Some(recipient); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// System program for creating associated token if needed - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CloseBondingCurveVaultCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - recipient_token_account: self - .instruction - .recipient_token_account - .expect("recipient_token_account is not set"), - - recipient: self.instruction.recipient.expect("recipient is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CloseBondingCurveVaultCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/collect_trading_fees.rs b/crates/boop-parser/src/generated_sdk/instructions/collect_trading_fees.rs deleted file mode 100644 index 4aebfe73..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/collect_trading_fees.rs +++ /dev/null @@ -1,1287 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CollectTradingFees { - pub operator: solana_pubkey::Pubkey, - - pub protocol_fee_recipient: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub lock_program: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - /// Fee token account - pub fee_nft_account: solana_pubkey::Pubkey, - /// Store the locked the information of liquidity - pub locked_liquidity: solana_pubkey::Pubkey, - - pub cpmm_program: solana_pubkey::Pubkey, - - pub cp_authority: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - /// lp mint - /// address = pool_state.lp_mint - pub lp_mint: solana_pubkey::Pubkey, - /// The token account for receive token_0 - pub recipient_token0_account: solana_pubkey::Pubkey, - /// The token account for receive token_1 - pub recipient_token1_account: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_0 - pub token0_vault: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_1 - pub token1_vault: solana_pubkey::Pubkey, - /// The mint of token_0 vault - pub vault0_mint: solana_pubkey::Pubkey, - /// The mint of token_1 vault - pub vault1_mint: solana_pubkey::Pubkey, - /// locked lp token account - pub locked_lp_vault: solana_pubkey::Pubkey, - /// System program - pub system_program: solana_pubkey::Pubkey, - /// Associated token program - pub associated_token_program: solana_pubkey::Pubkey, - /// token Program - pub token_program: solana_pubkey::Pubkey, - /// Token program 2022 - pub token_program2022: solana_pubkey::Pubkey, - /// memo program - pub memo_program: solana_pubkey::Pubkey, -} - -impl CollectTradingFees { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(24 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.operator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.protocol_fee_recipient, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lock_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.locked_liquidity, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cpmm_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cp_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token0_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token1_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.locked_lp_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CollectTradingFeesInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectTradingFeesInstructionData { - discriminator: [u8; 8], -} - -impl CollectTradingFeesInstructionData { - pub fn new() -> Self { - Self { - discriminator: [189, 38, 205, 234, 81, 77, 25, 1], - } - } -} - -impl Default for CollectTradingFeesInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CollectTradingFees`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` operator -/// 1. `[]` protocol_fee_recipient -/// 2. `[]` config -/// 3. `[optional]` lock_program (default to `LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE`) -/// 4. `[]` vault_authority -/// 5. `[]` authority -/// 6. `[]` fee_nft_account -/// 7. `[writable]` locked_liquidity -/// 8. `[optional]` cpmm_program (default to `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C`) -/// 9. `[]` cp_authority -/// 10. `[writable]` pool_state -/// 11. `[writable]` lp_mint -/// 12. `[writable]` recipient_token0_account -/// 13. `[writable]` recipient_token1_account -/// 14. `[writable]` token0_vault -/// 15. `[writable]` token1_vault -/// 16. `[]` vault0_mint -/// 17. `[]` vault1_mint -/// 18. `[writable]` locked_lp_vault -/// 19. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 20. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 21. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 22. `[optional]` token_program2022 (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 23. `[optional]` memo_program (default to `MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr`) -#[derive(Clone, Debug, Default)] -pub struct CollectTradingFeesBuilder { - operator: Option, - protocol_fee_recipient: Option, - config: Option, - lock_program: Option, - vault_authority: Option, - authority: Option, - fee_nft_account: Option, - locked_liquidity: Option, - cpmm_program: Option, - cp_authority: Option, - pool_state: Option, - lp_mint: Option, - recipient_token0_account: Option, - recipient_token1_account: Option, - token0_vault: Option, - token1_vault: Option, - vault0_mint: Option, - vault1_mint: Option, - locked_lp_vault: Option, - system_program: Option, - associated_token_program: Option, - token_program: Option, - token_program2022: Option, - memo_program: Option, - __remaining_accounts: Vec, -} - -impl CollectTradingFeesBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient( - &mut self, - protocol_fee_recipient: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_fee_recipient = Some(protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to 'LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE']` - #[inline(always)] - pub fn lock_program(&mut self, lock_program: solana_pubkey::Pubkey) -> &mut Self { - self.lock_program = Some(lock_program); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Fee token account - #[inline(always)] - pub fn fee_nft_account(&mut self, fee_nft_account: solana_pubkey::Pubkey) -> &mut Self { - self.fee_nft_account = Some(fee_nft_account); - self - } - - /// Store the locked the information of liquidity - #[inline(always)] - pub fn locked_liquidity(&mut self, locked_liquidity: solana_pubkey::Pubkey) -> &mut Self { - self.locked_liquidity = Some(locked_liquidity); - self - } - - /// `[optional account, default to 'CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C']` - #[inline(always)] - pub fn cpmm_program(&mut self, cpmm_program: solana_pubkey::Pubkey) -> &mut Self { - self.cpmm_program = Some(cpmm_program); - self - } - - #[inline(always)] - pub fn cp_authority(&mut self, cp_authority: solana_pubkey::Pubkey) -> &mut Self { - self.cp_authority = Some(cp_authority); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// lp mint - /// address = pool_state.lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// The token account for receive token_0 - #[inline(always)] - pub fn recipient_token0_account( - &mut self, - recipient_token0_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token0_account = Some(recipient_token0_account); - self - } - - /// The token account for receive token_1 - #[inline(always)] - pub fn recipient_token1_account( - &mut self, - recipient_token1_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token1_account = Some(recipient_token1_account); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - /// locked lp token account - #[inline(always)] - pub fn locked_lp_vault(&mut self, locked_lp_vault: solana_pubkey::Pubkey) -> &mut Self { - self.locked_lp_vault = Some(locked_lp_vault); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Associated token program - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token Program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// Token program 2022 - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - /// `[optional account, default to 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr']` - /// memo program - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectTradingFees { - operator: self.operator.expect("operator is not set"), - protocol_fee_recipient: self - .protocol_fee_recipient - .expect("protocol_fee_recipient is not set"), - config: self.config.expect("config is not set"), - lock_program: self.lock_program.unwrap_or(solana_pubkey::pubkey!( - "LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE" - )), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - authority: self.authority.expect("authority is not set"), - fee_nft_account: self.fee_nft_account.expect("fee_nft_account is not set"), - locked_liquidity: self.locked_liquidity.expect("locked_liquidity is not set"), - cpmm_program: self.cpmm_program.unwrap_or(solana_pubkey::pubkey!( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - )), - cp_authority: self.cp_authority.expect("cp_authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - recipient_token0_account: self - .recipient_token0_account - .expect("recipient_token0_account is not set"), - recipient_token1_account: self - .recipient_token1_account - .expect("recipient_token1_account is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - locked_lp_vault: self.locked_lp_vault.expect("locked_lp_vault is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self.token_program2022.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - memo_program: self.memo_program.unwrap_or(solana_pubkey::pubkey!( - "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `collect_trading_fees` CPI accounts. -pub struct CollectTradingFeesCpiAccounts<'a, 'b> { - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub lock_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Fee token account - pub fee_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Store the locked the information of liquidity - pub locked_liquidity: &'b solana_account_info::AccountInfo<'a>, - - pub cpmm_program: &'b solana_account_info::AccountInfo<'a>, - - pub cp_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// lp mint - /// address = pool_state.lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for receive token_0 - pub recipient_token0_account: &'b solana_account_info::AccountInfo<'a>, - /// The token account for receive token_1 - pub recipient_token1_account: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// locked lp token account - pub locked_lp_vault: &'b solana_account_info::AccountInfo<'a>, - /// System program - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// token Program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program 2022 - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// memo program - pub memo_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_trading_fees` CPI instruction. -pub struct CollectTradingFeesCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub lock_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Fee token account - pub fee_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Store the locked the information of liquidity - pub locked_liquidity: &'b solana_account_info::AccountInfo<'a>, - - pub cpmm_program: &'b solana_account_info::AccountInfo<'a>, - - pub cp_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// lp mint - /// address = pool_state.lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for receive token_0 - pub recipient_token0_account: &'b solana_account_info::AccountInfo<'a>, - /// The token account for receive token_1 - pub recipient_token1_account: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// locked lp token account - pub locked_lp_vault: &'b solana_account_info::AccountInfo<'a>, - /// System program - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// token Program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program 2022 - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// memo program - pub memo_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CollectTradingFeesCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectTradingFeesCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - operator: accounts.operator, - protocol_fee_recipient: accounts.protocol_fee_recipient, - config: accounts.config, - lock_program: accounts.lock_program, - vault_authority: accounts.vault_authority, - authority: accounts.authority, - fee_nft_account: accounts.fee_nft_account, - locked_liquidity: accounts.locked_liquidity, - cpmm_program: accounts.cpmm_program, - cp_authority: accounts.cp_authority, - pool_state: accounts.pool_state, - lp_mint: accounts.lp_mint, - recipient_token0_account: accounts.recipient_token0_account, - recipient_token1_account: accounts.recipient_token1_account, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - locked_lp_vault: accounts.locked_lp_vault, - system_program: accounts.system_program, - associated_token_program: accounts.associated_token_program, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - memo_program: accounts.memo_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(24 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.protocol_fee_recipient.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lock_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.locked_liquidity.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cpmm_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cp_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token0_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token1_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.locked_lp_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CollectTradingFeesInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(25 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.protocol_fee_recipient.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.lock_program.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.fee_nft_account.clone()); - account_infos.push(self.locked_liquidity.clone()); - account_infos.push(self.cpmm_program.clone()); - account_infos.push(self.cp_authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.recipient_token0_account.clone()); - account_infos.push(self.recipient_token1_account.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - account_infos.push(self.locked_lp_vault.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.memo_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectTradingFees` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` operator -/// 1. `[]` protocol_fee_recipient -/// 2. `[]` config -/// 3. `[]` lock_program -/// 4. `[]` vault_authority -/// 5. `[]` authority -/// 6. `[]` fee_nft_account -/// 7. `[writable]` locked_liquidity -/// 8. `[]` cpmm_program -/// 9. `[]` cp_authority -/// 10. `[writable]` pool_state -/// 11. `[writable]` lp_mint -/// 12. `[writable]` recipient_token0_account -/// 13. `[writable]` recipient_token1_account -/// 14. `[writable]` token0_vault -/// 15. `[writable]` token1_vault -/// 16. `[]` vault0_mint -/// 17. `[]` vault1_mint -/// 18. `[writable]` locked_lp_vault -/// 19. `[]` system_program -/// 20. `[]` associated_token_program -/// 21. `[]` token_program -/// 22. `[]` token_program2022 -/// 23. `[]` memo_program -#[derive(Clone, Debug)] -pub struct CollectTradingFeesCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectTradingFeesCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectTradingFeesCpiBuilderInstruction { - __program: program, - operator: None, - protocol_fee_recipient: None, - config: None, - lock_program: None, - vault_authority: None, - authority: None, - fee_nft_account: None, - locked_liquidity: None, - cpmm_program: None, - cp_authority: None, - pool_state: None, - lp_mint: None, - recipient_token0_account: None, - recipient_token1_account: None, - token0_vault: None, - token1_vault: None, - vault0_mint: None, - vault1_mint: None, - locked_lp_vault: None, - system_program: None, - associated_token_program: None, - token_program: None, - token_program2022: None, - memo_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient( - &mut self, - protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_fee_recipient = Some(protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn lock_program( - &mut self, - lock_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_program = Some(lock_program); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Fee token account - #[inline(always)] - pub fn fee_nft_account( - &mut self, - fee_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_nft_account = Some(fee_nft_account); - self - } - - /// Store the locked the information of liquidity - #[inline(always)] - pub fn locked_liquidity( - &mut self, - locked_liquidity: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.locked_liquidity = Some(locked_liquidity); - self - } - - #[inline(always)] - pub fn cpmm_program( - &mut self, - cpmm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpmm_program = Some(cpmm_program); - self - } - - #[inline(always)] - pub fn cp_authority( - &mut self, - cp_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cp_authority = Some(cp_authority); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// lp mint - /// address = pool_state.lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// The token account for receive token_0 - #[inline(always)] - pub fn recipient_token0_account( - &mut self, - recipient_token0_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token0_account = Some(recipient_token0_account); - self - } - - /// The token account for receive token_1 - #[inline(always)] - pub fn recipient_token1_account( - &mut self, - recipient_token1_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token1_account = Some(recipient_token1_account); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - /// locked lp token account - #[inline(always)] - pub fn locked_lp_vault( - &mut self, - locked_lp_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.locked_lp_vault = Some(locked_lp_vault); - self - } - - /// System program - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Associated token program - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// token Program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Token program 2022 - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - /// memo program - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CollectTradingFeesCpi { - __program: self.instruction.__program, - - operator: self.instruction.operator.expect("operator is not set"), - - protocol_fee_recipient: self - .instruction - .protocol_fee_recipient - .expect("protocol_fee_recipient is not set"), - - config: self.instruction.config.expect("config is not set"), - - lock_program: self - .instruction - .lock_program - .expect("lock_program is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - fee_nft_account: self - .instruction - .fee_nft_account - .expect("fee_nft_account is not set"), - - locked_liquidity: self - .instruction - .locked_liquidity - .expect("locked_liquidity is not set"), - - cpmm_program: self - .instruction - .cpmm_program - .expect("cpmm_program is not set"), - - cp_authority: self - .instruction - .cp_authority - .expect("cp_authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - recipient_token0_account: self - .instruction - .recipient_token0_account - .expect("recipient_token0_account is not set"), - - recipient_token1_account: self - .instruction - .recipient_token1_account - .expect("recipient_token1_account is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - - locked_lp_vault: self - .instruction - .locked_lp_vault - .expect("locked_lp_vault is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectTradingFeesCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_fee_recipient: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - locked_liquidity: Option<&'b solana_account_info::AccountInfo<'a>>, - cpmm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - cp_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token0_account: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token1_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - locked_lp_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/complete_authority_transfer.rs b/crates/boop-parser/src/generated_sdk/instructions/complete_authority_transfer.rs deleted file mode 100644 index 4a15d17d..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/complete_authority_transfer.rs +++ /dev/null @@ -1,363 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CompleteAuthorityTransfer { - pub pending_authority: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl CompleteAuthorityTransfer { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pending_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CompleteAuthorityTransferInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CompleteAuthorityTransferInstructionData { - discriminator: [u8; 8], -} - -impl CompleteAuthorityTransferInstructionData { - pub fn new() -> Self { - Self { - discriminator: [81, 233, 91, 132, 175, 31, 151, 141], - } - } -} - -impl Default for CompleteAuthorityTransferInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CompleteAuthorityTransfer`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` pending_authority -/// 1. `[writable]` config -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CompleteAuthorityTransferBuilder { - pending_authority: Option, - config: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl CompleteAuthorityTransferBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pending_authority(&mut self, pending_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pending_authority = Some(pending_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CompleteAuthorityTransfer { - pending_authority: self - .pending_authority - .expect("pending_authority is not set"), - config: self.config.expect("config is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `complete_authority_transfer` CPI accounts. -pub struct CompleteAuthorityTransferCpiAccounts<'a, 'b> { - pub pending_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `complete_authority_transfer` CPI instruction. -pub struct CompleteAuthorityTransferCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pending_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CompleteAuthorityTransferCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CompleteAuthorityTransferCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pending_authority: accounts.pending_authority, - config: accounts.config, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pending_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CompleteAuthorityTransferInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pending_authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CompleteAuthorityTransfer` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` pending_authority -/// 1. `[writable]` config -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct CompleteAuthorityTransferCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CompleteAuthorityTransferCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CompleteAuthorityTransferCpiBuilderInstruction { - __program: program, - pending_authority: None, - config: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pending_authority( - &mut self, - pending_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pending_authority = Some(pending_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CompleteAuthorityTransferCpi { - __program: self.instruction.__program, - - pending_authority: self - .instruction - .pending_authority - .expect("pending_authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CompleteAuthorityTransferCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pending_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/create_raydium_pool.rs b/crates/boop-parser/src/generated_sdk/instructions/create_raydium_pool.rs deleted file mode 100644 index d1d2125a..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/create_raydium_pool.rs +++ /dev/null @@ -1,1166 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateRaydiumPool { - pub cpmm_program: solana_pubkey::Pubkey, - /// Which config the pool belongs to. - pub amm_config: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub token0_mint: solana_pubkey::Pubkey, - /// Token_1 mint, the key must be greater than token_0 mint. - pub token1_mint: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub bonding_curve_wsol_vault: solana_pubkey::Pubkey, - - pub creator_lp_token: solana_pubkey::Pubkey, - - pub token0_vault: solana_pubkey::Pubkey, - - pub token1_vault: solana_pubkey::Pubkey, - /// create pool fee account - pub create_pool_fee: solana_pubkey::Pubkey, - - pub observation_state: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_program: solana_pubkey::Pubkey, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: solana_pubkey::Pubkey, - /// To create a new program account - pub system_program: solana_pubkey::Pubkey, - /// Sysvar for program account - pub rent: solana_pubkey::Pubkey, -} - -impl CreateRaydiumPool { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(22 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cpmm_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_wsol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_lp_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.create_pool_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.operator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateRaydiumPoolInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateRaydiumPoolInstructionData { - discriminator: [u8; 8], -} - -impl CreateRaydiumPoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [65, 45, 119, 77, 204, 178, 84, 2], - } - } -} - -impl Default for CreateRaydiumPoolInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateRaydiumPool`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` cpmm_program (default to `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C`) -/// 1. `[]` amm_config -/// 2. `[]` authority -/// 3. `[writable]` pool_state -/// 4. `[writable]` token0_mint -/// 5. `[optional]` token1_mint (default to `So11111111111111111111111111111111111111112`) -/// 6. `[writable]` lp_mint -/// 7. `[writable]` vault_authority -/// 8. `[writable]` bonding_curve -/// 9. `[writable]` bonding_curve_vault -/// 10. `[writable]` bonding_curve_wsol_vault -/// 11. `[writable]` creator_lp_token -/// 12. `[writable]` token0_vault -/// 13. `[writable]` token1_vault -/// 14. `[writable, optional]` create_pool_fee (default to `DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8`) -/// 15. `[writable]` observation_state -/// 16. `[writable, signer]` operator -/// 17. `[]` config -/// 18. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 19. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 20. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 21. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateRaydiumPoolBuilder { - cpmm_program: Option, - amm_config: Option, - authority: Option, - pool_state: Option, - token0_mint: Option, - token1_mint: Option, - lp_mint: Option, - vault_authority: Option, - bonding_curve: Option, - bonding_curve_vault: Option, - bonding_curve_wsol_vault: Option, - creator_lp_token: Option, - token0_vault: Option, - token1_vault: Option, - create_pool_fee: Option, - observation_state: Option, - operator: Option, - config: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - rent: Option, - __remaining_accounts: Vec, -} - -impl CreateRaydiumPoolBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C']` - #[inline(always)] - pub fn cpmm_program(&mut self, cpmm_program: solana_pubkey::Pubkey) -> &mut Self { - self.cpmm_program = Some(cpmm_program); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn token0_mint(&mut self, token0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token0_mint = Some(token0_mint); - self - } - - /// `[optional account, default to 'So11111111111111111111111111111111111111112']` - /// Token_1 mint, the key must be greater than token_0 mint. - #[inline(always)] - pub fn token1_mint(&mut self, token1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token1_mint = Some(token1_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_vault( - &mut self, - bonding_curve_wsol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_wsol_vault = Some(bonding_curve_wsol_vault); - self - } - - #[inline(always)] - pub fn creator_lp_token(&mut self, creator_lp_token: solana_pubkey::Pubkey) -> &mut Self { - self.creator_lp_token = Some(creator_lp_token); - self - } - - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - /// `[optional account, default to 'DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8']` - /// create pool fee account - #[inline(always)] - pub fn create_pool_fee(&mut self, create_pool_fee: solana_pubkey::Pubkey) -> &mut Self { - self.create_pool_fee = Some(create_pool_fee); - self - } - - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Program to create an ATA for receiving position NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// To create a new program account - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Sysvar for program account - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateRaydiumPool { - cpmm_program: self.cpmm_program.unwrap_or(solana_pubkey::pubkey!( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - )), - amm_config: self.amm_config.expect("amm_config is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - token0_mint: self.token0_mint.expect("token0_mint is not set"), - token1_mint: self.token1_mint.unwrap_or(solana_pubkey::pubkey!( - "So11111111111111111111111111111111111111112" - )), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - bonding_curve_wsol_vault: self - .bonding_curve_wsol_vault - .expect("bonding_curve_wsol_vault is not set"), - creator_lp_token: self.creator_lp_token.expect("creator_lp_token is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - create_pool_fee: self.create_pool_fee.unwrap_or(solana_pubkey::pubkey!( - "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8" - )), - observation_state: self - .observation_state - .expect("observation_state is not set"), - operator: self.operator.expect("operator is not set"), - config: self.config.expect("config is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_raydium_pool` CPI accounts. -pub struct CreateRaydiumPoolCpiAccounts<'a, 'b> { - pub cpmm_program: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub token0_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token_1 mint, the key must be greater than token_0 mint. - pub token1_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub creator_lp_token: &'b solana_account_info::AccountInfo<'a>, - - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// create pool fee account - pub create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// To create a new program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Sysvar for program account - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_raydium_pool` CPI instruction. -pub struct CreateRaydiumPoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub cpmm_program: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub token0_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token_1 mint, the key must be greater than token_0 mint. - pub token1_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub creator_lp_token: &'b solana_account_info::AccountInfo<'a>, - - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// create pool fee account - pub create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// To create a new program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Sysvar for program account - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateRaydiumPoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateRaydiumPoolCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - cpmm_program: accounts.cpmm_program, - amm_config: accounts.amm_config, - authority: accounts.authority, - pool_state: accounts.pool_state, - token0_mint: accounts.token0_mint, - token1_mint: accounts.token1_mint, - lp_mint: accounts.lp_mint, - vault_authority: accounts.vault_authority, - bonding_curve: accounts.bonding_curve, - bonding_curve_vault: accounts.bonding_curve_vault, - bonding_curve_wsol_vault: accounts.bonding_curve_wsol_vault, - creator_lp_token: accounts.creator_lp_token, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - create_pool_fee: accounts.create_pool_fee, - observation_state: accounts.observation_state, - operator: accounts.operator, - config: accounts.config, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - rent: accounts.rent, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(22 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cpmm_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_wsol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_lp_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.create_pool_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateRaydiumPoolInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(23 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.cpmm_program.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.token0_mint.clone()); - account_infos.push(self.token1_mint.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.bonding_curve_wsol_vault.clone()); - account_infos.push(self.creator_lp_token.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.create_pool_fee.clone()); - account_infos.push(self.observation_state.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateRaydiumPool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` cpmm_program -/// 1. `[]` amm_config -/// 2. `[]` authority -/// 3. `[writable]` pool_state -/// 4. `[writable]` token0_mint -/// 5. `[]` token1_mint -/// 6. `[writable]` lp_mint -/// 7. `[writable]` vault_authority -/// 8. `[writable]` bonding_curve -/// 9. `[writable]` bonding_curve_vault -/// 10. `[writable]` bonding_curve_wsol_vault -/// 11. `[writable]` creator_lp_token -/// 12. `[writable]` token0_vault -/// 13. `[writable]` token1_vault -/// 14. `[writable]` create_pool_fee -/// 15. `[writable]` observation_state -/// 16. `[writable, signer]` operator -/// 17. `[]` config -/// 18. `[]` token_program -/// 19. `[]` associated_token_program -/// 20. `[]` system_program -/// 21. `[]` rent -#[derive(Clone, Debug)] -pub struct CreateRaydiumPoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateRaydiumPoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateRaydiumPoolCpiBuilderInstruction { - __program: program, - cpmm_program: None, - amm_config: None, - authority: None, - pool_state: None, - token0_mint: None, - token1_mint: None, - lp_mint: None, - vault_authority: None, - bonding_curve: None, - bonding_curve_vault: None, - bonding_curve_wsol_vault: None, - creator_lp_token: None, - token0_vault: None, - token1_vault: None, - create_pool_fee: None, - observation_state: None, - operator: None, - config: None, - token_program: None, - associated_token_program: None, - system_program: None, - rent: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn cpmm_program( - &mut self, - cpmm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpmm_program = Some(cpmm_program); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn token0_mint( - &mut self, - token0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_mint = Some(token0_mint); - self - } - - /// Token_1 mint, the key must be greater than token_0 mint. - #[inline(always)] - pub fn token1_mint( - &mut self, - token1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_mint = Some(token1_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_vault( - &mut self, - bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_wsol_vault = Some(bonding_curve_wsol_vault); - self - } - - #[inline(always)] - pub fn creator_lp_token( - &mut self, - creator_lp_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_lp_token = Some(creator_lp_token); - self - } - - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - /// create pool fee account - #[inline(always)] - pub fn create_pool_fee( - &mut self, - create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.create_pool_fee = Some(create_pool_fee); - self - } - - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Program to create an ATA for receiving position NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// To create a new program account - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Sysvar for program account - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateRaydiumPoolCpi { - __program: self.instruction.__program, - - cpmm_program: self - .instruction - .cpmm_program - .expect("cpmm_program is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - token0_mint: self - .instruction - .token0_mint - .expect("token0_mint is not set"), - - token1_mint: self - .instruction - .token1_mint - .expect("token1_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - bonding_curve_wsol_vault: self - .instruction - .bonding_curve_wsol_vault - .expect("bonding_curve_wsol_vault is not set"), - - creator_lp_token: self - .instruction - .creator_lp_token - .expect("creator_lp_token is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - create_pool_fee: self - .instruction - .create_pool_fee - .expect("create_pool_fee is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - config: self.instruction.config.expect("config is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateRaydiumPoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - cpmm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_wsol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_lp_token: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - create_pool_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/create_raydium_random_pool.rs b/crates/boop-parser/src/generated_sdk/instructions/create_raydium_random_pool.rs deleted file mode 100644 index 3a88e5f6..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/create_raydium_random_pool.rs +++ /dev/null @@ -1,1166 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateRaydiumRandomPool { - pub cpmm_program: solana_pubkey::Pubkey, - /// Which config the pool belongs to. - pub amm_config: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub token0_mint: solana_pubkey::Pubkey, - /// Token_1 mint, the key must be greater than token_0 mint. - pub token1_mint: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub bonding_curve_wsol_vault: solana_pubkey::Pubkey, - - pub creator_lp_token: solana_pubkey::Pubkey, - - pub token0_vault: solana_pubkey::Pubkey, - - pub token1_vault: solana_pubkey::Pubkey, - /// create pool fee account - pub create_pool_fee: solana_pubkey::Pubkey, - - pub observation_state: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_program: solana_pubkey::Pubkey, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: solana_pubkey::Pubkey, - /// To create a new program account - pub system_program: solana_pubkey::Pubkey, - /// Sysvar for program account - pub rent: solana_pubkey::Pubkey, -} - -impl CreateRaydiumRandomPool { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(22 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cpmm_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_wsol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_lp_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.create_pool_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.operator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateRaydiumRandomPoolInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateRaydiumRandomPoolInstructionData { - discriminator: [u8; 8], -} - -impl CreateRaydiumRandomPoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [78, 44, 173, 29, 132, 180, 4, 172], - } - } -} - -impl Default for CreateRaydiumRandomPoolInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateRaydiumRandomPool`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` cpmm_program (default to `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C`) -/// 1. `[]` amm_config -/// 2. `[]` authority -/// 3. `[writable, signer]` pool_state -/// 4. `[writable]` token0_mint -/// 5. `[optional]` token1_mint (default to `So11111111111111111111111111111111111111112`) -/// 6. `[writable]` lp_mint -/// 7. `[writable]` vault_authority -/// 8. `[writable]` bonding_curve -/// 9. `[writable]` bonding_curve_vault -/// 10. `[writable]` bonding_curve_wsol_vault -/// 11. `[writable]` creator_lp_token -/// 12. `[writable]` token0_vault -/// 13. `[writable]` token1_vault -/// 14. `[writable, optional]` create_pool_fee (default to `DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8`) -/// 15. `[writable]` observation_state -/// 16. `[writable, signer]` operator -/// 17. `[]` config -/// 18. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 19. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 20. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 21. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateRaydiumRandomPoolBuilder { - cpmm_program: Option, - amm_config: Option, - authority: Option, - pool_state: Option, - token0_mint: Option, - token1_mint: Option, - lp_mint: Option, - vault_authority: Option, - bonding_curve: Option, - bonding_curve_vault: Option, - bonding_curve_wsol_vault: Option, - creator_lp_token: Option, - token0_vault: Option, - token1_vault: Option, - create_pool_fee: Option, - observation_state: Option, - operator: Option, - config: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - rent: Option, - __remaining_accounts: Vec, -} - -impl CreateRaydiumRandomPoolBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C']` - #[inline(always)] - pub fn cpmm_program(&mut self, cpmm_program: solana_pubkey::Pubkey) -> &mut Self { - self.cpmm_program = Some(cpmm_program); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn token0_mint(&mut self, token0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token0_mint = Some(token0_mint); - self - } - - /// `[optional account, default to 'So11111111111111111111111111111111111111112']` - /// Token_1 mint, the key must be greater than token_0 mint. - #[inline(always)] - pub fn token1_mint(&mut self, token1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token1_mint = Some(token1_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_vault( - &mut self, - bonding_curve_wsol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_wsol_vault = Some(bonding_curve_wsol_vault); - self - } - - #[inline(always)] - pub fn creator_lp_token(&mut self, creator_lp_token: solana_pubkey::Pubkey) -> &mut Self { - self.creator_lp_token = Some(creator_lp_token); - self - } - - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - /// `[optional account, default to 'DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8']` - /// create pool fee account - #[inline(always)] - pub fn create_pool_fee(&mut self, create_pool_fee: solana_pubkey::Pubkey) -> &mut Self { - self.create_pool_fee = Some(create_pool_fee); - self - } - - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Program to create an ATA for receiving position NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// To create a new program account - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Sysvar for program account - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateRaydiumRandomPool { - cpmm_program: self.cpmm_program.unwrap_or(solana_pubkey::pubkey!( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - )), - amm_config: self.amm_config.expect("amm_config is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - token0_mint: self.token0_mint.expect("token0_mint is not set"), - token1_mint: self.token1_mint.unwrap_or(solana_pubkey::pubkey!( - "So11111111111111111111111111111111111111112" - )), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - bonding_curve_wsol_vault: self - .bonding_curve_wsol_vault - .expect("bonding_curve_wsol_vault is not set"), - creator_lp_token: self.creator_lp_token.expect("creator_lp_token is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - create_pool_fee: self.create_pool_fee.unwrap_or(solana_pubkey::pubkey!( - "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8" - )), - observation_state: self - .observation_state - .expect("observation_state is not set"), - operator: self.operator.expect("operator is not set"), - config: self.config.expect("config is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_raydium_random_pool` CPI accounts. -pub struct CreateRaydiumRandomPoolCpiAccounts<'a, 'b> { - pub cpmm_program: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub token0_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token_1 mint, the key must be greater than token_0 mint. - pub token1_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub creator_lp_token: &'b solana_account_info::AccountInfo<'a>, - - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// create pool fee account - pub create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// To create a new program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Sysvar for program account - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_raydium_random_pool` CPI instruction. -pub struct CreateRaydiumRandomPoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub cpmm_program: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub token0_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token_1 mint, the key must be greater than token_0 mint. - pub token1_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub creator_lp_token: &'b solana_account_info::AccountInfo<'a>, - - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// create pool fee account - pub create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// To create a new program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Sysvar for program account - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateRaydiumRandomPoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateRaydiumRandomPoolCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - cpmm_program: accounts.cpmm_program, - amm_config: accounts.amm_config, - authority: accounts.authority, - pool_state: accounts.pool_state, - token0_mint: accounts.token0_mint, - token1_mint: accounts.token1_mint, - lp_mint: accounts.lp_mint, - vault_authority: accounts.vault_authority, - bonding_curve: accounts.bonding_curve, - bonding_curve_vault: accounts.bonding_curve_vault, - bonding_curve_wsol_vault: accounts.bonding_curve_wsol_vault, - creator_lp_token: accounts.creator_lp_token, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - create_pool_fee: accounts.create_pool_fee, - observation_state: accounts.observation_state, - operator: accounts.operator, - config: accounts.config, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - rent: accounts.rent, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(22 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cpmm_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_wsol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_lp_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.create_pool_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateRaydiumRandomPoolInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(23 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.cpmm_program.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.token0_mint.clone()); - account_infos.push(self.token1_mint.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.bonding_curve_wsol_vault.clone()); - account_infos.push(self.creator_lp_token.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.create_pool_fee.clone()); - account_infos.push(self.observation_state.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateRaydiumRandomPool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` cpmm_program -/// 1. `[]` amm_config -/// 2. `[]` authority -/// 3. `[writable, signer]` pool_state -/// 4. `[writable]` token0_mint -/// 5. `[]` token1_mint -/// 6. `[writable]` lp_mint -/// 7. `[writable]` vault_authority -/// 8. `[writable]` bonding_curve -/// 9. `[writable]` bonding_curve_vault -/// 10. `[writable]` bonding_curve_wsol_vault -/// 11. `[writable]` creator_lp_token -/// 12. `[writable]` token0_vault -/// 13. `[writable]` token1_vault -/// 14. `[writable]` create_pool_fee -/// 15. `[writable]` observation_state -/// 16. `[writable, signer]` operator -/// 17. `[]` config -/// 18. `[]` token_program -/// 19. `[]` associated_token_program -/// 20. `[]` system_program -/// 21. `[]` rent -#[derive(Clone, Debug)] -pub struct CreateRaydiumRandomPoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateRaydiumRandomPoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateRaydiumRandomPoolCpiBuilderInstruction { - __program: program, - cpmm_program: None, - amm_config: None, - authority: None, - pool_state: None, - token0_mint: None, - token1_mint: None, - lp_mint: None, - vault_authority: None, - bonding_curve: None, - bonding_curve_vault: None, - bonding_curve_wsol_vault: None, - creator_lp_token: None, - token0_vault: None, - token1_vault: None, - create_pool_fee: None, - observation_state: None, - operator: None, - config: None, - token_program: None, - associated_token_program: None, - system_program: None, - rent: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn cpmm_program( - &mut self, - cpmm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpmm_program = Some(cpmm_program); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn token0_mint( - &mut self, - token0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_mint = Some(token0_mint); - self - } - - /// Token_1 mint, the key must be greater than token_0 mint. - #[inline(always)] - pub fn token1_mint( - &mut self, - token1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_mint = Some(token1_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_vault( - &mut self, - bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_wsol_vault = Some(bonding_curve_wsol_vault); - self - } - - #[inline(always)] - pub fn creator_lp_token( - &mut self, - creator_lp_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_lp_token = Some(creator_lp_token); - self - } - - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - /// create pool fee account - #[inline(always)] - pub fn create_pool_fee( - &mut self, - create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.create_pool_fee = Some(create_pool_fee); - self - } - - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Program to create an ATA for receiving position NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// To create a new program account - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Sysvar for program account - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateRaydiumRandomPoolCpi { - __program: self.instruction.__program, - - cpmm_program: self - .instruction - .cpmm_program - .expect("cpmm_program is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - token0_mint: self - .instruction - .token0_mint - .expect("token0_mint is not set"), - - token1_mint: self - .instruction - .token1_mint - .expect("token1_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - bonding_curve_wsol_vault: self - .instruction - .bonding_curve_wsol_vault - .expect("bonding_curve_wsol_vault is not set"), - - creator_lp_token: self - .instruction - .creator_lp_token - .expect("creator_lp_token is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - create_pool_fee: self - .instruction - .create_pool_fee - .expect("create_pool_fee is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - config: self.instruction.config.expect("config is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateRaydiumRandomPoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - cpmm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_wsol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_lp_token: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - create_pool_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/create_token.rs b/crates/boop-parser/src/generated_sdk/instructions/create_token.rs deleted file mode 100644 index 0db7b8dc..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/create_token.rs +++ /dev/null @@ -1,638 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateToken { - pub config: solana_pubkey::Pubkey, - - pub metadata: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token_metadata_program: solana_pubkey::Pubkey, -} - -impl CreateToken { - pub fn instruction(&self, args: CreateTokenInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateTokenInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.metadata, false)); - accounts.push(solana_instruction::AccountMeta::new(self.mint, false)); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_metadata_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateTokenInstructionData { - discriminator: [u8; 8], -} - -impl CreateTokenInstructionData { - pub fn new() -> Self { - Self { - discriminator: [84, 52, 204, 228, 24, 140, 234, 75], - } - } -} - -impl Default for CreateTokenInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateTokenInstructionArgs { - pub salt: u64, - pub name: String, - pub symbol: String, - pub uri: String, -} - -/// Instruction builder for `CreateToken`. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` metadata -/// 2. `[writable]` mint -/// 3. `[writable, signer]` payer -/// 4. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[optional]` token_metadata_program (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -#[derive(Clone, Debug, Default)] -pub struct CreateTokenBuilder { - config: Option, - metadata: Option, - mint: Option, - payer: Option, - rent: Option, - system_program: Option, - token_program: Option, - token_metadata_program: Option, - salt: Option, - name: Option, - symbol: Option, - uri: Option, - __remaining_accounts: Vec, -} - -impl CreateTokenBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: solana_pubkey::Pubkey) -> &mut Self { - self.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - #[inline(always)] - pub fn token_metadata_program( - &mut self, - token_metadata_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_metadata_program = Some(token_metadata_program); - self - } - - #[inline(always)] - pub fn salt(&mut self, salt: u64) -> &mut Self { - self.salt = Some(salt); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.name = Some(name); - self - } - - #[inline(always)] - pub fn symbol(&mut self, symbol: String) -> &mut Self { - self.symbol = Some(symbol); - self - } - - #[inline(always)] - pub fn uri(&mut self, uri: String) -> &mut Self { - self.uri = Some(uri); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = - CreateToken { - config: self.config.expect("config is not set"), - metadata: self.metadata.expect("metadata is not set"), - mint: self.mint.expect("mint is not set"), - payer: self.payer.expect("payer is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_metadata_program: self.token_metadata_program.unwrap_or( - solana_pubkey::pubkey!("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"), - ), - }; - let args = CreateTokenInstructionArgs { - salt: self.salt.clone().expect("salt is not set"), - name: self.name.clone().expect("name is not set"), - symbol: self.symbol.clone().expect("symbol is not set"), - uri: self.uri.clone().expect("uri is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_token` CPI accounts. -pub struct CreateTokenCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_metadata_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_token` CPI instruction. -pub struct CreateTokenCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateTokenInstructionArgs, -} - -impl<'a, 'b> CreateTokenCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateTokenCpiAccounts<'a, 'b>, - args: CreateTokenInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - metadata: accounts.metadata, - mint: accounts.mint, - payer: accounts.payer, - rent: accounts.rent, - system_program: accounts.system_program, - token_program: accounts.token_program, - token_metadata_program: accounts.token_metadata_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.mint.key, false)); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_metadata_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.metadata.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_metadata_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateToken` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` metadata -/// 2. `[writable]` mint -/// 3. `[writable, signer]` payer -/// 4. `[]` rent -/// 5. `[]` system_program -/// 6. `[]` token_program -/// 7. `[]` token_metadata_program -#[derive(Clone, Debug)] -pub struct CreateTokenCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateTokenCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateTokenCpiBuilderInstruction { - __program: program, - config: None, - metadata: None, - mint: None, - payer: None, - rent: None, - system_program: None, - token_program: None, - token_metadata_program: None, - salt: None, - name: None, - symbol: None, - uri: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_metadata_program( - &mut self, - token_metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_metadata_program = Some(token_metadata_program); - self - } - - #[inline(always)] - pub fn salt(&mut self, salt: u64) -> &mut Self { - self.instruction.salt = Some(salt); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.instruction.name = Some(name); - self - } - - #[inline(always)] - pub fn symbol(&mut self, symbol: String) -> &mut Self { - self.instruction.symbol = Some(symbol); - self - } - - #[inline(always)] - pub fn uri(&mut self, uri: String) -> &mut Self { - self.instruction.uri = Some(uri); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateTokenInstructionArgs { - salt: self.instruction.salt.clone().expect("salt is not set"), - name: self.instruction.name.clone().expect("name is not set"), - symbol: self.instruction.symbol.clone().expect("symbol is not set"), - uri: self.instruction.uri.clone().expect("uri is not set"), - }; - let instruction = CreateTokenCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - metadata: self.instruction.metadata.expect("metadata is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_metadata_program: self - .instruction - .token_metadata_program - .expect("token_metadata_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateTokenCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - salt: Option, - name: Option, - symbol: Option, - uri: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/create_token_fallback.rs b/crates/boop-parser/src/generated_sdk/instructions/create_token_fallback.rs deleted file mode 100644 index b4680a0e..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/create_token_fallback.rs +++ /dev/null @@ -1,641 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateTokenFallback { - pub config: solana_pubkey::Pubkey, - - pub metadata: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token_metadata_program: solana_pubkey::Pubkey, -} - -impl CreateTokenFallback { - pub fn instruction( - &self, - args: CreateTokenFallbackInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateTokenFallbackInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.metadata, false)); - accounts.push(solana_instruction::AccountMeta::new(self.mint, false)); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_metadata_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateTokenFallbackInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateTokenFallbackInstructionData { - discriminator: [u8; 8], -} - -impl CreateTokenFallbackInstructionData { - pub fn new() -> Self { - Self { - discriminator: [253, 184, 126, 199, 235, 232, 172, 162], - } - } -} - -impl Default for CreateTokenFallbackInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateTokenFallbackInstructionArgs { - pub salt: u64, - pub name: String, - pub symbol: String, - pub uri: String, -} - -/// Instruction builder for `CreateTokenFallback`. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` metadata -/// 2. `[writable]` mint -/// 3. `[writable, signer]` payer -/// 4. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[optional]` token_metadata_program (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -#[derive(Clone, Debug, Default)] -pub struct CreateTokenFallbackBuilder { - config: Option, - metadata: Option, - mint: Option, - payer: Option, - rent: Option, - system_program: Option, - token_program: Option, - token_metadata_program: Option, - salt: Option, - name: Option, - symbol: Option, - uri: Option, - __remaining_accounts: Vec, -} - -impl CreateTokenFallbackBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: solana_pubkey::Pubkey) -> &mut Self { - self.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - #[inline(always)] - pub fn token_metadata_program( - &mut self, - token_metadata_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_metadata_program = Some(token_metadata_program); - self - } - - #[inline(always)] - pub fn salt(&mut self, salt: u64) -> &mut Self { - self.salt = Some(salt); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.name = Some(name); - self - } - - #[inline(always)] - pub fn symbol(&mut self, symbol: String) -> &mut Self { - self.symbol = Some(symbol); - self - } - - #[inline(always)] - pub fn uri(&mut self, uri: String) -> &mut Self { - self.uri = Some(uri); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = - CreateTokenFallback { - config: self.config.expect("config is not set"), - metadata: self.metadata.expect("metadata is not set"), - mint: self.mint.expect("mint is not set"), - payer: self.payer.expect("payer is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_metadata_program: self.token_metadata_program.unwrap_or( - solana_pubkey::pubkey!("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"), - ), - }; - let args = CreateTokenFallbackInstructionArgs { - salt: self.salt.clone().expect("salt is not set"), - name: self.name.clone().expect("name is not set"), - symbol: self.symbol.clone().expect("symbol is not set"), - uri: self.uri.clone().expect("uri is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_token_fallback` CPI accounts. -pub struct CreateTokenFallbackCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_metadata_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_token_fallback` CPI instruction. -pub struct CreateTokenFallbackCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateTokenFallbackInstructionArgs, -} - -impl<'a, 'b> CreateTokenFallbackCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateTokenFallbackCpiAccounts<'a, 'b>, - args: CreateTokenFallbackInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - metadata: accounts.metadata, - mint: accounts.mint, - payer: accounts.payer, - rent: accounts.rent, - system_program: accounts.system_program, - token_program: accounts.token_program, - token_metadata_program: accounts.token_metadata_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.mint.key, false)); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_metadata_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateTokenFallbackInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.metadata.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_metadata_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateTokenFallback` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` metadata -/// 2. `[writable]` mint -/// 3. `[writable, signer]` payer -/// 4. `[]` rent -/// 5. `[]` system_program -/// 6. `[]` token_program -/// 7. `[]` token_metadata_program -#[derive(Clone, Debug)] -pub struct CreateTokenFallbackCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateTokenFallbackCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateTokenFallbackCpiBuilderInstruction { - __program: program, - config: None, - metadata: None, - mint: None, - payer: None, - rent: None, - system_program: None, - token_program: None, - token_metadata_program: None, - salt: None, - name: None, - symbol: None, - uri: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_metadata_program( - &mut self, - token_metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_metadata_program = Some(token_metadata_program); - self - } - - #[inline(always)] - pub fn salt(&mut self, salt: u64) -> &mut Self { - self.instruction.salt = Some(salt); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.instruction.name = Some(name); - self - } - - #[inline(always)] - pub fn symbol(&mut self, symbol: String) -> &mut Self { - self.instruction.symbol = Some(symbol); - self - } - - #[inline(always)] - pub fn uri(&mut self, uri: String) -> &mut Self { - self.instruction.uri = Some(uri); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateTokenFallbackInstructionArgs { - salt: self.instruction.salt.clone().expect("salt is not set"), - name: self.instruction.name.clone().expect("name is not set"), - symbol: self.instruction.symbol.clone().expect("symbol is not set"), - uri: self.instruction.uri.clone().expect("uri is not set"), - }; - let instruction = CreateTokenFallbackCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - metadata: self.instruction.metadata.expect("metadata is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_metadata_program: self - .instruction - .token_metadata_program - .expect("token_metadata_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateTokenFallbackCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - salt: Option, - name: Option, - symbol: Option, - uri: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/deploy_bonding_curve.rs b/crates/boop-parser/src/generated_sdk/instructions/deploy_bonding_curve.rs deleted file mode 100644 index eed200c5..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/deploy_bonding_curve.rs +++ /dev/null @@ -1,713 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct DeployBondingCurve { - pub mint: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub bonding_curve_sol_vault: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl DeployBondingCurve { - pub fn instruction( - &self, - args: DeployBondingCurveInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DeployBondingCurveInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_sol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DeployBondingCurveInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DeployBondingCurveInstructionData { - discriminator: [u8; 8], -} - -impl DeployBondingCurveInstructionData { - pub fn new() -> Self { - Self { - discriminator: [180, 89, 199, 76, 168, 236, 217, 138], - } - } -} - -impl Default for DeployBondingCurveInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DeployBondingCurveInstructionArgs { - pub creator: Pubkey, - pub salt: u64, -} - -/// Instruction builder for `DeployBondingCurve`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` mint -/// 1. `[]` vault_authority -/// 2. `[writable]` bonding_curve -/// 3. `[writable]` bonding_curve_sol_vault -/// 4. `[writable]` bonding_curve_vault -/// 5. `[]` config -/// 6. `[writable, signer]` payer -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -#[derive(Clone, Debug, Default)] -pub struct DeployBondingCurveBuilder { - mint: Option, - vault_authority: Option, - bonding_curve: Option, - bonding_curve_sol_vault: Option, - bonding_curve_vault: Option, - config: Option, - payer: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - creator: Option, - salt: Option, - __remaining_accounts: Vec, -} - -impl DeployBondingCurveBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_sol_vault( - &mut self, - bonding_curve_sol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_sol_vault = Some(bonding_curve_sol_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn salt(&mut self, salt: u64) -> &mut Self { - self.salt = Some(salt); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = DeployBondingCurve { - mint: self.mint.expect("mint is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - bonding_curve_sol_vault: self - .bonding_curve_sol_vault - .expect("bonding_curve_sol_vault is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - config: self.config.expect("config is not set"), - payer: self.payer.expect("payer is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - }; - let args = DeployBondingCurveInstructionArgs { - creator: self.creator.clone().expect("creator is not set"), - salt: self.salt.clone().expect("salt is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `deploy_bonding_curve` CPI accounts. -pub struct DeployBondingCurveCpiAccounts<'a, 'b> { - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `deploy_bonding_curve` CPI instruction. -pub struct DeployBondingCurveCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DeployBondingCurveInstructionArgs, -} - -impl<'a, 'b> DeployBondingCurveCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DeployBondingCurveCpiAccounts<'a, 'b>, - args: DeployBondingCurveInstructionArgs, - ) -> Self { - Self { - __program: program, - mint: accounts.mint, - vault_authority: accounts.vault_authority, - bonding_curve: accounts.bonding_curve, - bonding_curve_sol_vault: accounts.bonding_curve_sol_vault, - bonding_curve_vault: accounts.bonding_curve_vault, - config: accounts.config, - payer: accounts.payer, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.mint.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_sol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DeployBondingCurveInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.bonding_curve_sol_vault.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `DeployBondingCurve` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` mint -/// 1. `[]` vault_authority -/// 2. `[writable]` bonding_curve -/// 3. `[writable]` bonding_curve_sol_vault -/// 4. `[writable]` bonding_curve_vault -/// 5. `[]` config -/// 6. `[writable, signer]` payer -/// 7. `[]` system_program -/// 8. `[]` token_program -/// 9. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct DeployBondingCurveCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DeployBondingCurveCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DeployBondingCurveCpiBuilderInstruction { - __program: program, - mint: None, - vault_authority: None, - bonding_curve: None, - bonding_curve_sol_vault: None, - bonding_curve_vault: None, - config: None, - payer: None, - system_program: None, - token_program: None, - associated_token_program: None, - creator: None, - salt: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_sol_vault( - &mut self, - bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_sol_vault = Some(bonding_curve_sol_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: Pubkey) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn salt(&mut self, salt: u64) -> &mut Self { - self.instruction.salt = Some(salt); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DeployBondingCurveInstructionArgs { - creator: self - .instruction - .creator - .clone() - .expect("creator is not set"), - salt: self.instruction.salt.clone().expect("salt is not set"), - }; - let instruction = DeployBondingCurveCpi { - __program: self.instruction.__program, - - mint: self.instruction.mint.expect("mint is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - bonding_curve_sol_vault: self - .instruction - .bonding_curve_sol_vault - .expect("bonding_curve_sol_vault is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - config: self.instruction.config.expect("config is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DeployBondingCurveCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_sol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option, - salt: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/deploy_bonding_curve_fallback.rs b/crates/boop-parser/src/generated_sdk/instructions/deploy_bonding_curve_fallback.rs deleted file mode 100644 index 9c87c513..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/deploy_bonding_curve_fallback.rs +++ /dev/null @@ -1,713 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct DeployBondingCurveFallback { - pub mint: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub bonding_curve_sol_vault: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl DeployBondingCurveFallback { - pub fn instruction( - &self, - args: DeployBondingCurveFallbackInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DeployBondingCurveFallbackInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_sol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DeployBondingCurveFallbackInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DeployBondingCurveFallbackInstructionData { - discriminator: [u8; 8], -} - -impl DeployBondingCurveFallbackInstructionData { - pub fn new() -> Self { - Self { - discriminator: [53, 230, 172, 84, 77, 174, 22, 61], - } - } -} - -impl Default for DeployBondingCurveFallbackInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DeployBondingCurveFallbackInstructionArgs { - pub creator: Pubkey, - pub salt: u64, -} - -/// Instruction builder for `DeployBondingCurveFallback`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` mint -/// 1. `[]` vault_authority -/// 2. `[writable]` bonding_curve -/// 3. `[writable]` bonding_curve_sol_vault -/// 4. `[writable]` bonding_curve_vault -/// 5. `[]` config -/// 6. `[writable, signer]` payer -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -#[derive(Clone, Debug, Default)] -pub struct DeployBondingCurveFallbackBuilder { - mint: Option, - vault_authority: Option, - bonding_curve: Option, - bonding_curve_sol_vault: Option, - bonding_curve_vault: Option, - config: Option, - payer: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - creator: Option, - salt: Option, - __remaining_accounts: Vec, -} - -impl DeployBondingCurveFallbackBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_sol_vault( - &mut self, - bonding_curve_sol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_sol_vault = Some(bonding_curve_sol_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn salt(&mut self, salt: u64) -> &mut Self { - self.salt = Some(salt); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = DeployBondingCurveFallback { - mint: self.mint.expect("mint is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - bonding_curve_sol_vault: self - .bonding_curve_sol_vault - .expect("bonding_curve_sol_vault is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - config: self.config.expect("config is not set"), - payer: self.payer.expect("payer is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - }; - let args = DeployBondingCurveFallbackInstructionArgs { - creator: self.creator.clone().expect("creator is not set"), - salt: self.salt.clone().expect("salt is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `deploy_bonding_curve_fallback` CPI accounts. -pub struct DeployBondingCurveFallbackCpiAccounts<'a, 'b> { - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `deploy_bonding_curve_fallback` CPI instruction. -pub struct DeployBondingCurveFallbackCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DeployBondingCurveFallbackInstructionArgs, -} - -impl<'a, 'b> DeployBondingCurveFallbackCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DeployBondingCurveFallbackCpiAccounts<'a, 'b>, - args: DeployBondingCurveFallbackInstructionArgs, - ) -> Self { - Self { - __program: program, - mint: accounts.mint, - vault_authority: accounts.vault_authority, - bonding_curve: accounts.bonding_curve, - bonding_curve_sol_vault: accounts.bonding_curve_sol_vault, - bonding_curve_vault: accounts.bonding_curve_vault, - config: accounts.config, - payer: accounts.payer, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.mint.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_sol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DeployBondingCurveFallbackInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.bonding_curve_sol_vault.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `DeployBondingCurveFallback` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` mint -/// 1. `[]` vault_authority -/// 2. `[writable]` bonding_curve -/// 3. `[writable]` bonding_curve_sol_vault -/// 4. `[writable]` bonding_curve_vault -/// 5. `[]` config -/// 6. `[writable, signer]` payer -/// 7. `[]` system_program -/// 8. `[]` token_program -/// 9. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct DeployBondingCurveFallbackCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DeployBondingCurveFallbackCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DeployBondingCurveFallbackCpiBuilderInstruction { - __program: program, - mint: None, - vault_authority: None, - bonding_curve: None, - bonding_curve_sol_vault: None, - bonding_curve_vault: None, - config: None, - payer: None, - system_program: None, - token_program: None, - associated_token_program: None, - creator: None, - salt: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_sol_vault( - &mut self, - bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_sol_vault = Some(bonding_curve_sol_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: Pubkey) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn salt(&mut self, salt: u64) -> &mut Self { - self.instruction.salt = Some(salt); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DeployBondingCurveFallbackInstructionArgs { - creator: self - .instruction - .creator - .clone() - .expect("creator is not set"), - salt: self.instruction.salt.clone().expect("salt is not set"), - }; - let instruction = DeployBondingCurveFallbackCpi { - __program: self.instruction.__program, - - mint: self.instruction.mint.expect("mint is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - bonding_curve_sol_vault: self - .instruction - .bonding_curve_sol_vault - .expect("bonding_curve_sol_vault is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - config: self.instruction.config.expect("config is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DeployBondingCurveFallbackCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_sol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option, - salt: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/deposit_into_raydium.rs b/crates/boop-parser/src/generated_sdk/instructions/deposit_into_raydium.rs deleted file mode 100644 index 94537198..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/deposit_into_raydium.rs +++ /dev/null @@ -1,1226 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct DepositIntoRaydium { - pub config: solana_pubkey::Pubkey, - /// Which config the pool belongs to. - pub amm_config: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub operator_wsol_account: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub token0_vault: solana_pubkey::Pubkey, - - pub token1_vault: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub bonding_curve_wsol_vault: solana_pubkey::Pubkey, - /// token Program - pub token_program: solana_pubkey::Pubkey, - /// Token program 2022 - pub token_program2022: solana_pubkey::Pubkey, - /// System program - pub system_program: solana_pubkey::Pubkey, - /// Program to create an ATA for the operator to recoup any potential remaining WSOL - pub associated_token_program: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub cpmm_program: solana_pubkey::Pubkey, - - pub owner_lp_token: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub token0_mint: solana_pubkey::Pubkey, - /// token_1 mint, the key must greater than token_0 mint - pub token1_mint: solana_pubkey::Pubkey, -} - -impl DepositIntoRaydium { - pub fn instruction( - &self, - args: DepositIntoRaydiumInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DepositIntoRaydiumInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(21 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.operator, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.operator_wsol_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_wsol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cpmm_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.owner_lp_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token1_mint, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DepositIntoRaydiumInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositIntoRaydiumInstructionData { - discriminator: [u8; 8], -} - -impl DepositIntoRaydiumInstructionData { - pub fn new() -> Self { - Self { - discriminator: [168, 89, 99, 30, 117, 49, 88, 224], - } - } -} - -impl Default for DepositIntoRaydiumInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositIntoRaydiumInstructionArgs { - pub lp_token_amount: u64, - pub maximum_token0_amount: u64, - pub maximum_token1_amount: u64, -} - -/// Instruction builder for `DepositIntoRaydium`. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[]` amm_config -/// 2. `[writable, signer]` operator -/// 3. `[writable]` operator_wsol_account -/// 4. `[writable]` vault_authority -/// 5. `[]` authority -/// 6. `[writable]` pool_state -/// 7. `[writable]` token0_vault -/// 8. `[writable]` token1_vault -/// 9. `[writable]` bonding_curve_vault -/// 10. `[writable]` bonding_curve_wsol_vault -/// 11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 12. `[optional]` token_program2022 (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 13. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 14. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 15. `[writable]` lp_mint -/// 16. `[optional]` cpmm_program (default to `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C`) -/// 17. `[writable]` owner_lp_token -/// 18. `[writable]` bonding_curve -/// 19. `[writable]` token0_mint -/// 20. `[optional]` token1_mint (default to `So11111111111111111111111111111111111111112`) -#[derive(Clone, Debug, Default)] -pub struct DepositIntoRaydiumBuilder { - config: Option, - amm_config: Option, - operator: Option, - operator_wsol_account: Option, - vault_authority: Option, - authority: Option, - pool_state: Option, - token0_vault: Option, - token1_vault: Option, - bonding_curve_vault: Option, - bonding_curve_wsol_vault: Option, - token_program: Option, - token_program2022: Option, - system_program: Option, - associated_token_program: Option, - lp_mint: Option, - cpmm_program: Option, - owner_lp_token: Option, - bonding_curve: Option, - token0_mint: Option, - token1_mint: Option, - lp_token_amount: Option, - maximum_token0_amount: Option, - maximum_token1_amount: Option, - __remaining_accounts: Vec, -} - -impl DepositIntoRaydiumBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn operator_wsol_account( - &mut self, - operator_wsol_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.operator_wsol_account = Some(operator_wsol_account); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_vault( - &mut self, - bonding_curve_wsol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_wsol_vault = Some(bonding_curve_wsol_vault); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token Program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// Token program 2022 - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Program to create an ATA for the operator to recoup any potential remaining WSOL - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// `[optional account, default to 'CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C']` - #[inline(always)] - pub fn cpmm_program(&mut self, cpmm_program: solana_pubkey::Pubkey) -> &mut Self { - self.cpmm_program = Some(cpmm_program); - self - } - - #[inline(always)] - pub fn owner_lp_token(&mut self, owner_lp_token: solana_pubkey::Pubkey) -> &mut Self { - self.owner_lp_token = Some(owner_lp_token); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn token0_mint(&mut self, token0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token0_mint = Some(token0_mint); - self - } - - /// `[optional account, default to 'So11111111111111111111111111111111111111112']` - /// token_1 mint, the key must greater than token_0 mint - #[inline(always)] - pub fn token1_mint(&mut self, token1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token1_mint = Some(token1_mint); - self - } - - #[inline(always)] - pub fn lp_token_amount(&mut self, lp_token_amount: u64) -> &mut Self { - self.lp_token_amount = Some(lp_token_amount); - self - } - - #[inline(always)] - pub fn maximum_token0_amount(&mut self, maximum_token0_amount: u64) -> &mut Self { - self.maximum_token0_amount = Some(maximum_token0_amount); - self - } - - #[inline(always)] - pub fn maximum_token1_amount(&mut self, maximum_token1_amount: u64) -> &mut Self { - self.maximum_token1_amount = Some(maximum_token1_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = DepositIntoRaydium { - config: self.config.expect("config is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - operator: self.operator.expect("operator is not set"), - operator_wsol_account: self - .operator_wsol_account - .expect("operator_wsol_account is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - bonding_curve_wsol_vault: self - .bonding_curve_wsol_vault - .expect("bonding_curve_wsol_vault is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self.token_program2022.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - cpmm_program: self.cpmm_program.unwrap_or(solana_pubkey::pubkey!( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - )), - owner_lp_token: self.owner_lp_token.expect("owner_lp_token is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - token0_mint: self.token0_mint.expect("token0_mint is not set"), - token1_mint: self.token1_mint.unwrap_or(solana_pubkey::pubkey!( - "So11111111111111111111111111111111111111112" - )), - }; - let args = DepositIntoRaydiumInstructionArgs { - lp_token_amount: self - .lp_token_amount - .clone() - .expect("lp_token_amount is not set"), - maximum_token0_amount: self - .maximum_token0_amount - .clone() - .expect("maximum_token0_amount is not set"), - maximum_token1_amount: self - .maximum_token1_amount - .clone() - .expect("maximum_token1_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `deposit_into_raydium` CPI accounts. -pub struct DepositIntoRaydiumCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub operator_wsol_account: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - /// token Program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program 2022 - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// System program - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for the operator to recoup any potential remaining WSOL - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub cpmm_program: &'b solana_account_info::AccountInfo<'a>, - - pub owner_lp_token: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub token0_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_1 mint, the key must greater than token_0 mint - pub token1_mint: &'b solana_account_info::AccountInfo<'a>, -} - -/// `deposit_into_raydium` CPI instruction. -pub struct DepositIntoRaydiumCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub operator_wsol_account: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - /// token Program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program 2022 - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// System program - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for the operator to recoup any potential remaining WSOL - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub cpmm_program: &'b solana_account_info::AccountInfo<'a>, - - pub owner_lp_token: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub token0_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_1 mint, the key must greater than token_0 mint - pub token1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DepositIntoRaydiumInstructionArgs, -} - -impl<'a, 'b> DepositIntoRaydiumCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DepositIntoRaydiumCpiAccounts<'a, 'b>, - args: DepositIntoRaydiumInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - amm_config: accounts.amm_config, - operator: accounts.operator, - operator_wsol_account: accounts.operator_wsol_account, - vault_authority: accounts.vault_authority, - authority: accounts.authority, - pool_state: accounts.pool_state, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - bonding_curve_vault: accounts.bonding_curve_vault, - bonding_curve_wsol_vault: accounts.bonding_curve_wsol_vault, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - system_program: accounts.system_program, - associated_token_program: accounts.associated_token_program, - lp_mint: accounts.lp_mint, - cpmm_program: accounts.cpmm_program, - owner_lp_token: accounts.owner_lp_token, - bonding_curve: accounts.bonding_curve, - token0_mint: accounts.token0_mint, - token1_mint: accounts.token1_mint, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(21 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator_wsol_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_wsol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cpmm_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.owner_lp_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token1_mint.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DepositIntoRaydiumInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(22 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.operator_wsol_account.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.bonding_curve_wsol_vault.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.cpmm_program.clone()); - account_infos.push(self.owner_lp_token.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.token0_mint.clone()); - account_infos.push(self.token1_mint.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `DepositIntoRaydium` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[]` amm_config -/// 2. `[writable, signer]` operator -/// 3. `[writable]` operator_wsol_account -/// 4. `[writable]` vault_authority -/// 5. `[]` authority -/// 6. `[writable]` pool_state -/// 7. `[writable]` token0_vault -/// 8. `[writable]` token1_vault -/// 9. `[writable]` bonding_curve_vault -/// 10. `[writable]` bonding_curve_wsol_vault -/// 11. `[]` token_program -/// 12. `[]` token_program2022 -/// 13. `[]` system_program -/// 14. `[]` associated_token_program -/// 15. `[writable]` lp_mint -/// 16. `[]` cpmm_program -/// 17. `[writable]` owner_lp_token -/// 18. `[writable]` bonding_curve -/// 19. `[writable]` token0_mint -/// 20. `[]` token1_mint -#[derive(Clone, Debug)] -pub struct DepositIntoRaydiumCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DepositIntoRaydiumCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DepositIntoRaydiumCpiBuilderInstruction { - __program: program, - config: None, - amm_config: None, - operator: None, - operator_wsol_account: None, - vault_authority: None, - authority: None, - pool_state: None, - token0_vault: None, - token1_vault: None, - bonding_curve_vault: None, - bonding_curve_wsol_vault: None, - token_program: None, - token_program2022: None, - system_program: None, - associated_token_program: None, - lp_mint: None, - cpmm_program: None, - owner_lp_token: None, - bonding_curve: None, - token0_mint: None, - token1_mint: None, - lp_token_amount: None, - maximum_token0_amount: None, - maximum_token1_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn operator_wsol_account( - &mut self, - operator_wsol_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.operator_wsol_account = Some(operator_wsol_account); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_vault( - &mut self, - bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_wsol_vault = Some(bonding_curve_wsol_vault); - self - } - - /// token Program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Token program 2022 - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - /// System program - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Program to create an ATA for the operator to recoup any potential remaining WSOL - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn cpmm_program( - &mut self, - cpmm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpmm_program = Some(cpmm_program); - self - } - - #[inline(always)] - pub fn owner_lp_token( - &mut self, - owner_lp_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.owner_lp_token = Some(owner_lp_token); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn token0_mint( - &mut self, - token0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_mint = Some(token0_mint); - self - } - - /// token_1 mint, the key must greater than token_0 mint - #[inline(always)] - pub fn token1_mint( - &mut self, - token1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_mint = Some(token1_mint); - self - } - - #[inline(always)] - pub fn lp_token_amount(&mut self, lp_token_amount: u64) -> &mut Self { - self.instruction.lp_token_amount = Some(lp_token_amount); - self - } - - #[inline(always)] - pub fn maximum_token0_amount(&mut self, maximum_token0_amount: u64) -> &mut Self { - self.instruction.maximum_token0_amount = Some(maximum_token0_amount); - self - } - - #[inline(always)] - pub fn maximum_token1_amount(&mut self, maximum_token1_amount: u64) -> &mut Self { - self.instruction.maximum_token1_amount = Some(maximum_token1_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DepositIntoRaydiumInstructionArgs { - lp_token_amount: self - .instruction - .lp_token_amount - .clone() - .expect("lp_token_amount is not set"), - maximum_token0_amount: self - .instruction - .maximum_token0_amount - .clone() - .expect("maximum_token0_amount is not set"), - maximum_token1_amount: self - .instruction - .maximum_token1_amount - .clone() - .expect("maximum_token1_amount is not set"), - }; - let instruction = DepositIntoRaydiumCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - operator_wsol_account: self - .instruction - .operator_wsol_account - .expect("operator_wsol_account is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - bonding_curve_wsol_vault: self - .instruction - .bonding_curve_wsol_vault - .expect("bonding_curve_wsol_vault is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - cpmm_program: self - .instruction - .cpmm_program - .expect("cpmm_program is not set"), - - owner_lp_token: self - .instruction - .owner_lp_token - .expect("owner_lp_token is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - token0_mint: self - .instruction - .token0_mint - .expect("token0_mint is not set"), - - token1_mint: self - .instruction - .token1_mint - .expect("token1_mint is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DepositIntoRaydiumCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - operator_wsol_account: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_wsol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - cpmm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - owner_lp_token: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_token_amount: Option, - maximum_token0_amount: Option, - maximum_token1_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/graduate.rs b/crates/boop-parser/src/generated_sdk/instructions/graduate.rs deleted file mode 100644 index 231432c4..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/graduate.rs +++ /dev/null @@ -1,881 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Graduate { - pub mint: solana_pubkey::Pubkey, - - pub wsol: solana_pubkey::Pubkey, - - pub protocol_fee_recipient: solana_pubkey::Pubkey, - - pub token_distributor: solana_pubkey::Pubkey, - - pub token_distributor_token_account: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub bonding_curve_sol_vault: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub bonding_curve_wsol_account: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl Graduate { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.wsol, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_fee_recipient, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_distributor, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_distributor_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_sol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_wsol_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.operator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&GraduateInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct GraduateInstructionData { - discriminator: [u8; 8], -} - -impl GraduateInstructionData { - pub fn new() -> Self { - Self { - discriminator: [45, 235, 225, 181, 17, 218, 64, 130], - } - } -} - -impl Default for GraduateInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `Graduate`. -/// -/// ### Accounts: -/// -/// 0. `[]` mint -/// 1. `[optional]` wsol (default to `So11111111111111111111111111111111111111112`) -/// 2. `[writable]` protocol_fee_recipient -/// 3. `[]` token_distributor -/// 4. `[writable]` token_distributor_token_account -/// 5. `[]` vault_authority -/// 6. `[writable]` bonding_curve_sol_vault -/// 7. `[writable]` bonding_curve -/// 8. `[writable]` bonding_curve_vault -/// 9. `[writable]` bonding_curve_wsol_account -/// 10. `[writable, signer]` operator -/// 11. `[]` config -/// 12. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 13. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 14. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -#[derive(Clone, Debug, Default)] -pub struct GraduateBuilder { - mint: Option, - wsol: Option, - protocol_fee_recipient: Option, - token_distributor: Option, - token_distributor_token_account: Option, - vault_authority: Option, - bonding_curve_sol_vault: Option, - bonding_curve: Option, - bonding_curve_vault: Option, - bonding_curve_wsol_account: Option, - operator: Option, - config: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - __remaining_accounts: Vec, -} - -impl GraduateBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - /// `[optional account, default to 'So11111111111111111111111111111111111111112']` - #[inline(always)] - pub fn wsol(&mut self, wsol: solana_pubkey::Pubkey) -> &mut Self { - self.wsol = Some(wsol); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient( - &mut self, - protocol_fee_recipient: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_fee_recipient = Some(protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn token_distributor(&mut self, token_distributor: solana_pubkey::Pubkey) -> &mut Self { - self.token_distributor = Some(token_distributor); - self - } - - #[inline(always)] - pub fn token_distributor_token_account( - &mut self, - token_distributor_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_distributor_token_account = Some(token_distributor_token_account); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve_sol_vault( - &mut self, - bonding_curve_sol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_sol_vault = Some(bonding_curve_sol_vault); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_account( - &mut self, - bonding_curve_wsol_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_wsol_account = Some(bonding_curve_wsol_account); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Graduate { - mint: self.mint.expect("mint is not set"), - wsol: self.wsol.unwrap_or(solana_pubkey::pubkey!( - "So11111111111111111111111111111111111111112" - )), - protocol_fee_recipient: self - .protocol_fee_recipient - .expect("protocol_fee_recipient is not set"), - token_distributor: self - .token_distributor - .expect("token_distributor is not set"), - token_distributor_token_account: self - .token_distributor_token_account - .expect("token_distributor_token_account is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - bonding_curve_sol_vault: self - .bonding_curve_sol_vault - .expect("bonding_curve_sol_vault is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - bonding_curve_wsol_account: self - .bonding_curve_wsol_account - .expect("bonding_curve_wsol_account is not set"), - operator: self.operator.expect("operator is not set"), - config: self.config.expect("config is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `graduate` CPI accounts. -pub struct GraduateCpiAccounts<'a, 'b> { - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub wsol: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub token_distributor: &'b solana_account_info::AccountInfo<'a>, - - pub token_distributor_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_account: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `graduate` CPI instruction. -pub struct GraduateCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub wsol: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub token_distributor: &'b solana_account_info::AccountInfo<'a>, - - pub token_distributor_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_account: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> GraduateCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: GraduateCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - mint: accounts.mint, - wsol: accounts.wsol, - protocol_fee_recipient: accounts.protocol_fee_recipient, - token_distributor: accounts.token_distributor, - token_distributor_token_account: accounts.token_distributor_token_account, - vault_authority: accounts.vault_authority, - bonding_curve_sol_vault: accounts.bonding_curve_sol_vault, - bonding_curve: accounts.bonding_curve, - bonding_curve_vault: accounts.bonding_curve_vault, - bonding_curve_wsol_account: accounts.bonding_curve_wsol_account, - operator: accounts.operator, - config: accounts.config, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.wsol.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_fee_recipient.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_distributor.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_distributor_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_sol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_wsol_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&GraduateInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.wsol.clone()); - account_infos.push(self.protocol_fee_recipient.clone()); - account_infos.push(self.token_distributor.clone()); - account_infos.push(self.token_distributor_token_account.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.bonding_curve_sol_vault.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.bonding_curve_wsol_account.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Graduate` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` mint -/// 1. `[]` wsol -/// 2. `[writable]` protocol_fee_recipient -/// 3. `[]` token_distributor -/// 4. `[writable]` token_distributor_token_account -/// 5. `[]` vault_authority -/// 6. `[writable]` bonding_curve_sol_vault -/// 7. `[writable]` bonding_curve -/// 8. `[writable]` bonding_curve_vault -/// 9. `[writable]` bonding_curve_wsol_account -/// 10. `[writable, signer]` operator -/// 11. `[]` config -/// 12. `[]` system_program -/// 13. `[]` token_program -/// 14. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct GraduateCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> GraduateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(GraduateCpiBuilderInstruction { - __program: program, - mint: None, - wsol: None, - protocol_fee_recipient: None, - token_distributor: None, - token_distributor_token_account: None, - vault_authority: None, - bonding_curve_sol_vault: None, - bonding_curve: None, - bonding_curve_vault: None, - bonding_curve_wsol_account: None, - operator: None, - config: None, - system_program: None, - token_program: None, - associated_token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn wsol(&mut self, wsol: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.wsol = Some(wsol); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient( - &mut self, - protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_fee_recipient = Some(protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn token_distributor( - &mut self, - token_distributor: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_distributor = Some(token_distributor); - self - } - - #[inline(always)] - pub fn token_distributor_token_account( - &mut self, - token_distributor_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_distributor_token_account = Some(token_distributor_token_account); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve_sol_vault( - &mut self, - bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_sol_vault = Some(bonding_curve_sol_vault); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_account( - &mut self, - bonding_curve_wsol_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_wsol_account = Some(bonding_curve_wsol_account); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = GraduateCpi { - __program: self.instruction.__program, - - mint: self.instruction.mint.expect("mint is not set"), - - wsol: self.instruction.wsol.expect("wsol is not set"), - - protocol_fee_recipient: self - .instruction - .protocol_fee_recipient - .expect("protocol_fee_recipient is not set"), - - token_distributor: self - .instruction - .token_distributor - .expect("token_distributor is not set"), - - token_distributor_token_account: self - .instruction - .token_distributor_token_account - .expect("token_distributor_token_account is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - bonding_curve_sol_vault: self - .instruction - .bonding_curve_sol_vault - .expect("bonding_curve_sol_vault is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - bonding_curve_wsol_account: self - .instruction - .bonding_curve_wsol_account - .expect("bonding_curve_wsol_account is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - config: self.instruction.config.expect("config is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct GraduateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - wsol: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_fee_recipient: Option<&'b solana_account_info::AccountInfo<'a>>, - token_distributor: Option<&'b solana_account_info::AccountInfo<'a>>, - token_distributor_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_sol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_wsol_account: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/initialize.rs b/crates/boop-parser/src/generated_sdk/instructions/initialize.rs deleted file mode 100644 index 7492bb27..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/initialize.rs +++ /dev/null @@ -1,422 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct Initialize { - pub config: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl Initialize { - pub fn instruction(&self, args: InitializeInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new(self.authority, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionData { - discriminator: [u8; 8], -} - -impl InitializeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [175, 175, 109, 31, 13, 152, 155, 237], - } - } -} - -impl Default for InitializeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionArgs { - pub protocol_fee_recipient: Pubkey, - pub token_distributor: Pubkey, -} - -/// Instruction builder for `Initialize`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` authority -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeBuilder { - config: Option, - authority: Option, - system_program: Option, - protocol_fee_recipient: Option, - token_distributor: Option, - __remaining_accounts: Vec, -} - -impl InitializeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient(&mut self, protocol_fee_recipient: Pubkey) -> &mut Self { - self.protocol_fee_recipient = Some(protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn token_distributor(&mut self, token_distributor: Pubkey) -> &mut Self { - self.token_distributor = Some(token_distributor); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Initialize { - config: self.config.expect("config is not set"), - authority: self.authority.expect("authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializeInstructionArgs { - protocol_fee_recipient: self - .protocol_fee_recipient - .clone() - .expect("protocol_fee_recipient is not set"), - token_distributor: self - .token_distributor - .clone() - .expect("token_distributor is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize` CPI accounts. -pub struct InitializeCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize` CPI instruction. -pub struct InitializeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeInstructionArgs, -} - -impl<'a, 'b> InitializeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCpiAccounts<'a, 'b>, - args: InitializeInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - authority: accounts.authority, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Initialize` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` authority -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCpiBuilderInstruction { - __program: program, - config: None, - authority: None, - system_program: None, - protocol_fee_recipient: None, - token_distributor: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient(&mut self, protocol_fee_recipient: Pubkey) -> &mut Self { - self.instruction.protocol_fee_recipient = Some(protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn token_distributor(&mut self, token_distributor: Pubkey) -> &mut Self { - self.instruction.token_distributor = Some(token_distributor); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeInstructionArgs { - protocol_fee_recipient: self - .instruction - .protocol_fee_recipient - .clone() - .expect("protocol_fee_recipient is not set"), - token_distributor: self - .instruction - .token_distributor - .clone() - .expect("token_distributor is not set"), - }; - let instruction = InitializeCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_fee_recipient: Option, - token_distributor: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/initiate_authority_transfer.rs b/crates/boop-parser/src/generated_sdk/instructions/initiate_authority_transfer.rs deleted file mode 100644 index 3981ecef..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/initiate_authority_transfer.rs +++ /dev/null @@ -1,403 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct InitiateAuthorityTransfer { - pub authority: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitiateAuthorityTransfer { - pub fn instruction( - &self, - args: InitiateAuthorityTransferInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitiateAuthorityTransferInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitiateAuthorityTransferInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitiateAuthorityTransferInstructionData { - discriminator: [u8; 8], -} - -impl InitiateAuthorityTransferInstructionData { - pub fn new() -> Self { - Self { - discriminator: [210, 43, 101, 215, 119, 140, 106, 218], - } - } -} - -impl Default for InitiateAuthorityTransferInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitiateAuthorityTransferInstructionArgs { - pub new_authority: Pubkey, -} - -/// Instruction builder for `InitiateAuthorityTransfer`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[writable]` config -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitiateAuthorityTransferBuilder { - authority: Option, - config: Option, - system_program: Option, - new_authority: Option, - __remaining_accounts: Vec, -} - -impl InitiateAuthorityTransferBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn new_authority(&mut self, new_authority: Pubkey) -> &mut Self { - self.new_authority = Some(new_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitiateAuthorityTransfer { - authority: self.authority.expect("authority is not set"), - config: self.config.expect("config is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitiateAuthorityTransferInstructionArgs { - new_authority: self - .new_authority - .clone() - .expect("new_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initiate_authority_transfer` CPI accounts. -pub struct InitiateAuthorityTransferCpiAccounts<'a, 'b> { - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initiate_authority_transfer` CPI instruction. -pub struct InitiateAuthorityTransferCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitiateAuthorityTransferInstructionArgs, -} - -impl<'a, 'b> InitiateAuthorityTransferCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitiateAuthorityTransferCpiAccounts<'a, 'b>, - args: InitiateAuthorityTransferInstructionArgs, - ) -> Self { - Self { - __program: program, - authority: accounts.authority, - config: accounts.config, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitiateAuthorityTransferInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitiateAuthorityTransfer` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[writable]` config -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitiateAuthorityTransferCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitiateAuthorityTransferCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitiateAuthorityTransferCpiBuilderInstruction { - __program: program, - authority: None, - config: None, - system_program: None, - new_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn new_authority(&mut self, new_authority: Pubkey) -> &mut Self { - self.instruction.new_authority = Some(new_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitiateAuthorityTransferInstructionArgs { - new_authority: self - .instruction - .new_authority - .clone() - .expect("new_authority is not set"), - }; - let instruction = InitiateAuthorityTransferCpi { - __program: self.instruction.__program, - - authority: self.instruction.authority.expect("authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitiateAuthorityTransferCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - new_authority: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/lock_raydium_liquidity.rs b/crates/boop-parser/src/generated_sdk/instructions/lock_raydium_liquidity.rs deleted file mode 100644 index bd3ff7a7..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/lock_raydium_liquidity.rs +++ /dev/null @@ -1,1167 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct LockRaydiumLiquidity { - pub lock_program: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub fee_nft_owner: solana_pubkey::Pubkey, - - pub fee_nft_mint: solana_pubkey::Pubkey, - - pub fee_nft_account: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - /// Store the locked information of liquidity - pub locked_liquidity: solana_pubkey::Pubkey, - /// The mint of liquidity token - pub lp_mint: solana_pubkey::Pubkey, - /// liquidity owner lp token account - pub liquidity_owner_lp: solana_pubkey::Pubkey, - - pub locked_lp_vault: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_0 - pub token0_vault: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_1 - pub token1_vault: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - /// To store metaplex metadata - pub metadata_account: solana_pubkey::Pubkey, - /// Sysvar for token mint and ATA creation - pub rent: solana_pubkey::Pubkey, - /// Program to create the new account - pub system_program: solana_pubkey::Pubkey, - /// Program to create/transfer mint/token account - pub token_program: solana_pubkey::Pubkey, - /// Program to create an ATA for receiving fee NFT - pub associated_token_program: solana_pubkey::Pubkey, - /// Program to create NFT metadata accunt - pub metadata_program: solana_pubkey::Pubkey, -} - -impl LockRaydiumLiquidity { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(22 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lock_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_nft_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_nft_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.locked_liquidity, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.liquidity_owner_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.locked_lp_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.operator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.metadata_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&LockRaydiumLiquidityInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockRaydiumLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl LockRaydiumLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [173, 255, 148, 6, 122, 99, 140, 22], - } - } -} - -impl Default for LockRaydiumLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `LockRaydiumLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` lock_program (default to `LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE`) -/// 1. `[writable]` vault_authority -/// 2. `[]` authority -/// 3. `[]` fee_nft_owner -/// 4. `[writable, signer]` fee_nft_mint -/// 5. `[writable]` fee_nft_account -/// 6. `[writable]` pool_state -/// 7. `[writable]` locked_liquidity -/// 8. `[writable]` lp_mint -/// 9. `[writable]` liquidity_owner_lp -/// 10. `[writable]` locked_lp_vault -/// 11. `[writable]` token0_vault -/// 12. `[writable]` token1_vault -/// 13. `[writable, signer]` operator -/// 14. `[]` config -/// 15. `[writable]` bonding_curve -/// 16. `[writable]` metadata_account -/// 17. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 18. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 19. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 20. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 21. `[optional]` metadata_program (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -#[derive(Clone, Debug, Default)] -pub struct LockRaydiumLiquidityBuilder { - lock_program: Option, - vault_authority: Option, - authority: Option, - fee_nft_owner: Option, - fee_nft_mint: Option, - fee_nft_account: Option, - pool_state: Option, - locked_liquidity: Option, - lp_mint: Option, - liquidity_owner_lp: Option, - locked_lp_vault: Option, - token0_vault: Option, - token1_vault: Option, - operator: Option, - config: Option, - bonding_curve: Option, - metadata_account: Option, - rent: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - metadata_program: Option, - __remaining_accounts: Vec, -} - -impl LockRaydiumLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE']` - #[inline(always)] - pub fn lock_program(&mut self, lock_program: solana_pubkey::Pubkey) -> &mut Self { - self.lock_program = Some(lock_program); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn fee_nft_owner(&mut self, fee_nft_owner: solana_pubkey::Pubkey) -> &mut Self { - self.fee_nft_owner = Some(fee_nft_owner); - self - } - - #[inline(always)] - pub fn fee_nft_mint(&mut self, fee_nft_mint: solana_pubkey::Pubkey) -> &mut Self { - self.fee_nft_mint = Some(fee_nft_mint); - self - } - - #[inline(always)] - pub fn fee_nft_account(&mut self, fee_nft_account: solana_pubkey::Pubkey) -> &mut Self { - self.fee_nft_account = Some(fee_nft_account); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Store the locked information of liquidity - #[inline(always)] - pub fn locked_liquidity(&mut self, locked_liquidity: solana_pubkey::Pubkey) -> &mut Self { - self.locked_liquidity = Some(locked_liquidity); - self - } - - /// The mint of liquidity token - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// liquidity owner lp token account - #[inline(always)] - pub fn liquidity_owner_lp(&mut self, liquidity_owner_lp: solana_pubkey::Pubkey) -> &mut Self { - self.liquidity_owner_lp = Some(liquidity_owner_lp); - self - } - - #[inline(always)] - pub fn locked_lp_vault(&mut self, locked_lp_vault: solana_pubkey::Pubkey) -> &mut Self { - self.locked_lp_vault = Some(locked_lp_vault); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - /// To store metaplex metadata - #[inline(always)] - pub fn metadata_account(&mut self, metadata_account: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_account = Some(metadata_account); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Sysvar for token mint and ATA creation - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Program to create the new account - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Program to create/transfer mint/token account - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Program to create an ATA for receiving fee NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - /// Program to create NFT metadata accunt - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = LockRaydiumLiquidity { - lock_program: self.lock_program.unwrap_or(solana_pubkey::pubkey!( - "LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE" - )), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - authority: self.authority.expect("authority is not set"), - fee_nft_owner: self.fee_nft_owner.expect("fee_nft_owner is not set"), - fee_nft_mint: self.fee_nft_mint.expect("fee_nft_mint is not set"), - fee_nft_account: self.fee_nft_account.expect("fee_nft_account is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - locked_liquidity: self.locked_liquidity.expect("locked_liquidity is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - liquidity_owner_lp: self - .liquidity_owner_lp - .expect("liquidity_owner_lp is not set"), - locked_lp_vault: self.locked_lp_vault.expect("locked_lp_vault is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - operator: self.operator.expect("operator is not set"), - config: self.config.expect("config is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - metadata_account: self.metadata_account.expect("metadata_account is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - metadata_program: self.metadata_program.unwrap_or(solana_pubkey::pubkey!( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `lock_raydium_liquidity` CPI accounts. -pub struct LockRaydiumLiquidityCpiAccounts<'a, 'b> { - pub lock_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub fee_nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub fee_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub fee_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Store the locked information of liquidity - pub locked_liquidity: &'b solana_account_info::AccountInfo<'a>, - /// The mint of liquidity token - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// liquidity owner lp token account - pub liquidity_owner_lp: &'b solana_account_info::AccountInfo<'a>, - - pub locked_lp_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - /// To store metaplex metadata - pub metadata_account: &'b solana_account_info::AccountInfo<'a>, - /// Sysvar for token mint and ATA creation - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// Program to create the new account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create/transfer mint/token account - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving fee NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT metadata accunt - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `lock_raydium_liquidity` CPI instruction. -pub struct LockRaydiumLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lock_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub fee_nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub fee_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub fee_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Store the locked information of liquidity - pub locked_liquidity: &'b solana_account_info::AccountInfo<'a>, - /// The mint of liquidity token - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// liquidity owner lp token account - pub liquidity_owner_lp: &'b solana_account_info::AccountInfo<'a>, - - pub locked_lp_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - /// To store metaplex metadata - pub metadata_account: &'b solana_account_info::AccountInfo<'a>, - /// Sysvar for token mint and ATA creation - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// Program to create the new account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create/transfer mint/token account - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving fee NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT metadata accunt - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> LockRaydiumLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: LockRaydiumLiquidityCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - lock_program: accounts.lock_program, - vault_authority: accounts.vault_authority, - authority: accounts.authority, - fee_nft_owner: accounts.fee_nft_owner, - fee_nft_mint: accounts.fee_nft_mint, - fee_nft_account: accounts.fee_nft_account, - pool_state: accounts.pool_state, - locked_liquidity: accounts.locked_liquidity, - lp_mint: accounts.lp_mint, - liquidity_owner_lp: accounts.liquidity_owner_lp, - locked_lp_vault: accounts.locked_lp_vault, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - operator: accounts.operator, - config: accounts.config, - bonding_curve: accounts.bonding_curve, - metadata_account: accounts.metadata_account, - rent: accounts.rent, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - metadata_program: accounts.metadata_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(22 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lock_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_nft_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_nft_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.locked_liquidity.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.liquidity_owner_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.locked_lp_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.metadata_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&LockRaydiumLiquidityInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(23 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lock_program.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.fee_nft_owner.clone()); - account_infos.push(self.fee_nft_mint.clone()); - account_infos.push(self.fee_nft_account.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.locked_liquidity.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.liquidity_owner_lp.clone()); - account_infos.push(self.locked_lp_vault.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.metadata_account.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.metadata_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `LockRaydiumLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` lock_program -/// 1. `[writable]` vault_authority -/// 2. `[]` authority -/// 3. `[]` fee_nft_owner -/// 4. `[writable, signer]` fee_nft_mint -/// 5. `[writable]` fee_nft_account -/// 6. `[writable]` pool_state -/// 7. `[writable]` locked_liquidity -/// 8. `[writable]` lp_mint -/// 9. `[writable]` liquidity_owner_lp -/// 10. `[writable]` locked_lp_vault -/// 11. `[writable]` token0_vault -/// 12. `[writable]` token1_vault -/// 13. `[writable, signer]` operator -/// 14. `[]` config -/// 15. `[writable]` bonding_curve -/// 16. `[writable]` metadata_account -/// 17. `[]` rent -/// 18. `[]` system_program -/// 19. `[]` token_program -/// 20. `[]` associated_token_program -/// 21. `[]` metadata_program -#[derive(Clone, Debug)] -pub struct LockRaydiumLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> LockRaydiumLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(LockRaydiumLiquidityCpiBuilderInstruction { - __program: program, - lock_program: None, - vault_authority: None, - authority: None, - fee_nft_owner: None, - fee_nft_mint: None, - fee_nft_account: None, - pool_state: None, - locked_liquidity: None, - lp_mint: None, - liquidity_owner_lp: None, - locked_lp_vault: None, - token0_vault: None, - token1_vault: None, - operator: None, - config: None, - bonding_curve: None, - metadata_account: None, - rent: None, - system_program: None, - token_program: None, - associated_token_program: None, - metadata_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lock_program( - &mut self, - lock_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_program = Some(lock_program); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn fee_nft_owner( - &mut self, - fee_nft_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_nft_owner = Some(fee_nft_owner); - self - } - - #[inline(always)] - pub fn fee_nft_mint( - &mut self, - fee_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_nft_mint = Some(fee_nft_mint); - self - } - - #[inline(always)] - pub fn fee_nft_account( - &mut self, - fee_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_nft_account = Some(fee_nft_account); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Store the locked information of liquidity - #[inline(always)] - pub fn locked_liquidity( - &mut self, - locked_liquidity: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.locked_liquidity = Some(locked_liquidity); - self - } - - /// The mint of liquidity token - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// liquidity owner lp token account - #[inline(always)] - pub fn liquidity_owner_lp( - &mut self, - liquidity_owner_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.liquidity_owner_lp = Some(liquidity_owner_lp); - self - } - - #[inline(always)] - pub fn locked_lp_vault( - &mut self, - locked_lp_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.locked_lp_vault = Some(locked_lp_vault); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - /// To store metaplex metadata - #[inline(always)] - pub fn metadata_account( - &mut self, - metadata_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_account = Some(metadata_account); - self - } - - /// Sysvar for token mint and ATA creation - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - /// Program to create the new account - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Program to create/transfer mint/token account - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Program to create an ATA for receiving fee NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// Program to create NFT metadata accunt - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = LockRaydiumLiquidityCpi { - __program: self.instruction.__program, - - lock_program: self - .instruction - .lock_program - .expect("lock_program is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - fee_nft_owner: self - .instruction - .fee_nft_owner - .expect("fee_nft_owner is not set"), - - fee_nft_mint: self - .instruction - .fee_nft_mint - .expect("fee_nft_mint is not set"), - - fee_nft_account: self - .instruction - .fee_nft_account - .expect("fee_nft_account is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - locked_liquidity: self - .instruction - .locked_liquidity - .expect("locked_liquidity is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - liquidity_owner_lp: self - .instruction - .liquidity_owner_lp - .expect("liquidity_owner_lp is not set"), - - locked_lp_vault: self - .instruction - .locked_lp_vault - .expect("locked_lp_vault is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - config: self.instruction.config.expect("config is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - metadata_account: self - .instruction - .metadata_account - .expect("metadata_account is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct LockRaydiumLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lock_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_nft_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - locked_liquidity: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity_owner_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - locked_lp_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_account: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/mod.rs b/crates/boop-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index eae0afdc..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,42 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#add_operators; -pub(crate) mod r#buy_token; -pub(crate) mod r#cancel_authority_transfer; -pub(crate) mod r#close_bonding_curve_vault; -pub(crate) mod r#collect_trading_fees; -pub(crate) mod r#complete_authority_transfer; -pub(crate) mod r#create_raydium_pool; -pub(crate) mod r#create_raydium_random_pool; -pub(crate) mod r#create_token; -pub(crate) mod r#create_token_fallback; -pub(crate) mod r#deploy_bonding_curve; -pub(crate) mod r#deploy_bonding_curve_fallback; -pub(crate) mod r#deposit_into_raydium; -pub(crate) mod r#graduate; -pub(crate) mod r#initialize; -pub(crate) mod r#initiate_authority_transfer; -pub(crate) mod r#lock_raydium_liquidity; -pub(crate) mod r#remove_operators; -pub(crate) mod r#sell_token; -pub(crate) mod r#split_trading_fees; -pub(crate) mod r#swap_sol_for_tokens_on_raydium; -pub(crate) mod r#swap_tokens_for_sol_on_raydium; -pub(crate) mod r#toggle_paused; -pub(crate) mod r#update_config; - -pub use self::{ - r#add_operators::*, r#buy_token::*, r#cancel_authority_transfer::*, - r#close_bonding_curve_vault::*, r#collect_trading_fees::*, r#complete_authority_transfer::*, - r#create_raydium_pool::*, r#create_raydium_random_pool::*, r#create_token::*, - r#create_token_fallback::*, r#deploy_bonding_curve::*, r#deploy_bonding_curve_fallback::*, - r#deposit_into_raydium::*, r#graduate::*, r#initialize::*, r#initiate_authority_transfer::*, - r#lock_raydium_liquidity::*, r#remove_operators::*, r#sell_token::*, r#split_trading_fees::*, - r#swap_sol_for_tokens_on_raydium::*, r#swap_tokens_for_sol_on_raydium::*, r#toggle_paused::*, - r#update_config::*, -}; diff --git a/crates/boop-parser/src/generated_sdk/instructions/remove_operators.rs b/crates/boop-parser/src/generated_sdk/instructions/remove_operators.rs deleted file mode 100644 index fd76801b..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/remove_operators.rs +++ /dev/null @@ -1,397 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveOperators { - pub config: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl RemoveOperators { - pub fn instruction( - &self, - args: RemoveOperatorsInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemoveOperatorsInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new(self.authority, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RemoveOperatorsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveOperatorsInstructionData { - discriminator: [u8; 8], -} - -impl RemoveOperatorsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [42, 20, 89, 83, 222, 37, 4, 109], - } - } -} - -impl Default for RemoveOperatorsInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveOperatorsInstructionArgs { - pub operators: Vec, -} - -/// Instruction builder for `RemoveOperators`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` authority -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct RemoveOperatorsBuilder { - config: Option, - authority: Option, - system_program: Option, - operators: Option>, - __remaining_accounts: Vec, -} - -impl RemoveOperatorsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn operators(&mut self, operators: Vec) -> &mut Self { - self.operators = Some(operators); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveOperators { - config: self.config.expect("config is not set"), - authority: self.authority.expect("authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = RemoveOperatorsInstructionArgs { - operators: self.operators.clone().expect("operators is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_operators` CPI accounts. -pub struct RemoveOperatorsCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_operators` CPI instruction. -pub struct RemoveOperatorsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemoveOperatorsInstructionArgs, -} - -impl<'a, 'b> RemoveOperatorsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveOperatorsCpiAccounts<'a, 'b>, - args: RemoveOperatorsInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - authority: accounts.authority, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RemoveOperatorsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveOperators` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` authority -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct RemoveOperatorsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveOperatorsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveOperatorsCpiBuilderInstruction { - __program: program, - config: None, - authority: None, - system_program: None, - operators: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn operators(&mut self, operators: Vec) -> &mut Self { - self.instruction.operators = Some(operators); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RemoveOperatorsInstructionArgs { - operators: self - .instruction - .operators - .clone() - .expect("operators is not set"), - }; - let instruction = RemoveOperatorsCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveOperatorsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - operators: Option>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/sell_token.rs b/crates/boop-parser/src/generated_sdk/instructions/sell_token.rs deleted file mode 100644 index 61ef3c6a..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/sell_token.rs +++ /dev/null @@ -1,803 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SellToken { - pub mint: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub trading_fees_vault: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub bonding_curve_sol_vault: solana_pubkey::Pubkey, - - pub seller_token_account: solana_pubkey::Pubkey, - - pub seller: solana_pubkey::Pubkey, - - pub recipient: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl SellToken { - pub fn instruction(&self, args: SellTokenInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SellTokenInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.trading_fees_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_sol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.seller_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.seller, true)); - accounts.push(solana_instruction::AccountMeta::new(self.recipient, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SellTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellTokenInstructionData { - discriminator: [u8; 8], -} - -impl SellTokenInstructionData { - pub fn new() -> Self { - Self { - discriminator: [109, 61, 40, 187, 230, 176, 135, 174], - } - } -} - -impl Default for SellTokenInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellTokenInstructionArgs { - pub sell_amount: u64, - pub amount_out_min: u64, -} - -/// Instruction builder for `SellToken`. -/// -/// ### Accounts: -/// -/// 0. `[]` mint -/// 1. `[writable]` bonding_curve -/// 2. `[writable]` trading_fees_vault -/// 3. `[writable]` bonding_curve_vault -/// 4. `[writable]` bonding_curve_sol_vault -/// 5. `[writable]` seller_token_account -/// 6. `[writable, signer]` seller -/// 7. `[writable]` recipient -/// 8. `[]` config -/// 9. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 10. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 11. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -#[derive(Clone, Debug, Default)] -pub struct SellTokenBuilder { - mint: Option, - bonding_curve: Option, - trading_fees_vault: Option, - bonding_curve_vault: Option, - bonding_curve_sol_vault: Option, - seller_token_account: Option, - seller: Option, - recipient: Option, - config: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - sell_amount: Option, - amount_out_min: Option, - __remaining_accounts: Vec, -} - -impl SellTokenBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn trading_fees_vault(&mut self, trading_fees_vault: solana_pubkey::Pubkey) -> &mut Self { - self.trading_fees_vault = Some(trading_fees_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_sol_vault( - &mut self, - bonding_curve_sol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_sol_vault = Some(bonding_curve_sol_vault); - self - } - - #[inline(always)] - pub fn seller_token_account( - &mut self, - seller_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.seller_token_account = Some(seller_token_account); - self - } - - #[inline(always)] - pub fn seller(&mut self, seller: solana_pubkey::Pubkey) -> &mut Self { - self.seller = Some(seller); - self - } - - #[inline(always)] - pub fn recipient(&mut self, recipient: solana_pubkey::Pubkey) -> &mut Self { - self.recipient = Some(recipient); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn sell_amount(&mut self, sell_amount: u64) -> &mut Self { - self.sell_amount = Some(sell_amount); - self - } - - #[inline(always)] - pub fn amount_out_min(&mut self, amount_out_min: u64) -> &mut Self { - self.amount_out_min = Some(amount_out_min); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SellToken { - mint: self.mint.expect("mint is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - trading_fees_vault: self - .trading_fees_vault - .expect("trading_fees_vault is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - bonding_curve_sol_vault: self - .bonding_curve_sol_vault - .expect("bonding_curve_sol_vault is not set"), - seller_token_account: self - .seller_token_account - .expect("seller_token_account is not set"), - seller: self.seller.expect("seller is not set"), - recipient: self.recipient.expect("recipient is not set"), - config: self.config.expect("config is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - }; - let args = SellTokenInstructionArgs { - sell_amount: self.sell_amount.clone().expect("sell_amount is not set"), - amount_out_min: self - .amount_out_min - .clone() - .expect("amount_out_min is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `sell_token` CPI accounts. -pub struct SellTokenCpiAccounts<'a, 'b> { - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub trading_fees_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub seller_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub seller: &'b solana_account_info::AccountInfo<'a>, - - pub recipient: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `sell_token` CPI instruction. -pub struct SellTokenCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub trading_fees_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub seller_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub seller: &'b solana_account_info::AccountInfo<'a>, - - pub recipient: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SellTokenInstructionArgs, -} - -impl<'a, 'b> SellTokenCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SellTokenCpiAccounts<'a, 'b>, - args: SellTokenInstructionArgs, - ) -> Self { - Self { - __program: program, - mint: accounts.mint, - bonding_curve: accounts.bonding_curve, - trading_fees_vault: accounts.trading_fees_vault, - bonding_curve_vault: accounts.bonding_curve_vault, - bonding_curve_sol_vault: accounts.bonding_curve_sol_vault, - seller_token_account: accounts.seller_token_account, - seller: accounts.seller, - recipient: accounts.recipient, - config: accounts.config, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.trading_fees_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_sol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.seller_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.seller.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SellTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.trading_fees_vault.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.bonding_curve_sol_vault.clone()); - account_infos.push(self.seller_token_account.clone()); - account_infos.push(self.seller.clone()); - account_infos.push(self.recipient.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SellToken` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` mint -/// 1. `[writable]` bonding_curve -/// 2. `[writable]` trading_fees_vault -/// 3. `[writable]` bonding_curve_vault -/// 4. `[writable]` bonding_curve_sol_vault -/// 5. `[writable]` seller_token_account -/// 6. `[writable, signer]` seller -/// 7. `[writable]` recipient -/// 8. `[]` config -/// 9. `[]` system_program -/// 10. `[]` token_program -/// 11. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct SellTokenCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SellTokenCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SellTokenCpiBuilderInstruction { - __program: program, - mint: None, - bonding_curve: None, - trading_fees_vault: None, - bonding_curve_vault: None, - bonding_curve_sol_vault: None, - seller_token_account: None, - seller: None, - recipient: None, - config: None, - system_program: None, - token_program: None, - associated_token_program: None, - sell_amount: None, - amount_out_min: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn trading_fees_vault( - &mut self, - trading_fees_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.trading_fees_vault = Some(trading_fees_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_sol_vault( - &mut self, - bonding_curve_sol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_sol_vault = Some(bonding_curve_sol_vault); - self - } - - #[inline(always)] - pub fn seller_token_account( - &mut self, - seller_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.seller_token_account = Some(seller_token_account); - self - } - - #[inline(always)] - pub fn seller(&mut self, seller: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.seller = Some(seller); - self - } - - #[inline(always)] - pub fn recipient(&mut self, recipient: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.recipient = Some(recipient); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn sell_amount(&mut self, sell_amount: u64) -> &mut Self { - self.instruction.sell_amount = Some(sell_amount); - self - } - - #[inline(always)] - pub fn amount_out_min(&mut self, amount_out_min: u64) -> &mut Self { - self.instruction.amount_out_min = Some(amount_out_min); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SellTokenInstructionArgs { - sell_amount: self - .instruction - .sell_amount - .clone() - .expect("sell_amount is not set"), - amount_out_min: self - .instruction - .amount_out_min - .clone() - .expect("amount_out_min is not set"), - }; - let instruction = SellTokenCpi { - __program: self.instruction.__program, - - mint: self.instruction.mint.expect("mint is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - trading_fees_vault: self - .instruction - .trading_fees_vault - .expect("trading_fees_vault is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - bonding_curve_sol_vault: self - .instruction - .bonding_curve_sol_vault - .expect("bonding_curve_sol_vault is not set"), - - seller_token_account: self - .instruction - .seller_token_account - .expect("seller_token_account is not set"), - - seller: self.instruction.seller.expect("seller is not set"), - - recipient: self.instruction.recipient.expect("recipient is not set"), - - config: self.instruction.config.expect("config is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SellTokenCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - trading_fees_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_sol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - seller_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - seller: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - sell_amount: Option, - amount_out_min: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/split_trading_fees.rs b/crates/boop-parser/src/generated_sdk/instructions/split_trading_fees.rs deleted file mode 100644 index 96af9971..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/split_trading_fees.rs +++ /dev/null @@ -1,1313 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SplitTradingFees { - pub operator: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub wsol: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub trading_fees_vault: solana_pubkey::Pubkey, - - pub fee_splitter_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub fee_splitter_config: solana_pubkey::Pubkey, - - pub fee_splitter_creator_vault: solana_pubkey::Pubkey, - - pub fee_splitter_vault_authority: solana_pubkey::Pubkey, - - pub fee_splitter_creator_vault_authority: solana_pubkey::Pubkey, - - pub fee_splitter_staking_mint: solana_pubkey::Pubkey, - - pub fee_splitter_wsol_vault: solana_pubkey::Pubkey, - - pub fee_splitter_creator_vault_authority_wsol_vault: solana_pubkey::Pubkey, - - pub fee_splitter_treasury_wsol_vault: solana_pubkey::Pubkey, - - pub fee_splitter_team_wsol_vault: solana_pubkey::Pubkey, - - pub fee_splitter_reward_pool: solana_pubkey::Pubkey, - - pub fee_splitter_reward_pool_staking_vault: solana_pubkey::Pubkey, - - pub fee_splitter_reward_pool_reward_vault: solana_pubkey::Pubkey, - - pub fee_splitter_reward_pool_program: solana_pubkey::Pubkey, -} - -impl SplitTradingFees { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(24 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.operator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.wsol, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.trading_fees_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_splitter_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_splitter_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_splitter_creator_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_splitter_vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_splitter_creator_vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_splitter_staking_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_splitter_wsol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_splitter_creator_vault_authority_wsol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_splitter_treasury_wsol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_splitter_team_wsol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_splitter_reward_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_splitter_reward_pool_staking_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_splitter_reward_pool_reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_splitter_reward_pool_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SplitTradingFeesInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SplitTradingFeesInstructionData { - discriminator: [u8; 8], -} - -impl SplitTradingFeesInstructionData { - pub fn new() -> Self { - Self { - discriminator: [96, 126, 225, 47, 185, 213, 50, 58], - } - } -} - -impl Default for SplitTradingFeesInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SplitTradingFees`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` operator -/// 1. `[]` mint -/// 2. `[optional]` wsol (default to `So11111111111111111111111111111111111111112`) -/// 3. `[]` config -/// 4. `[]` vault_authority -/// 5. `[writable]` bonding_curve -/// 6. `[writable]` trading_fees_vault -/// 7. `[optional]` fee_splitter_program (default to `boopEYztaEYSnajfMtjcRysyzyRcchgKsPboRZEbnJi`) -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 10. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 11. `[]` fee_splitter_config -/// 12. `[writable]` fee_splitter_creator_vault -/// 13. `[writable]` fee_splitter_vault_authority -/// 14. `[writable]` fee_splitter_creator_vault_authority -/// 15. `[]` fee_splitter_staking_mint -/// 16. `[writable]` fee_splitter_wsol_vault -/// 17. `[writable]` fee_splitter_creator_vault_authority_wsol_vault -/// 18. `[writable]` fee_splitter_treasury_wsol_vault -/// 19. `[writable]` fee_splitter_team_wsol_vault -/// 20. `[writable]` fee_splitter_reward_pool -/// 21. `[writable]` fee_splitter_reward_pool_staking_vault -/// 22. `[writable]` fee_splitter_reward_pool_reward_vault -/// 23. `[]` fee_splitter_reward_pool_program -#[derive(Clone, Debug, Default)] -pub struct SplitTradingFeesBuilder { - operator: Option, - mint: Option, - wsol: Option, - config: Option, - vault_authority: Option, - bonding_curve: Option, - trading_fees_vault: Option, - fee_splitter_program: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - fee_splitter_config: Option, - fee_splitter_creator_vault: Option, - fee_splitter_vault_authority: Option, - fee_splitter_creator_vault_authority: Option, - fee_splitter_staking_mint: Option, - fee_splitter_wsol_vault: Option, - fee_splitter_creator_vault_authority_wsol_vault: Option, - fee_splitter_treasury_wsol_vault: Option, - fee_splitter_team_wsol_vault: Option, - fee_splitter_reward_pool: Option, - fee_splitter_reward_pool_staking_vault: Option, - fee_splitter_reward_pool_reward_vault: Option, - fee_splitter_reward_pool_program: Option, - __remaining_accounts: Vec, -} - -impl SplitTradingFeesBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - /// `[optional account, default to 'So11111111111111111111111111111111111111112']` - #[inline(always)] - pub fn wsol(&mut self, wsol: solana_pubkey::Pubkey) -> &mut Self { - self.wsol = Some(wsol); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn trading_fees_vault(&mut self, trading_fees_vault: solana_pubkey::Pubkey) -> &mut Self { - self.trading_fees_vault = Some(trading_fees_vault); - self - } - - /// `[optional account, default to 'boopEYztaEYSnajfMtjcRysyzyRcchgKsPboRZEbnJi']` - #[inline(always)] - pub fn fee_splitter_program( - &mut self, - fee_splitter_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_program = Some(fee_splitter_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn fee_splitter_config(&mut self, fee_splitter_config: solana_pubkey::Pubkey) -> &mut Self { - self.fee_splitter_config = Some(fee_splitter_config); - self - } - - #[inline(always)] - pub fn fee_splitter_creator_vault( - &mut self, - fee_splitter_creator_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_creator_vault = Some(fee_splitter_creator_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_vault_authority( - &mut self, - fee_splitter_vault_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_vault_authority = Some(fee_splitter_vault_authority); - self - } - - #[inline(always)] - pub fn fee_splitter_creator_vault_authority( - &mut self, - fee_splitter_creator_vault_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_creator_vault_authority = Some(fee_splitter_creator_vault_authority); - self - } - - #[inline(always)] - pub fn fee_splitter_staking_mint( - &mut self, - fee_splitter_staking_mint: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_staking_mint = Some(fee_splitter_staking_mint); - self - } - - #[inline(always)] - pub fn fee_splitter_wsol_vault( - &mut self, - fee_splitter_wsol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_wsol_vault = Some(fee_splitter_wsol_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_creator_vault_authority_wsol_vault( - &mut self, - fee_splitter_creator_vault_authority_wsol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_creator_vault_authority_wsol_vault = - Some(fee_splitter_creator_vault_authority_wsol_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_treasury_wsol_vault( - &mut self, - fee_splitter_treasury_wsol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_treasury_wsol_vault = Some(fee_splitter_treasury_wsol_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_team_wsol_vault( - &mut self, - fee_splitter_team_wsol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_team_wsol_vault = Some(fee_splitter_team_wsol_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_reward_pool( - &mut self, - fee_splitter_reward_pool: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_reward_pool = Some(fee_splitter_reward_pool); - self - } - - #[inline(always)] - pub fn fee_splitter_reward_pool_staking_vault( - &mut self, - fee_splitter_reward_pool_staking_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_reward_pool_staking_vault = Some(fee_splitter_reward_pool_staking_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_reward_pool_reward_vault( - &mut self, - fee_splitter_reward_pool_reward_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_reward_pool_reward_vault = Some(fee_splitter_reward_pool_reward_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_reward_pool_program( - &mut self, - fee_splitter_reward_pool_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.fee_splitter_reward_pool_program = Some(fee_splitter_reward_pool_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SplitTradingFees { - operator: self.operator.expect("operator is not set"), - mint: self.mint.expect("mint is not set"), - wsol: self.wsol.unwrap_or(solana_pubkey::pubkey!( - "So11111111111111111111111111111111111111112" - )), - config: self.config.expect("config is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - trading_fees_vault: self - .trading_fees_vault - .expect("trading_fees_vault is not set"), - fee_splitter_program: self.fee_splitter_program.unwrap_or(solana_pubkey::pubkey!( - "boopEYztaEYSnajfMtjcRysyzyRcchgKsPboRZEbnJi" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - fee_splitter_config: self - .fee_splitter_config - .expect("fee_splitter_config is not set"), - fee_splitter_creator_vault: self - .fee_splitter_creator_vault - .expect("fee_splitter_creator_vault is not set"), - fee_splitter_vault_authority: self - .fee_splitter_vault_authority - .expect("fee_splitter_vault_authority is not set"), - fee_splitter_creator_vault_authority: self - .fee_splitter_creator_vault_authority - .expect("fee_splitter_creator_vault_authority is not set"), - fee_splitter_staking_mint: self - .fee_splitter_staking_mint - .expect("fee_splitter_staking_mint is not set"), - fee_splitter_wsol_vault: self - .fee_splitter_wsol_vault - .expect("fee_splitter_wsol_vault is not set"), - fee_splitter_creator_vault_authority_wsol_vault: self - .fee_splitter_creator_vault_authority_wsol_vault - .expect("fee_splitter_creator_vault_authority_wsol_vault is not set"), - fee_splitter_treasury_wsol_vault: self - .fee_splitter_treasury_wsol_vault - .expect("fee_splitter_treasury_wsol_vault is not set"), - fee_splitter_team_wsol_vault: self - .fee_splitter_team_wsol_vault - .expect("fee_splitter_team_wsol_vault is not set"), - fee_splitter_reward_pool: self - .fee_splitter_reward_pool - .expect("fee_splitter_reward_pool is not set"), - fee_splitter_reward_pool_staking_vault: self - .fee_splitter_reward_pool_staking_vault - .expect("fee_splitter_reward_pool_staking_vault is not set"), - fee_splitter_reward_pool_reward_vault: self - .fee_splitter_reward_pool_reward_vault - .expect("fee_splitter_reward_pool_reward_vault is not set"), - fee_splitter_reward_pool_program: self - .fee_splitter_reward_pool_program - .expect("fee_splitter_reward_pool_program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `split_trading_fees` CPI accounts. -pub struct SplitTradingFeesCpiAccounts<'a, 'b> { - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub wsol: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub trading_fees_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_creator_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_staking_mint: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_creator_vault_authority_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_treasury_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_team_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_reward_pool: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_reward_pool_staking_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_reward_pool_reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_reward_pool_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `split_trading_fees` CPI instruction. -pub struct SplitTradingFeesCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub wsol: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub trading_fees_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_creator_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_staking_mint: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_creator_vault_authority_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_treasury_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_team_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_reward_pool: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_reward_pool_staking_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_reward_pool_reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub fee_splitter_reward_pool_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SplitTradingFeesCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SplitTradingFeesCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - operator: accounts.operator, - mint: accounts.mint, - wsol: accounts.wsol, - config: accounts.config, - vault_authority: accounts.vault_authority, - bonding_curve: accounts.bonding_curve, - trading_fees_vault: accounts.trading_fees_vault, - fee_splitter_program: accounts.fee_splitter_program, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - fee_splitter_config: accounts.fee_splitter_config, - fee_splitter_creator_vault: accounts.fee_splitter_creator_vault, - fee_splitter_vault_authority: accounts.fee_splitter_vault_authority, - fee_splitter_creator_vault_authority: accounts.fee_splitter_creator_vault_authority, - fee_splitter_staking_mint: accounts.fee_splitter_staking_mint, - fee_splitter_wsol_vault: accounts.fee_splitter_wsol_vault, - fee_splitter_creator_vault_authority_wsol_vault: accounts - .fee_splitter_creator_vault_authority_wsol_vault, - fee_splitter_treasury_wsol_vault: accounts.fee_splitter_treasury_wsol_vault, - fee_splitter_team_wsol_vault: accounts.fee_splitter_team_wsol_vault, - fee_splitter_reward_pool: accounts.fee_splitter_reward_pool, - fee_splitter_reward_pool_staking_vault: accounts.fee_splitter_reward_pool_staking_vault, - fee_splitter_reward_pool_reward_vault: accounts.fee_splitter_reward_pool_reward_vault, - fee_splitter_reward_pool_program: accounts.fee_splitter_reward_pool_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(24 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.wsol.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.trading_fees_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_splitter_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_splitter_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_splitter_creator_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_splitter_vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_splitter_creator_vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_splitter_staking_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_splitter_wsol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_splitter_creator_vault_authority_wsol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_splitter_treasury_wsol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_splitter_team_wsol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_splitter_reward_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_splitter_reward_pool_staking_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_splitter_reward_pool_reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_splitter_reward_pool_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SplitTradingFeesInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(25 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.wsol.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.trading_fees_vault.clone()); - account_infos.push(self.fee_splitter_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.fee_splitter_config.clone()); - account_infos.push(self.fee_splitter_creator_vault.clone()); - account_infos.push(self.fee_splitter_vault_authority.clone()); - account_infos.push(self.fee_splitter_creator_vault_authority.clone()); - account_infos.push(self.fee_splitter_staking_mint.clone()); - account_infos.push(self.fee_splitter_wsol_vault.clone()); - account_infos.push(self.fee_splitter_creator_vault_authority_wsol_vault.clone()); - account_infos.push(self.fee_splitter_treasury_wsol_vault.clone()); - account_infos.push(self.fee_splitter_team_wsol_vault.clone()); - account_infos.push(self.fee_splitter_reward_pool.clone()); - account_infos.push(self.fee_splitter_reward_pool_staking_vault.clone()); - account_infos.push(self.fee_splitter_reward_pool_reward_vault.clone()); - account_infos.push(self.fee_splitter_reward_pool_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SplitTradingFees` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` operator -/// 1. `[]` mint -/// 2. `[]` wsol -/// 3. `[]` config -/// 4. `[]` vault_authority -/// 5. `[writable]` bonding_curve -/// 6. `[writable]` trading_fees_vault -/// 7. `[]` fee_splitter_program -/// 8. `[]` system_program -/// 9. `[]` token_program -/// 10. `[]` associated_token_program -/// 11. `[]` fee_splitter_config -/// 12. `[writable]` fee_splitter_creator_vault -/// 13. `[writable]` fee_splitter_vault_authority -/// 14. `[writable]` fee_splitter_creator_vault_authority -/// 15. `[]` fee_splitter_staking_mint -/// 16. `[writable]` fee_splitter_wsol_vault -/// 17. `[writable]` fee_splitter_creator_vault_authority_wsol_vault -/// 18. `[writable]` fee_splitter_treasury_wsol_vault -/// 19. `[writable]` fee_splitter_team_wsol_vault -/// 20. `[writable]` fee_splitter_reward_pool -/// 21. `[writable]` fee_splitter_reward_pool_staking_vault -/// 22. `[writable]` fee_splitter_reward_pool_reward_vault -/// 23. `[]` fee_splitter_reward_pool_program -#[derive(Clone, Debug)] -pub struct SplitTradingFeesCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SplitTradingFeesCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SplitTradingFeesCpiBuilderInstruction { - __program: program, - operator: None, - mint: None, - wsol: None, - config: None, - vault_authority: None, - bonding_curve: None, - trading_fees_vault: None, - fee_splitter_program: None, - system_program: None, - token_program: None, - associated_token_program: None, - fee_splitter_config: None, - fee_splitter_creator_vault: None, - fee_splitter_vault_authority: None, - fee_splitter_creator_vault_authority: None, - fee_splitter_staking_mint: None, - fee_splitter_wsol_vault: None, - fee_splitter_creator_vault_authority_wsol_vault: None, - fee_splitter_treasury_wsol_vault: None, - fee_splitter_team_wsol_vault: None, - fee_splitter_reward_pool: None, - fee_splitter_reward_pool_staking_vault: None, - fee_splitter_reward_pool_reward_vault: None, - fee_splitter_reward_pool_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn wsol(&mut self, wsol: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.wsol = Some(wsol); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn trading_fees_vault( - &mut self, - trading_fees_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.trading_fees_vault = Some(trading_fees_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_program( - &mut self, - fee_splitter_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_program = Some(fee_splitter_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn fee_splitter_config( - &mut self, - fee_splitter_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_config = Some(fee_splitter_config); - self - } - - #[inline(always)] - pub fn fee_splitter_creator_vault( - &mut self, - fee_splitter_creator_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_creator_vault = Some(fee_splitter_creator_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_vault_authority( - &mut self, - fee_splitter_vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_vault_authority = Some(fee_splitter_vault_authority); - self - } - - #[inline(always)] - pub fn fee_splitter_creator_vault_authority( - &mut self, - fee_splitter_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_creator_vault_authority = - Some(fee_splitter_creator_vault_authority); - self - } - - #[inline(always)] - pub fn fee_splitter_staking_mint( - &mut self, - fee_splitter_staking_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_staking_mint = Some(fee_splitter_staking_mint); - self - } - - #[inline(always)] - pub fn fee_splitter_wsol_vault( - &mut self, - fee_splitter_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_wsol_vault = Some(fee_splitter_wsol_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_creator_vault_authority_wsol_vault( - &mut self, - fee_splitter_creator_vault_authority_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction - .fee_splitter_creator_vault_authority_wsol_vault = - Some(fee_splitter_creator_vault_authority_wsol_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_treasury_wsol_vault( - &mut self, - fee_splitter_treasury_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_treasury_wsol_vault = Some(fee_splitter_treasury_wsol_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_team_wsol_vault( - &mut self, - fee_splitter_team_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_team_wsol_vault = Some(fee_splitter_team_wsol_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_reward_pool( - &mut self, - fee_splitter_reward_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_reward_pool = Some(fee_splitter_reward_pool); - self - } - - #[inline(always)] - pub fn fee_splitter_reward_pool_staking_vault( - &mut self, - fee_splitter_reward_pool_staking_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_reward_pool_staking_vault = - Some(fee_splitter_reward_pool_staking_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_reward_pool_reward_vault( - &mut self, - fee_splitter_reward_pool_reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_reward_pool_reward_vault = - Some(fee_splitter_reward_pool_reward_vault); - self - } - - #[inline(always)] - pub fn fee_splitter_reward_pool_program( - &mut self, - fee_splitter_reward_pool_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_splitter_reward_pool_program = Some(fee_splitter_reward_pool_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SplitTradingFeesCpi { - __program: self.instruction.__program, - - operator: self.instruction.operator.expect("operator is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - wsol: self.instruction.wsol.expect("wsol is not set"), - - config: self.instruction.config.expect("config is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - trading_fees_vault: self - .instruction - .trading_fees_vault - .expect("trading_fees_vault is not set"), - - fee_splitter_program: self - .instruction - .fee_splitter_program - .expect("fee_splitter_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - fee_splitter_config: self - .instruction - .fee_splitter_config - .expect("fee_splitter_config is not set"), - - fee_splitter_creator_vault: self - .instruction - .fee_splitter_creator_vault - .expect("fee_splitter_creator_vault is not set"), - - fee_splitter_vault_authority: self - .instruction - .fee_splitter_vault_authority - .expect("fee_splitter_vault_authority is not set"), - - fee_splitter_creator_vault_authority: self - .instruction - .fee_splitter_creator_vault_authority - .expect("fee_splitter_creator_vault_authority is not set"), - - fee_splitter_staking_mint: self - .instruction - .fee_splitter_staking_mint - .expect("fee_splitter_staking_mint is not set"), - - fee_splitter_wsol_vault: self - .instruction - .fee_splitter_wsol_vault - .expect("fee_splitter_wsol_vault is not set"), - - fee_splitter_creator_vault_authority_wsol_vault: self - .instruction - .fee_splitter_creator_vault_authority_wsol_vault - .expect("fee_splitter_creator_vault_authority_wsol_vault is not set"), - - fee_splitter_treasury_wsol_vault: self - .instruction - .fee_splitter_treasury_wsol_vault - .expect("fee_splitter_treasury_wsol_vault is not set"), - - fee_splitter_team_wsol_vault: self - .instruction - .fee_splitter_team_wsol_vault - .expect("fee_splitter_team_wsol_vault is not set"), - - fee_splitter_reward_pool: self - .instruction - .fee_splitter_reward_pool - .expect("fee_splitter_reward_pool is not set"), - - fee_splitter_reward_pool_staking_vault: self - .instruction - .fee_splitter_reward_pool_staking_vault - .expect("fee_splitter_reward_pool_staking_vault is not set"), - - fee_splitter_reward_pool_reward_vault: self - .instruction - .fee_splitter_reward_pool_reward_vault - .expect("fee_splitter_reward_pool_reward_vault is not set"), - - fee_splitter_reward_pool_program: self - .instruction - .fee_splitter_reward_pool_program - .expect("fee_splitter_reward_pool_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SplitTradingFeesCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - wsol: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - trading_fees_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_config: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_creator_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_creator_vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_staking_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_wsol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_creator_vault_authority_wsol_vault: - Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_treasury_wsol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_team_wsol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_reward_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_reward_pool_staking_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_reward_pool_reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_splitter_reward_pool_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/swap_sol_for_tokens_on_raydium.rs b/crates/boop-parser/src/generated_sdk/instructions/swap_sol_for_tokens_on_raydium.rs deleted file mode 100644 index 991354c5..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/swap_sol_for_tokens_on_raydium.rs +++ /dev/null @@ -1,980 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SwapSolForTokensOnRaydium { - pub config: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - /// Which config the pool belongs to. - pub amm_config: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub input_vault: solana_pubkey::Pubkey, - - pub output_vault: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub bonding_curve_wsol_vault: solana_pubkey::Pubkey, - /// token_0 mint, the key must smaller than token_1 mint - pub output_token_mint: solana_pubkey::Pubkey, - /// token_1 mint, the key must greater than token_0 mint - pub input_token_mint: solana_pubkey::Pubkey, - /// input_token_mint and output_token_mint have the same token program - pub token_program: solana_pubkey::Pubkey, - - pub cp_swap_program: solana_pubkey::Pubkey, - - pub observation_state: solana_pubkey::Pubkey, -} - -impl SwapSolForTokensOnRaydium { - pub fn instruction( - &self, - args: SwapSolForTokensOnRaydiumInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapSolForTokensOnRaydiumInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.operator, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_wsol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cp_swap_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapSolForTokensOnRaydiumInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapSolForTokensOnRaydiumInstructionData { - discriminator: [u8; 8], -} - -impl SwapSolForTokensOnRaydiumInstructionData { - pub fn new() -> Self { - Self { - discriminator: [107, 248, 131, 239, 152, 234, 54, 35], - } - } -} - -impl Default for SwapSolForTokensOnRaydiumInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapSolForTokensOnRaydiumInstructionArgs { - pub amount_in: u64, - pub minimum_amount_out: u64, -} - -/// Instruction builder for `SwapSolForTokensOnRaydium`. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` bonding_curve -/// 2. `[]` amm_config -/// 3. `[writable, signer]` operator -/// 4. `[writable]` vault_authority -/// 5. `[]` authority -/// 6. `[writable]` pool_state -/// 7. `[writable]` input_vault -/// 8. `[writable]` output_vault -/// 9. `[writable]` bonding_curve_vault -/// 10. `[writable]` bonding_curve_wsol_vault -/// 11. `[]` output_token_mint -/// 12. `[optional]` input_token_mint (default to `So11111111111111111111111111111111111111112`) -/// 13. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 14. `[optional]` cp_swap_program (default to `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C`) -/// 15. `[writable]` observation_state -#[derive(Clone, Debug, Default)] -pub struct SwapSolForTokensOnRaydiumBuilder { - config: Option, - bonding_curve: Option, - amm_config: Option, - operator: Option, - vault_authority: Option, - authority: Option, - pool_state: Option, - input_vault: Option, - output_vault: Option, - bonding_curve_vault: Option, - bonding_curve_wsol_vault: Option, - output_token_mint: Option, - input_token_mint: Option, - token_program: Option, - cp_swap_program: Option, - observation_state: Option, - amount_in: Option, - minimum_amount_out: Option, - __remaining_accounts: Vec, -} - -impl SwapSolForTokensOnRaydiumBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn output_vault(&mut self, output_vault: solana_pubkey::Pubkey) -> &mut Self { - self.output_vault = Some(output_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_vault( - &mut self, - bonding_curve_wsol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_wsol_vault = Some(bonding_curve_wsol_vault); - self - } - - /// token_0 mint, the key must smaller than token_1 mint - #[inline(always)] - pub fn output_token_mint(&mut self, output_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_token_mint = Some(output_token_mint); - self - } - - /// `[optional account, default to 'So11111111111111111111111111111111111111112']` - /// token_1 mint, the key must greater than token_0 mint - #[inline(always)] - pub fn input_token_mint(&mut self, input_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_mint = Some(input_token_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// input_token_mint and output_token_mint have the same token program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C']` - #[inline(always)] - pub fn cp_swap_program(&mut self, cp_swap_program: solana_pubkey::Pubkey) -> &mut Self { - self.cp_swap_program = Some(cp_swap_program); - self - } - - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.minimum_amount_out = Some(minimum_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapSolForTokensOnRaydium { - config: self.config.expect("config is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - operator: self.operator.expect("operator is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - output_vault: self.output_vault.expect("output_vault is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - bonding_curve_wsol_vault: self - .bonding_curve_wsol_vault - .expect("bonding_curve_wsol_vault is not set"), - output_token_mint: self - .output_token_mint - .expect("output_token_mint is not set"), - input_token_mint: self.input_token_mint.unwrap_or(solana_pubkey::pubkey!( - "So11111111111111111111111111111111111111112" - )), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - cp_swap_program: self.cp_swap_program.unwrap_or(solana_pubkey::pubkey!( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - )), - observation_state: self - .observation_state - .expect("observation_state is not set"), - }; - let args = SwapSolForTokensOnRaydiumInstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - minimum_amount_out: self - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_sol_for_tokens_on_raydium` CPI accounts. -pub struct SwapSolForTokensOnRaydiumCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - /// token_0 mint, the key must smaller than token_1 mint - pub output_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_1 mint, the key must greater than token_0 mint - pub input_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// input_token_mint and output_token_mint have the same token program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub cp_swap_program: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_sol_for_tokens_on_raydium` CPI instruction. -pub struct SwapSolForTokensOnRaydiumCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - /// token_0 mint, the key must smaller than token_1 mint - pub output_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_1 mint, the key must greater than token_0 mint - pub input_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// input_token_mint and output_token_mint have the same token program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub cp_swap_program: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapSolForTokensOnRaydiumInstructionArgs, -} - -impl<'a, 'b> SwapSolForTokensOnRaydiumCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapSolForTokensOnRaydiumCpiAccounts<'a, 'b>, - args: SwapSolForTokensOnRaydiumInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - bonding_curve: accounts.bonding_curve, - amm_config: accounts.amm_config, - operator: accounts.operator, - vault_authority: accounts.vault_authority, - authority: accounts.authority, - pool_state: accounts.pool_state, - input_vault: accounts.input_vault, - output_vault: accounts.output_vault, - bonding_curve_vault: accounts.bonding_curve_vault, - bonding_curve_wsol_vault: accounts.bonding_curve_wsol_vault, - output_token_mint: accounts.output_token_mint, - input_token_mint: accounts.input_token_mint, - token_program: accounts.token_program, - cp_swap_program: accounts.cp_swap_program, - observation_state: accounts.observation_state, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_wsol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cp_swap_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapSolForTokensOnRaydiumInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.output_vault.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.bonding_curve_wsol_vault.clone()); - account_infos.push(self.output_token_mint.clone()); - account_infos.push(self.input_token_mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.cp_swap_program.clone()); - account_infos.push(self.observation_state.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapSolForTokensOnRaydium` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` bonding_curve -/// 2. `[]` amm_config -/// 3. `[writable, signer]` operator -/// 4. `[writable]` vault_authority -/// 5. `[]` authority -/// 6. `[writable]` pool_state -/// 7. `[writable]` input_vault -/// 8. `[writable]` output_vault -/// 9. `[writable]` bonding_curve_vault -/// 10. `[writable]` bonding_curve_wsol_vault -/// 11. `[]` output_token_mint -/// 12. `[]` input_token_mint -/// 13. `[]` token_program -/// 14. `[]` cp_swap_program -/// 15. `[writable]` observation_state -#[derive(Clone, Debug)] -pub struct SwapSolForTokensOnRaydiumCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapSolForTokensOnRaydiumCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapSolForTokensOnRaydiumCpiBuilderInstruction { - __program: program, - config: None, - bonding_curve: None, - amm_config: None, - operator: None, - vault_authority: None, - authority: None, - pool_state: None, - input_vault: None, - output_vault: None, - bonding_curve_vault: None, - bonding_curve_wsol_vault: None, - output_token_mint: None, - input_token_mint: None, - token_program: None, - cp_swap_program: None, - observation_state: None, - amount_in: None, - minimum_amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn output_vault( - &mut self, - output_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_vault = Some(output_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_vault( - &mut self, - bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_wsol_vault = Some(bonding_curve_wsol_vault); - self - } - - /// token_0 mint, the key must smaller than token_1 mint - #[inline(always)] - pub fn output_token_mint( - &mut self, - output_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_mint = Some(output_token_mint); - self - } - - /// token_1 mint, the key must greater than token_0 mint - #[inline(always)] - pub fn input_token_mint( - &mut self, - input_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_mint = Some(input_token_mint); - self - } - - /// input_token_mint and output_token_mint have the same token program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn cp_swap_program( - &mut self, - cp_swap_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cp_swap_program = Some(cp_swap_program); - self - } - - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.instruction.minimum_amount_out = Some(minimum_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapSolForTokensOnRaydiumInstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - minimum_amount_out: self - .instruction - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - }; - let instruction = SwapSolForTokensOnRaydiumCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - output_vault: self - .instruction - .output_vault - .expect("output_vault is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - bonding_curve_wsol_vault: self - .instruction - .bonding_curve_wsol_vault - .expect("bonding_curve_wsol_vault is not set"), - - output_token_mint: self - .instruction - .output_token_mint - .expect("output_token_mint is not set"), - - input_token_mint: self - .instruction - .input_token_mint - .expect("input_token_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - cp_swap_program: self - .instruction - .cp_swap_program - .expect("cp_swap_program is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapSolForTokensOnRaydiumCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - output_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_wsol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - cp_swap_program: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - minimum_amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/swap_tokens_for_sol_on_raydium.rs b/crates/boop-parser/src/generated_sdk/instructions/swap_tokens_for_sol_on_raydium.rs deleted file mode 100644 index 2fc1649b..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/swap_tokens_for_sol_on_raydium.rs +++ /dev/null @@ -1,978 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SwapTokensForSolOnRaydium { - pub config: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - /// Which config the pool belongs to. - pub amm_config: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub vault_authority: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub input_vault: solana_pubkey::Pubkey, - - pub output_vault: solana_pubkey::Pubkey, - - pub bonding_curve_vault: solana_pubkey::Pubkey, - - pub bonding_curve_wsol_vault: solana_pubkey::Pubkey, - /// token_0 mint, the key must smaller than token_1 mint - pub input_token_mint: solana_pubkey::Pubkey, - /// token_1 mint, the key must greater than token_0 mint - pub output_token_mint: solana_pubkey::Pubkey, - /// input_token_mint and output_token_mint have the same token program - pub token_program: solana_pubkey::Pubkey, - - pub cp_swap_program: solana_pubkey::Pubkey, - - pub observation_state: solana_pubkey::Pubkey, -} - -impl SwapTokensForSolOnRaydium { - pub fn instruction( - &self, - args: SwapTokensForSolOnRaydiumInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapTokensForSolOnRaydiumInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.operator, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve_wsol_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cp_swap_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapTokensForSolOnRaydiumInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapTokensForSolOnRaydiumInstructionData { - discriminator: [u8; 8], -} - -impl SwapTokensForSolOnRaydiumInstructionData { - pub fn new() -> Self { - Self { - discriminator: [216, 172, 130, 148, 34, 98, 215, 163], - } - } -} - -impl Default for SwapTokensForSolOnRaydiumInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapTokensForSolOnRaydiumInstructionArgs { - pub amount_in: u64, - pub minimum_amount_out: u64, -} - -/// Instruction builder for `SwapTokensForSolOnRaydium`. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` bonding_curve -/// 2. `[]` amm_config -/// 3. `[writable, signer]` operator -/// 4. `[writable]` vault_authority -/// 5. `[]` authority -/// 6. `[writable]` pool_state -/// 7. `[writable]` input_vault -/// 8. `[writable]` output_vault -/// 9. `[writable]` bonding_curve_vault -/// 10. `[writable]` bonding_curve_wsol_vault -/// 11. `[]` input_token_mint -/// 12. `[optional]` output_token_mint (default to `So11111111111111111111111111111111111111112`) -/// 13. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 14. `[optional]` cp_swap_program (default to `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C`) -/// 15. `[writable]` observation_state -#[derive(Clone, Debug, Default)] -pub struct SwapTokensForSolOnRaydiumBuilder { - config: Option, - bonding_curve: Option, - amm_config: Option, - operator: Option, - vault_authority: Option, - authority: Option, - pool_state: Option, - input_vault: Option, - output_vault: Option, - bonding_curve_vault: Option, - bonding_curve_wsol_vault: Option, - input_token_mint: Option, - output_token_mint: Option, - token_program: Option, - cp_swap_program: Option, - observation_state: Option, - amount_in: Option, - minimum_amount_out: Option, - __remaining_accounts: Vec, -} - -impl SwapTokensForSolOnRaydiumBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn vault_authority(&mut self, vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn output_vault(&mut self, output_vault: solana_pubkey::Pubkey) -> &mut Self { - self.output_vault = Some(output_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault(&mut self, bonding_curve_vault: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_vault( - &mut self, - bonding_curve_wsol_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bonding_curve_wsol_vault = Some(bonding_curve_wsol_vault); - self - } - - /// token_0 mint, the key must smaller than token_1 mint - #[inline(always)] - pub fn input_token_mint(&mut self, input_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_mint = Some(input_token_mint); - self - } - - /// `[optional account, default to 'So11111111111111111111111111111111111111112']` - /// token_1 mint, the key must greater than token_0 mint - #[inline(always)] - pub fn output_token_mint(&mut self, output_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_token_mint = Some(output_token_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// input_token_mint and output_token_mint have the same token program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C']` - #[inline(always)] - pub fn cp_swap_program(&mut self, cp_swap_program: solana_pubkey::Pubkey) -> &mut Self { - self.cp_swap_program = Some(cp_swap_program); - self - } - - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.minimum_amount_out = Some(minimum_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapTokensForSolOnRaydium { - config: self.config.expect("config is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - operator: self.operator.expect("operator is not set"), - vault_authority: self.vault_authority.expect("vault_authority is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - output_vault: self.output_vault.expect("output_vault is not set"), - bonding_curve_vault: self - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - bonding_curve_wsol_vault: self - .bonding_curve_wsol_vault - .expect("bonding_curve_wsol_vault is not set"), - input_token_mint: self.input_token_mint.expect("input_token_mint is not set"), - output_token_mint: self.output_token_mint.unwrap_or(solana_pubkey::pubkey!( - "So11111111111111111111111111111111111111112" - )), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - cp_swap_program: self.cp_swap_program.unwrap_or(solana_pubkey::pubkey!( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - )), - observation_state: self - .observation_state - .expect("observation_state is not set"), - }; - let args = SwapTokensForSolOnRaydiumInstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - minimum_amount_out: self - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_tokens_for_sol_on_raydium` CPI accounts. -pub struct SwapTokensForSolOnRaydiumCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - /// token_0 mint, the key must smaller than token_1 mint - pub input_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_1 mint, the key must greater than token_0 mint - pub output_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// input_token_mint and output_token_mint have the same token program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub cp_swap_program: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_tokens_for_sol_on_raydium` CPI instruction. -pub struct SwapTokensForSolOnRaydiumCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - /// token_0 mint, the key must smaller than token_1 mint - pub input_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_1 mint, the key must greater than token_0 mint - pub output_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// input_token_mint and output_token_mint have the same token program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub cp_swap_program: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapTokensForSolOnRaydiumInstructionArgs, -} - -impl<'a, 'b> SwapTokensForSolOnRaydiumCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapTokensForSolOnRaydiumCpiAccounts<'a, 'b>, - args: SwapTokensForSolOnRaydiumInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - bonding_curve: accounts.bonding_curve, - amm_config: accounts.amm_config, - operator: accounts.operator, - vault_authority: accounts.vault_authority, - authority: accounts.authority, - pool_state: accounts.pool_state, - input_vault: accounts.input_vault, - output_vault: accounts.output_vault, - bonding_curve_vault: accounts.bonding_curve_vault, - bonding_curve_wsol_vault: accounts.bonding_curve_wsol_vault, - input_token_mint: accounts.input_token_mint, - output_token_mint: accounts.output_token_mint, - token_program: accounts.token_program, - cp_swap_program: accounts.cp_swap_program, - observation_state: accounts.observation_state, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve_wsol_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cp_swap_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapTokensForSolOnRaydiumInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.vault_authority.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.output_vault.clone()); - account_infos.push(self.bonding_curve_vault.clone()); - account_infos.push(self.bonding_curve_wsol_vault.clone()); - account_infos.push(self.input_token_mint.clone()); - account_infos.push(self.output_token_mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.cp_swap_program.clone()); - account_infos.push(self.observation_state.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapTokensForSolOnRaydium` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` bonding_curve -/// 2. `[]` amm_config -/// 3. `[writable, signer]` operator -/// 4. `[writable]` vault_authority -/// 5. `[]` authority -/// 6. `[writable]` pool_state -/// 7. `[writable]` input_vault -/// 8. `[writable]` output_vault -/// 9. `[writable]` bonding_curve_vault -/// 10. `[writable]` bonding_curve_wsol_vault -/// 11. `[]` input_token_mint -/// 12. `[]` output_token_mint -/// 13. `[]` token_program -/// 14. `[]` cp_swap_program -/// 15. `[writable]` observation_state -#[derive(Clone, Debug)] -pub struct SwapTokensForSolOnRaydiumCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapTokensForSolOnRaydiumCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapTokensForSolOnRaydiumCpiBuilderInstruction { - __program: program, - config: None, - bonding_curve: None, - amm_config: None, - operator: None, - vault_authority: None, - authority: None, - pool_state: None, - input_vault: None, - output_vault: None, - bonding_curve_vault: None, - bonding_curve_wsol_vault: None, - input_token_mint: None, - output_token_mint: None, - token_program: None, - cp_swap_program: None, - observation_state: None, - amount_in: None, - minimum_amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn vault_authority( - &mut self, - vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_authority = Some(vault_authority); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn output_vault( - &mut self, - output_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_vault = Some(output_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_vault( - &mut self, - bonding_curve_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_vault = Some(bonding_curve_vault); - self - } - - #[inline(always)] - pub fn bonding_curve_wsol_vault( - &mut self, - bonding_curve_wsol_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve_wsol_vault = Some(bonding_curve_wsol_vault); - self - } - - /// token_0 mint, the key must smaller than token_1 mint - #[inline(always)] - pub fn input_token_mint( - &mut self, - input_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_mint = Some(input_token_mint); - self - } - - /// token_1 mint, the key must greater than token_0 mint - #[inline(always)] - pub fn output_token_mint( - &mut self, - output_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_mint = Some(output_token_mint); - self - } - - /// input_token_mint and output_token_mint have the same token program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn cp_swap_program( - &mut self, - cp_swap_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cp_swap_program = Some(cp_swap_program); - self - } - - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.instruction.minimum_amount_out = Some(minimum_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapTokensForSolOnRaydiumInstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - minimum_amount_out: self - .instruction - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - }; - let instruction = SwapTokensForSolOnRaydiumCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - vault_authority: self - .instruction - .vault_authority - .expect("vault_authority is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - output_vault: self - .instruction - .output_vault - .expect("output_vault is not set"), - - bonding_curve_vault: self - .instruction - .bonding_curve_vault - .expect("bonding_curve_vault is not set"), - - bonding_curve_wsol_vault: self - .instruction - .bonding_curve_wsol_vault - .expect("bonding_curve_wsol_vault is not set"), - - input_token_mint: self - .instruction - .input_token_mint - .expect("input_token_mint is not set"), - - output_token_mint: self - .instruction - .output_token_mint - .expect("output_token_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - cp_swap_program: self - .instruction - .cp_swap_program - .expect("cp_swap_program is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapTokensForSolOnRaydiumCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - output_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve_wsol_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - cp_swap_program: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - minimum_amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/toggle_paused.rs b/crates/boop-parser/src/generated_sdk/instructions/toggle_paused.rs deleted file mode 100644 index c2a3f3b1..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/toggle_paused.rs +++ /dev/null @@ -1,307 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct TogglePaused { - pub authority: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, -} - -impl TogglePaused { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.authority, true)); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&TogglePausedInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TogglePausedInstructionData { - discriminator: [u8; 8], -} - -impl TogglePausedInstructionData { - pub fn new() -> Self { - Self { - discriminator: [54, 83, 147, 198, 123, 97, 218, 72], - } - } -} - -impl Default for TogglePausedInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `TogglePaused`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` authority -/// 1. `[writable]` config -#[derive(Clone, Debug, Default)] -pub struct TogglePausedBuilder { - authority: Option, - config: Option, - __remaining_accounts: Vec, -} - -impl TogglePausedBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = TogglePaused { - authority: self.authority.expect("authority is not set"), - config: self.config.expect("config is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `toggle_paused` CPI accounts. -pub struct TogglePausedCpiAccounts<'a, 'b> { - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, -} - -/// `toggle_paused` CPI instruction. -pub struct TogglePausedCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> TogglePausedCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: TogglePausedCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - authority: accounts.authority, - config: accounts.config, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&TogglePausedInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.config.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `TogglePaused` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` authority -/// 1. `[writable]` config -#[derive(Clone, Debug)] -pub struct TogglePausedCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> TogglePausedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(TogglePausedCpiBuilderInstruction { - __program: program, - authority: None, - config: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = TogglePausedCpi { - __program: self.instruction.__program, - - authority: self.instruction.authority.expect("authority is not set"), - - config: self.instruction.config.expect("config is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct TogglePausedCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/instructions/update_config.rs b/crates/boop-parser/src/generated_sdk/instructions/update_config.rs deleted file mode 100644 index fe88348b..00000000 --- a/crates/boop-parser/src/generated_sdk/instructions/update_config.rs +++ /dev/null @@ -1,685 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateConfig { - pub config: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl UpdateConfig { - pub fn instruction( - &self, - args: UpdateConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateConfigInstructionData { - discriminator: [u8; 8], -} - -impl UpdateConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [29, 158, 252, 191, 10, 83, 219, 99], - } - } -} - -impl Default for UpdateConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateConfigInstructionArgs { - pub new_protocol_fee_recipient: Pubkey, - pub new_virtual_sol_reserves: u64, - pub new_virtual_token_reserves: u64, - pub new_graduation_target: u64, - pub new_graduation_fee: u64, - pub new_damping_term: u8, - pub new_swap_fee_basis_points: u8, - pub new_token_for_stakers_basis_points: u16, - pub new_token_amount_for_raydium_liquidity: u64, - pub new_max_graduation_price_deviation_basis_points: u16, - pub new_max_swap_amount_for_pool_price_correction_basis_points: u16, -} - -/// Instruction builder for `UpdateConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[signer]` authority -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct UpdateConfigBuilder { - config: Option, - authority: Option, - system_program: Option, - new_protocol_fee_recipient: Option, - new_virtual_sol_reserves: Option, - new_virtual_token_reserves: Option, - new_graduation_target: Option, - new_graduation_fee: Option, - new_damping_term: Option, - new_swap_fee_basis_points: Option, - new_token_for_stakers_basis_points: Option, - new_token_amount_for_raydium_liquidity: Option, - new_max_graduation_price_deviation_basis_points: Option, - new_max_swap_amount_for_pool_price_correction_basis_points: Option, - __remaining_accounts: Vec, -} - -impl UpdateConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn new_protocol_fee_recipient(&mut self, new_protocol_fee_recipient: Pubkey) -> &mut Self { - self.new_protocol_fee_recipient = Some(new_protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn new_virtual_sol_reserves(&mut self, new_virtual_sol_reserves: u64) -> &mut Self { - self.new_virtual_sol_reserves = Some(new_virtual_sol_reserves); - self - } - - #[inline(always)] - pub fn new_virtual_token_reserves(&mut self, new_virtual_token_reserves: u64) -> &mut Self { - self.new_virtual_token_reserves = Some(new_virtual_token_reserves); - self - } - - #[inline(always)] - pub fn new_graduation_target(&mut self, new_graduation_target: u64) -> &mut Self { - self.new_graduation_target = Some(new_graduation_target); - self - } - - #[inline(always)] - pub fn new_graduation_fee(&mut self, new_graduation_fee: u64) -> &mut Self { - self.new_graduation_fee = Some(new_graduation_fee); - self - } - - #[inline(always)] - pub fn new_damping_term(&mut self, new_damping_term: u8) -> &mut Self { - self.new_damping_term = Some(new_damping_term); - self - } - - #[inline(always)] - pub fn new_swap_fee_basis_points(&mut self, new_swap_fee_basis_points: u8) -> &mut Self { - self.new_swap_fee_basis_points = Some(new_swap_fee_basis_points); - self - } - - #[inline(always)] - pub fn new_token_for_stakers_basis_points( - &mut self, - new_token_for_stakers_basis_points: u16, - ) -> &mut Self { - self.new_token_for_stakers_basis_points = Some(new_token_for_stakers_basis_points); - self - } - - #[inline(always)] - pub fn new_token_amount_for_raydium_liquidity( - &mut self, - new_token_amount_for_raydium_liquidity: u64, - ) -> &mut Self { - self.new_token_amount_for_raydium_liquidity = Some(new_token_amount_for_raydium_liquidity); - self - } - - #[inline(always)] - pub fn new_max_graduation_price_deviation_basis_points( - &mut self, - new_max_graduation_price_deviation_basis_points: u16, - ) -> &mut Self { - self.new_max_graduation_price_deviation_basis_points = - Some(new_max_graduation_price_deviation_basis_points); - self - } - - #[inline(always)] - pub fn new_max_swap_amount_for_pool_price_correction_basis_points( - &mut self, - new_max_swap_amount_for_pool_price_correction_basis_points: u16, - ) -> &mut Self { - self.new_max_swap_amount_for_pool_price_correction_basis_points = - Some(new_max_swap_amount_for_pool_price_correction_basis_points); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateConfig { - config: self.config.expect("config is not set"), - authority: self.authority.expect("authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = UpdateConfigInstructionArgs { - new_protocol_fee_recipient: self - .new_protocol_fee_recipient - .clone() - .expect("new_protocol_fee_recipient is not set"), - new_virtual_sol_reserves: self - .new_virtual_sol_reserves - .clone() - .expect("new_virtual_sol_reserves is not set"), - new_virtual_token_reserves: self - .new_virtual_token_reserves - .clone() - .expect("new_virtual_token_reserves is not set"), - new_graduation_target: self - .new_graduation_target - .clone() - .expect("new_graduation_target is not set"), - new_graduation_fee: self - .new_graduation_fee - .clone() - .expect("new_graduation_fee is not set"), - new_damping_term: self - .new_damping_term - .clone() - .expect("new_damping_term is not set"), - new_swap_fee_basis_points: self - .new_swap_fee_basis_points - .clone() - .expect("new_swap_fee_basis_points is not set"), - new_token_for_stakers_basis_points: self - .new_token_for_stakers_basis_points - .clone() - .expect("new_token_for_stakers_basis_points is not set"), - new_token_amount_for_raydium_liquidity: self - .new_token_amount_for_raydium_liquidity - .clone() - .expect("new_token_amount_for_raydium_liquidity is not set"), - new_max_graduation_price_deviation_basis_points: self - .new_max_graduation_price_deviation_basis_points - .clone() - .expect("new_max_graduation_price_deviation_basis_points is not set"), - new_max_swap_amount_for_pool_price_correction_basis_points: self - .new_max_swap_amount_for_pool_price_correction_basis_points - .clone() - .expect("new_max_swap_amount_for_pool_price_correction_basis_points is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_config` CPI accounts. -pub struct UpdateConfigCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_config` CPI instruction. -pub struct UpdateConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateConfigInstructionArgs, -} - -impl<'a, 'b> UpdateConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateConfigCpiAccounts<'a, 'b>, - args: UpdateConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - authority: accounts.authority, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::BOOP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[signer]` authority -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct UpdateConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateConfigCpiBuilderInstruction { - __program: program, - config: None, - authority: None, - system_program: None, - new_protocol_fee_recipient: None, - new_virtual_sol_reserves: None, - new_virtual_token_reserves: None, - new_graduation_target: None, - new_graduation_fee: None, - new_damping_term: None, - new_swap_fee_basis_points: None, - new_token_for_stakers_basis_points: None, - new_token_amount_for_raydium_liquidity: None, - new_max_graduation_price_deviation_basis_points: None, - new_max_swap_amount_for_pool_price_correction_basis_points: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn new_protocol_fee_recipient(&mut self, new_protocol_fee_recipient: Pubkey) -> &mut Self { - self.instruction.new_protocol_fee_recipient = Some(new_protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn new_virtual_sol_reserves(&mut self, new_virtual_sol_reserves: u64) -> &mut Self { - self.instruction.new_virtual_sol_reserves = Some(new_virtual_sol_reserves); - self - } - - #[inline(always)] - pub fn new_virtual_token_reserves(&mut self, new_virtual_token_reserves: u64) -> &mut Self { - self.instruction.new_virtual_token_reserves = Some(new_virtual_token_reserves); - self - } - - #[inline(always)] - pub fn new_graduation_target(&mut self, new_graduation_target: u64) -> &mut Self { - self.instruction.new_graduation_target = Some(new_graduation_target); - self - } - - #[inline(always)] - pub fn new_graduation_fee(&mut self, new_graduation_fee: u64) -> &mut Self { - self.instruction.new_graduation_fee = Some(new_graduation_fee); - self - } - - #[inline(always)] - pub fn new_damping_term(&mut self, new_damping_term: u8) -> &mut Self { - self.instruction.new_damping_term = Some(new_damping_term); - self - } - - #[inline(always)] - pub fn new_swap_fee_basis_points(&mut self, new_swap_fee_basis_points: u8) -> &mut Self { - self.instruction.new_swap_fee_basis_points = Some(new_swap_fee_basis_points); - self - } - - #[inline(always)] - pub fn new_token_for_stakers_basis_points( - &mut self, - new_token_for_stakers_basis_points: u16, - ) -> &mut Self { - self.instruction.new_token_for_stakers_basis_points = - Some(new_token_for_stakers_basis_points); - self - } - - #[inline(always)] - pub fn new_token_amount_for_raydium_liquidity( - &mut self, - new_token_amount_for_raydium_liquidity: u64, - ) -> &mut Self { - self.instruction.new_token_amount_for_raydium_liquidity = - Some(new_token_amount_for_raydium_liquidity); - self - } - - #[inline(always)] - pub fn new_max_graduation_price_deviation_basis_points( - &mut self, - new_max_graduation_price_deviation_basis_points: u16, - ) -> &mut Self { - self.instruction - .new_max_graduation_price_deviation_basis_points = - Some(new_max_graduation_price_deviation_basis_points); - self - } - - #[inline(always)] - pub fn new_max_swap_amount_for_pool_price_correction_basis_points( - &mut self, - new_max_swap_amount_for_pool_price_correction_basis_points: u16, - ) -> &mut Self { - self.instruction - .new_max_swap_amount_for_pool_price_correction_basis_points = - Some(new_max_swap_amount_for_pool_price_correction_basis_points); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateConfigInstructionArgs { - new_protocol_fee_recipient: self - .instruction - .new_protocol_fee_recipient - .clone() - .expect("new_protocol_fee_recipient is not set"), - new_virtual_sol_reserves: self - .instruction - .new_virtual_sol_reserves - .clone() - .expect("new_virtual_sol_reserves is not set"), - new_virtual_token_reserves: self - .instruction - .new_virtual_token_reserves - .clone() - .expect("new_virtual_token_reserves is not set"), - new_graduation_target: self - .instruction - .new_graduation_target - .clone() - .expect("new_graduation_target is not set"), - new_graduation_fee: self - .instruction - .new_graduation_fee - .clone() - .expect("new_graduation_fee is not set"), - new_damping_term: self - .instruction - .new_damping_term - .clone() - .expect("new_damping_term is not set"), - new_swap_fee_basis_points: self - .instruction - .new_swap_fee_basis_points - .clone() - .expect("new_swap_fee_basis_points is not set"), - new_token_for_stakers_basis_points: self - .instruction - .new_token_for_stakers_basis_points - .clone() - .expect("new_token_for_stakers_basis_points is not set"), - new_token_amount_for_raydium_liquidity: self - .instruction - .new_token_amount_for_raydium_liquidity - .clone() - .expect("new_token_amount_for_raydium_liquidity is not set"), - new_max_graduation_price_deviation_basis_points: self - .instruction - .new_max_graduation_price_deviation_basis_points - .clone() - .expect("new_max_graduation_price_deviation_basis_points is not set"), - new_max_swap_amount_for_pool_price_correction_basis_points: self - .instruction - .new_max_swap_amount_for_pool_price_correction_basis_points - .clone() - .expect("new_max_swap_amount_for_pool_price_correction_basis_points is not set"), - }; - let instruction = UpdateConfigCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - new_protocol_fee_recipient: Option, - new_virtual_sol_reserves: Option, - new_virtual_token_reserves: Option, - new_graduation_target: Option, - new_graduation_fee: Option, - new_damping_term: Option, - new_swap_fee_basis_points: Option, - new_token_for_stakers_basis_points: Option, - new_token_amount_for_raydium_liquidity: Option, - new_max_graduation_price_deviation_basis_points: Option, - new_max_swap_amount_for_pool_price_correction_basis_points: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/boop-parser/src/generated_sdk/mod.rs b/crates/boop-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/boop-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/boop-parser/src/generated_sdk/programs.rs b/crates/boop-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 8938d5f6..00000000 --- a/crates/boop-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `boop` program ID. -pub const BOOP_ID: Pubkey = pubkey!("boop8hVGQGqehUK2iVEMEnMrL5RbjywRzHKBmBE7ry4"); diff --git a/crates/boop-parser/src/generated_sdk/shared.rs b/crates/boop-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/boop-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/boop-parser/src/generated_sdk/types/authority_transfer_cancelled_event.rs b/crates/boop-parser/src/generated_sdk/types/authority_transfer_cancelled_event.rs deleted file mode 100644 index 60a13fb4..00000000 --- a/crates/boop-parser/src/generated_sdk/types/authority_transfer_cancelled_event.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorityTransferCancelledEvent {} diff --git a/crates/boop-parser/src/generated_sdk/types/authority_transfer_completed_event.rs b/crates/boop-parser/src/generated_sdk/types/authority_transfer_completed_event.rs deleted file mode 100644 index 3c199267..00000000 --- a/crates/boop-parser/src/generated_sdk/types/authority_transfer_completed_event.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorityTransferCompletedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub old_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub new_authority: Pubkey, -} diff --git a/crates/boop-parser/src/generated_sdk/types/authority_transfer_initiated_event.rs b/crates/boop-parser/src/generated_sdk/types/authority_transfer_initiated_event.rs deleted file mode 100644 index 2d2b9c4c..00000000 --- a/crates/boop-parser/src/generated_sdk/types/authority_transfer_initiated_event.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AuthorityTransferInitiatedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub old_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub new_authority: Pubkey, -} diff --git a/crates/boop-parser/src/generated_sdk/types/bonding_curve_deployed_event.rs b/crates/boop-parser/src/generated_sdk/types/bonding_curve_deployed_event.rs deleted file mode 100644 index b380a598..00000000 --- a/crates/boop-parser/src/generated_sdk/types/bonding_curve_deployed_event.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BondingCurveDeployedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, -} diff --git a/crates/boop-parser/src/generated_sdk/types/bonding_curve_deployed_fallback_event.rs b/crates/boop-parser/src/generated_sdk/types/bonding_curve_deployed_fallback_event.rs deleted file mode 100644 index 23aa504c..00000000 --- a/crates/boop-parser/src/generated_sdk/types/bonding_curve_deployed_fallback_event.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BondingCurveDeployedFallbackEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, -} diff --git a/crates/boop-parser/src/generated_sdk/types/bonding_curve_status.rs b/crates/boop-parser/src/generated_sdk/types/bonding_curve_status.rs deleted file mode 100644 index 35bdc0ce..00000000 --- a/crates/boop-parser/src/generated_sdk/types/bonding_curve_status.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum BondingCurveStatus { - Trading, - Graduated, - PoolPriceCorrected, - LiquidityProvisioned, - LiquidityLocked, -} diff --git a/crates/boop-parser/src/generated_sdk/types/bonding_curve_vault_closed_event.rs b/crates/boop-parser/src/generated_sdk/types/bonding_curve_vault_closed_event.rs deleted file mode 100644 index 0c91b3e1..00000000 --- a/crates/boop-parser/src/generated_sdk/types/bonding_curve_vault_closed_event.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BondingCurveVaultClosedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub recipient: Pubkey, - pub amount: u64, -} diff --git a/crates/boop-parser/src/generated_sdk/types/config_updated_event.rs b/crates/boop-parser/src/generated_sdk/types/config_updated_event.rs deleted file mode 100644 index 40327574..00000000 --- a/crates/boop-parser/src/generated_sdk/types/config_updated_event.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ConfigUpdatedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_fee_recipient: Pubkey, - pub virtual_sol_reserves: u64, - pub virtual_token_reserves: u64, - pub graduation_target: u64, - pub graduation_fee: u64, - pub damping_term: u8, - pub swap_fee_basis_points: u8, - pub token_for_stakers_basis_points: u16, - pub token_amount_for_raydium_liquidity: u64, - pub max_graduation_price_deviation_basis_points: u16, - pub max_swap_amount_for_pool_price_correction_basis_points: u16, -} diff --git a/crates/boop-parser/src/generated_sdk/types/liquidity_deposited_into_raydium_event.rs b/crates/boop-parser/src/generated_sdk/types/liquidity_deposited_into_raydium_event.rs deleted file mode 100644 index e4ff782a..00000000 --- a/crates/boop-parser/src/generated_sdk/types/liquidity_deposited_into_raydium_event.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LiquidityDepositedIntoRaydiumEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_state: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub lp_token_amount: u64, - pub tokens_deposited: u64, - pub wsol_deposited: u64, -} diff --git a/crates/boop-parser/src/generated_sdk/types/mod.rs b/crates/boop-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index 64e50911..00000000 --- a/crates/boop-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#authority_transfer_cancelled_event; -pub(crate) mod r#authority_transfer_completed_event; -pub(crate) mod r#authority_transfer_initiated_event; -pub(crate) mod r#bonding_curve_deployed_event; -pub(crate) mod r#bonding_curve_deployed_fallback_event; -pub(crate) mod r#bonding_curve_status; -pub(crate) mod r#bonding_curve_vault_closed_event; -pub(crate) mod r#config_updated_event; -pub(crate) mod r#liquidity_deposited_into_raydium_event; -pub(crate) mod r#operators_added_event; -pub(crate) mod r#operators_removed_event; -pub(crate) mod r#paused_toggled_event; -pub(crate) mod r#raydium_liquidity_locked_event; -pub(crate) mod r#raydium_pool_created_event; -pub(crate) mod r#raydium_random_pool_created_event; -pub(crate) mod r#swap_sol_for_tokens_on_raydium_event; -pub(crate) mod r#swap_tokens_for_sol_on_raydium_event; -pub(crate) mod r#token_bought_event; -pub(crate) mod r#token_created_event; -pub(crate) mod r#token_created_fallback_event; -pub(crate) mod r#token_graduated_event; -pub(crate) mod r#token_sold_event; -pub(crate) mod r#trading_fees_collected_event; -pub(crate) mod r#trading_fees_split_event; - -pub use self::{ - r#authority_transfer_cancelled_event::*, r#authority_transfer_completed_event::*, - r#authority_transfer_initiated_event::*, r#bonding_curve_deployed_event::*, - r#bonding_curve_deployed_fallback_event::*, r#bonding_curve_status::*, - r#bonding_curve_vault_closed_event::*, r#config_updated_event::*, - r#liquidity_deposited_into_raydium_event::*, r#operators_added_event::*, - r#operators_removed_event::*, r#paused_toggled_event::*, r#raydium_liquidity_locked_event::*, - r#raydium_pool_created_event::*, r#raydium_random_pool_created_event::*, - r#swap_sol_for_tokens_on_raydium_event::*, r#swap_tokens_for_sol_on_raydium_event::*, - r#token_bought_event::*, r#token_created_event::*, r#token_created_fallback_event::*, - r#token_graduated_event::*, r#token_sold_event::*, r#trading_fees_collected_event::*, - r#trading_fees_split_event::*, -}; diff --git a/crates/boop-parser/src/generated_sdk/types/operators_added_event.rs b/crates/boop-parser/src/generated_sdk/types/operators_added_event.rs deleted file mode 100644 index d2a4871d..00000000 --- a/crates/boop-parser/src/generated_sdk/types/operators_added_event.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OperatorsAddedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::>") - )] - pub operators: Vec, -} diff --git a/crates/boop-parser/src/generated_sdk/types/operators_removed_event.rs b/crates/boop-parser/src/generated_sdk/types/operators_removed_event.rs deleted file mode 100644 index b5216dd6..00000000 --- a/crates/boop-parser/src/generated_sdk/types/operators_removed_event.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OperatorsRemovedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::>") - )] - pub operators: Vec, -} diff --git a/crates/boop-parser/src/generated_sdk/types/paused_toggled_event.rs b/crates/boop-parser/src/generated_sdk/types/paused_toggled_event.rs deleted file mode 100644 index d3085dd5..00000000 --- a/crates/boop-parser/src/generated_sdk/types/paused_toggled_event.rs +++ /dev/null @@ -1,14 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PausedToggledEvent { - pub is_paused: bool, -} diff --git a/crates/boop-parser/src/generated_sdk/types/raydium_liquidity_locked_event.rs b/crates/boop-parser/src/generated_sdk/types/raydium_liquidity_locked_event.rs deleted file mode 100644 index 2bc9e770..00000000 --- a/crates/boop-parser/src/generated_sdk/types/raydium_liquidity_locked_event.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RaydiumLiquidityLockedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_state: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub lp_amount: u64, -} diff --git a/crates/boop-parser/src/generated_sdk/types/raydium_pool_created_event.rs b/crates/boop-parser/src/generated_sdk/types/raydium_pool_created_event.rs deleted file mode 100644 index 04377856..00000000 --- a/crates/boop-parser/src/generated_sdk/types/raydium_pool_created_event.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RaydiumPoolCreatedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_state: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, -} diff --git a/crates/boop-parser/src/generated_sdk/types/raydium_random_pool_created_event.rs b/crates/boop-parser/src/generated_sdk/types/raydium_random_pool_created_event.rs deleted file mode 100644 index ba28d3a6..00000000 --- a/crates/boop-parser/src/generated_sdk/types/raydium_random_pool_created_event.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RaydiumRandomPoolCreatedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_state: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, -} diff --git a/crates/boop-parser/src/generated_sdk/types/swap_sol_for_tokens_on_raydium_event.rs b/crates/boop-parser/src/generated_sdk/types/swap_sol_for_tokens_on_raydium_event.rs deleted file mode 100644 index 132dd2d3..00000000 --- a/crates/boop-parser/src/generated_sdk/types/swap_sol_for_tokens_on_raydium_event.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapSolForTokensOnRaydiumEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub amount_in: u64, - pub amount_out: u64, -} diff --git a/crates/boop-parser/src/generated_sdk/types/swap_tokens_for_sol_on_raydium_event.rs b/crates/boop-parser/src/generated_sdk/types/swap_tokens_for_sol_on_raydium_event.rs deleted file mode 100644 index c156996a..00000000 --- a/crates/boop-parser/src/generated_sdk/types/swap_tokens_for_sol_on_raydium_event.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapTokensForSolOnRaydiumEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub amount_in: u64, - pub amount_out: u64, -} diff --git a/crates/boop-parser/src/generated_sdk/types/token_bought_event.rs b/crates/boop-parser/src/generated_sdk/types/token_bought_event.rs deleted file mode 100644 index f44e6a6c..00000000 --- a/crates/boop-parser/src/generated_sdk/types/token_bought_event.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenBoughtEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub amount_in: u64, - pub amount_out: u64, - pub swap_fee: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub buyer: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub recipient: Pubkey, -} diff --git a/crates/boop-parser/src/generated_sdk/types/token_created_event.rs b/crates/boop-parser/src/generated_sdk/types/token_created_event.rs deleted file mode 100644 index 7736b2a7..00000000 --- a/crates/boop-parser/src/generated_sdk/types/token_created_event.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenCreatedEvent { - pub name: String, - pub symbol: String, - pub uri: String, -} diff --git a/crates/boop-parser/src/generated_sdk/types/token_created_fallback_event.rs b/crates/boop-parser/src/generated_sdk/types/token_created_fallback_event.rs deleted file mode 100644 index 057cd737..00000000 --- a/crates/boop-parser/src/generated_sdk/types/token_created_fallback_event.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenCreatedFallbackEvent { - pub name: String, - pub symbol: String, - pub uri: String, -} diff --git a/crates/boop-parser/src/generated_sdk/types/token_graduated_event.rs b/crates/boop-parser/src/generated_sdk/types/token_graduated_event.rs deleted file mode 100644 index 25b3e0a1..00000000 --- a/crates/boop-parser/src/generated_sdk/types/token_graduated_event.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenGraduatedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub sol_for_liquidity: u64, - pub graduation_fee: u64, - pub token_for_distributor: u64, -} diff --git a/crates/boop-parser/src/generated_sdk/types/token_sold_event.rs b/crates/boop-parser/src/generated_sdk/types/token_sold_event.rs deleted file mode 100644 index 70c26cfa..00000000 --- a/crates/boop-parser/src/generated_sdk/types/token_sold_event.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenSoldEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub amount_in: u64, - pub amount_out: u64, - pub swap_fee: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub seller: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub recipient: Pubkey, -} diff --git a/crates/boop-parser/src/generated_sdk/types/trading_fees_collected_event.rs b/crates/boop-parser/src/generated_sdk/types/trading_fees_collected_event.rs deleted file mode 100644 index dfa2f504..00000000 --- a/crates/boop-parser/src/generated_sdk/types/trading_fees_collected_event.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TradingFeesCollectedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_state: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, -} diff --git a/crates/boop-parser/src/generated_sdk/types/trading_fees_split_event.rs b/crates/boop-parser/src/generated_sdk/types/trading_fees_split_event.rs deleted file mode 100644 index 4b7f6290..00000000 --- a/crates/boop-parser/src/generated_sdk/types/trading_fees_split_event.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TradingFeesSplitEvent { - pub amount: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, -} diff --git a/crates/boop-parser/src/lib.rs b/crates/boop-parser/src/lib.rs deleted file mode 100644 index 9b1df0b3..00000000 --- a/crates/boop-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = BOOP_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.boop"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index bb93e881..d7c4e830 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -35,10 +35,12 @@ use yellowstone_grpc_proto::geyser::{ }; pub extern crate bs58; + #[cfg(feature = "proto")] pub extern crate yellowstone_vixen_proto; pub mod instruction; + #[cfg(feature = "proto")] pub mod proto; diff --git a/crates/jupiter-swap-parser/Cargo.toml b/crates/jupiter-swap-parser/Cargo.toml deleted file mode 100644 index f0bee3a0..00000000 --- a/crates/jupiter-swap-parser/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "yellowstone-vixen-jupiter-swap-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Jupiter Swap program" -license.workspace = true -repository.workspace = true -authors.workspace = true - - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info = { workspace = true } -solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction.workspace = true -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true diff --git a/crates/jupiter-swap-parser/build.rs b/crates/jupiter-swap-parser/build.rs deleted file mode 100644 index ead3bbf4..00000000 --- a/crates/jupiter-swap-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/jupiter_swap.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/jupiter-swap-parser/idl.json b/crates/jupiter-swap-parser/idl.json deleted file mode 100644 index 50490491..00000000 --- a/crates/jupiter-swap-parser/idl.json +++ /dev/null @@ -1,1668 +0,0 @@ -{ - "address": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", - "metadata": { - "name": "jupiter", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Jupiter aggregator program" - }, - "instructions": [ - { - "name": "claim", - "discriminator": [62, 198, 214, 193, 213, 159, 108, 210], - "accounts": [ - { - "name": "wallet", - "writable": true, - "address": "J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64" - }, - { - "name": "program_authority", - "writable": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "id", - "type": "u8" - } - ], - "returns": "u64" - }, - { - "name": "claim_token", - "discriminator": [116, 206, 27, 191, 166, 19, 0, 73], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "wallet", - "address": "J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64" - }, - { - "name": "program_authority" - }, - { - "name": "program_token_account", - "writable": true - }, - { - "name": "destination_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "wallet" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "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": "mint" - }, - { - "name": "token_program" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "id", - "type": "u8" - } - ], - "returns": "u64" - }, - { - "name": "close_token", - "discriminator": [26, 74, 236, 151, 104, 64, 183, 249], - "accounts": [ - { - "name": "operator", - "signer": true - }, - { - "name": "wallet", - "writable": true, - "address": "J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64" - }, - { - "name": "program_authority" - }, - { - "name": "program_token_account", - "writable": true - }, - { - "name": "mint", - "writable": true - }, - { - "name": "token_program" - } - ], - "args": [ - { - "name": "id", - "type": "u8" - }, - { - "name": "burn_all", - "type": "bool" - } - ] - }, - { - "name": "create_open_orders", - "discriminator": [229, 194, 212, 172, 8, 10, 134, 147], - "accounts": [ - { - "name": "open_orders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 111, 112, 101, 110, 95, 111, 114, 100, 101, - 114, 115 - ] - }, - { - "kind": "account", - "path": "market" - }, - { - "kind": "account", - "path": "payer" - } - ] - } - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "dex_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "market" - } - ], - "args": [] - }, - { - "name": "create_program_open_orders", - "discriminator": [28, 226, 32, 148, 188, 136, 113, 171], - "accounts": [ - { - "name": "open_orders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 111, 112, 101, 110, 95, 111, 114, 100, 101, - 114, 115 - ] - }, - { - "kind": "account", - "path": "market" - }, - { - "kind": "account", - "path": "program_authority" - } - ] - } - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "program_authority" - }, - { - "name": "dex_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "market" - } - ], - "args": [ - { - "name": "id", - "type": "u8" - } - ] - }, - { - "name": "create_token_ledger", - "discriminator": [232, 242, 197, 253, 240, 143, 129, 52], - "accounts": [ - { - "name": "token_ledger", - "writable": true, - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "create_token_account", - "discriminator": [147, 241, 123, 100, 244, 132, 174, 118], - "accounts": [ - { - "name": "token_account", - "writable": true - }, - { - "name": "user", - "writable": true, - "signer": true - }, - { - "name": "mint" - }, - { - "name": "token_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "bump", - "type": "u8" - } - ] - }, - { - "name": "exact_out_route", - "discriminator": [208, 51, 239, 151, 123, 43, 237, 92], - "accounts": [ - { - "name": "token_program" - }, - { - "name": "user_transfer_authority", - "signer": true - }, - { - "name": "user_source_token_account", - "writable": true - }, - { - "name": "user_destination_token_account", - "writable": true - }, - { - "name": "destination_token_account", - "writable": true, - "optional": true - }, - { - "name": "source_mint" - }, - { - "name": "destination_mint" - }, - { - "name": "platform_fee_account", - "writable": true, - "optional": true - }, - { - "name": "token_2022_program", - "optional": true - }, - { - "name": "event_authority", - "address": "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "route_plan", - "type": { - "vec": { - "defined": { - "name": "RoutePlanStep" - } - } - } - }, - { - "name": "out_amount", - "type": "u64" - }, - { - "name": "quoted_in_amount", - "type": "u64" - }, - { - "name": "slippage_bps", - "type": "u16" - }, - { - "name": "platform_fee_bps", - "type": "u8" - } - ], - "returns": "u64" - }, - { - "name": "route", - "docs": ["route_plan Topologically sorted trade DAG"], - "discriminator": [229, 23, 203, 151, 122, 227, 173, 42], - "accounts": [ - { - "name": "token_program" - }, - { - "name": "user_transfer_authority", - "signer": true - }, - { - "name": "user_source_token_account", - "writable": true - }, - { - "name": "user_destination_token_account", - "writable": true - }, - { - "name": "destination_token_account", - "writable": true, - "optional": true - }, - { - "name": "destination_mint" - }, - { - "name": "platform_fee_account", - "writable": true, - "optional": true - }, - { - "name": "event_authority", - "address": "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "route_plan", - "type": { - "vec": { - "defined": { - "name": "RoutePlanStep" - } - } - } - }, - { - "name": "in_amount", - "type": "u64" - }, - { - "name": "quoted_out_amount", - "type": "u64" - }, - { - "name": "slippage_bps", - "type": "u16" - }, - { - "name": "platform_fee_bps", - "type": "u8" - } - ], - "returns": "u64" - }, - { - "name": "route_with_token_ledger", - "discriminator": [150, 86, 71, 116, 167, 93, 14, 104], - "accounts": [ - { - "name": "token_program" - }, - { - "name": "user_transfer_authority", - "signer": true - }, - { - "name": "user_source_token_account", - "writable": true - }, - { - "name": "user_destination_token_account", - "writable": true - }, - { - "name": "destination_token_account", - "writable": true, - "optional": true - }, - { - "name": "destination_mint" - }, - { - "name": "platform_fee_account", - "writable": true, - "optional": true - }, - { - "name": "token_ledger" - }, - { - "name": "event_authority", - "address": "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "route_plan", - "type": { - "vec": { - "defined": { - "name": "RoutePlanStep" - } - } - } - }, - { - "name": "quoted_out_amount", - "type": "u64" - }, - { - "name": "slippage_bps", - "type": "u16" - }, - { - "name": "platform_fee_bps", - "type": "u8" - } - ], - "returns": "u64" - }, - { - "name": "set_token_ledger", - "discriminator": [228, 85, 185, 112, 78, 79, 77, 2], - "accounts": [ - { - "name": "token_ledger", - "writable": true - }, - { - "name": "token_account" - } - ], - "args": [] - }, - { - "name": "shared_accounts_exact_out_route", - "docs": [ - "Route by using program owned token accounts and open orders accounts." - ], - "discriminator": [176, 209, 105, 168, 154, 125, 69, 62], - "accounts": [ - { - "name": "token_program" - }, - { - "name": "program_authority" - }, - { - "name": "user_transfer_authority", - "signer": true - }, - { - "name": "source_token_account", - "writable": true - }, - { - "name": "program_source_token_account", - "writable": true - }, - { - "name": "program_destination_token_account", - "writable": true - }, - { - "name": "destination_token_account", - "writable": true - }, - { - "name": "source_mint" - }, - { - "name": "destination_mint" - }, - { - "name": "platform_fee_account", - "writable": true, - "optional": true - }, - { - "name": "token_2022_program", - "optional": true - }, - { - "name": "event_authority", - "address": "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "id", - "type": "u8" - }, - { - "name": "route_plan", - "type": { - "vec": { - "defined": { - "name": "RoutePlanStep" - } - } - } - }, - { - "name": "out_amount", - "type": "u64" - }, - { - "name": "quoted_in_amount", - "type": "u64" - }, - { - "name": "slippage_bps", - "type": "u16" - }, - { - "name": "platform_fee_bps", - "type": "u8" - } - ], - "returns": "u64" - }, - { - "name": "shared_accounts_route", - "docs": [ - "Route by using program owned token accounts and open orders accounts." - ], - "discriminator": [193, 32, 155, 51, 65, 214, 156, 129], - "accounts": [ - { - "name": "token_program" - }, - { - "name": "program_authority" - }, - { - "name": "user_transfer_authority", - "signer": true - }, - { - "name": "source_token_account", - "writable": true - }, - { - "name": "program_source_token_account", - "writable": true - }, - { - "name": "program_destination_token_account", - "writable": true - }, - { - "name": "destination_token_account", - "writable": true - }, - { - "name": "source_mint" - }, - { - "name": "destination_mint" - }, - { - "name": "platform_fee_account", - "writable": true, - "optional": true - }, - { - "name": "token_2022_program", - "optional": true - }, - { - "name": "event_authority", - "address": "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "id", - "type": "u8" - }, - { - "name": "route_plan", - "type": { - "vec": { - "defined": { - "name": "RoutePlanStep" - } - } - } - }, - { - "name": "in_amount", - "type": "u64" - }, - { - "name": "quoted_out_amount", - "type": "u64" - }, - { - "name": "slippage_bps", - "type": "u16" - }, - { - "name": "platform_fee_bps", - "type": "u8" - } - ], - "returns": "u64" - }, - { - "name": "shared_accounts_route_with_token_ledger", - "discriminator": [230, 121, 143, 80, 119, 159, 106, 170], - "accounts": [ - { - "name": "token_program" - }, - { - "name": "program_authority" - }, - { - "name": "user_transfer_authority", - "signer": true - }, - { - "name": "source_token_account", - "writable": true - }, - { - "name": "program_source_token_account", - "writable": true - }, - { - "name": "program_destination_token_account", - "writable": true - }, - { - "name": "destination_token_account", - "writable": true - }, - { - "name": "source_mint" - }, - { - "name": "destination_mint" - }, - { - "name": "platform_fee_account", - "writable": true, - "optional": true - }, - { - "name": "token_2022_program", - "optional": true - }, - { - "name": "token_ledger" - }, - { - "name": "event_authority", - "address": "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "id", - "type": "u8" - }, - { - "name": "route_plan", - "type": { - "vec": { - "defined": { - "name": "RoutePlanStep" - } - } - } - }, - { - "name": "quoted_out_amount", - "type": "u64" - }, - { - "name": "slippage_bps", - "type": "u16" - }, - { - "name": "platform_fee_bps", - "type": "u8" - } - ], - "returns": "u64" - } - ], - "accounts": [ - { - "name": "TokenLedger", - "discriminator": [156, 247, 9, 188, 54, 108, 85, 77] - } - ], - "events": [ - { - "name": "FeeEvent", - "discriminator": [73, 79, 78, 127, 184, 213, 13, 220] - }, - { - "name": "SwapEvent", - "discriminator": [64, 198, 205, 232, 38, 8, 113, 226] - } - ], - "errors": [ - { - "code": 6000, - "name": "EmptyRoute", - "msg": "Empty route" - }, - { - "code": 6001, - "name": "SlippageToleranceExceeded", - "msg": "Slippage tolerance exceeded" - }, - { - "code": 6002, - "name": "InvalidCalculation", - "msg": "Invalid calculation" - }, - { - "code": 6003, - "name": "MissingPlatformFeeAccount", - "msg": "Missing platform fee account" - }, - { - "code": 6004, - "name": "InvalidSlippage", - "msg": "Invalid slippage" - }, - { - "code": 6005, - "name": "NotEnoughPercent", - "msg": "Not enough percent to 100" - }, - { - "code": 6006, - "name": "InvalidInputIndex", - "msg": "Token input index is invalid" - }, - { - "code": 6007, - "name": "InvalidOutputIndex", - "msg": "Token output index is invalid" - }, - { - "code": 6008, - "name": "NotEnoughAccountKeys", - "msg": "Not Enough Account keys" - }, - { - "code": 6009, - "name": "NonZeroMinimumOutAmountNotSupported", - "msg": "Non zero minimum out amount not supported" - }, - { - "code": 6010, - "name": "InvalidRoutePlan", - "msg": "Invalid route plan" - }, - { - "code": 6011, - "name": "InvalidReferralAuthority", - "msg": "Invalid referral authority" - }, - { - "code": 6012, - "name": "LedgerTokenAccountDoesNotMatch", - "msg": "Token account doesn't match the ledger" - }, - { - "code": 6013, - "name": "InvalidTokenLedger", - "msg": "Invalid token ledger" - }, - { - "code": 6014, - "name": "IncorrectTokenProgramID", - "msg": "Token program ID is invalid" - }, - { - "code": 6015, - "name": "TokenProgramNotProvided", - "msg": "Token program not provided" - }, - { - "code": 6016, - "name": "SwapNotSupported", - "msg": "Swap not supported" - }, - { - "code": 6017, - "name": "ExactOutAmountNotMatched", - "msg": "Exact out amount doesn't match" - }, - { - "code": 6018, - "name": "SourceAndDestinationMintCannotBeTheSame", - "msg": "Source mint and destination mint cannot the same" - } - ], - "types": [ - { - "name": "AccountsType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "TransferHookA" - }, - { - "name": "TransferHookB" - }, - { - "name": "TransferHookReward" - }, - { - "name": "TransferHookInput" - }, - { - "name": "TransferHookIntermediate" - }, - { - "name": "TransferHookOutput" - }, - { - "name": "SupplementalTickArrays" - }, - { - "name": "SupplementalTickArraysOne" - }, - { - "name": "SupplementalTickArraysTwo" - } - ] - } - }, - { - "name": "FeeEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "RemainingAccountsInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "slices", - "type": { - "vec": { - "defined": { - "name": "RemainingAccountsSlice" - } - } - } - } - ] - } - }, - { - "name": "RemainingAccountsSlice", - "type": { - "kind": "struct", - "fields": [ - { - "name": "accounts_type", - "type": { - "defined": { - "name": "AccountsType" - } - } - }, - { - "name": "length", - "type": "u8" - } - ] - } - }, - { - "name": "RoutePlanStep", - "type": { - "kind": "struct", - "fields": [ - { - "name": "swap", - "type": { - "defined": { - "name": "Swap" - } - } - }, - { - "name": "percent", - "type": "u8" - }, - { - "name": "input_index", - "type": "u8" - }, - { - "name": "output_index", - "type": "u8" - } - ] - } - }, - { - "name": "Side", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Bid" - }, - { - "name": "Ask" - } - ] - } - }, - { - "name": "Swap", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Saber" - }, - { - "name": "SaberAddDecimalsDeposit" - }, - { - "name": "SaberAddDecimalsWithdraw" - }, - { - "name": "TokenSwap" - }, - { - "name": "Sencha" - }, - { - "name": "Step" - }, - { - "name": "Cropper" - }, - { - "name": "Raydium" - }, - { - "name": "Crema", - "fields": [ - { - "name": "a_to_b", - "type": "bool" - } - ] - }, - { - "name": "Lifinity" - }, - { - "name": "Mercurial" - }, - { - "name": "Cykura" - }, - { - "name": "Serum", - "fields": [ - { - "name": "side", - "type": { - "defined": { - "name": "Side" - } - } - } - ] - }, - { - "name": "MarinadeDeposit" - }, - { - "name": "MarinadeUnstake" - }, - { - "name": "Aldrin", - "fields": [ - { - "name": "side", - "type": { - "defined": { - "name": "Side" - } - } - } - ] - }, - { - "name": "AldrinV2", - "fields": [ - { - "name": "side", - "type": { - "defined": { - "name": "Side" - } - } - } - ] - }, - { - "name": "Whirlpool", - "fields": [ - { - "name": "a_to_b", - "type": "bool" - } - ] - }, - { - "name": "Invariant", - "fields": [ - { - "name": "x_to_y", - "type": "bool" - } - ] - }, - { - "name": "Meteora" - }, - { - "name": "GooseFX" - }, - { - "name": "DeltaFi", - "fields": [ - { - "name": "stable", - "type": "bool" - } - ] - }, - { - "name": "Balansol" - }, - { - "name": "MarcoPolo", - "fields": [ - { - "name": "x_to_y", - "type": "bool" - } - ] - }, - { - "name": "Dradex", - "fields": [ - { - "name": "side", - "type": { - "defined": { - "name": "Side" - } - } - } - ] - }, - { - "name": "LifinityV2" - }, - { - "name": "RaydiumClmm" - }, - { - "name": "Openbook", - "fields": [ - { - "name": "side", - "type": { - "defined": { - "name": "Side" - } - } - } - ] - }, - { - "name": "Phoenix", - "fields": [ - { - "name": "side", - "type": { - "defined": { - "name": "Side" - } - } - } - ] - }, - { - "name": "Symmetry", - "fields": [ - { - "name": "from_token_id", - "type": "u64" - }, - { - "name": "to_token_id", - "type": "u64" - } - ] - }, - { - "name": "TokenSwapV2" - }, - { - "name": "HeliumTreasuryManagementRedeemV0" - }, - { - "name": "StakeDexStakeWrappedSol" - }, - { - "name": "StakeDexSwapViaStake", - "fields": [ - { - "name": "bridge_stake_seed", - "type": "u32" - } - ] - }, - { - "name": "GooseFXV2" - }, - { - "name": "Perps" - }, - { - "name": "PerpsAddLiquidity" - }, - { - "name": "PerpsRemoveLiquidity" - }, - { - "name": "MeteoraDlmm" - }, - { - "name": "OpenBookV2", - "fields": [ - { - "name": "side", - "type": { - "defined": { - "name": "Side" - } - } - } - ] - }, - { - "name": "RaydiumClmmV2" - }, - { - "name": "StakeDexPrefundWithdrawStakeAndDepositStake", - "fields": [ - { - "name": "bridge_stake_seed", - "type": "u32" - } - ] - }, - { - "name": "Clone", - "fields": [ - { - "name": "pool_index", - "type": "u8" - }, - { - "name": "quantity_is_input", - "type": "bool" - }, - { - "name": "quantity_is_collateral", - "type": "bool" - } - ] - }, - { - "name": "SanctumS", - "fields": [ - { - "name": "src_lst_value_calc_accs", - "type": "u8" - }, - { - "name": "dst_lst_value_calc_accs", - "type": "u8" - }, - { - "name": "src_lst_index", - "type": "u32" - }, - { - "name": "dst_lst_index", - "type": "u32" - } - ] - }, - { - "name": "SanctumSAddLiquidity", - "fields": [ - { - "name": "lst_value_calc_accs", - "type": "u8" - }, - { - "name": "lst_index", - "type": "u32" - } - ] - }, - { - "name": "SanctumSRemoveLiquidity", - "fields": [ - { - "name": "lst_value_calc_accs", - "type": "u8" - }, - { - "name": "lst_index", - "type": "u32" - } - ] - }, - { - "name": "RaydiumCP" - }, - { - "name": "WhirlpoolSwapV2", - "fields": [ - { - "name": "a_to_b", - "type": "bool" - }, - { - "name": "remaining_accounts_info", - "type": { - "option": { - "defined": { - "name": "RemainingAccountsInfo" - } - } - } - } - ] - }, - { - "name": "OneIntro" - }, - { - "name": "PumpdotfunWrappedBuy" - }, - { - "name": "PumpdotfunWrappedSell" - }, - { - "name": "PerpsV2" - }, - { - "name": "PerpsV2AddLiquidity" - }, - { - "name": "PerpsV2RemoveLiquidity" - }, - { - "name": "MoonshotWrappedBuy" - }, - { - "name": "MoonshotWrappedSell" - }, - { - "name": "StabbleStableSwap" - }, - { - "name": "StabbleWeightedSwap" - }, - { - "name": "Obric", - "fields": [ - { - "name": "x_to_y", - "type": "bool" - } - ] - }, - { - "name": "FoxBuyFromEstimatedCost" - }, - { - "name": "FoxClaimPartial", - "fields": [ - { - "name": "is_y", - "type": "bool" - } - ] - }, - { - "name": "SolFi", - "fields": [ - { - "name": "is_quote_to_base", - "type": "bool" - } - ] - }, - { - "name": "SolayerDelegateNoInit" - }, - { - "name": "SolayerUndelegateNoInit" - }, - { - "name": "TokenMill", - "fields": [ - { - "name": "side", - "type": { - "defined": { - "name": "Side" - } - } - } - ] - }, - { - "name": "DaosFunBuy" - }, - { - "name": "DaosFunSell" - }, - { - "name": "ZeroFi" - }, - { - "name": "StakeDexWithdrawWrappedSol" - }, - { - "name": "VirtualsBuy" - }, - { - "name": "VirtualsSell" - }, - { - "name": "Perena", - "fields": [ - { - "name": "in_index", - "type": "u8" - }, - { - "name": "out_index", - "type": "u8" - } - ] - }, - { - "name": "PumpdotfunAmmBuy" - }, - { - "name": "PumpdotfunAmmSell" - }, - { - "name": "Gamma" - }, - { - "name": "MeteoraDlmmSwapV2", - "fields": [ - { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "Woofi" - }, - { - "name": "MeteoraDammV2" - }, - { - "name": "MeteoraDynamicBondingCurveSwap" - }, - { - "name": "StabbleStableSwapV2" - }, - { - "name": "StabbleWeightedSwapV2" - }, - { - "name": "RaydiumLaunchlabBuy", - "fields": [ - { - "name": "share_fee_rate", - "type": "u64" - } - ] - }, - { - "name": "RaydiumLaunchlabSell", - "fields": [ - { - "name": "share_fee_rate", - "type": "u64" - } - ] - }, - { - "name": "BoopdotfunWrappedBuy" - }, - { - "name": "BoopdotfunWrappedSell" - }, - { - "name": "Plasma", - "fields": [ - { - "name": "side", - "type": { - "defined": { - "name": "Side" - } - } - } - ] - }, - { - "name": "GoonFi", - "fields": [ - { - "name": "is_bid", - "type": "bool" - }, - { - "name": "blacklist_bump", - "type": "u8" - } - ] - }, - { - "name": "HumidiFi", - "fields": [ - { - "name": "swap_id", - "type": "u64" - }, - { - "name": "is_base_to_quote", - "type": "bool" - } - ] - }, - { - "name": "MeteoraDynamicBondingCurveSwapWithRemainingAccounts" - }, - { - "name": "TesseraV", - "fields": [ - { - "name": "side", - "type": { - "defined": { - "name": "Side" - } - } - } - ] - }, - { - "name": "RaydiumStable" - } - ] - } - }, - { - "name": "SwapEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amm", - "type": "pubkey" - }, - { - "name": "input_mint", - "type": "pubkey" - }, - { - "name": "input_amount", - "type": "u64" - }, - { - "name": "output_mint", - "type": "pubkey" - }, - { - "name": "output_amount", - "type": "u64" - } - ] - } - }, - { - "name": "TokenLedger", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_account", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - } - ] -} diff --git a/crates/jupiter-swap-parser/proto/jupiter_swap.proto b/crates/jupiter-swap-parser/proto/jupiter_swap.proto deleted file mode 100644 index 6e881b9f..00000000 --- a/crates/jupiter-swap-parser/proto/jupiter_swap.proto +++ /dev/null @@ -1,738 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.jupiter_swap; - -message SwapSaber { } - -message SwapSaberAddDecimalsDeposit { } - -message SwapSaberAddDecimalsWithdraw { } - -message SwapTokenSwap { } - -message SwapSencha { } - -message SwapStep { } - -message SwapCropper { } - -message SwapRaydium { } - -message SwapCrema { - bool a_to_b = 1; -} - -message SwapLifinity { } - -message SwapMercurial { } - -message SwapCykura { } - -message SwapSerum { - Side side = 1; -} - -message SwapMarinadeDeposit { } - -message SwapMarinadeUnstake { } - -message SwapAldrin { - Side side = 1; -} - -message SwapAldrinV2 { - Side side = 1; -} - -message SwapWhirlpool { - bool a_to_b = 1; -} - -message SwapInvariant { - bool x_to_y = 1; -} - -message SwapMeteora { } - -message SwapGooseFX { } - -message SwapDeltaFi { - bool stable = 1; -} - -message SwapBalansol { } - -message SwapMarcoPolo { - bool x_to_y = 1; -} - -message SwapDradex { - Side side = 1; -} - -message SwapLifinityV2 { } - -message SwapRaydiumClmm { } - -message SwapOpenbook { - Side side = 1; -} - -message SwapPhoenix { - Side side = 1; -} - -message SwapSymmetry { - uint64 from_token_id = 1; - uint64 to_token_id = 2; -} - -message SwapTokenSwapV2 { } - -message SwapHeliumTreasuryManagementRedeemV0 { } - -message SwapStakeDexStakeWrappedSol { } - -message SwapStakeDexSwapViaStake { - uint32 bridge_stake_seed = 1; -} - -message SwapGooseFXV2 { } - -message SwapPerps { } - -message SwapPerpsAddLiquidity { } - -message SwapPerpsRemoveLiquidity { } - -message SwapMeteoraDlmm { } - -message SwapOpenBookV2 { - Side side = 1; -} - -message SwapRaydiumClmmV2 { } - -message SwapStakeDexPrefundWithdrawStakeAndDepositStake { - uint32 bridge_stake_seed = 1; -} - -message SwapClone { - uint32 pool_index = 1; - bool quantity_is_input = 2; - bool quantity_is_collateral = 3; -} - -message SwapSanctumS { - uint32 src_lst_value_calc_accs = 1; - uint32 dst_lst_value_calc_accs = 2; - uint32 src_lst_index = 3; - uint32 dst_lst_index = 4; -} - -message SwapSanctumSAddLiquidity { - uint32 lst_value_calc_accs = 1; - uint32 lst_index = 2; -} - -message SwapSanctumSRemoveLiquidity { - uint32 lst_value_calc_accs = 1; - uint32 lst_index = 2; -} - -message SwapRaydiumCP { } - -message SwapWhirlpoolSwapV2 { - bool a_to_b = 1; - optional RemainingAccountsInfo remaining_accounts_info = 2; -} - -message SwapOneIntro { } - -message SwapPumpdotfunWrappedBuy { } - -message SwapPumpdotfunWrappedSell { } - -message SwapPerpsV2 { } - -message SwapPerpsV2AddLiquidity { } - -message SwapPerpsV2RemoveLiquidity { } - -message SwapMoonshotWrappedBuy { } - -message SwapMoonshotWrappedSell { } - -message SwapStabbleStableSwap { } - -message SwapStabbleWeightedSwap { } - -message SwapObric { - bool x_to_y = 1; -} - -message SwapFoxBuyFromEstimatedCost { } - -message SwapFoxClaimPartial { - bool is_y = 1; -} - -message SwapSolFi { - bool is_quote_to_base = 1; -} - -message SwapSolayerDelegateNoInit { } - -message SwapSolayerUndelegateNoInit { } - -message SwapTokenMill { - Side side = 1; -} - -message SwapDaosFunBuy { } - -message SwapDaosFunSell { } - -message SwapZeroFi { } - -message SwapStakeDexWithdrawWrappedSol { } - -message SwapVirtualsBuy { } - -message SwapVirtualsSell { } - -message SwapPerena { - uint32 in_index = 1; - uint32 out_index = 2; -} - -message SwapPumpdotfunAmmBuy { } - -message SwapPumpdotfunAmmSell { } - -message SwapGamma { } - -message SwapMeteoraDlmmSwapV2 { - RemainingAccountsInfo remaining_accounts_info = 1; -} - -message SwapWoofi { } - -message SwapMeteoraDammV2 { } - -message SwapMeteoraDynamicBondingCurveSwap { } - -message SwapStabbleStableSwapV2 { } - -message SwapStabbleWeightedSwapV2 { } - -message SwapRaydiumLaunchlabBuy { - uint64 share_fee_rate = 1; -} - -message SwapRaydiumLaunchlabSell { - uint64 share_fee_rate = 1; -} - -message SwapBoopdotfunWrappedBuy { } - -message SwapBoopdotfunWrappedSell { } - -message SwapPlasma { - Side side = 1; -} - -message SwapGoonFi { - bool is_bid = 1; - uint32 blacklist_bump = 2; -} - -message SwapHumidiFi { - uint64 swap_id = 1; - bool is_base_to_quote = 2; -} - -message SwapMeteoraDynamicBondingCurveSwapWithRemainingAccounts { } - -message SwapTesseraV { - Side side = 1; -} - -message SwapRaydiumStable { } - -message ClaimIx { - ClaimIxAccounts accounts = 1; - ClaimIxData data = 2; -} - -message ClaimTokenIx { - ClaimTokenIxAccounts accounts = 1; - ClaimTokenIxData data = 2; -} - -message CloseTokenIx { - CloseTokenIxAccounts accounts = 1; - CloseTokenIxData data = 2; -} - -message CreateOpenOrdersIx { - CreateOpenOrdersIxAccounts accounts = 1; -} - -message CreateProgramOpenOrdersIx { - CreateProgramOpenOrdersIxAccounts accounts = 1; - CreateProgramOpenOrdersIxData data = 2; -} - -message CreateTokenLedgerIx { - CreateTokenLedgerIxAccounts accounts = 1; -} - -message CreateTokenAccountIx { - CreateTokenAccountIxAccounts accounts = 1; - CreateTokenAccountIxData data = 2; -} - -message ExactOutRouteIx { - ExactOutRouteIxAccounts accounts = 1; - ExactOutRouteIxData data = 2; -} - -message RouteIx { - RouteIxAccounts accounts = 1; - RouteIxData data = 2; -} - -message RouteWithTokenLedgerIx { - RouteWithTokenLedgerIxAccounts accounts = 1; - RouteWithTokenLedgerIxData data = 2; -} - -message SetTokenLedgerIx { - SetTokenLedgerIxAccounts accounts = 1; -} - -message SharedAccountsExactOutRouteIx { - SharedAccountsExactOutRouteIxAccounts accounts = 1; - SharedAccountsExactOutRouteIxData data = 2; -} - -message SharedAccountsRouteIx { - SharedAccountsRouteIxAccounts accounts = 1; - SharedAccountsRouteIxData data = 2; -} - -message SharedAccountsRouteWithTokenLedgerIx { - SharedAccountsRouteWithTokenLedgerIxAccounts accounts = 1; - SharedAccountsRouteWithTokenLedgerIxData data = 2; -} - - -enum AccountsType { - AccountsTypeTransferHookA = 0; - AccountsTypeTransferHookB = 1; - AccountsTypeTransferHookReward = 2; - AccountsTypeTransferHookInput = 3; - AccountsTypeTransferHookIntermediate = 4; - AccountsTypeTransferHookOutput = 5; - AccountsTypeSupplementalTickArrays = 6; - AccountsTypeSupplementalTickArraysOne = 7; - AccountsTypeSupplementalTickArraysTwo = 8; -} - -message FeeEvent { - string account = 1; - string mint = 2; - uint64 amount = 3; -} - -message RemainingAccountsInfo { - repeated RemainingAccountsSlice slices = 1; -} - -message RemainingAccountsSlice { - AccountsType accounts_type = 1; - uint32 length = 2; -} - -message RoutePlanStep { - Swap swap = 1; - uint32 percent = 2; - uint32 input_index = 3; - uint32 output_index = 4; -} - -enum Side { - SideBid = 0; - SideAsk = 1; -} - -message Swap { - oneof variant{ - SwapSaber saber = 1; - SwapSaberAddDecimalsDeposit saber_add_decimals_deposit = 2; - SwapSaberAddDecimalsWithdraw saber_add_decimals_withdraw = 3; - SwapTokenSwap token_swap = 4; - SwapSencha sencha = 5; - SwapStep step = 6; - SwapCropper cropper = 7; - SwapRaydium raydium = 8; - SwapCrema crema = 9; - SwapLifinity lifinity = 10; - SwapMercurial mercurial = 11; - SwapCykura cykura = 12; - SwapSerum serum = 13; - SwapMarinadeDeposit marinade_deposit = 14; - SwapMarinadeUnstake marinade_unstake = 15; - SwapAldrin aldrin = 16; - SwapAldrinV2 aldrin_v2 = 17; - SwapWhirlpool whirlpool = 18; - SwapInvariant invariant = 19; - SwapMeteora meteora = 20; - SwapGooseFX goose_f_x = 21; - SwapDeltaFi delta_fi = 22; - SwapBalansol balansol = 23; - SwapMarcoPolo marco_polo = 24; - SwapDradex dradex = 25; - SwapLifinityV2 lifinity_v2 = 26; - SwapRaydiumClmm raydium_clmm = 27; - SwapOpenbook openbook = 28; - SwapPhoenix phoenix = 29; - SwapSymmetry symmetry = 30; - SwapTokenSwapV2 token_swap_v2 = 31; - SwapHeliumTreasuryManagementRedeemV0 helium_treasury_management_redeem_v0 = 32; - SwapStakeDexStakeWrappedSol stake_dex_stake_wrapped_sol = 33; - SwapStakeDexSwapViaStake stake_dex_swap_via_stake = 34; - SwapGooseFXV2 goose_f_x_v2 = 35; - SwapPerps perps = 36; - SwapPerpsAddLiquidity perps_add_liquidity = 37; - SwapPerpsRemoveLiquidity perps_remove_liquidity = 38; - SwapMeteoraDlmm meteora_dlmm = 39; - SwapOpenBookV2 open_book_v2 = 40; - SwapRaydiumClmmV2 raydium_clmm_v2 = 41; - SwapStakeDexPrefundWithdrawStakeAndDepositStake stake_dex_prefund_withdraw_stake_and_deposit_stake = 42; - SwapClone clone = 43; - SwapSanctumS sanctum_s = 44; - SwapSanctumSAddLiquidity sanctum_s_add_liquidity = 45; - SwapSanctumSRemoveLiquidity sanctum_s_remove_liquidity = 46; - SwapRaydiumCP raydium_c_p = 47; - SwapWhirlpoolSwapV2 whirlpool_swap_v2 = 48; - SwapOneIntro one_intro = 49; - SwapPumpdotfunWrappedBuy pumpdotfun_wrapped_buy = 50; - SwapPumpdotfunWrappedSell pumpdotfun_wrapped_sell = 51; - SwapPerpsV2 perps_v2 = 52; - SwapPerpsV2AddLiquidity perps_v2_add_liquidity = 53; - SwapPerpsV2RemoveLiquidity perps_v2_remove_liquidity = 54; - SwapMoonshotWrappedBuy moonshot_wrapped_buy = 55; - SwapMoonshotWrappedSell moonshot_wrapped_sell = 56; - SwapStabbleStableSwap stabble_stable_swap = 57; - SwapStabbleWeightedSwap stabble_weighted_swap = 58; - SwapObric obric = 59; - SwapFoxBuyFromEstimatedCost fox_buy_from_estimated_cost = 60; - SwapFoxClaimPartial fox_claim_partial = 61; - SwapSolFi sol_fi = 62; - SwapSolayerDelegateNoInit solayer_delegate_no_init = 63; - SwapSolayerUndelegateNoInit solayer_undelegate_no_init = 64; - SwapTokenMill token_mill = 65; - SwapDaosFunBuy daos_fun_buy = 66; - SwapDaosFunSell daos_fun_sell = 67; - SwapZeroFi zero_fi = 68; - SwapStakeDexWithdrawWrappedSol stake_dex_withdraw_wrapped_sol = 69; - SwapVirtualsBuy virtuals_buy = 70; - SwapVirtualsSell virtuals_sell = 71; - SwapPerena perena = 72; - SwapPumpdotfunAmmBuy pumpdotfun_amm_buy = 73; - SwapPumpdotfunAmmSell pumpdotfun_amm_sell = 74; - SwapGamma gamma = 75; - SwapMeteoraDlmmSwapV2 meteora_dlmm_swap_v2 = 76; - SwapWoofi woofi = 77; - SwapMeteoraDammV2 meteora_damm_v2 = 78; - SwapMeteoraDynamicBondingCurveSwap meteora_dynamic_bonding_curve_swap = 79; - SwapStabbleStableSwapV2 stabble_stable_swap_v2 = 80; - SwapStabbleWeightedSwapV2 stabble_weighted_swap_v2 = 81; - SwapRaydiumLaunchlabBuy raydium_launchlab_buy = 82; - SwapRaydiumLaunchlabSell raydium_launchlab_sell = 83; - SwapBoopdotfunWrappedBuy boopdotfun_wrapped_buy = 84; - SwapBoopdotfunWrappedSell boopdotfun_wrapped_sell = 85; - SwapPlasma plasma = 86; - SwapGoonFi goon_fi = 87; - SwapHumidiFi humidi_fi = 88; - SwapMeteoraDynamicBondingCurveSwapWithRemainingAccounts meteora_dynamic_bonding_curve_swap_with_remaining_accounts = 89; - SwapTesseraV tessera_v = 90; - SwapRaydiumStable raydium_stable = 91; - } -} - -message SwapEvent { - string amm = 1; - string input_mint = 2; - uint64 input_amount = 3; - string output_mint = 4; - uint64 output_amount = 5; -} - - -message TokenLedger { - string token_account = 1; - uint64 amount = 2; -} - - -message ClaimIxAccounts { - string wallet = 1; - string program_authority = 2; - string system_program = 3; -} - -message ClaimIxData { - uint32 id = 1; -} - -message ClaimTokenIxAccounts { - string payer = 1; - string wallet = 2; - string program_authority = 3; - string program_token_account = 4; - string destination_token_account = 5; - string mint = 6; - string token_program = 7; - string associated_token_program = 8; - string system_program = 9; -} - -message ClaimTokenIxData { - uint32 id = 1; -} - -message CloseTokenIxAccounts { - string operator = 1; - string wallet = 2; - string program_authority = 3; - string program_token_account = 4; - string mint = 5; - string token_program = 6; -} - -message CloseTokenIxData { - uint32 id = 1; - bool burn_all = 2; -} - -message CreateOpenOrdersIxAccounts { - string open_orders = 1; - string payer = 2; - string dex_program = 3; - string system_program = 4; - string rent = 5; - string market = 6; -} - - -message CreateProgramOpenOrdersIxAccounts { - string open_orders = 1; - string payer = 2; - string program_authority = 3; - string dex_program = 4; - string system_program = 5; - string rent = 6; - string market = 7; -} - -message CreateProgramOpenOrdersIxData { - uint32 id = 1; -} - -message CreateTokenLedgerIxAccounts { - string token_ledger = 1; - string payer = 2; - string system_program = 3; -} - - -message CreateTokenAccountIxAccounts { - string token_account = 1; - string user = 2; - string mint = 3; - string token_program = 4; - string system_program = 5; -} - -message CreateTokenAccountIxData { - uint32 bump = 1; -} - -message ExactOutRouteIxAccounts { - string token_program = 1; - string user_transfer_authority = 2; - string user_source_token_account = 3; - string user_destination_token_account = 4; - optional string destination_token_account = 5; - string source_mint = 6; - string destination_mint = 7; - optional string platform_fee_account = 8; - optional string token2022_program = 9; - string event_authority = 10; - string program = 11; -} - -message ExactOutRouteIxData { - repeated RoutePlanStep route_plan = 1; - uint64 out_amount = 2; - uint64 quoted_in_amount = 3; - uint32 slippage_bps = 4; - uint32 platform_fee_bps = 5; -} - -message RouteIxAccounts { - string token_program = 1; - string user_transfer_authority = 2; - string user_source_token_account = 3; - string user_destination_token_account = 4; - optional string destination_token_account = 5; - string destination_mint = 6; - optional string platform_fee_account = 7; - string event_authority = 8; - string program = 9; -} - -message RouteIxData { - repeated RoutePlanStep route_plan = 1; - uint64 in_amount = 2; - uint64 quoted_out_amount = 3; - uint32 slippage_bps = 4; - uint32 platform_fee_bps = 5; -} - -message RouteWithTokenLedgerIxAccounts { - string token_program = 1; - string user_transfer_authority = 2; - string user_source_token_account = 3; - string user_destination_token_account = 4; - optional string destination_token_account = 5; - string destination_mint = 6; - optional string platform_fee_account = 7; - string token_ledger = 8; - string event_authority = 9; - string program = 10; -} - -message RouteWithTokenLedgerIxData { - repeated RoutePlanStep route_plan = 1; - uint64 quoted_out_amount = 2; - uint32 slippage_bps = 3; - uint32 platform_fee_bps = 4; -} - -message SetTokenLedgerIxAccounts { - string token_ledger = 1; - string token_account = 2; -} - - -message SharedAccountsExactOutRouteIxAccounts { - string token_program = 1; - string program_authority = 2; - string user_transfer_authority = 3; - string source_token_account = 4; - string program_source_token_account = 5; - string program_destination_token_account = 6; - string destination_token_account = 7; - string source_mint = 8; - string destination_mint = 9; - optional string platform_fee_account = 10; - optional string token2022_program = 11; - string event_authority = 12; - string program = 13; -} - -message SharedAccountsExactOutRouteIxData { - uint32 id = 1; - repeated RoutePlanStep route_plan = 2; - uint64 out_amount = 3; - uint64 quoted_in_amount = 4; - uint32 slippage_bps = 5; - uint32 platform_fee_bps = 6; -} - -message SharedAccountsRouteIxAccounts { - string token_program = 1; - string program_authority = 2; - string user_transfer_authority = 3; - string source_token_account = 4; - string program_source_token_account = 5; - string program_destination_token_account = 6; - string destination_token_account = 7; - string source_mint = 8; - string destination_mint = 9; - optional string platform_fee_account = 10; - optional string token2022_program = 11; - string event_authority = 12; - string program = 13; -} - -message SharedAccountsRouteIxData { - uint32 id = 1; - repeated RoutePlanStep route_plan = 2; - uint64 in_amount = 3; - uint64 quoted_out_amount = 4; - uint32 slippage_bps = 5; - uint32 platform_fee_bps = 6; -} - -message SharedAccountsRouteWithTokenLedgerIxAccounts { - string token_program = 1; - string program_authority = 2; - string user_transfer_authority = 3; - string source_token_account = 4; - string program_source_token_account = 5; - string program_destination_token_account = 6; - string destination_token_account = 7; - string source_mint = 8; - string destination_mint = 9; - optional string platform_fee_account = 10; - optional string token2022_program = 11; - string token_ledger = 12; - string event_authority = 13; - string program = 14; -} - -message SharedAccountsRouteWithTokenLedgerIxData { - uint32 id = 1; - repeated RoutePlanStep route_plan = 2; - uint64 quoted_out_amount = 3; - uint32 slippage_bps = 4; - uint32 platform_fee_bps = 5; -} - - -message ProgramState { - oneof state_oneof { - TokenLedger token_ledger = 1; - } -} - -message ProgramIxs { - oneof ix_oneof { - ClaimIx claim = 1; - ClaimTokenIx claim_token = 2; - CloseTokenIx close_token = 3; - CreateOpenOrdersIx create_open_orders = 4; - CreateProgramOpenOrdersIx create_program_open_orders = 5; - CreateTokenLedgerIx create_token_ledger = 6; - CreateTokenAccountIx create_token_account = 7; - ExactOutRouteIx exact_out_route = 8; - RouteIx route = 9; - RouteWithTokenLedgerIx route_with_token_ledger = 10; - SetTokenLedgerIx set_token_ledger = 11; - SharedAccountsExactOutRouteIx shared_accounts_exact_out_route = 12; - SharedAccountsRouteIx shared_accounts_route = 13; - SharedAccountsRouteWithTokenLedgerIx shared_accounts_route_with_token_ledger = 14; - } -} - diff --git a/crates/jupiter-swap-parser/src/generated_parser/accounts_parser.rs b/crates/jupiter-swap-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index 4c4838a7..00000000 --- a/crates/jupiter-swap-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,138 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{accounts::TokenLedger, deserialize_checked, ID}; - -/// Jupiter Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum JupiterProgramState { - TokenLedger(TokenLedger), -} - -impl JupiterProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [156, 247, 9, 188, 54, 108, 85, 77] => Ok(JupiterProgramState::TokenLedger( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = JupiterProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "jupiter::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = JupiterProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, JupiterProgramState, TokenLedger}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for TokenLedger { - fn into_proto(self) -> proto_def::TokenLedger { - proto_def::TokenLedger { - token_account: self.token_account.to_string(), - amount: self.amount, - } - } - } - - impl IntoProto for JupiterProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - JupiterProgramState::TokenLedger(data) => { - proto_def::program_state::StateOneof::TokenLedger(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/jupiter-swap-parser/src/generated_parser/instructions_parser.rs b/crates/jupiter-swap-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index 55c4fdae..00000000 --- a/crates/jupiter-swap-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,962 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - Claim as ClaimIxAccounts, ClaimInstructionArgs as ClaimIxData, - ClaimToken as ClaimTokenIxAccounts, ClaimTokenInstructionArgs as ClaimTokenIxData, - CloseToken as CloseTokenIxAccounts, CloseTokenInstructionArgs as CloseTokenIxData, - CreateOpenOrders as CreateOpenOrdersIxAccounts, - CreateProgramOpenOrders as CreateProgramOpenOrdersIxAccounts, - CreateProgramOpenOrdersInstructionArgs as CreateProgramOpenOrdersIxData, - CreateTokenAccount as CreateTokenAccountIxAccounts, - CreateTokenAccountInstructionArgs as CreateTokenAccountIxData, - CreateTokenLedger as CreateTokenLedgerIxAccounts, ExactOutRoute as ExactOutRouteIxAccounts, - ExactOutRouteInstructionArgs as ExactOutRouteIxData, Route as RouteIxAccounts, - RouteInstructionArgs as RouteIxData, - RouteWithTokenLedger as RouteWithTokenLedgerIxAccounts, - RouteWithTokenLedgerInstructionArgs as RouteWithTokenLedgerIxData, - SetTokenLedger as SetTokenLedgerIxAccounts, - SharedAccountsExactOutRoute as SharedAccountsExactOutRouteIxAccounts, - SharedAccountsExactOutRouteInstructionArgs as SharedAccountsExactOutRouteIxData, - SharedAccountsRoute as SharedAccountsRouteIxAccounts, - SharedAccountsRouteInstructionArgs as SharedAccountsRouteIxData, - SharedAccountsRouteWithTokenLedger as SharedAccountsRouteWithTokenLedgerIxAccounts, - SharedAccountsRouteWithTokenLedgerInstructionArgs as SharedAccountsRouteWithTokenLedgerIxData, - }, - ID, -}; - -/// Jupiter Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum JupiterProgramIx { - Claim(ClaimIxAccounts, ClaimIxData), - ClaimToken(ClaimTokenIxAccounts, ClaimTokenIxData), - CloseToken(CloseTokenIxAccounts, CloseTokenIxData), - CreateOpenOrders(CreateOpenOrdersIxAccounts), - CreateProgramOpenOrders( - CreateProgramOpenOrdersIxAccounts, - CreateProgramOpenOrdersIxData, - ), - CreateTokenLedger(CreateTokenLedgerIxAccounts), - CreateTokenAccount(CreateTokenAccountIxAccounts, CreateTokenAccountIxData), - ExactOutRoute(ExactOutRouteIxAccounts, ExactOutRouteIxData), - Route(RouteIxAccounts, RouteIxData), - RouteWithTokenLedger(RouteWithTokenLedgerIxAccounts, RouteWithTokenLedgerIxData), - SetTokenLedger(SetTokenLedgerIxAccounts), - SharedAccountsExactOutRoute( - SharedAccountsExactOutRouteIxAccounts, - SharedAccountsExactOutRouteIxData, - ), - SharedAccountsRoute(SharedAccountsRouteIxAccounts, SharedAccountsRouteIxData), - SharedAccountsRouteWithTokenLedger( - SharedAccountsRouteWithTokenLedgerIxAccounts, - SharedAccountsRouteWithTokenLedgerIxData, - ), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = JupiterProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "Jupiter::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [62, 198, 214, 193, 213, 159, 108, 210] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimIxAccounts { - wallet: next_account(accounts)?, - program_authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: ClaimIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::Claim(ix_accounts, de_ix_data)) - }, - [116, 206, 27, 191, 166, 19, 0, 73] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimTokenIxAccounts { - payer: next_account(accounts)?, - wallet: next_account(accounts)?, - program_authority: next_account(accounts)?, - program_token_account: next_account(accounts)?, - destination_token_account: next_account(accounts)?, - mint: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: ClaimTokenIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::ClaimToken(ix_accounts, de_ix_data)) - }, - [26, 74, 236, 151, 104, 64, 183, 249] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CloseTokenIxAccounts { - operator: next_account(accounts)?, - wallet: next_account(accounts)?, - program_authority: next_account(accounts)?, - program_token_account: next_account(accounts)?, - mint: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: CloseTokenIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::CloseToken(ix_accounts, de_ix_data)) - }, - [229, 194, 212, 172, 8, 10, 134, 147] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateOpenOrdersIxAccounts { - open_orders: next_account(accounts)?, - payer: next_account(accounts)?, - dex_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - market: next_account(accounts)?, - }; - Ok(JupiterProgramIx::CreateOpenOrders(ix_accounts)) - }, - [28, 226, 32, 148, 188, 136, 113, 171] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateProgramOpenOrdersIxAccounts { - open_orders: next_account(accounts)?, - payer: next_account(accounts)?, - program_authority: next_account(accounts)?, - dex_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - market: next_account(accounts)?, - }; - let de_ix_data: CreateProgramOpenOrdersIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::CreateProgramOpenOrders( - ix_accounts, - de_ix_data, - )) - }, - [232, 242, 197, 253, 240, 143, 129, 52] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateTokenLedgerIxAccounts { - token_ledger: next_account(accounts)?, - payer: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(JupiterProgramIx::CreateTokenLedger(ix_accounts)) - }, - [147, 241, 123, 100, 244, 132, 174, 118] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateTokenAccountIxAccounts { - token_account: next_account(accounts)?, - user: next_account(accounts)?, - mint: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: CreateTokenAccountIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::CreateTokenAccount( - ix_accounts, - de_ix_data, - )) - }, - [208, 51, 239, 151, 123, 43, 237, 92] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ExactOutRouteIxAccounts { - token_program: next_account(accounts)?, - user_transfer_authority: next_account(accounts)?, - user_source_token_account: next_account(accounts)?, - user_destination_token_account: next_account(accounts)?, - destination_token_account: next_program_id_optional_account(accounts)?, - source_mint: next_account(accounts)?, - destination_mint: next_account(accounts)?, - platform_fee_account: next_program_id_optional_account(accounts)?, - token2022_program: next_program_id_optional_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: ExactOutRouteIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::ExactOutRoute(ix_accounts, de_ix_data)) - }, - [229, 23, 203, 151, 122, 227, 173, 42] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RouteIxAccounts { - token_program: next_account(accounts)?, - user_transfer_authority: next_account(accounts)?, - user_source_token_account: next_account(accounts)?, - user_destination_token_account: next_account(accounts)?, - destination_token_account: next_program_id_optional_account(accounts)?, - destination_mint: next_account(accounts)?, - platform_fee_account: next_program_id_optional_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: RouteIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::Route(ix_accounts, de_ix_data)) - }, - [150, 86, 71, 116, 167, 93, 14, 104] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RouteWithTokenLedgerIxAccounts { - token_program: next_account(accounts)?, - user_transfer_authority: next_account(accounts)?, - user_source_token_account: next_account(accounts)?, - user_destination_token_account: next_account(accounts)?, - destination_token_account: next_program_id_optional_account(accounts)?, - destination_mint: next_account(accounts)?, - platform_fee_account: next_program_id_optional_account(accounts)?, - token_ledger: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: RouteWithTokenLedgerIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::RouteWithTokenLedger( - ix_accounts, - de_ix_data, - )) - }, - [228, 85, 185, 112, 78, 79, 77, 2] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetTokenLedgerIxAccounts { - token_ledger: next_account(accounts)?, - token_account: next_account(accounts)?, - }; - Ok(JupiterProgramIx::SetTokenLedger(ix_accounts)) - }, - [176, 209, 105, 168, 154, 125, 69, 62] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SharedAccountsExactOutRouteIxAccounts { - token_program: next_account(accounts)?, - program_authority: next_account(accounts)?, - user_transfer_authority: next_account(accounts)?, - source_token_account: next_account(accounts)?, - program_source_token_account: next_account(accounts)?, - program_destination_token_account: next_account(accounts)?, - destination_token_account: next_account(accounts)?, - source_mint: next_account(accounts)?, - destination_mint: next_account(accounts)?, - platform_fee_account: next_program_id_optional_account(accounts)?, - token2022_program: next_program_id_optional_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SharedAccountsExactOutRouteIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::SharedAccountsExactOutRoute( - ix_accounts, - de_ix_data, - )) - }, - [193, 32, 155, 51, 65, 214, 156, 129] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SharedAccountsRouteIxAccounts { - token_program: next_account(accounts)?, - program_authority: next_account(accounts)?, - user_transfer_authority: next_account(accounts)?, - source_token_account: next_account(accounts)?, - program_source_token_account: next_account(accounts)?, - program_destination_token_account: next_account(accounts)?, - destination_token_account: next_account(accounts)?, - source_mint: next_account(accounts)?, - destination_mint: next_account(accounts)?, - platform_fee_account: next_program_id_optional_account(accounts)?, - token2022_program: next_program_id_optional_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SharedAccountsRouteIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::SharedAccountsRoute( - ix_accounts, - de_ix_data, - )) - }, - [230, 121, 143, 80, 119, 159, 106, 170] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SharedAccountsRouteWithTokenLedgerIxAccounts { - token_program: next_account(accounts)?, - program_authority: next_account(accounts)?, - user_transfer_authority: next_account(accounts)?, - source_token_account: next_account(accounts)?, - program_source_token_account: next_account(accounts)?, - program_destination_token_account: next_account(accounts)?, - destination_token_account: next_account(accounts)?, - source_mint: next_account(accounts)?, - destination_mint: next_account(accounts)?, - platform_fee_account: next_program_id_optional_account(accounts)?, - token2022_program: next_program_id_optional_account(accounts)?, - token_ledger: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SharedAccountsRouteWithTokenLedgerIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(JupiterProgramIx::SharedAccountsRouteWithTokenLedger( - ix_accounts, - de_ix_data, - )) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{ClaimIxAccounts, InstructionParser, JupiterProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for ClaimIxAccounts { - fn into_proto(self) -> proto_def::ClaimIxAccounts { - proto_def::ClaimIxAccounts { - wallet: self.wallet.to_string(), - program_authority: self.program_authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::ClaimIxData; - impl IntoProto for ClaimIxData { - fn into_proto(self) -> proto_def::ClaimIxData { - proto_def::ClaimIxData { id: self.id.into() } - } - } - use super::ClaimTokenIxAccounts; - impl IntoProto for ClaimTokenIxAccounts { - fn into_proto(self) -> proto_def::ClaimTokenIxAccounts { - proto_def::ClaimTokenIxAccounts { - payer: self.payer.to_string(), - wallet: self.wallet.to_string(), - program_authority: self.program_authority.to_string(), - program_token_account: self.program_token_account.to_string(), - destination_token_account: self.destination_token_account.to_string(), - mint: self.mint.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::ClaimTokenIxData; - impl IntoProto for ClaimTokenIxData { - fn into_proto(self) -> proto_def::ClaimTokenIxData { - proto_def::ClaimTokenIxData { id: self.id.into() } - } - } - use super::CloseTokenIxAccounts; - impl IntoProto for CloseTokenIxAccounts { - fn into_proto(self) -> proto_def::CloseTokenIxAccounts { - proto_def::CloseTokenIxAccounts { - operator: self.operator.to_string(), - wallet: self.wallet.to_string(), - program_authority: self.program_authority.to_string(), - program_token_account: self.program_token_account.to_string(), - mint: self.mint.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::CloseTokenIxData; - impl IntoProto for CloseTokenIxData { - fn into_proto(self) -> proto_def::CloseTokenIxData { - proto_def::CloseTokenIxData { - id: self.id.into(), - burn_all: self.burn_all, - } - } - } - use super::CreateOpenOrdersIxAccounts; - impl IntoProto for CreateOpenOrdersIxAccounts { - fn into_proto(self) -> proto_def::CreateOpenOrdersIxAccounts { - proto_def::CreateOpenOrdersIxAccounts { - open_orders: self.open_orders.to_string(), - payer: self.payer.to_string(), - dex_program: self.dex_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - market: self.market.to_string(), - } - } - } - use super::CreateProgramOpenOrdersIxAccounts; - impl IntoProto for CreateProgramOpenOrdersIxAccounts { - fn into_proto(self) -> proto_def::CreateProgramOpenOrdersIxAccounts { - proto_def::CreateProgramOpenOrdersIxAccounts { - open_orders: self.open_orders.to_string(), - payer: self.payer.to_string(), - program_authority: self.program_authority.to_string(), - dex_program: self.dex_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - market: self.market.to_string(), - } - } - } - use super::CreateProgramOpenOrdersIxData; - impl IntoProto for CreateProgramOpenOrdersIxData { - fn into_proto(self) -> proto_def::CreateProgramOpenOrdersIxData { - proto_def::CreateProgramOpenOrdersIxData { id: self.id.into() } - } - } - use super::CreateTokenLedgerIxAccounts; - impl IntoProto for CreateTokenLedgerIxAccounts { - fn into_proto(self) -> proto_def::CreateTokenLedgerIxAccounts { - proto_def::CreateTokenLedgerIxAccounts { - token_ledger: self.token_ledger.to_string(), - payer: self.payer.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreateTokenAccountIxAccounts; - impl IntoProto for CreateTokenAccountIxAccounts { - fn into_proto(self) -> proto_def::CreateTokenAccountIxAccounts { - proto_def::CreateTokenAccountIxAccounts { - token_account: self.token_account.to_string(), - user: self.user.to_string(), - mint: self.mint.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreateTokenAccountIxData; - impl IntoProto for CreateTokenAccountIxData { - fn into_proto(self) -> proto_def::CreateTokenAccountIxData { - proto_def::CreateTokenAccountIxData { - bump: self.bump.into(), - } - } - } - use super::ExactOutRouteIxAccounts; - impl IntoProto for ExactOutRouteIxAccounts { - fn into_proto(self) -> proto_def::ExactOutRouteIxAccounts { - proto_def::ExactOutRouteIxAccounts { - token_program: self.token_program.to_string(), - user_transfer_authority: self.user_transfer_authority.to_string(), - user_source_token_account: self.user_source_token_account.to_string(), - user_destination_token_account: self.user_destination_token_account.to_string(), - destination_token_account: self.destination_token_account.map(|p| p.to_string()), - source_mint: self.source_mint.to_string(), - destination_mint: self.destination_mint.to_string(), - platform_fee_account: self.platform_fee_account.map(|p| p.to_string()), - token2022_program: self.token2022_program.map(|p| p.to_string()), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ExactOutRouteIxData; - impl IntoProto for ExactOutRouteIxData { - fn into_proto(self) -> proto_def::ExactOutRouteIxData { - proto_def::ExactOutRouteIxData { - route_plan: self - .route_plan - .into_iter() - .map(|x| x.into_proto()) - .collect(), - out_amount: self.out_amount, - quoted_in_amount: self.quoted_in_amount, - slippage_bps: self.slippage_bps.into(), - platform_fee_bps: self.platform_fee_bps.into(), - } - } - } - use super::RouteIxAccounts; - impl IntoProto for RouteIxAccounts { - fn into_proto(self) -> proto_def::RouteIxAccounts { - proto_def::RouteIxAccounts { - token_program: self.token_program.to_string(), - user_transfer_authority: self.user_transfer_authority.to_string(), - user_source_token_account: self.user_source_token_account.to_string(), - user_destination_token_account: self.user_destination_token_account.to_string(), - destination_token_account: self.destination_token_account.map(|p| p.to_string()), - destination_mint: self.destination_mint.to_string(), - platform_fee_account: self.platform_fee_account.map(|p| p.to_string()), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::RouteIxData; - impl IntoProto for RouteIxData { - fn into_proto(self) -> proto_def::RouteIxData { - proto_def::RouteIxData { - route_plan: self - .route_plan - .into_iter() - .map(|x| x.into_proto()) - .collect(), - in_amount: self.in_amount, - quoted_out_amount: self.quoted_out_amount, - slippage_bps: self.slippage_bps.into(), - platform_fee_bps: self.platform_fee_bps.into(), - } - } - } - use super::RouteWithTokenLedgerIxAccounts; - impl IntoProto for RouteWithTokenLedgerIxAccounts { - fn into_proto(self) -> proto_def::RouteWithTokenLedgerIxAccounts { - proto_def::RouteWithTokenLedgerIxAccounts { - token_program: self.token_program.to_string(), - user_transfer_authority: self.user_transfer_authority.to_string(), - user_source_token_account: self.user_source_token_account.to_string(), - user_destination_token_account: self.user_destination_token_account.to_string(), - destination_token_account: self.destination_token_account.map(|p| p.to_string()), - destination_mint: self.destination_mint.to_string(), - platform_fee_account: self.platform_fee_account.map(|p| p.to_string()), - token_ledger: self.token_ledger.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::RouteWithTokenLedgerIxData; - impl IntoProto for RouteWithTokenLedgerIxData { - fn into_proto(self) -> proto_def::RouteWithTokenLedgerIxData { - proto_def::RouteWithTokenLedgerIxData { - route_plan: self - .route_plan - .into_iter() - .map(|x| x.into_proto()) - .collect(), - quoted_out_amount: self.quoted_out_amount, - slippage_bps: self.slippage_bps.into(), - platform_fee_bps: self.platform_fee_bps.into(), - } - } - } - use super::SetTokenLedgerIxAccounts; - impl IntoProto for SetTokenLedgerIxAccounts { - fn into_proto(self) -> proto_def::SetTokenLedgerIxAccounts { - proto_def::SetTokenLedgerIxAccounts { - token_ledger: self.token_ledger.to_string(), - token_account: self.token_account.to_string(), - } - } - } - use super::SharedAccountsExactOutRouteIxAccounts; - impl IntoProto - for SharedAccountsExactOutRouteIxAccounts - { - fn into_proto(self) -> proto_def::SharedAccountsExactOutRouteIxAccounts { - proto_def::SharedAccountsExactOutRouteIxAccounts { - token_program: self.token_program.to_string(), - program_authority: self.program_authority.to_string(), - user_transfer_authority: self.user_transfer_authority.to_string(), - source_token_account: self.source_token_account.to_string(), - program_source_token_account: self.program_source_token_account.to_string(), - program_destination_token_account: self - .program_destination_token_account - .to_string(), - destination_token_account: self.destination_token_account.to_string(), - source_mint: self.source_mint.to_string(), - destination_mint: self.destination_mint.to_string(), - platform_fee_account: self.platform_fee_account.map(|p| p.to_string()), - token2022_program: self.token2022_program.map(|p| p.to_string()), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SharedAccountsExactOutRouteIxData; - impl IntoProto for SharedAccountsExactOutRouteIxData { - fn into_proto(self) -> proto_def::SharedAccountsExactOutRouteIxData { - proto_def::SharedAccountsExactOutRouteIxData { - id: self.id.into(), - route_plan: self - .route_plan - .into_iter() - .map(|x| x.into_proto()) - .collect(), - out_amount: self.out_amount, - quoted_in_amount: self.quoted_in_amount, - slippage_bps: self.slippage_bps.into(), - platform_fee_bps: self.platform_fee_bps.into(), - } - } - } - use super::SharedAccountsRouteIxAccounts; - impl IntoProto for SharedAccountsRouteIxAccounts { - fn into_proto(self) -> proto_def::SharedAccountsRouteIxAccounts { - proto_def::SharedAccountsRouteIxAccounts { - token_program: self.token_program.to_string(), - program_authority: self.program_authority.to_string(), - user_transfer_authority: self.user_transfer_authority.to_string(), - source_token_account: self.source_token_account.to_string(), - program_source_token_account: self.program_source_token_account.to_string(), - program_destination_token_account: self - .program_destination_token_account - .to_string(), - destination_token_account: self.destination_token_account.to_string(), - source_mint: self.source_mint.to_string(), - destination_mint: self.destination_mint.to_string(), - platform_fee_account: self.platform_fee_account.map(|p| p.to_string()), - token2022_program: self.token2022_program.map(|p| p.to_string()), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SharedAccountsRouteIxData; - impl IntoProto for SharedAccountsRouteIxData { - fn into_proto(self) -> proto_def::SharedAccountsRouteIxData { - proto_def::SharedAccountsRouteIxData { - id: self.id.into(), - route_plan: self - .route_plan - .into_iter() - .map(|x| x.into_proto()) - .collect(), - in_amount: self.in_amount, - quoted_out_amount: self.quoted_out_amount, - slippage_bps: self.slippage_bps.into(), - platform_fee_bps: self.platform_fee_bps.into(), - } - } - } - use super::SharedAccountsRouteWithTokenLedgerIxAccounts; - impl IntoProto - for SharedAccountsRouteWithTokenLedgerIxAccounts - { - fn into_proto(self) -> proto_def::SharedAccountsRouteWithTokenLedgerIxAccounts { - proto_def::SharedAccountsRouteWithTokenLedgerIxAccounts { - token_program: self.token_program.to_string(), - program_authority: self.program_authority.to_string(), - user_transfer_authority: self.user_transfer_authority.to_string(), - source_token_account: self.source_token_account.to_string(), - program_source_token_account: self.program_source_token_account.to_string(), - program_destination_token_account: self - .program_destination_token_account - .to_string(), - destination_token_account: self.destination_token_account.to_string(), - source_mint: self.source_mint.to_string(), - destination_mint: self.destination_mint.to_string(), - platform_fee_account: self.platform_fee_account.map(|p| p.to_string()), - token2022_program: self.token2022_program.map(|p| p.to_string()), - token_ledger: self.token_ledger.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SharedAccountsRouteWithTokenLedgerIxData; - impl IntoProto - for SharedAccountsRouteWithTokenLedgerIxData - { - fn into_proto(self) -> proto_def::SharedAccountsRouteWithTokenLedgerIxData { - proto_def::SharedAccountsRouteWithTokenLedgerIxData { - id: self.id.into(), - route_plan: self - .route_plan - .into_iter() - .map(|x| x.into_proto()) - .collect(), - quoted_out_amount: self.quoted_out_amount, - slippage_bps: self.slippage_bps.into(), - platform_fee_bps: self.platform_fee_bps.into(), - } - } - } - - impl IntoProto for JupiterProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - JupiterProgramIx::Claim(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Claim(proto_def::ClaimIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - JupiterProgramIx::ClaimToken(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimToken( - proto_def::ClaimTokenIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - JupiterProgramIx::CloseToken(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CloseToken( - proto_def::CloseTokenIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - JupiterProgramIx::CreateOpenOrders(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateOpenOrders( - proto_def::CreateOpenOrdersIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - JupiterProgramIx::CreateProgramOpenOrders(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateProgramOpenOrders( - proto_def::CreateProgramOpenOrdersIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - JupiterProgramIx::CreateTokenLedger(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateTokenLedger( - proto_def::CreateTokenLedgerIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - JupiterProgramIx::CreateTokenAccount(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateTokenAccount( - proto_def::CreateTokenAccountIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - JupiterProgramIx::ExactOutRoute(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ExactOutRoute( - proto_def::ExactOutRouteIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - JupiterProgramIx::Route(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Route(proto_def::RouteIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - JupiterProgramIx::RouteWithTokenLedger(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RouteWithTokenLedger( - proto_def::RouteWithTokenLedgerIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - JupiterProgramIx::SetTokenLedger(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetTokenLedger( - proto_def::SetTokenLedgerIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - JupiterProgramIx::SharedAccountsExactOutRoute(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::SharedAccountsExactOutRoute( - proto_def::SharedAccountsExactOutRouteIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - }, - JupiterProgramIx::SharedAccountsRoute(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SharedAccountsRoute( - proto_def::SharedAccountsRouteIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - JupiterProgramIx::SharedAccountsRouteWithTokenLedger(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::SharedAccountsRouteWithTokenLedger( - proto_def::SharedAccountsRouteWithTokenLedgerIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/jupiter-swap-parser/src/generated_parser/mod.rs b/crates/jupiter-swap-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/jupiter-swap-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/jupiter-swap-parser/src/generated_parser/proto_helpers.rs b/crates/jupiter-swap-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index db74d7b5..00000000 --- a/crates/jupiter-swap-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,351 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::FeeEvent}; - impl IntoProto for FeeEvent { - fn into_proto(self) -> proto_def::FeeEvent { - proto_def::FeeEvent { - account: self.account.to_string(), - mint: self.mint.to_string(), - amount: self.amount, - } - } - } - use crate::types::RemainingAccountsInfo; - impl IntoProto for RemainingAccountsInfo { - fn into_proto(self) -> proto_def::RemainingAccountsInfo { - proto_def::RemainingAccountsInfo { - slices: self.slices.into_iter().map(|x| x.into_proto()).collect(), - } - } - } - use crate::types::RemainingAccountsSlice; - impl IntoProto for RemainingAccountsSlice { - fn into_proto(self) -> proto_def::RemainingAccountsSlice { - proto_def::RemainingAccountsSlice { - accounts_type: self.accounts_type as i32, - length: self.length.into(), - } - } - } - use crate::types::RoutePlanStep; - impl IntoProto for RoutePlanStep { - fn into_proto(self) -> proto_def::RoutePlanStep { - proto_def::RoutePlanStep { - swap: Some(self.swap.into_proto()), - percent: self.percent.into(), - input_index: self.input_index.into(), - output_index: self.output_index.into(), - } - } - } - use crate::types::SwapEvent; - impl IntoProto for SwapEvent { - fn into_proto(self) -> proto_def::SwapEvent { - proto_def::SwapEvent { - amm: self.amm.to_string(), - input_mint: self.input_mint.to_string(), - input_amount: self.input_amount, - output_mint: self.output_mint.to_string(), - output_amount: self.output_amount, - } - } - } - - use proto_def::swap; - - use crate::types::Swap; - impl IntoProto for Swap { - fn into_proto(self) -> proto_def::Swap { - let variant = match self { - Swap::Saber => swap::Variant::Saber(proto_def::SwapSaber {}), - Swap::SaberAddDecimalsDeposit => swap::Variant::SaberAddDecimalsDeposit( - proto_def::SwapSaberAddDecimalsDeposit {}, - ), - Swap::SaberAddDecimalsWithdraw => swap::Variant::SaberAddDecimalsWithdraw( - proto_def::SwapSaberAddDecimalsWithdraw {}, - ), - Swap::TokenSwap => swap::Variant::TokenSwap(proto_def::SwapTokenSwap {}), - Swap::Sencha => swap::Variant::Sencha(proto_def::SwapSencha {}), - Swap::Step => swap::Variant::Step(proto_def::SwapStep {}), - Swap::Cropper => swap::Variant::Cropper(proto_def::SwapCropper {}), - Swap::Raydium => swap::Variant::Raydium(proto_def::SwapRaydium {}), - Swap::Crema { a_to_b } => swap::Variant::Crema(proto_def::SwapCrema { a_to_b }), - Swap::Lifinity => swap::Variant::Lifinity(proto_def::SwapLifinity {}), - Swap::Mercurial => swap::Variant::Mercurial(proto_def::SwapMercurial {}), - Swap::Cykura => swap::Variant::Cykura(proto_def::SwapCykura {}), - Swap::Serum { side } => { - swap::Variant::Serum(proto_def::SwapSerum { side: side as i32 }) - }, - Swap::MarinadeDeposit => { - swap::Variant::MarinadeDeposit(proto_def::SwapMarinadeDeposit {}) - }, - Swap::MarinadeUnstake => { - swap::Variant::MarinadeUnstake(proto_def::SwapMarinadeUnstake {}) - }, - Swap::Aldrin { side } => { - swap::Variant::Aldrin(proto_def::SwapAldrin { side: side as i32 }) - }, - Swap::AldrinV2 { side } => { - swap::Variant::AldrinV2(proto_def::SwapAldrinV2 { side: side as i32 }) - }, - Swap::Whirlpool { a_to_b } => { - swap::Variant::Whirlpool(proto_def::SwapWhirlpool { a_to_b }) - }, - Swap::Invariant { x_to_y } => { - swap::Variant::Invariant(proto_def::SwapInvariant { x_to_y }) - }, - Swap::Meteora => swap::Variant::Meteora(proto_def::SwapMeteora {}), - Swap::GooseFX => swap::Variant::GooseFX(proto_def::SwapGooseFx {}), - Swap::DeltaFi { stable } => { - swap::Variant::DeltaFi(proto_def::SwapDeltaFi { stable }) - }, - Swap::Balansol => swap::Variant::Balansol(proto_def::SwapBalansol {}), - Swap::MarcoPolo { x_to_y } => { - swap::Variant::MarcoPolo(proto_def::SwapMarcoPolo { x_to_y }) - }, - Swap::Dradex { side } => { - swap::Variant::Dradex(proto_def::SwapDradex { side: side as i32 }) - }, - Swap::LifinityV2 => swap::Variant::LifinityV2(proto_def::SwapLifinityV2 {}), - Swap::RaydiumClmm => swap::Variant::RaydiumClmm(proto_def::SwapRaydiumClmm {}), - Swap::Openbook { side } => { - swap::Variant::Openbook(proto_def::SwapOpenbook { side: side as i32 }) - }, - Swap::Phoenix { side } => { - swap::Variant::Phoenix(proto_def::SwapPhoenix { side: side as i32 }) - }, - Swap::Symmetry { - from_token_id, - to_token_id, - } => swap::Variant::Symmetry(proto_def::SwapSymmetry { - from_token_id, - to_token_id, - }), - Swap::TokenSwapV2 => swap::Variant::TokenSwapV2(proto_def::SwapTokenSwapV2 {}), - Swap::HeliumTreasuryManagementRedeemV0 => { - swap::Variant::HeliumTreasuryManagementRedeemV0( - proto_def::SwapHeliumTreasuryManagementRedeemV0 {}, - ) - }, - Swap::StakeDexStakeWrappedSol => swap::Variant::StakeDexStakeWrappedSol( - proto_def::SwapStakeDexStakeWrappedSol {}, - ), - Swap::StakeDexSwapViaStake { bridge_stake_seed } => { - swap::Variant::StakeDexSwapViaStake(proto_def::SwapStakeDexSwapViaStake { - bridge_stake_seed, - }) - }, - Swap::GooseFXV2 => swap::Variant::GooseFXV2(proto_def::SwapGooseFxv2 {}), - Swap::Perps => swap::Variant::Perps(proto_def::SwapPerps {}), - Swap::PerpsAddLiquidity => { - swap::Variant::PerpsAddLiquidity(proto_def::SwapPerpsAddLiquidity {}) - }, - Swap::PerpsRemoveLiquidity => { - swap::Variant::PerpsRemoveLiquidity(proto_def::SwapPerpsRemoveLiquidity {}) - }, - Swap::MeteoraDlmm => swap::Variant::MeteoraDlmm(proto_def::SwapMeteoraDlmm {}), - Swap::OpenBookV2 { side } => { - swap::Variant::OpenBookV2(proto_def::SwapOpenBookV2 { side: side as i32 }) - }, - Swap::RaydiumClmmV2 => { - swap::Variant::RaydiumClmmV2(proto_def::SwapRaydiumClmmV2 {}) - }, - Swap::StakeDexPrefundWithdrawStakeAndDepositStake { bridge_stake_seed } => { - swap::Variant::StakeDexPrefundWithdrawStakeAndDepositStake( - proto_def::SwapStakeDexPrefundWithdrawStakeAndDepositStake { - bridge_stake_seed, - }, - ) - }, - Swap::Clone { - pool_index, - quantity_is_input, - quantity_is_collateral, - } => swap::Variant::Clone(proto_def::SwapClone { - pool_index: pool_index.into(), - quantity_is_input, - quantity_is_collateral, - }), - Swap::SanctumS { - src_lst_value_calc_accs, - dst_lst_value_calc_accs, - src_lst_index, - dst_lst_index, - } => swap::Variant::SanctumS(proto_def::SwapSanctumS { - src_lst_value_calc_accs: src_lst_value_calc_accs.into(), - dst_lst_value_calc_accs: dst_lst_value_calc_accs.into(), - src_lst_index, - dst_lst_index, - }), - Swap::SanctumSAddLiquidity { - lst_value_calc_accs, - lst_index, - } => swap::Variant::SanctumSAddLiquidity(proto_def::SwapSanctumSAddLiquidity { - lst_value_calc_accs: lst_value_calc_accs.into(), - lst_index, - }), - Swap::SanctumSRemoveLiquidity { - lst_value_calc_accs, - lst_index, - } => { - swap::Variant::SanctumSRemoveLiquidity(proto_def::SwapSanctumSRemoveLiquidity { - lst_value_calc_accs: lst_value_calc_accs.into(), - lst_index, - }) - }, - Swap::RaydiumCP => swap::Variant::RaydiumCP(proto_def::SwapRaydiumCp {}), - Swap::WhirlpoolSwapV2 { - a_to_b, - remaining_accounts_info, - } => swap::Variant::WhirlpoolSwapV2(proto_def::SwapWhirlpoolSwapV2 { - a_to_b, - remaining_accounts_info: remaining_accounts_info.map(|x| x.into_proto()), - }), - Swap::OneIntro => swap::Variant::OneIntro(proto_def::SwapOneIntro {}), - Swap::PumpdotfunWrappedBuy => { - swap::Variant::PumpdotfunWrappedBuy(proto_def::SwapPumpdotfunWrappedBuy {}) - }, - Swap::PumpdotfunWrappedSell => { - swap::Variant::PumpdotfunWrappedSell(proto_def::SwapPumpdotfunWrappedSell {}) - }, - Swap::PerpsV2 => swap::Variant::PerpsV2(proto_def::SwapPerpsV2 {}), - Swap::PerpsV2AddLiquidity => { - swap::Variant::PerpsV2AddLiquidity(proto_def::SwapPerpsV2AddLiquidity {}) - }, - Swap::PerpsV2RemoveLiquidity => { - swap::Variant::PerpsV2RemoveLiquidity(proto_def::SwapPerpsV2RemoveLiquidity {}) - }, - Swap::MoonshotWrappedBuy => { - swap::Variant::MoonshotWrappedBuy(proto_def::SwapMoonshotWrappedBuy {}) - }, - Swap::MoonshotWrappedSell => { - swap::Variant::MoonshotWrappedSell(proto_def::SwapMoonshotWrappedSell {}) - }, - Swap::StabbleStableSwap => { - swap::Variant::StabbleStableSwap(proto_def::SwapStabbleStableSwap {}) - }, - Swap::StabbleWeightedSwap => { - swap::Variant::StabbleWeightedSwap(proto_def::SwapStabbleWeightedSwap {}) - }, - Swap::Obric { x_to_y } => swap::Variant::Obric(proto_def::SwapObric { x_to_y }), - Swap::FoxBuyFromEstimatedCost => swap::Variant::FoxBuyFromEstimatedCost( - proto_def::SwapFoxBuyFromEstimatedCost {}, - ), - Swap::FoxClaimPartial { is_y } => { - swap::Variant::FoxClaimPartial(proto_def::SwapFoxClaimPartial { is_y }) - }, - Swap::SolFi { is_quote_to_base } => { - swap::Variant::SolFi(proto_def::SwapSolFi { is_quote_to_base }) - }, - Swap::SolayerDelegateNoInit => { - swap::Variant::SolayerDelegateNoInit(proto_def::SwapSolayerDelegateNoInit {}) - }, - Swap::SolayerUndelegateNoInit => swap::Variant::SolayerUndelegateNoInit( - proto_def::SwapSolayerUndelegateNoInit {}, - ), - Swap::TokenMill { side } => { - swap::Variant::TokenMill(proto_def::SwapTokenMill { side: side as i32 }) - }, - Swap::DaosFunBuy => swap::Variant::DaosFunBuy(proto_def::SwapDaosFunBuy {}), - Swap::DaosFunSell => swap::Variant::DaosFunSell(proto_def::SwapDaosFunSell {}), - Swap::ZeroFi => swap::Variant::ZeroFi(proto_def::SwapZeroFi {}), - Swap::StakeDexWithdrawWrappedSol => swap::Variant::StakeDexWithdrawWrappedSol( - proto_def::SwapStakeDexWithdrawWrappedSol {}, - ), - Swap::VirtualsBuy => swap::Variant::VirtualsBuy(proto_def::SwapVirtualsBuy {}), - Swap::VirtualsSell => swap::Variant::VirtualsSell(proto_def::SwapVirtualsSell {}), - Swap::Perena { - in_index, - out_index, - } => swap::Variant::Perena(proto_def::SwapPerena { - in_index: in_index.into(), - out_index: out_index.into(), - }), - Swap::PumpdotfunAmmBuy => { - swap::Variant::PumpdotfunAmmBuy(proto_def::SwapPumpdotfunAmmBuy {}) - }, - Swap::PumpdotfunAmmSell => { - swap::Variant::PumpdotfunAmmSell(proto_def::SwapPumpdotfunAmmSell {}) - }, - Swap::Gamma => swap::Variant::Gamma(proto_def::SwapGamma {}), - Swap::MeteoraDlmmSwapV2 { - remaining_accounts_info, - } => swap::Variant::MeteoraDlmmSwapV2(proto_def::SwapMeteoraDlmmSwapV2 { - remaining_accounts_info: Some(remaining_accounts_info.into_proto()), - }), - Swap::Woofi => swap::Variant::Woofi(proto_def::SwapWoofi {}), - Swap::MeteoraDammV2 => { - swap::Variant::MeteoraDammV2(proto_def::SwapMeteoraDammV2 {}) - }, - Swap::MeteoraDynamicBondingCurveSwap => { - swap::Variant::MeteoraDynamicBondingCurveSwap( - proto_def::SwapMeteoraDynamicBondingCurveSwap {}, - ) - }, - Swap::StabbleStableSwapV2 => { - swap::Variant::StabbleStableSwapV2(proto_def::SwapStabbleStableSwapV2 {}) - }, - Swap::StabbleWeightedSwapV2 => { - swap::Variant::StabbleWeightedSwapV2(proto_def::SwapStabbleWeightedSwapV2 {}) - }, - Swap::RaydiumLaunchlabBuy { share_fee_rate } => { - swap::Variant::RaydiumLaunchlabBuy(proto_def::SwapRaydiumLaunchlabBuy { - share_fee_rate, - }) - }, - Swap::RaydiumLaunchlabSell { share_fee_rate } => { - swap::Variant::RaydiumLaunchlabSell(proto_def::SwapRaydiumLaunchlabSell { - share_fee_rate, - }) - }, - Swap::BoopdotfunWrappedBuy => { - swap::Variant::BoopdotfunWrappedBuy(proto_def::SwapBoopdotfunWrappedBuy {}) - }, - Swap::BoopdotfunWrappedSell => { - swap::Variant::BoopdotfunWrappedSell(proto_def::SwapBoopdotfunWrappedSell {}) - }, - Swap::Plasma { side } => { - swap::Variant::Plasma(proto_def::SwapPlasma { side: side as i32 }) - }, - Swap::GoonFi { - is_bid, - blacklist_bump, - } => swap::Variant::GoonFi(proto_def::SwapGoonFi { - is_bid, - blacklist_bump: blacklist_bump.into(), - }), - Swap::HumidiFi { - swap_id, - is_base_to_quote, - } => swap::Variant::HumidiFi(proto_def::SwapHumidiFi { - swap_id, - is_base_to_quote, - }), - Swap::MeteoraDynamicBondingCurveSwapWithRemainingAccounts => { - swap::Variant::MeteoraDynamicBondingCurveSwapWithRemainingAccounts( - proto_def::SwapMeteoraDynamicBondingCurveSwapWithRemainingAccounts {}, - ) - }, - Swap::TesseraV { side } => { - swap::Variant::TesseraV(proto_def::SwapTesseraV { side: side as i32 }) - }, - Swap::RaydiumStable => { - swap::Variant::RaydiumStable(proto_def::SwapRaydiumStable {}) - }, - }; - - proto_def::Swap { - variant: Some(variant), - } - } - } -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/accounts/mod.rs b/crates/jupiter-swap-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index a39b0e60..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#token_ledger; - -pub use self::r#token_ledger::*; diff --git a/crates/jupiter-swap-parser/src/generated_sdk/accounts/token_ledger.rs b/crates/jupiter-swap-parser/src/generated_sdk/accounts/token_ledger.rs deleted file mode 100644 index ed2f5e88..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/accounts/token_ledger.rs +++ /dev/null @@ -1,133 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenLedger { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_account: Pubkey, - pub amount: u64, -} - -impl TokenLedger { - pub const LEN: usize = 48; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for TokenLedger { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_token_ledger( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_token_ledger(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_token_ledger( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = TokenLedger::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_token_ledger( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_token_ledger(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_token_ledger( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = TokenLedger::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for TokenLedger { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for TokenLedger {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for TokenLedger { - fn owner() -> Pubkey { crate::JUPITER_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for TokenLedger {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for TokenLedger { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/errors/jupiter.rs b/crates/jupiter-swap-parser/src/generated_sdk/errors/jupiter.rs deleted file mode 100644 index 5a087473..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/errors/jupiter.rs +++ /dev/null @@ -1,82 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum JupiterError { - /// 6000 - Empty route - #[error("Empty route")] - EmptyRoute = 0x1770, - /// 6001 - Slippage tolerance exceeded - #[error("Slippage tolerance exceeded")] - SlippageToleranceExceeded = 0x1771, - /// 6002 - Invalid calculation - #[error("Invalid calculation")] - InvalidCalculation = 0x1772, - /// 6003 - Missing platform fee account - #[error("Missing platform fee account")] - MissingPlatformFeeAccount = 0x1773, - /// 6004 - Invalid slippage - #[error("Invalid slippage")] - InvalidSlippage = 0x1774, - /// 6005 - Not enough percent to 100 - #[error("Not enough percent to 100")] - NotEnoughPercent = 0x1775, - /// 6006 - Token input index is invalid - #[error("Token input index is invalid")] - InvalidInputIndex = 0x1776, - /// 6007 - Token output index is invalid - #[error("Token output index is invalid")] - InvalidOutputIndex = 0x1777, - /// 6008 - Not Enough Account keys - #[error("Not Enough Account keys")] - NotEnoughAccountKeys = 0x1778, - /// 6009 - Non zero minimum out amount not supported - #[error("Non zero minimum out amount not supported")] - NonZeroMinimumOutAmountNotSupported = 0x1779, - /// 6010 - Invalid route plan - #[error("Invalid route plan")] - InvalidRoutePlan = 0x177a, - /// 6011 - Invalid referral authority - #[error("Invalid referral authority")] - InvalidReferralAuthority = 0x177b, - /// 6012 - Token account doesn't match the ledger - #[error("Token account doesn't match the ledger")] - LedgerTokenAccountDoesNotMatch = 0x177c, - /// 6013 - Invalid token ledger - #[error("Invalid token ledger")] - InvalidTokenLedger = 0x177d, - /// 6014 - Token program ID is invalid - #[error("Token program ID is invalid")] - IncorrectTokenProgramID = 0x177e, - /// 6015 - Token program not provided - #[error("Token program not provided")] - TokenProgramNotProvided = 0x177f, - /// 6016 - Swap not supported - #[error("Swap not supported")] - SwapNotSupported = 0x1780, - /// 6017 - Exact out amount doesn't match - #[error("Exact out amount doesn't match")] - ExactOutAmountNotMatched = 0x1781, - /// 6018 - Source mint and destination mint cannot the same - #[error("Source mint and destination mint cannot the same")] - SourceAndDestinationMintCannotBeTheSame = 0x1782, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for JupiterError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for JupiterError { - fn type_of() -> &'static str { "JupiterError" } -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/errors/mod.rs b/crates/jupiter-swap-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 72e976ea..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod jupiter; - -pub use self::jupiter::JupiterError; diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/claim.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/claim.rs deleted file mode 100644 index f1d5ab12..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/claim.rs +++ /dev/null @@ -1,403 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Claim { - pub wallet: solana_pubkey::Pubkey, - - pub program_authority: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl Claim { - pub fn instruction(&self, args: ClaimInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.wallet, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.program_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ClaimInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimInstructionData { - discriminator: [u8; 8], -} - -impl ClaimInstructionData { - pub fn new() -> Self { - Self { - discriminator: [62, 198, 214, 193, 213, 159, 108, 210], - } - } -} - -impl Default for ClaimInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimInstructionArgs { - pub id: u8, -} - -/// Instruction builder for `Claim`. -/// -/// ### Accounts: -/// -/// 0. `[writable, optional]` wallet (default to `J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64`) -/// 1. `[writable]` program_authority -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct ClaimBuilder { - wallet: Option, - program_authority: Option, - system_program: Option, - id: Option, - __remaining_accounts: Vec, -} - -impl ClaimBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64']` - #[inline(always)] - pub fn wallet(&mut self, wallet: solana_pubkey::Pubkey) -> &mut Self { - self.wallet = Some(wallet); - self - } - - #[inline(always)] - pub fn program_authority(&mut self, program_authority: solana_pubkey::Pubkey) -> &mut Self { - self.program_authority = Some(program_authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.id = Some(id); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Claim { - wallet: self.wallet.unwrap_or(solana_pubkey::pubkey!( - "J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64" - )), - program_authority: self - .program_authority - .expect("program_authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = ClaimInstructionArgs { - id: self.id.clone().expect("id is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim` CPI accounts. -pub struct ClaimCpiAccounts<'a, 'b> { - pub wallet: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim` CPI instruction. -pub struct ClaimCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub wallet: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimInstructionArgs, -} - -impl<'a, 'b> ClaimCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimCpiAccounts<'a, 'b>, - args: ClaimInstructionArgs, - ) -> Self { - Self { - __program: program, - wallet: accounts.wallet, - program_authority: accounts.program_authority, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.wallet.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.program_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ClaimInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.wallet.clone()); - account_infos.push(self.program_authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Claim` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` wallet -/// 1. `[writable]` program_authority -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct ClaimCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimCpiBuilderInstruction { - __program: program, - wallet: None, - program_authority: None, - system_program: None, - id: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn wallet(&mut self, wallet: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.wallet = Some(wallet); - self - } - - #[inline(always)] - pub fn program_authority( - &mut self, - program_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.instruction.id = Some(id); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ClaimInstructionArgs { - id: self.instruction.id.clone().expect("id is not set"), - }; - let instruction = ClaimCpi { - __program: self.instruction.__program, - - wallet: self.instruction.wallet.expect("wallet is not set"), - - program_authority: self - .instruction - .program_authority - .expect("program_authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - program_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - id: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/claim_token.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/claim_token.rs deleted file mode 100644 index 4978705f..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/claim_token.rs +++ /dev/null @@ -1,658 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimToken { - pub payer: solana_pubkey::Pubkey, - - pub wallet: solana_pubkey::Pubkey, - - pub program_authority: solana_pubkey::Pubkey, - - pub program_token_account: solana_pubkey::Pubkey, - - pub destination_token_account: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl ClaimToken { - pub fn instruction(&self, args: ClaimTokenInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimTokenInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.wallet, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.program_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.destination_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ClaimTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimTokenInstructionData { - discriminator: [u8; 8], -} - -impl ClaimTokenInstructionData { - pub fn new() -> Self { - Self { - discriminator: [116, 206, 27, 191, 166, 19, 0, 73], - } - } -} - -impl Default for ClaimTokenInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimTokenInstructionArgs { - pub id: u8, -} - -/// Instruction builder for `ClaimToken`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[optional]` wallet (default to `J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64`) -/// 2. `[]` program_authority -/// 3. `[writable]` program_token_account -/// 4. `[writable]` destination_token_account -/// 5. `[]` mint -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct ClaimTokenBuilder { - payer: Option, - wallet: Option, - program_authority: Option, - program_token_account: Option, - destination_token_account: Option, - mint: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - id: Option, - __remaining_accounts: Vec, -} - -impl ClaimTokenBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64']` - #[inline(always)] - pub fn wallet(&mut self, wallet: solana_pubkey::Pubkey) -> &mut Self { - self.wallet = Some(wallet); - self - } - - #[inline(always)] - pub fn program_authority(&mut self, program_authority: solana_pubkey::Pubkey) -> &mut Self { - self.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn program_token_account( - &mut self, - program_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.program_token_account = Some(program_token_account); - self - } - - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.destination_token_account = Some(destination_token_account); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.id = Some(id); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimToken { - payer: self.payer.expect("payer is not set"), - wallet: self.wallet.unwrap_or(solana_pubkey::pubkey!( - "J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64" - )), - program_authority: self - .program_authority - .expect("program_authority is not set"), - program_token_account: self - .program_token_account - .expect("program_token_account is not set"), - destination_token_account: self - .destination_token_account - .expect("destination_token_account is not set"), - mint: self.mint.expect("mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = ClaimTokenInstructionArgs { - id: self.id.clone().expect("id is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim_token` CPI accounts. -pub struct ClaimTokenCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub wallet: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_token` CPI instruction. -pub struct ClaimTokenCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub wallet: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimTokenInstructionArgs, -} - -impl<'a, 'b> ClaimTokenCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimTokenCpiAccounts<'a, 'b>, - args: ClaimTokenInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - wallet: accounts.wallet, - program_authority: accounts.program_authority, - program_token_account: accounts.program_token_account, - destination_token_account: accounts.destination_token_account, - mint: accounts.mint, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.wallet.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.program_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.destination_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ClaimTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.wallet.clone()); - account_infos.push(self.program_authority.clone()); - account_infos.push(self.program_token_account.clone()); - account_infos.push(self.destination_token_account.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimToken` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` wallet -/// 2. `[]` program_authority -/// 3. `[writable]` program_token_account -/// 4. `[writable]` destination_token_account -/// 5. `[]` mint -/// 6. `[]` token_program -/// 7. `[]` associated_token_program -/// 8. `[]` system_program -#[derive(Clone, Debug)] -pub struct ClaimTokenCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimTokenCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimTokenCpiBuilderInstruction { - __program: program, - payer: None, - wallet: None, - program_authority: None, - program_token_account: None, - destination_token_account: None, - mint: None, - token_program: None, - associated_token_program: None, - system_program: None, - id: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn wallet(&mut self, wallet: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.wallet = Some(wallet); - self - } - - #[inline(always)] - pub fn program_authority( - &mut self, - program_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn program_token_account( - &mut self, - program_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_token_account = Some(program_token_account); - self - } - - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_token_account = Some(destination_token_account); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.instruction.id = Some(id); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ClaimTokenInstructionArgs { - id: self.instruction.id.clone().expect("id is not set"), - }; - let instruction = ClaimTokenCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - wallet: self.instruction.wallet.expect("wallet is not set"), - - program_authority: self - .instruction - .program_authority - .expect("program_authority is not set"), - - program_token_account: self - .instruction - .program_token_account - .expect("program_token_account is not set"), - - destination_token_account: self - .instruction - .destination_token_account - .expect("destination_token_account is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimTokenCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - program_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - id: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/close_token.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/close_token.rs deleted file mode 100644 index 213bed14..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/close_token.rs +++ /dev/null @@ -1,538 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CloseToken { - pub operator: solana_pubkey::Pubkey, - - pub wallet: solana_pubkey::Pubkey, - - pub program_authority: solana_pubkey::Pubkey, - - pub program_token_account: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl CloseToken { - pub fn instruction(&self, args: CloseTokenInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CloseTokenInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.wallet, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.program_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CloseTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseTokenInstructionData { - discriminator: [u8; 8], -} - -impl CloseTokenInstructionData { - pub fn new() -> Self { - Self { - discriminator: [26, 74, 236, 151, 104, 64, 183, 249], - } - } -} - -impl Default for CloseTokenInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseTokenInstructionArgs { - pub id: u8, - pub burn_all: bool, -} - -/// Instruction builder for `CloseToken`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` operator -/// 1. `[writable, optional]` wallet (default to `J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64`) -/// 2. `[]` program_authority -/// 3. `[writable]` program_token_account -/// 4. `[writable]` mint -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct CloseTokenBuilder { - operator: Option, - wallet: Option, - program_authority: Option, - program_token_account: Option, - mint: Option, - token_program: Option, - id: Option, - burn_all: Option, - __remaining_accounts: Vec, -} - -impl CloseTokenBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - /// `[optional account, default to 'J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64']` - #[inline(always)] - pub fn wallet(&mut self, wallet: solana_pubkey::Pubkey) -> &mut Self { - self.wallet = Some(wallet); - self - } - - #[inline(always)] - pub fn program_authority(&mut self, program_authority: solana_pubkey::Pubkey) -> &mut Self { - self.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn program_token_account( - &mut self, - program_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.program_token_account = Some(program_token_account); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.id = Some(id); - self - } - - #[inline(always)] - pub fn burn_all(&mut self, burn_all: bool) -> &mut Self { - self.burn_all = Some(burn_all); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CloseToken { - operator: self.operator.expect("operator is not set"), - wallet: self.wallet.unwrap_or(solana_pubkey::pubkey!( - "J434EKW6KDmnJHxVty1axHT6kjszKKFEyesKqxdQ7y64" - )), - program_authority: self - .program_authority - .expect("program_authority is not set"), - program_token_account: self - .program_token_account - .expect("program_token_account is not set"), - mint: self.mint.expect("mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = CloseTokenInstructionArgs { - id: self.id.clone().expect("id is not set"), - burn_all: self.burn_all.clone().expect("burn_all is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `close_token` CPI accounts. -pub struct CloseTokenCpiAccounts<'a, 'b> { - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub wallet: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_token` CPI instruction. -pub struct CloseTokenCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub wallet: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CloseTokenInstructionArgs, -} - -impl<'a, 'b> CloseTokenCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CloseTokenCpiAccounts<'a, 'b>, - args: CloseTokenInstructionArgs, - ) -> Self { - Self { - __program: program, - operator: accounts.operator, - wallet: accounts.wallet, - program_authority: accounts.program_authority, - program_token_account: accounts.program_token_account, - mint: accounts.mint, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.wallet.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.program_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.mint.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CloseTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.wallet.clone()); - account_infos.push(self.program_authority.clone()); - account_infos.push(self.program_token_account.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CloseToken` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` operator -/// 1. `[writable]` wallet -/// 2. `[]` program_authority -/// 3. `[writable]` program_token_account -/// 4. `[writable]` mint -/// 5. `[]` token_program -#[derive(Clone, Debug)] -pub struct CloseTokenCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CloseTokenCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CloseTokenCpiBuilderInstruction { - __program: program, - operator: None, - wallet: None, - program_authority: None, - program_token_account: None, - mint: None, - token_program: None, - id: None, - burn_all: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn wallet(&mut self, wallet: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.wallet = Some(wallet); - self - } - - #[inline(always)] - pub fn program_authority( - &mut self, - program_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn program_token_account( - &mut self, - program_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_token_account = Some(program_token_account); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.instruction.id = Some(id); - self - } - - #[inline(always)] - pub fn burn_all(&mut self, burn_all: bool) -> &mut Self { - self.instruction.burn_all = Some(burn_all); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CloseTokenInstructionArgs { - id: self.instruction.id.clone().expect("id is not set"), - burn_all: self - .instruction - .burn_all - .clone() - .expect("burn_all is not set"), - }; - let instruction = CloseTokenCpi { - __program: self.instruction.__program, - - operator: self.instruction.operator.expect("operator is not set"), - - wallet: self.instruction.wallet.expect("wallet is not set"), - - program_authority: self - .instruction - .program_authority - .expect("program_authority is not set"), - - program_token_account: self - .instruction - .program_token_account - .expect("program_token_account is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CloseTokenCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - program_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - id: Option, - burn_all: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_open_orders.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_open_orders.rs deleted file mode 100644 index 00219688..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_open_orders.rs +++ /dev/null @@ -1,474 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateOpenOrders { - pub open_orders: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub dex_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub market: solana_pubkey::Pubkey, -} - -impl CreateOpenOrders { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.dex_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.market, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateOpenOrdersInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateOpenOrdersInstructionData { - discriminator: [u8; 8], -} - -impl CreateOpenOrdersInstructionData { - pub fn new() -> Self { - Self { - discriminator: [229, 194, 212, 172, 8, 10, 134, 147], - } - } -} - -impl Default for CreateOpenOrdersInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateOpenOrders`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` open_orders -/// 1. `[writable, signer]` payer -/// 2. `[]` dex_program -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 4. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 5. `[]` market -#[derive(Clone, Debug, Default)] -pub struct CreateOpenOrdersBuilder { - open_orders: Option, - payer: Option, - dex_program: Option, - system_program: Option, - rent: Option, - market: Option, - __remaining_accounts: Vec, -} - -impl CreateOpenOrdersBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn open_orders(&mut self, open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.open_orders = Some(open_orders); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn dex_program(&mut self, dex_program: solana_pubkey::Pubkey) -> &mut Self { - self.dex_program = Some(dex_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn market(&mut self, market: solana_pubkey::Pubkey) -> &mut Self { - self.market = Some(market); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateOpenOrders { - open_orders: self.open_orders.expect("open_orders is not set"), - payer: self.payer.expect("payer is not set"), - dex_program: self.dex_program.expect("dex_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - market: self.market.expect("market is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_open_orders` CPI accounts. -pub struct CreateOpenOrdersCpiAccounts<'a, 'b> { - pub open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub dex_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub market: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_open_orders` CPI instruction. -pub struct CreateOpenOrdersCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub dex_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub market: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateOpenOrdersCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateOpenOrdersCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - open_orders: accounts.open_orders, - payer: accounts.payer, - dex_program: accounts.dex_program, - system_program: accounts.system_program, - rent: accounts.rent, - market: accounts.market, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.dex_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.market.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateOpenOrdersInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.open_orders.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.dex_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.market.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateOpenOrders` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` open_orders -/// 1. `[writable, signer]` payer -/// 2. `[]` dex_program -/// 3. `[]` system_program -/// 4. `[]` rent -/// 5. `[]` market -#[derive(Clone, Debug)] -pub struct CreateOpenOrdersCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateOpenOrdersCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateOpenOrdersCpiBuilderInstruction { - __program: program, - open_orders: None, - payer: None, - dex_program: None, - system_program: None, - rent: None, - market: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn open_orders( - &mut self, - open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.open_orders = Some(open_orders); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn dex_program( - &mut self, - dex_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.dex_program = Some(dex_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn market(&mut self, market: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.market = Some(market); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateOpenOrdersCpi { - __program: self.instruction.__program, - - open_orders: self - .instruction - .open_orders - .expect("open_orders is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - dex_program: self - .instruction - .dex_program - .expect("dex_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - market: self.instruction.market.expect("market is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateOpenOrdersCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - dex_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - market: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_program_open_orders.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_program_open_orders.rs deleted file mode 100644 index 49ff1d34..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_program_open_orders.rs +++ /dev/null @@ -1,558 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateProgramOpenOrders { - pub open_orders: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub program_authority: solana_pubkey::Pubkey, - - pub dex_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub market: solana_pubkey::Pubkey, -} - -impl CreateProgramOpenOrders { - pub fn instruction( - &self, - args: CreateProgramOpenOrdersInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateProgramOpenOrdersInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.dex_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.market, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateProgramOpenOrdersInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateProgramOpenOrdersInstructionData { - discriminator: [u8; 8], -} - -impl CreateProgramOpenOrdersInstructionData { - pub fn new() -> Self { - Self { - discriminator: [28, 226, 32, 148, 188, 136, 113, 171], - } - } -} - -impl Default for CreateProgramOpenOrdersInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateProgramOpenOrdersInstructionArgs { - pub id: u8, -} - -/// Instruction builder for `CreateProgramOpenOrders`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` open_orders -/// 1. `[writable, signer]` payer -/// 2. `[]` program_authority -/// 3. `[]` dex_program -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 5. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 6. `[]` market -#[derive(Clone, Debug, Default)] -pub struct CreateProgramOpenOrdersBuilder { - open_orders: Option, - payer: Option, - program_authority: Option, - dex_program: Option, - system_program: Option, - rent: Option, - market: Option, - id: Option, - __remaining_accounts: Vec, -} - -impl CreateProgramOpenOrdersBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn open_orders(&mut self, open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.open_orders = Some(open_orders); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn program_authority(&mut self, program_authority: solana_pubkey::Pubkey) -> &mut Self { - self.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn dex_program(&mut self, dex_program: solana_pubkey::Pubkey) -> &mut Self { - self.dex_program = Some(dex_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn market(&mut self, market: solana_pubkey::Pubkey) -> &mut Self { - self.market = Some(market); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.id = Some(id); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateProgramOpenOrders { - open_orders: self.open_orders.expect("open_orders is not set"), - payer: self.payer.expect("payer is not set"), - program_authority: self - .program_authority - .expect("program_authority is not set"), - dex_program: self.dex_program.expect("dex_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - market: self.market.expect("market is not set"), - }; - let args = CreateProgramOpenOrdersInstructionArgs { - id: self.id.clone().expect("id is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_program_open_orders` CPI accounts. -pub struct CreateProgramOpenOrdersCpiAccounts<'a, 'b> { - pub open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub dex_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub market: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_program_open_orders` CPI instruction. -pub struct CreateProgramOpenOrdersCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub dex_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub market: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateProgramOpenOrdersInstructionArgs, -} - -impl<'a, 'b> CreateProgramOpenOrdersCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateProgramOpenOrdersCpiAccounts<'a, 'b>, - args: CreateProgramOpenOrdersInstructionArgs, - ) -> Self { - Self { - __program: program, - open_orders: accounts.open_orders, - payer: accounts.payer, - program_authority: accounts.program_authority, - dex_program: accounts.dex_program, - system_program: accounts.system_program, - rent: accounts.rent, - market: accounts.market, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.dex_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.market.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateProgramOpenOrdersInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.open_orders.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.program_authority.clone()); - account_infos.push(self.dex_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.market.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateProgramOpenOrders` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` open_orders -/// 1. `[writable, signer]` payer -/// 2. `[]` program_authority -/// 3. `[]` dex_program -/// 4. `[]` system_program -/// 5. `[]` rent -/// 6. `[]` market -#[derive(Clone, Debug)] -pub struct CreateProgramOpenOrdersCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateProgramOpenOrdersCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateProgramOpenOrdersCpiBuilderInstruction { - __program: program, - open_orders: None, - payer: None, - program_authority: None, - dex_program: None, - system_program: None, - rent: None, - market: None, - id: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn open_orders( - &mut self, - open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.open_orders = Some(open_orders); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn program_authority( - &mut self, - program_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn dex_program( - &mut self, - dex_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.dex_program = Some(dex_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn market(&mut self, market: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.market = Some(market); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.instruction.id = Some(id); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateProgramOpenOrdersInstructionArgs { - id: self.instruction.id.clone().expect("id is not set"), - }; - let instruction = CreateProgramOpenOrdersCpi { - __program: self.instruction.__program, - - open_orders: self - .instruction - .open_orders - .expect("open_orders is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - program_authority: self - .instruction - .program_authority - .expect("program_authority is not set"), - - dex_program: self - .instruction - .dex_program - .expect("dex_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - market: self.instruction.market.expect("market is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateProgramOpenOrdersCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - program_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - dex_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - market: Option<&'b solana_account_info::AccountInfo<'a>>, - id: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_token_account.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_token_account.rs deleted file mode 100644 index 535b9fd7..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_token_account.rs +++ /dev/null @@ -1,478 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateTokenAccount { - pub token_account: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateTokenAccount { - pub fn instruction( - &self, - args: CreateTokenAccountInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateTokenAccountInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.user, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateTokenAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateTokenAccountInstructionData { - discriminator: [u8; 8], -} - -impl CreateTokenAccountInstructionData { - pub fn new() -> Self { - Self { - discriminator: [147, 241, 123, 100, 244, 132, 174, 118], - } - } -} - -impl Default for CreateTokenAccountInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateTokenAccountInstructionArgs { - pub bump: u8, -} - -/// Instruction builder for `CreateTokenAccount`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` token_account -/// 1. `[writable, signer]` user -/// 2. `[]` mint -/// 3. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateTokenAccountBuilder { - token_account: Option, - user: Option, - mint: Option, - token_program: Option, - system_program: Option, - bump: Option, - __remaining_accounts: Vec, -} - -impl CreateTokenAccountBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn token_account(&mut self, token_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_account = Some(token_account); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn bump(&mut self, bump: u8) -> &mut Self { - self.bump = Some(bump); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateTokenAccount { - token_account: self.token_account.expect("token_account is not set"), - user: self.user.expect("user is not set"), - mint: self.mint.expect("mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = CreateTokenAccountInstructionArgs { - bump: self.bump.clone().expect("bump is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_token_account` CPI accounts. -pub struct CreateTokenAccountCpiAccounts<'a, 'b> { - pub token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_token_account` CPI instruction. -pub struct CreateTokenAccountCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateTokenAccountInstructionArgs, -} - -impl<'a, 'b> CreateTokenAccountCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateTokenAccountCpiAccounts<'a, 'b>, - args: CreateTokenAccountInstructionArgs, - ) -> Self { - Self { - __program: program, - token_account: accounts.token_account, - user: accounts.user, - mint: accounts.mint, - token_program: accounts.token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.user.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateTokenAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_account.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateTokenAccount` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` token_account -/// 1. `[writable, signer]` user -/// 2. `[]` mint -/// 3. `[]` token_program -/// 4. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateTokenAccountCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateTokenAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateTokenAccountCpiBuilderInstruction { - __program: program, - token_account: None, - user: None, - mint: None, - token_program: None, - system_program: None, - bump: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_account( - &mut self, - token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account = Some(token_account); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn bump(&mut self, bump: u8) -> &mut Self { - self.instruction.bump = Some(bump); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateTokenAccountInstructionArgs { - bump: self.instruction.bump.clone().expect("bump is not set"), - }; - let instruction = CreateTokenAccountCpi { - __program: self.instruction.__program, - - token_account: self - .instruction - .token_account - .expect("token_account is not set"), - - user: self.instruction.user.expect("user is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateTokenAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - bump: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_token_ledger.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_token_ledger.rs deleted file mode 100644 index cbe34264..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/create_token_ledger.rs +++ /dev/null @@ -1,358 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateTokenLedger { - pub token_ledger: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateTokenLedger { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.token_ledger, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateTokenLedgerInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateTokenLedgerInstructionData { - discriminator: [u8; 8], -} - -impl CreateTokenLedgerInstructionData { - pub fn new() -> Self { - Self { - discriminator: [232, 242, 197, 253, 240, 143, 129, 52], - } - } -} - -impl Default for CreateTokenLedgerInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateTokenLedger`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` token_ledger -/// 1. `[writable, signer]` payer -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateTokenLedgerBuilder { - token_ledger: Option, - payer: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl CreateTokenLedgerBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn token_ledger(&mut self, token_ledger: solana_pubkey::Pubkey) -> &mut Self { - self.token_ledger = Some(token_ledger); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateTokenLedger { - token_ledger: self.token_ledger.expect("token_ledger is not set"), - payer: self.payer.expect("payer is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_token_ledger` CPI accounts. -pub struct CreateTokenLedgerCpiAccounts<'a, 'b> { - pub token_ledger: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_token_ledger` CPI instruction. -pub struct CreateTokenLedgerCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_ledger: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateTokenLedgerCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateTokenLedgerCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - token_ledger: accounts.token_ledger, - payer: accounts.payer, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_ledger.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateTokenLedgerInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_ledger.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateTokenLedger` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` token_ledger -/// 1. `[writable, signer]` payer -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateTokenLedgerCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateTokenLedgerCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateTokenLedgerCpiBuilderInstruction { - __program: program, - token_ledger: None, - payer: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_ledger( - &mut self, - token_ledger: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_ledger = Some(token_ledger); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateTokenLedgerCpi { - __program: self.instruction.__program, - - token_ledger: self - .instruction - .token_ledger - .expect("token_ledger is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateTokenLedgerCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_ledger: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/exact_out_route.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/exact_out_route.rs deleted file mode 100644 index 357d4441..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/exact_out_route.rs +++ /dev/null @@ -1,912 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RoutePlanStep; - -/// Accounts. -#[derive(Debug)] -pub struct ExactOutRoute { - pub token_program: solana_pubkey::Pubkey, - - pub user_transfer_authority: solana_pubkey::Pubkey, - - pub user_source_token_account: solana_pubkey::Pubkey, - - pub user_destination_token_account: solana_pubkey::Pubkey, - - pub destination_token_account: Option, - - pub source_mint: solana_pubkey::Pubkey, - - pub destination_mint: solana_pubkey::Pubkey, - - pub platform_fee_account: Option, - - pub token2022_program: Option, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ExactOutRoute { - pub fn instruction( - &self, - args: ExactOutRouteInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ExactOutRouteInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_transfer_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_destination_token_account, - false, - )); - if let Some(destination_token_account) = self.destination_token_account { - accounts.push(solana_instruction::AccountMeta::new( - destination_token_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.source_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.destination_mint, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - platform_fee_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - if let Some(token2022_program) = self.token2022_program { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token2022_program, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ExactOutRouteInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ExactOutRouteInstructionData { - discriminator: [u8; 8], -} - -impl ExactOutRouteInstructionData { - pub fn new() -> Self { - Self { - discriminator: [208, 51, 239, 151, 123, 43, 237, 92], - } - } -} - -impl Default for ExactOutRouteInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ExactOutRouteInstructionArgs { - pub route_plan: Vec, - pub out_amount: u64, - pub quoted_in_amount: u64, - pub slippage_bps: u16, - pub platform_fee_bps: u8, -} - -/// Instruction builder for `ExactOutRoute`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[signer]` user_transfer_authority -/// 2. `[writable]` user_source_token_account -/// 3. `[writable]` user_destination_token_account -/// 4. `[writable, optional]` destination_token_account -/// 5. `[]` source_mint -/// 6. `[]` destination_mint -/// 7. `[writable, optional]` platform_fee_account -/// 8. `[optional]` token2022_program -/// 9. `[optional]` event_authority (default to `D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf`) -/// 10. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ExactOutRouteBuilder { - token_program: Option, - user_transfer_authority: Option, - user_source_token_account: Option, - user_destination_token_account: Option, - destination_token_account: Option, - source_mint: Option, - destination_mint: Option, - platform_fee_account: Option, - token2022_program: Option, - event_authority: Option, - program: Option, - route_plan: Option>, - out_amount: Option, - quoted_in_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - __remaining_accounts: Vec, -} - -impl ExactOutRouteBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn user_source_token_account( - &mut self, - user_source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_source_token_account = Some(user_source_token_account); - self - } - - #[inline(always)] - pub fn user_destination_token_account( - &mut self, - user_destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_destination_token_account = Some(user_destination_token_account); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: Option, - ) -> &mut Self { - self.destination_token_account = destination_token_account; - self - } - - #[inline(always)] - pub fn source_mint(&mut self, source_mint: solana_pubkey::Pubkey) -> &mut Self { - self.source_mint = Some(source_mint); - self - } - - #[inline(always)] - pub fn destination_mint(&mut self, destination_mint: solana_pubkey::Pubkey) -> &mut Self { - self.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option, - ) -> &mut Self { - self.platform_fee_account = platform_fee_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: Option, - ) -> &mut Self { - self.token2022_program = token2022_program; - self - } - - /// `[optional account, default to 'D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf']` - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn out_amount(&mut self, out_amount: u64) -> &mut Self { - self.out_amount = Some(out_amount); - self - } - - #[inline(always)] - pub fn quoted_in_amount(&mut self, quoted_in_amount: u64) -> &mut Self { - self.quoted_in_amount = Some(quoted_in_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ExactOutRoute { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - user_transfer_authority: self - .user_transfer_authority - .expect("user_transfer_authority is not set"), - user_source_token_account: self - .user_source_token_account - .expect("user_source_token_account is not set"), - user_destination_token_account: self - .user_destination_token_account - .expect("user_destination_token_account is not set"), - destination_token_account: self.destination_token_account, - source_mint: self.source_mint.expect("source_mint is not set"), - destination_mint: self.destination_mint.expect("destination_mint is not set"), - platform_fee_account: self.platform_fee_account, - token2022_program: self.token2022_program, - event_authority: self.event_authority.unwrap_or(solana_pubkey::pubkey!( - "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - )), - program: self.program.expect("program is not set"), - }; - let args = ExactOutRouteInstructionArgs { - route_plan: self.route_plan.clone().expect("route_plan is not set"), - out_amount: self.out_amount.clone().expect("out_amount is not set"), - quoted_in_amount: self - .quoted_in_amount - .clone() - .expect("quoted_in_amount is not set"), - slippage_bps: self.slippage_bps.clone().expect("slippage_bps is not set"), - platform_fee_bps: self - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `exact_out_route` CPI accounts. -pub struct ExactOutRouteCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub source_mint: &'b solana_account_info::AccountInfo<'a>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `exact_out_route` CPI instruction. -pub struct ExactOutRouteCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub source_mint: &'b solana_account_info::AccountInfo<'a>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ExactOutRouteInstructionArgs, -} - -impl<'a, 'b> ExactOutRouteCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ExactOutRouteCpiAccounts<'a, 'b>, - args: ExactOutRouteInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - user_transfer_authority: accounts.user_transfer_authority, - user_source_token_account: accounts.user_source_token_account, - user_destination_token_account: accounts.user_destination_token_account, - destination_token_account: accounts.destination_token_account, - source_mint: accounts.source_mint, - destination_mint: accounts.destination_mint, - platform_fee_account: accounts.platform_fee_account, - token2022_program: accounts.token2022_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_transfer_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_destination_token_account.key, - false, - )); - if let Some(destination_token_account) = self.destination_token_account { - accounts.push(solana_instruction::AccountMeta::new( - *destination_token_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.source_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.destination_mint.key, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - *platform_fee_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - if let Some(token2022_program) = self.token2022_program { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token2022_program.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ExactOutRouteInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.user_transfer_authority.clone()); - account_infos.push(self.user_source_token_account.clone()); - account_infos.push(self.user_destination_token_account.clone()); - if let Some(destination_token_account) = self.destination_token_account { - account_infos.push(destination_token_account.clone()); - } - account_infos.push(self.source_mint.clone()); - account_infos.push(self.destination_mint.clone()); - if let Some(platform_fee_account) = self.platform_fee_account { - account_infos.push(platform_fee_account.clone()); - } - if let Some(token2022_program) = self.token2022_program { - account_infos.push(token2022_program.clone()); - } - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ExactOutRoute` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[signer]` user_transfer_authority -/// 2. `[writable]` user_source_token_account -/// 3. `[writable]` user_destination_token_account -/// 4. `[writable, optional]` destination_token_account -/// 5. `[]` source_mint -/// 6. `[]` destination_mint -/// 7. `[writable, optional]` platform_fee_account -/// 8. `[optional]` token2022_program -/// 9. `[]` event_authority -/// 10. `[]` program -#[derive(Clone, Debug)] -pub struct ExactOutRouteCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ExactOutRouteCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ExactOutRouteCpiBuilderInstruction { - __program: program, - token_program: None, - user_transfer_authority: None, - user_source_token_account: None, - user_destination_token_account: None, - destination_token_account: None, - source_mint: None, - destination_mint: None, - platform_fee_account: None, - token2022_program: None, - event_authority: None, - program: None, - route_plan: None, - out_amount: None, - quoted_in_amount: None, - slippage_bps: None, - platform_fee_bps: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn user_source_token_account( - &mut self, - user_source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_source_token_account = Some(user_source_token_account); - self - } - - #[inline(always)] - pub fn user_destination_token_account( - &mut self, - user_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_destination_token_account = Some(user_destination_token_account); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.destination_token_account = destination_token_account; - self - } - - #[inline(always)] - pub fn source_mint( - &mut self, - source_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_mint = Some(source_mint); - self - } - - #[inline(always)] - pub fn destination_mint( - &mut self, - destination_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.platform_fee_account = platform_fee_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token2022_program = token2022_program; - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.instruction.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn out_amount(&mut self, out_amount: u64) -> &mut Self { - self.instruction.out_amount = Some(out_amount); - self - } - - #[inline(always)] - pub fn quoted_in_amount(&mut self, quoted_in_amount: u64) -> &mut Self { - self.instruction.quoted_in_amount = Some(quoted_in_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.instruction.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.instruction.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ExactOutRouteInstructionArgs { - route_plan: self - .instruction - .route_plan - .clone() - .expect("route_plan is not set"), - out_amount: self - .instruction - .out_amount - .clone() - .expect("out_amount is not set"), - quoted_in_amount: self - .instruction - .quoted_in_amount - .clone() - .expect("quoted_in_amount is not set"), - slippage_bps: self - .instruction - .slippage_bps - .clone() - .expect("slippage_bps is not set"), - platform_fee_bps: self - .instruction - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - let instruction = ExactOutRouteCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - user_transfer_authority: self - .instruction - .user_transfer_authority - .expect("user_transfer_authority is not set"), - - user_source_token_account: self - .instruction - .user_source_token_account - .expect("user_source_token_account is not set"), - - user_destination_token_account: self - .instruction - .user_destination_token_account - .expect("user_destination_token_account is not set"), - - destination_token_account: self.instruction.destination_token_account, - - source_mint: self - .instruction - .source_mint - .expect("source_mint is not set"), - - destination_mint: self - .instruction - .destination_mint - .expect("destination_mint is not set"), - - platform_fee_account: self.instruction.platform_fee_account, - - token2022_program: self.instruction.token2022_program, - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ExactOutRouteCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - user_transfer_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - user_source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - source_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - route_plan: Option>, - out_amount: Option, - quoted_in_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/mod.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index b502513a..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#claim; -pub(crate) mod r#claim_token; -pub(crate) mod r#close_token; -pub(crate) mod r#create_open_orders; -pub(crate) mod r#create_program_open_orders; -pub(crate) mod r#create_token_account; -pub(crate) mod r#create_token_ledger; -pub(crate) mod r#exact_out_route; -pub(crate) mod r#route; -pub(crate) mod r#route_with_token_ledger; -pub(crate) mod r#set_token_ledger; -pub(crate) mod r#shared_accounts_exact_out_route; -pub(crate) mod r#shared_accounts_route; -pub(crate) mod r#shared_accounts_route_with_token_ledger; - -pub use self::{ - r#claim::*, r#claim_token::*, r#close_token::*, r#create_open_orders::*, - r#create_program_open_orders::*, r#create_token_account::*, r#create_token_ledger::*, - r#exact_out_route::*, r#route::*, r#route_with_token_ledger::*, r#set_token_ledger::*, - r#shared_accounts_exact_out_route::*, r#shared_accounts_route::*, - r#shared_accounts_route_with_token_ledger::*, -}; diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/route.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/route.rs deleted file mode 100644 index cccff2db..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/route.rs +++ /dev/null @@ -1,807 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RoutePlanStep; - -/// Accounts. -#[derive(Debug)] -pub struct Route { - pub token_program: solana_pubkey::Pubkey, - - pub user_transfer_authority: solana_pubkey::Pubkey, - - pub user_source_token_account: solana_pubkey::Pubkey, - - pub user_destination_token_account: solana_pubkey::Pubkey, - - pub destination_token_account: Option, - - pub destination_mint: solana_pubkey::Pubkey, - - pub platform_fee_account: Option, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Route { - pub fn instruction(&self, args: RouteInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RouteInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_transfer_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_destination_token_account, - false, - )); - if let Some(destination_token_account) = self.destination_token_account { - accounts.push(solana_instruction::AccountMeta::new( - destination_token_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.destination_mint, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - platform_fee_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RouteInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RouteInstructionData { - discriminator: [u8; 8], -} - -impl RouteInstructionData { - pub fn new() -> Self { - Self { - discriminator: [229, 23, 203, 151, 122, 227, 173, 42], - } - } -} - -impl Default for RouteInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RouteInstructionArgs { - pub route_plan: Vec, - pub in_amount: u64, - pub quoted_out_amount: u64, - pub slippage_bps: u16, - pub platform_fee_bps: u8, -} - -/// Instruction builder for `Route`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[signer]` user_transfer_authority -/// 2. `[writable]` user_source_token_account -/// 3. `[writable]` user_destination_token_account -/// 4. `[writable, optional]` destination_token_account -/// 5. `[]` destination_mint -/// 6. `[writable, optional]` platform_fee_account -/// 7. `[optional]` event_authority (default to `D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf`) -/// 8. `[]` program -#[derive(Clone, Debug, Default)] -pub struct RouteBuilder { - token_program: Option, - user_transfer_authority: Option, - user_source_token_account: Option, - user_destination_token_account: Option, - destination_token_account: Option, - destination_mint: Option, - platform_fee_account: Option, - event_authority: Option, - program: Option, - route_plan: Option>, - in_amount: Option, - quoted_out_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - __remaining_accounts: Vec, -} - -impl RouteBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn user_source_token_account( - &mut self, - user_source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_source_token_account = Some(user_source_token_account); - self - } - - #[inline(always)] - pub fn user_destination_token_account( - &mut self, - user_destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_destination_token_account = Some(user_destination_token_account); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: Option, - ) -> &mut Self { - self.destination_token_account = destination_token_account; - self - } - - #[inline(always)] - pub fn destination_mint(&mut self, destination_mint: solana_pubkey::Pubkey) -> &mut Self { - self.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option, - ) -> &mut Self { - self.platform_fee_account = platform_fee_account; - self - } - - /// `[optional account, default to 'D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf']` - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn in_amount(&mut self, in_amount: u64) -> &mut Self { - self.in_amount = Some(in_amount); - self - } - - #[inline(always)] - pub fn quoted_out_amount(&mut self, quoted_out_amount: u64) -> &mut Self { - self.quoted_out_amount = Some(quoted_out_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Route { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - user_transfer_authority: self - .user_transfer_authority - .expect("user_transfer_authority is not set"), - user_source_token_account: self - .user_source_token_account - .expect("user_source_token_account is not set"), - user_destination_token_account: self - .user_destination_token_account - .expect("user_destination_token_account is not set"), - destination_token_account: self.destination_token_account, - destination_mint: self.destination_mint.expect("destination_mint is not set"), - platform_fee_account: self.platform_fee_account, - event_authority: self.event_authority.unwrap_or(solana_pubkey::pubkey!( - "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - )), - program: self.program.expect("program is not set"), - }; - let args = RouteInstructionArgs { - route_plan: self.route_plan.clone().expect("route_plan is not set"), - in_amount: self.in_amount.clone().expect("in_amount is not set"), - quoted_out_amount: self - .quoted_out_amount - .clone() - .expect("quoted_out_amount is not set"), - slippage_bps: self.slippage_bps.clone().expect("slippage_bps is not set"), - platform_fee_bps: self - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `route` CPI accounts. -pub struct RouteCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `route` CPI instruction. -pub struct RouteCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RouteInstructionArgs, -} - -impl<'a, 'b> RouteCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RouteCpiAccounts<'a, 'b>, - args: RouteInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - user_transfer_authority: accounts.user_transfer_authority, - user_source_token_account: accounts.user_source_token_account, - user_destination_token_account: accounts.user_destination_token_account, - destination_token_account: accounts.destination_token_account, - destination_mint: accounts.destination_mint, - platform_fee_account: accounts.platform_fee_account, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_transfer_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_destination_token_account.key, - false, - )); - if let Some(destination_token_account) = self.destination_token_account { - accounts.push(solana_instruction::AccountMeta::new( - *destination_token_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.destination_mint.key, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - *platform_fee_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RouteInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.user_transfer_authority.clone()); - account_infos.push(self.user_source_token_account.clone()); - account_infos.push(self.user_destination_token_account.clone()); - if let Some(destination_token_account) = self.destination_token_account { - account_infos.push(destination_token_account.clone()); - } - account_infos.push(self.destination_mint.clone()); - if let Some(platform_fee_account) = self.platform_fee_account { - account_infos.push(platform_fee_account.clone()); - } - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Route` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[signer]` user_transfer_authority -/// 2. `[writable]` user_source_token_account -/// 3. `[writable]` user_destination_token_account -/// 4. `[writable, optional]` destination_token_account -/// 5. `[]` destination_mint -/// 6. `[writable, optional]` platform_fee_account -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug)] -pub struct RouteCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RouteCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RouteCpiBuilderInstruction { - __program: program, - token_program: None, - user_transfer_authority: None, - user_source_token_account: None, - user_destination_token_account: None, - destination_token_account: None, - destination_mint: None, - platform_fee_account: None, - event_authority: None, - program: None, - route_plan: None, - in_amount: None, - quoted_out_amount: None, - slippage_bps: None, - platform_fee_bps: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn user_source_token_account( - &mut self, - user_source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_source_token_account = Some(user_source_token_account); - self - } - - #[inline(always)] - pub fn user_destination_token_account( - &mut self, - user_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_destination_token_account = Some(user_destination_token_account); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.destination_token_account = destination_token_account; - self - } - - #[inline(always)] - pub fn destination_mint( - &mut self, - destination_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.platform_fee_account = platform_fee_account; - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.instruction.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn in_amount(&mut self, in_amount: u64) -> &mut Self { - self.instruction.in_amount = Some(in_amount); - self - } - - #[inline(always)] - pub fn quoted_out_amount(&mut self, quoted_out_amount: u64) -> &mut Self { - self.instruction.quoted_out_amount = Some(quoted_out_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.instruction.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.instruction.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RouteInstructionArgs { - route_plan: self - .instruction - .route_plan - .clone() - .expect("route_plan is not set"), - in_amount: self - .instruction - .in_amount - .clone() - .expect("in_amount is not set"), - quoted_out_amount: self - .instruction - .quoted_out_amount - .clone() - .expect("quoted_out_amount is not set"), - slippage_bps: self - .instruction - .slippage_bps - .clone() - .expect("slippage_bps is not set"), - platform_fee_bps: self - .instruction - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - let instruction = RouteCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - user_transfer_authority: self - .instruction - .user_transfer_authority - .expect("user_transfer_authority is not set"), - - user_source_token_account: self - .instruction - .user_source_token_account - .expect("user_source_token_account is not set"), - - user_destination_token_account: self - .instruction - .user_destination_token_account - .expect("user_destination_token_account is not set"), - - destination_token_account: self.instruction.destination_token_account, - - destination_mint: self - .instruction - .destination_mint - .expect("destination_mint is not set"), - - platform_fee_account: self.instruction.platform_fee_account, - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RouteCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - user_transfer_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - user_source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - route_plan: Option>, - in_amount: Option, - quoted_out_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/route_with_token_ledger.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/route_with_token_ledger.rs deleted file mode 100644 index 056246e0..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/route_with_token_ledger.rs +++ /dev/null @@ -1,830 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RoutePlanStep; - -/// Accounts. -#[derive(Debug)] -pub struct RouteWithTokenLedger { - pub token_program: solana_pubkey::Pubkey, - - pub user_transfer_authority: solana_pubkey::Pubkey, - - pub user_source_token_account: solana_pubkey::Pubkey, - - pub user_destination_token_account: solana_pubkey::Pubkey, - - pub destination_token_account: Option, - - pub destination_mint: solana_pubkey::Pubkey, - - pub platform_fee_account: Option, - - pub token_ledger: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl RouteWithTokenLedger { - pub fn instruction( - &self, - args: RouteWithTokenLedgerInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RouteWithTokenLedgerInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_transfer_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_destination_token_account, - false, - )); - if let Some(destination_token_account) = self.destination_token_account { - accounts.push(solana_instruction::AccountMeta::new( - destination_token_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.destination_mint, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - platform_fee_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_ledger, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RouteWithTokenLedgerInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RouteWithTokenLedgerInstructionData { - discriminator: [u8; 8], -} - -impl RouteWithTokenLedgerInstructionData { - pub fn new() -> Self { - Self { - discriminator: [150, 86, 71, 116, 167, 93, 14, 104], - } - } -} - -impl Default for RouteWithTokenLedgerInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RouteWithTokenLedgerInstructionArgs { - pub route_plan: Vec, - pub quoted_out_amount: u64, - pub slippage_bps: u16, - pub platform_fee_bps: u8, -} - -/// Instruction builder for `RouteWithTokenLedger`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[signer]` user_transfer_authority -/// 2. `[writable]` user_source_token_account -/// 3. `[writable]` user_destination_token_account -/// 4. `[writable, optional]` destination_token_account -/// 5. `[]` destination_mint -/// 6. `[writable, optional]` platform_fee_account -/// 7. `[]` token_ledger -/// 8. `[optional]` event_authority (default to `D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf`) -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct RouteWithTokenLedgerBuilder { - token_program: Option, - user_transfer_authority: Option, - user_source_token_account: Option, - user_destination_token_account: Option, - destination_token_account: Option, - destination_mint: Option, - platform_fee_account: Option, - token_ledger: Option, - event_authority: Option, - program: Option, - route_plan: Option>, - quoted_out_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - __remaining_accounts: Vec, -} - -impl RouteWithTokenLedgerBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn user_source_token_account( - &mut self, - user_source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_source_token_account = Some(user_source_token_account); - self - } - - #[inline(always)] - pub fn user_destination_token_account( - &mut self, - user_destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_destination_token_account = Some(user_destination_token_account); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: Option, - ) -> &mut Self { - self.destination_token_account = destination_token_account; - self - } - - #[inline(always)] - pub fn destination_mint(&mut self, destination_mint: solana_pubkey::Pubkey) -> &mut Self { - self.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option, - ) -> &mut Self { - self.platform_fee_account = platform_fee_account; - self - } - - #[inline(always)] - pub fn token_ledger(&mut self, token_ledger: solana_pubkey::Pubkey) -> &mut Self { - self.token_ledger = Some(token_ledger); - self - } - - /// `[optional account, default to 'D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf']` - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn quoted_out_amount(&mut self, quoted_out_amount: u64) -> &mut Self { - self.quoted_out_amount = Some(quoted_out_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RouteWithTokenLedger { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - user_transfer_authority: self - .user_transfer_authority - .expect("user_transfer_authority is not set"), - user_source_token_account: self - .user_source_token_account - .expect("user_source_token_account is not set"), - user_destination_token_account: self - .user_destination_token_account - .expect("user_destination_token_account is not set"), - destination_token_account: self.destination_token_account, - destination_mint: self.destination_mint.expect("destination_mint is not set"), - platform_fee_account: self.platform_fee_account, - token_ledger: self.token_ledger.expect("token_ledger is not set"), - event_authority: self.event_authority.unwrap_or(solana_pubkey::pubkey!( - "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - )), - program: self.program.expect("program is not set"), - }; - let args = RouteWithTokenLedgerInstructionArgs { - route_plan: self.route_plan.clone().expect("route_plan is not set"), - quoted_out_amount: self - .quoted_out_amount - .clone() - .expect("quoted_out_amount is not set"), - slippage_bps: self.slippage_bps.clone().expect("slippage_bps is not set"), - platform_fee_bps: self - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `route_with_token_ledger` CPI accounts. -pub struct RouteWithTokenLedgerCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_ledger: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `route_with_token_ledger` CPI instruction. -pub struct RouteWithTokenLedgerCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_ledger: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RouteWithTokenLedgerInstructionArgs, -} - -impl<'a, 'b> RouteWithTokenLedgerCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RouteWithTokenLedgerCpiAccounts<'a, 'b>, - args: RouteWithTokenLedgerInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - user_transfer_authority: accounts.user_transfer_authority, - user_source_token_account: accounts.user_source_token_account, - user_destination_token_account: accounts.user_destination_token_account, - destination_token_account: accounts.destination_token_account, - destination_mint: accounts.destination_mint, - platform_fee_account: accounts.platform_fee_account, - token_ledger: accounts.token_ledger, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_transfer_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_destination_token_account.key, - false, - )); - if let Some(destination_token_account) = self.destination_token_account { - accounts.push(solana_instruction::AccountMeta::new( - *destination_token_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.destination_mint.key, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - *platform_fee_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_ledger.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RouteWithTokenLedgerInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.user_transfer_authority.clone()); - account_infos.push(self.user_source_token_account.clone()); - account_infos.push(self.user_destination_token_account.clone()); - if let Some(destination_token_account) = self.destination_token_account { - account_infos.push(destination_token_account.clone()); - } - account_infos.push(self.destination_mint.clone()); - if let Some(platform_fee_account) = self.platform_fee_account { - account_infos.push(platform_fee_account.clone()); - } - account_infos.push(self.token_ledger.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RouteWithTokenLedger` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[signer]` user_transfer_authority -/// 2. `[writable]` user_source_token_account -/// 3. `[writable]` user_destination_token_account -/// 4. `[writable, optional]` destination_token_account -/// 5. `[]` destination_mint -/// 6. `[writable, optional]` platform_fee_account -/// 7. `[]` token_ledger -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct RouteWithTokenLedgerCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RouteWithTokenLedgerCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RouteWithTokenLedgerCpiBuilderInstruction { - __program: program, - token_program: None, - user_transfer_authority: None, - user_source_token_account: None, - user_destination_token_account: None, - destination_token_account: None, - destination_mint: None, - platform_fee_account: None, - token_ledger: None, - event_authority: None, - program: None, - route_plan: None, - quoted_out_amount: None, - slippage_bps: None, - platform_fee_bps: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn user_source_token_account( - &mut self, - user_source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_source_token_account = Some(user_source_token_account); - self - } - - #[inline(always)] - pub fn user_destination_token_account( - &mut self, - user_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_destination_token_account = Some(user_destination_token_account); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.destination_token_account = destination_token_account; - self - } - - #[inline(always)] - pub fn destination_mint( - &mut self, - destination_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.platform_fee_account = platform_fee_account; - self - } - - #[inline(always)] - pub fn token_ledger( - &mut self, - token_ledger: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_ledger = Some(token_ledger); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.instruction.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn quoted_out_amount(&mut self, quoted_out_amount: u64) -> &mut Self { - self.instruction.quoted_out_amount = Some(quoted_out_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.instruction.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.instruction.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RouteWithTokenLedgerInstructionArgs { - route_plan: self - .instruction - .route_plan - .clone() - .expect("route_plan is not set"), - quoted_out_amount: self - .instruction - .quoted_out_amount - .clone() - .expect("quoted_out_amount is not set"), - slippage_bps: self - .instruction - .slippage_bps - .clone() - .expect("slippage_bps is not set"), - platform_fee_bps: self - .instruction - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - let instruction = RouteWithTokenLedgerCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - user_transfer_authority: self - .instruction - .user_transfer_authority - .expect("user_transfer_authority is not set"), - - user_source_token_account: self - .instruction - .user_source_token_account - .expect("user_source_token_account is not set"), - - user_destination_token_account: self - .instruction - .user_destination_token_account - .expect("user_destination_token_account is not set"), - - destination_token_account: self.instruction.destination_token_account, - - destination_mint: self - .instruction - .destination_mint - .expect("destination_mint is not set"), - - platform_fee_account: self.instruction.platform_fee_account, - - token_ledger: self - .instruction - .token_ledger - .expect("token_ledger is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RouteWithTokenLedgerCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - user_transfer_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - user_source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_ledger: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - route_plan: Option>, - quoted_out_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/set_token_ledger.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/set_token_ledger.rs deleted file mode 100644 index c4ace07a..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/set_token_ledger.rs +++ /dev/null @@ -1,325 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetTokenLedger { - pub token_ledger: solana_pubkey::Pubkey, - - pub token_account: solana_pubkey::Pubkey, -} - -impl SetTokenLedger { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.token_ledger, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_account, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetTokenLedgerInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetTokenLedgerInstructionData { - discriminator: [u8; 8], -} - -impl SetTokenLedgerInstructionData { - pub fn new() -> Self { - Self { - discriminator: [228, 85, 185, 112, 78, 79, 77, 2], - } - } -} - -impl Default for SetTokenLedgerInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetTokenLedger`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` token_ledger -/// 1. `[]` token_account -#[derive(Clone, Debug, Default)] -pub struct SetTokenLedgerBuilder { - token_ledger: Option, - token_account: Option, - __remaining_accounts: Vec, -} - -impl SetTokenLedgerBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn token_ledger(&mut self, token_ledger: solana_pubkey::Pubkey) -> &mut Self { - self.token_ledger = Some(token_ledger); - self - } - - #[inline(always)] - pub fn token_account(&mut self, token_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_account = Some(token_account); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetTokenLedger { - token_ledger: self.token_ledger.expect("token_ledger is not set"), - token_account: self.token_account.expect("token_account is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_token_ledger` CPI accounts. -pub struct SetTokenLedgerCpiAccounts<'a, 'b> { - pub token_ledger: &'b solana_account_info::AccountInfo<'a>, - - pub token_account: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_token_ledger` CPI instruction. -pub struct SetTokenLedgerCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_ledger: &'b solana_account_info::AccountInfo<'a>, - - pub token_account: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetTokenLedgerCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetTokenLedgerCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - token_ledger: accounts.token_ledger, - token_account: accounts.token_account, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_ledger.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_account.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetTokenLedgerInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_ledger.clone()); - account_infos.push(self.token_account.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetTokenLedger` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` token_ledger -/// 1. `[]` token_account -#[derive(Clone, Debug)] -pub struct SetTokenLedgerCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetTokenLedgerCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetTokenLedgerCpiBuilderInstruction { - __program: program, - token_ledger: None, - token_account: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_ledger( - &mut self, - token_ledger: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_ledger = Some(token_ledger); - self - } - - #[inline(always)] - pub fn token_account( - &mut self, - token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account = Some(token_account); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetTokenLedgerCpi { - __program: self.instruction.__program, - - token_ledger: self - .instruction - .token_ledger - .expect("token_ledger is not set"), - - token_account: self - .instruction - .token_account - .expect("token_account is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetTokenLedgerCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_ledger: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/shared_accounts_exact_out_route.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/shared_accounts_exact_out_route.rs deleted file mode 100644 index 5b2f14bf..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/shared_accounts_exact_out_route.rs +++ /dev/null @@ -1,1009 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RoutePlanStep; - -/// Accounts. -#[derive(Debug)] -pub struct SharedAccountsExactOutRoute { - pub token_program: solana_pubkey::Pubkey, - - pub program_authority: solana_pubkey::Pubkey, - - pub user_transfer_authority: solana_pubkey::Pubkey, - - pub source_token_account: solana_pubkey::Pubkey, - - pub program_source_token_account: solana_pubkey::Pubkey, - - pub program_destination_token_account: solana_pubkey::Pubkey, - - pub destination_token_account: solana_pubkey::Pubkey, - - pub source_mint: solana_pubkey::Pubkey, - - pub destination_mint: solana_pubkey::Pubkey, - - pub platform_fee_account: Option, - - pub token2022_program: Option, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SharedAccountsExactOutRoute { - pub fn instruction( - &self, - args: SharedAccountsExactOutRouteInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SharedAccountsExactOutRouteInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_transfer_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.program_source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.program_destination_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.destination_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.source_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.destination_mint, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - platform_fee_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - if let Some(token2022_program) = self.token2022_program { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token2022_program, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SharedAccountsExactOutRouteInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SharedAccountsExactOutRouteInstructionData { - discriminator: [u8; 8], -} - -impl SharedAccountsExactOutRouteInstructionData { - pub fn new() -> Self { - Self { - discriminator: [176, 209, 105, 168, 154, 125, 69, 62], - } - } -} - -impl Default for SharedAccountsExactOutRouteInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SharedAccountsExactOutRouteInstructionArgs { - pub id: u8, - pub route_plan: Vec, - pub out_amount: u64, - pub quoted_in_amount: u64, - pub slippage_bps: u16, - pub platform_fee_bps: u8, -} - -/// Instruction builder for `SharedAccountsExactOutRoute`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[]` program_authority -/// 2. `[signer]` user_transfer_authority -/// 3. `[writable]` source_token_account -/// 4. `[writable]` program_source_token_account -/// 5. `[writable]` program_destination_token_account -/// 6. `[writable]` destination_token_account -/// 7. `[]` source_mint -/// 8. `[]` destination_mint -/// 9. `[writable, optional]` platform_fee_account -/// 10. `[optional]` token2022_program -/// 11. `[optional]` event_authority (default to `D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf`) -/// 12. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SharedAccountsExactOutRouteBuilder { - token_program: Option, - program_authority: Option, - user_transfer_authority: Option, - source_token_account: Option, - program_source_token_account: Option, - program_destination_token_account: Option, - destination_token_account: Option, - source_mint: Option, - destination_mint: Option, - platform_fee_account: Option, - token2022_program: Option, - event_authority: Option, - program: Option, - id: Option, - route_plan: Option>, - out_amount: Option, - quoted_in_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - __remaining_accounts: Vec, -} - -impl SharedAccountsExactOutRouteBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn program_authority(&mut self, program_authority: solana_pubkey::Pubkey) -> &mut Self { - self.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn source_token_account( - &mut self, - source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.source_token_account = Some(source_token_account); - self - } - - #[inline(always)] - pub fn program_source_token_account( - &mut self, - program_source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.program_source_token_account = Some(program_source_token_account); - self - } - - #[inline(always)] - pub fn program_destination_token_account( - &mut self, - program_destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.program_destination_token_account = Some(program_destination_token_account); - self - } - - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.destination_token_account = Some(destination_token_account); - self - } - - #[inline(always)] - pub fn source_mint(&mut self, source_mint: solana_pubkey::Pubkey) -> &mut Self { - self.source_mint = Some(source_mint); - self - } - - #[inline(always)] - pub fn destination_mint(&mut self, destination_mint: solana_pubkey::Pubkey) -> &mut Self { - self.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option, - ) -> &mut Self { - self.platform_fee_account = platform_fee_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: Option, - ) -> &mut Self { - self.token2022_program = token2022_program; - self - } - - /// `[optional account, default to 'D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf']` - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.id = Some(id); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn out_amount(&mut self, out_amount: u64) -> &mut Self { - self.out_amount = Some(out_amount); - self - } - - #[inline(always)] - pub fn quoted_in_amount(&mut self, quoted_in_amount: u64) -> &mut Self { - self.quoted_in_amount = Some(quoted_in_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SharedAccountsExactOutRoute { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - program_authority: self - .program_authority - .expect("program_authority is not set"), - user_transfer_authority: self - .user_transfer_authority - .expect("user_transfer_authority is not set"), - source_token_account: self - .source_token_account - .expect("source_token_account is not set"), - program_source_token_account: self - .program_source_token_account - .expect("program_source_token_account is not set"), - program_destination_token_account: self - .program_destination_token_account - .expect("program_destination_token_account is not set"), - destination_token_account: self - .destination_token_account - .expect("destination_token_account is not set"), - source_mint: self.source_mint.expect("source_mint is not set"), - destination_mint: self.destination_mint.expect("destination_mint is not set"), - platform_fee_account: self.platform_fee_account, - token2022_program: self.token2022_program, - event_authority: self.event_authority.unwrap_or(solana_pubkey::pubkey!( - "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - )), - program: self.program.expect("program is not set"), - }; - let args = SharedAccountsExactOutRouteInstructionArgs { - id: self.id.clone().expect("id is not set"), - route_plan: self.route_plan.clone().expect("route_plan is not set"), - out_amount: self.out_amount.clone().expect("out_amount is not set"), - quoted_in_amount: self - .quoted_in_amount - .clone() - .expect("quoted_in_amount is not set"), - slippage_bps: self.slippage_bps.clone().expect("slippage_bps is not set"), - platform_fee_bps: self - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `shared_accounts_exact_out_route` CPI accounts. -pub struct SharedAccountsExactOutRouteCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub source_mint: &'b solana_account_info::AccountInfo<'a>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `shared_accounts_exact_out_route` CPI instruction. -pub struct SharedAccountsExactOutRouteCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub source_mint: &'b solana_account_info::AccountInfo<'a>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SharedAccountsExactOutRouteInstructionArgs, -} - -impl<'a, 'b> SharedAccountsExactOutRouteCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SharedAccountsExactOutRouteCpiAccounts<'a, 'b>, - args: SharedAccountsExactOutRouteInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - program_authority: accounts.program_authority, - user_transfer_authority: accounts.user_transfer_authority, - source_token_account: accounts.source_token_account, - program_source_token_account: accounts.program_source_token_account, - program_destination_token_account: accounts.program_destination_token_account, - destination_token_account: accounts.destination_token_account, - source_mint: accounts.source_mint, - destination_mint: accounts.destination_mint, - platform_fee_account: accounts.platform_fee_account, - token2022_program: accounts.token2022_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_transfer_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.program_source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.program_destination_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.destination_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.source_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.destination_mint.key, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - *platform_fee_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - if let Some(token2022_program) = self.token2022_program { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token2022_program.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SharedAccountsExactOutRouteInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.program_authority.clone()); - account_infos.push(self.user_transfer_authority.clone()); - account_infos.push(self.source_token_account.clone()); - account_infos.push(self.program_source_token_account.clone()); - account_infos.push(self.program_destination_token_account.clone()); - account_infos.push(self.destination_token_account.clone()); - account_infos.push(self.source_mint.clone()); - account_infos.push(self.destination_mint.clone()); - if let Some(platform_fee_account) = self.platform_fee_account { - account_infos.push(platform_fee_account.clone()); - } - if let Some(token2022_program) = self.token2022_program { - account_infos.push(token2022_program.clone()); - } - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SharedAccountsExactOutRoute` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[]` program_authority -/// 2. `[signer]` user_transfer_authority -/// 3. `[writable]` source_token_account -/// 4. `[writable]` program_source_token_account -/// 5. `[writable]` program_destination_token_account -/// 6. `[writable]` destination_token_account -/// 7. `[]` source_mint -/// 8. `[]` destination_mint -/// 9. `[writable, optional]` platform_fee_account -/// 10. `[optional]` token2022_program -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug)] -pub struct SharedAccountsExactOutRouteCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SharedAccountsExactOutRouteCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SharedAccountsExactOutRouteCpiBuilderInstruction { - __program: program, - token_program: None, - program_authority: None, - user_transfer_authority: None, - source_token_account: None, - program_source_token_account: None, - program_destination_token_account: None, - destination_token_account: None, - source_mint: None, - destination_mint: None, - platform_fee_account: None, - token2022_program: None, - event_authority: None, - program: None, - id: None, - route_plan: None, - out_amount: None, - quoted_in_amount: None, - slippage_bps: None, - platform_fee_bps: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn program_authority( - &mut self, - program_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn source_token_account( - &mut self, - source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_token_account = Some(source_token_account); - self - } - - #[inline(always)] - pub fn program_source_token_account( - &mut self, - program_source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_source_token_account = Some(program_source_token_account); - self - } - - #[inline(always)] - pub fn program_destination_token_account( - &mut self, - program_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_destination_token_account = - Some(program_destination_token_account); - self - } - - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_token_account = Some(destination_token_account); - self - } - - #[inline(always)] - pub fn source_mint( - &mut self, - source_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_mint = Some(source_mint); - self - } - - #[inline(always)] - pub fn destination_mint( - &mut self, - destination_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.platform_fee_account = platform_fee_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token2022_program = token2022_program; - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.instruction.id = Some(id); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.instruction.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn out_amount(&mut self, out_amount: u64) -> &mut Self { - self.instruction.out_amount = Some(out_amount); - self - } - - #[inline(always)] - pub fn quoted_in_amount(&mut self, quoted_in_amount: u64) -> &mut Self { - self.instruction.quoted_in_amount = Some(quoted_in_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.instruction.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.instruction.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SharedAccountsExactOutRouteInstructionArgs { - id: self.instruction.id.clone().expect("id is not set"), - route_plan: self - .instruction - .route_plan - .clone() - .expect("route_plan is not set"), - out_amount: self - .instruction - .out_amount - .clone() - .expect("out_amount is not set"), - quoted_in_amount: self - .instruction - .quoted_in_amount - .clone() - .expect("quoted_in_amount is not set"), - slippage_bps: self - .instruction - .slippage_bps - .clone() - .expect("slippage_bps is not set"), - platform_fee_bps: self - .instruction - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - let instruction = SharedAccountsExactOutRouteCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - program_authority: self - .instruction - .program_authority - .expect("program_authority is not set"), - - user_transfer_authority: self - .instruction - .user_transfer_authority - .expect("user_transfer_authority is not set"), - - source_token_account: self - .instruction - .source_token_account - .expect("source_token_account is not set"), - - program_source_token_account: self - .instruction - .program_source_token_account - .expect("program_source_token_account is not set"), - - program_destination_token_account: self - .instruction - .program_destination_token_account - .expect("program_destination_token_account is not set"), - - destination_token_account: self - .instruction - .destination_token_account - .expect("destination_token_account is not set"), - - source_mint: self - .instruction - .source_mint - .expect("source_mint is not set"), - - destination_mint: self - .instruction - .destination_mint - .expect("destination_mint is not set"), - - platform_fee_account: self.instruction.platform_fee_account, - - token2022_program: self.instruction.token2022_program, - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SharedAccountsExactOutRouteCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - program_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - user_transfer_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - program_source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - program_destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - source_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - id: Option, - route_plan: Option>, - out_amount: Option, - quoted_in_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/shared_accounts_route.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/shared_accounts_route.rs deleted file mode 100644 index b0fecdf9..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/shared_accounts_route.rs +++ /dev/null @@ -1,1009 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RoutePlanStep; - -/// Accounts. -#[derive(Debug)] -pub struct SharedAccountsRoute { - pub token_program: solana_pubkey::Pubkey, - - pub program_authority: solana_pubkey::Pubkey, - - pub user_transfer_authority: solana_pubkey::Pubkey, - - pub source_token_account: solana_pubkey::Pubkey, - - pub program_source_token_account: solana_pubkey::Pubkey, - - pub program_destination_token_account: solana_pubkey::Pubkey, - - pub destination_token_account: solana_pubkey::Pubkey, - - pub source_mint: solana_pubkey::Pubkey, - - pub destination_mint: solana_pubkey::Pubkey, - - pub platform_fee_account: Option, - - pub token2022_program: Option, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SharedAccountsRoute { - pub fn instruction( - &self, - args: SharedAccountsRouteInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SharedAccountsRouteInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_transfer_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.program_source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.program_destination_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.destination_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.source_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.destination_mint, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - platform_fee_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - if let Some(token2022_program) = self.token2022_program { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token2022_program, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SharedAccountsRouteInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SharedAccountsRouteInstructionData { - discriminator: [u8; 8], -} - -impl SharedAccountsRouteInstructionData { - pub fn new() -> Self { - Self { - discriminator: [193, 32, 155, 51, 65, 214, 156, 129], - } - } -} - -impl Default for SharedAccountsRouteInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SharedAccountsRouteInstructionArgs { - pub id: u8, - pub route_plan: Vec, - pub in_amount: u64, - pub quoted_out_amount: u64, - pub slippage_bps: u16, - pub platform_fee_bps: u8, -} - -/// Instruction builder for `SharedAccountsRoute`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[]` program_authority -/// 2. `[signer]` user_transfer_authority -/// 3. `[writable]` source_token_account -/// 4. `[writable]` program_source_token_account -/// 5. `[writable]` program_destination_token_account -/// 6. `[writable]` destination_token_account -/// 7. `[]` source_mint -/// 8. `[]` destination_mint -/// 9. `[writable, optional]` platform_fee_account -/// 10. `[optional]` token2022_program -/// 11. `[optional]` event_authority (default to `D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf`) -/// 12. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SharedAccountsRouteBuilder { - token_program: Option, - program_authority: Option, - user_transfer_authority: Option, - source_token_account: Option, - program_source_token_account: Option, - program_destination_token_account: Option, - destination_token_account: Option, - source_mint: Option, - destination_mint: Option, - platform_fee_account: Option, - token2022_program: Option, - event_authority: Option, - program: Option, - id: Option, - route_plan: Option>, - in_amount: Option, - quoted_out_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - __remaining_accounts: Vec, -} - -impl SharedAccountsRouteBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn program_authority(&mut self, program_authority: solana_pubkey::Pubkey) -> &mut Self { - self.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn source_token_account( - &mut self, - source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.source_token_account = Some(source_token_account); - self - } - - #[inline(always)] - pub fn program_source_token_account( - &mut self, - program_source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.program_source_token_account = Some(program_source_token_account); - self - } - - #[inline(always)] - pub fn program_destination_token_account( - &mut self, - program_destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.program_destination_token_account = Some(program_destination_token_account); - self - } - - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.destination_token_account = Some(destination_token_account); - self - } - - #[inline(always)] - pub fn source_mint(&mut self, source_mint: solana_pubkey::Pubkey) -> &mut Self { - self.source_mint = Some(source_mint); - self - } - - #[inline(always)] - pub fn destination_mint(&mut self, destination_mint: solana_pubkey::Pubkey) -> &mut Self { - self.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option, - ) -> &mut Self { - self.platform_fee_account = platform_fee_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: Option, - ) -> &mut Self { - self.token2022_program = token2022_program; - self - } - - /// `[optional account, default to 'D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf']` - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.id = Some(id); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn in_amount(&mut self, in_amount: u64) -> &mut Self { - self.in_amount = Some(in_amount); - self - } - - #[inline(always)] - pub fn quoted_out_amount(&mut self, quoted_out_amount: u64) -> &mut Self { - self.quoted_out_amount = Some(quoted_out_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SharedAccountsRoute { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - program_authority: self - .program_authority - .expect("program_authority is not set"), - user_transfer_authority: self - .user_transfer_authority - .expect("user_transfer_authority is not set"), - source_token_account: self - .source_token_account - .expect("source_token_account is not set"), - program_source_token_account: self - .program_source_token_account - .expect("program_source_token_account is not set"), - program_destination_token_account: self - .program_destination_token_account - .expect("program_destination_token_account is not set"), - destination_token_account: self - .destination_token_account - .expect("destination_token_account is not set"), - source_mint: self.source_mint.expect("source_mint is not set"), - destination_mint: self.destination_mint.expect("destination_mint is not set"), - platform_fee_account: self.platform_fee_account, - token2022_program: self.token2022_program, - event_authority: self.event_authority.unwrap_or(solana_pubkey::pubkey!( - "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - )), - program: self.program.expect("program is not set"), - }; - let args = SharedAccountsRouteInstructionArgs { - id: self.id.clone().expect("id is not set"), - route_plan: self.route_plan.clone().expect("route_plan is not set"), - in_amount: self.in_amount.clone().expect("in_amount is not set"), - quoted_out_amount: self - .quoted_out_amount - .clone() - .expect("quoted_out_amount is not set"), - slippage_bps: self.slippage_bps.clone().expect("slippage_bps is not set"), - platform_fee_bps: self - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `shared_accounts_route` CPI accounts. -pub struct SharedAccountsRouteCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub source_mint: &'b solana_account_info::AccountInfo<'a>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `shared_accounts_route` CPI instruction. -pub struct SharedAccountsRouteCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub source_mint: &'b solana_account_info::AccountInfo<'a>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SharedAccountsRouteInstructionArgs, -} - -impl<'a, 'b> SharedAccountsRouteCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SharedAccountsRouteCpiAccounts<'a, 'b>, - args: SharedAccountsRouteInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - program_authority: accounts.program_authority, - user_transfer_authority: accounts.user_transfer_authority, - source_token_account: accounts.source_token_account, - program_source_token_account: accounts.program_source_token_account, - program_destination_token_account: accounts.program_destination_token_account, - destination_token_account: accounts.destination_token_account, - source_mint: accounts.source_mint, - destination_mint: accounts.destination_mint, - platform_fee_account: accounts.platform_fee_account, - token2022_program: accounts.token2022_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_transfer_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.program_source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.program_destination_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.destination_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.source_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.destination_mint.key, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - *platform_fee_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - if let Some(token2022_program) = self.token2022_program { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token2022_program.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SharedAccountsRouteInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.program_authority.clone()); - account_infos.push(self.user_transfer_authority.clone()); - account_infos.push(self.source_token_account.clone()); - account_infos.push(self.program_source_token_account.clone()); - account_infos.push(self.program_destination_token_account.clone()); - account_infos.push(self.destination_token_account.clone()); - account_infos.push(self.source_mint.clone()); - account_infos.push(self.destination_mint.clone()); - if let Some(platform_fee_account) = self.platform_fee_account { - account_infos.push(platform_fee_account.clone()); - } - if let Some(token2022_program) = self.token2022_program { - account_infos.push(token2022_program.clone()); - } - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SharedAccountsRoute` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[]` program_authority -/// 2. `[signer]` user_transfer_authority -/// 3. `[writable]` source_token_account -/// 4. `[writable]` program_source_token_account -/// 5. `[writable]` program_destination_token_account -/// 6. `[writable]` destination_token_account -/// 7. `[]` source_mint -/// 8. `[]` destination_mint -/// 9. `[writable, optional]` platform_fee_account -/// 10. `[optional]` token2022_program -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug)] -pub struct SharedAccountsRouteCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SharedAccountsRouteCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SharedAccountsRouteCpiBuilderInstruction { - __program: program, - token_program: None, - program_authority: None, - user_transfer_authority: None, - source_token_account: None, - program_source_token_account: None, - program_destination_token_account: None, - destination_token_account: None, - source_mint: None, - destination_mint: None, - platform_fee_account: None, - token2022_program: None, - event_authority: None, - program: None, - id: None, - route_plan: None, - in_amount: None, - quoted_out_amount: None, - slippage_bps: None, - platform_fee_bps: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn program_authority( - &mut self, - program_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn source_token_account( - &mut self, - source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_token_account = Some(source_token_account); - self - } - - #[inline(always)] - pub fn program_source_token_account( - &mut self, - program_source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_source_token_account = Some(program_source_token_account); - self - } - - #[inline(always)] - pub fn program_destination_token_account( - &mut self, - program_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_destination_token_account = - Some(program_destination_token_account); - self - } - - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_token_account = Some(destination_token_account); - self - } - - #[inline(always)] - pub fn source_mint( - &mut self, - source_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_mint = Some(source_mint); - self - } - - #[inline(always)] - pub fn destination_mint( - &mut self, - destination_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.platform_fee_account = platform_fee_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token2022_program = token2022_program; - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.instruction.id = Some(id); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.instruction.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn in_amount(&mut self, in_amount: u64) -> &mut Self { - self.instruction.in_amount = Some(in_amount); - self - } - - #[inline(always)] - pub fn quoted_out_amount(&mut self, quoted_out_amount: u64) -> &mut Self { - self.instruction.quoted_out_amount = Some(quoted_out_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.instruction.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.instruction.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SharedAccountsRouteInstructionArgs { - id: self.instruction.id.clone().expect("id is not set"), - route_plan: self - .instruction - .route_plan - .clone() - .expect("route_plan is not set"), - in_amount: self - .instruction - .in_amount - .clone() - .expect("in_amount is not set"), - quoted_out_amount: self - .instruction - .quoted_out_amount - .clone() - .expect("quoted_out_amount is not set"), - slippage_bps: self - .instruction - .slippage_bps - .clone() - .expect("slippage_bps is not set"), - platform_fee_bps: self - .instruction - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - let instruction = SharedAccountsRouteCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - program_authority: self - .instruction - .program_authority - .expect("program_authority is not set"), - - user_transfer_authority: self - .instruction - .user_transfer_authority - .expect("user_transfer_authority is not set"), - - source_token_account: self - .instruction - .source_token_account - .expect("source_token_account is not set"), - - program_source_token_account: self - .instruction - .program_source_token_account - .expect("program_source_token_account is not set"), - - program_destination_token_account: self - .instruction - .program_destination_token_account - .expect("program_destination_token_account is not set"), - - destination_token_account: self - .instruction - .destination_token_account - .expect("destination_token_account is not set"), - - source_mint: self - .instruction - .source_mint - .expect("source_mint is not set"), - - destination_mint: self - .instruction - .destination_mint - .expect("destination_mint is not set"), - - platform_fee_account: self.instruction.platform_fee_account, - - token2022_program: self.instruction.token2022_program, - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SharedAccountsRouteCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - program_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - user_transfer_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - program_source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - program_destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - source_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - id: Option, - route_plan: Option>, - in_amount: Option, - quoted_out_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/instructions/shared_accounts_route_with_token_ledger.rs b/crates/jupiter-swap-parser/src/generated_sdk/instructions/shared_accounts_route_with_token_ledger.rs deleted file mode 100644 index 671141fa..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/instructions/shared_accounts_route_with_token_ledger.rs +++ /dev/null @@ -1,1031 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RoutePlanStep; - -/// Accounts. -#[derive(Debug)] -pub struct SharedAccountsRouteWithTokenLedger { - pub token_program: solana_pubkey::Pubkey, - - pub program_authority: solana_pubkey::Pubkey, - - pub user_transfer_authority: solana_pubkey::Pubkey, - - pub source_token_account: solana_pubkey::Pubkey, - - pub program_source_token_account: solana_pubkey::Pubkey, - - pub program_destination_token_account: solana_pubkey::Pubkey, - - pub destination_token_account: solana_pubkey::Pubkey, - - pub source_mint: solana_pubkey::Pubkey, - - pub destination_mint: solana_pubkey::Pubkey, - - pub platform_fee_account: Option, - - pub token2022_program: Option, - - pub token_ledger: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SharedAccountsRouteWithTokenLedger { - pub fn instruction( - &self, - args: SharedAccountsRouteWithTokenLedgerInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SharedAccountsRouteWithTokenLedgerInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_transfer_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.program_source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.program_destination_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.destination_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.source_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.destination_mint, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - platform_fee_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - if let Some(token2022_program) = self.token2022_program { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token2022_program, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_ledger, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = - borsh::to_vec(&SharedAccountsRouteWithTokenLedgerInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SharedAccountsRouteWithTokenLedgerInstructionData { - discriminator: [u8; 8], -} - -impl SharedAccountsRouteWithTokenLedgerInstructionData { - pub fn new() -> Self { - Self { - discriminator: [230, 121, 143, 80, 119, 159, 106, 170], - } - } -} - -impl Default for SharedAccountsRouteWithTokenLedgerInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SharedAccountsRouteWithTokenLedgerInstructionArgs { - pub id: u8, - pub route_plan: Vec, - pub quoted_out_amount: u64, - pub slippage_bps: u16, - pub platform_fee_bps: u8, -} - -/// Instruction builder for `SharedAccountsRouteWithTokenLedger`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[]` program_authority -/// 2. `[signer]` user_transfer_authority -/// 3. `[writable]` source_token_account -/// 4. `[writable]` program_source_token_account -/// 5. `[writable]` program_destination_token_account -/// 6. `[writable]` destination_token_account -/// 7. `[]` source_mint -/// 8. `[]` destination_mint -/// 9. `[writable, optional]` platform_fee_account -/// 10. `[optional]` token2022_program -/// 11. `[]` token_ledger -/// 12. `[optional]` event_authority (default to `D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf`) -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SharedAccountsRouteWithTokenLedgerBuilder { - token_program: Option, - program_authority: Option, - user_transfer_authority: Option, - source_token_account: Option, - program_source_token_account: Option, - program_destination_token_account: Option, - destination_token_account: Option, - source_mint: Option, - destination_mint: Option, - platform_fee_account: Option, - token2022_program: Option, - token_ledger: Option, - event_authority: Option, - program: Option, - id: Option, - route_plan: Option>, - quoted_out_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - __remaining_accounts: Vec, -} - -impl SharedAccountsRouteWithTokenLedgerBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn program_authority(&mut self, program_authority: solana_pubkey::Pubkey) -> &mut Self { - self.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn source_token_account( - &mut self, - source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.source_token_account = Some(source_token_account); - self - } - - #[inline(always)] - pub fn program_source_token_account( - &mut self, - program_source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.program_source_token_account = Some(program_source_token_account); - self - } - - #[inline(always)] - pub fn program_destination_token_account( - &mut self, - program_destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.program_destination_token_account = Some(program_destination_token_account); - self - } - - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.destination_token_account = Some(destination_token_account); - self - } - - #[inline(always)] - pub fn source_mint(&mut self, source_mint: solana_pubkey::Pubkey) -> &mut Self { - self.source_mint = Some(source_mint); - self - } - - #[inline(always)] - pub fn destination_mint(&mut self, destination_mint: solana_pubkey::Pubkey) -> &mut Self { - self.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option, - ) -> &mut Self { - self.platform_fee_account = platform_fee_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: Option, - ) -> &mut Self { - self.token2022_program = token2022_program; - self - } - - #[inline(always)] - pub fn token_ledger(&mut self, token_ledger: solana_pubkey::Pubkey) -> &mut Self { - self.token_ledger = Some(token_ledger); - self - } - - /// `[optional account, default to 'D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf']` - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.id = Some(id); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn quoted_out_amount(&mut self, quoted_out_amount: u64) -> &mut Self { - self.quoted_out_amount = Some(quoted_out_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SharedAccountsRouteWithTokenLedger { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - program_authority: self - .program_authority - .expect("program_authority is not set"), - user_transfer_authority: self - .user_transfer_authority - .expect("user_transfer_authority is not set"), - source_token_account: self - .source_token_account - .expect("source_token_account is not set"), - program_source_token_account: self - .program_source_token_account - .expect("program_source_token_account is not set"), - program_destination_token_account: self - .program_destination_token_account - .expect("program_destination_token_account is not set"), - destination_token_account: self - .destination_token_account - .expect("destination_token_account is not set"), - source_mint: self.source_mint.expect("source_mint is not set"), - destination_mint: self.destination_mint.expect("destination_mint is not set"), - platform_fee_account: self.platform_fee_account, - token2022_program: self.token2022_program, - token_ledger: self.token_ledger.expect("token_ledger is not set"), - event_authority: self.event_authority.unwrap_or(solana_pubkey::pubkey!( - "D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf" - )), - program: self.program.expect("program is not set"), - }; - let args = SharedAccountsRouteWithTokenLedgerInstructionArgs { - id: self.id.clone().expect("id is not set"), - route_plan: self.route_plan.clone().expect("route_plan is not set"), - quoted_out_amount: self - .quoted_out_amount - .clone() - .expect("quoted_out_amount is not set"), - slippage_bps: self.slippage_bps.clone().expect("slippage_bps is not set"), - platform_fee_bps: self - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `shared_accounts_route_with_token_ledger` CPI accounts. -pub struct SharedAccountsRouteWithTokenLedgerCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub source_mint: &'b solana_account_info::AccountInfo<'a>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_ledger: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `shared_accounts_route_with_token_ledger` CPI instruction. -pub struct SharedAccountsRouteWithTokenLedgerCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub program_authority: &'b solana_account_info::AccountInfo<'a>, - - pub user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - - pub source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub program_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub source_mint: &'b solana_account_info::AccountInfo<'a>, - - pub destination_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_ledger: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SharedAccountsRouteWithTokenLedgerInstructionArgs, -} - -impl<'a, 'b> SharedAccountsRouteWithTokenLedgerCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SharedAccountsRouteWithTokenLedgerCpiAccounts<'a, 'b>, - args: SharedAccountsRouteWithTokenLedgerInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - program_authority: accounts.program_authority, - user_transfer_authority: accounts.user_transfer_authority, - source_token_account: accounts.source_token_account, - program_source_token_account: accounts.program_source_token_account, - program_destination_token_account: accounts.program_destination_token_account, - destination_token_account: accounts.destination_token_account, - source_mint: accounts.source_mint, - destination_mint: accounts.destination_mint, - platform_fee_account: accounts.platform_fee_account, - token2022_program: accounts.token2022_program, - token_ledger: accounts.token_ledger, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_transfer_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.program_source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.program_destination_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.destination_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.source_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.destination_mint.key, - false, - )); - if let Some(platform_fee_account) = self.platform_fee_account { - accounts.push(solana_instruction::AccountMeta::new( - *platform_fee_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - if let Some(token2022_program) = self.token2022_program { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token2022_program.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::JUPITER_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_ledger.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = - borsh::to_vec(&SharedAccountsRouteWithTokenLedgerInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::JUPITER_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.program_authority.clone()); - account_infos.push(self.user_transfer_authority.clone()); - account_infos.push(self.source_token_account.clone()); - account_infos.push(self.program_source_token_account.clone()); - account_infos.push(self.program_destination_token_account.clone()); - account_infos.push(self.destination_token_account.clone()); - account_infos.push(self.source_mint.clone()); - account_infos.push(self.destination_mint.clone()); - if let Some(platform_fee_account) = self.platform_fee_account { - account_infos.push(platform_fee_account.clone()); - } - if let Some(token2022_program) = self.token2022_program { - account_infos.push(token2022_program.clone()); - } - account_infos.push(self.token_ledger.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SharedAccountsRouteWithTokenLedger` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[]` program_authority -/// 2. `[signer]` user_transfer_authority -/// 3. `[writable]` source_token_account -/// 4. `[writable]` program_source_token_account -/// 5. `[writable]` program_destination_token_account -/// 6. `[writable]` destination_token_account -/// 7. `[]` source_mint -/// 8. `[]` destination_mint -/// 9. `[writable, optional]` platform_fee_account -/// 10. `[optional]` token2022_program -/// 11. `[]` token_ledger -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct SharedAccountsRouteWithTokenLedgerCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SharedAccountsRouteWithTokenLedgerCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SharedAccountsRouteWithTokenLedgerCpiBuilderInstruction { - __program: program, - token_program: None, - program_authority: None, - user_transfer_authority: None, - source_token_account: None, - program_source_token_account: None, - program_destination_token_account: None, - destination_token_account: None, - source_mint: None, - destination_mint: None, - platform_fee_account: None, - token2022_program: None, - token_ledger: None, - event_authority: None, - program: None, - id: None, - route_plan: None, - quoted_out_amount: None, - slippage_bps: None, - platform_fee_bps: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn program_authority( - &mut self, - program_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_authority = Some(program_authority); - self - } - - #[inline(always)] - pub fn user_transfer_authority( - &mut self, - user_transfer_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_transfer_authority = Some(user_transfer_authority); - self - } - - #[inline(always)] - pub fn source_token_account( - &mut self, - source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_token_account = Some(source_token_account); - self - } - - #[inline(always)] - pub fn program_source_token_account( - &mut self, - program_source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_source_token_account = Some(program_source_token_account); - self - } - - #[inline(always)] - pub fn program_destination_token_account( - &mut self, - program_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.program_destination_token_account = - Some(program_destination_token_account); - self - } - - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_token_account = Some(destination_token_account); - self - } - - #[inline(always)] - pub fn source_mint( - &mut self, - source_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_mint = Some(source_mint); - self - } - - #[inline(always)] - pub fn destination_mint( - &mut self, - destination_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_mint = Some(destination_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn platform_fee_account( - &mut self, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.platform_fee_account = platform_fee_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token2022_program = token2022_program; - self - } - - #[inline(always)] - pub fn token_ledger( - &mut self, - token_ledger: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_ledger = Some(token_ledger); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn id(&mut self, id: u8) -> &mut Self { - self.instruction.id = Some(id); - self - } - - #[inline(always)] - pub fn route_plan(&mut self, route_plan: Vec) -> &mut Self { - self.instruction.route_plan = Some(route_plan); - self - } - - #[inline(always)] - pub fn quoted_out_amount(&mut self, quoted_out_amount: u64) -> &mut Self { - self.instruction.quoted_out_amount = Some(quoted_out_amount); - self - } - - #[inline(always)] - pub fn slippage_bps(&mut self, slippage_bps: u16) -> &mut Self { - self.instruction.slippage_bps = Some(slippage_bps); - self - } - - #[inline(always)] - pub fn platform_fee_bps(&mut self, platform_fee_bps: u8) -> &mut Self { - self.instruction.platform_fee_bps = Some(platform_fee_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SharedAccountsRouteWithTokenLedgerInstructionArgs { - id: self.instruction.id.clone().expect("id is not set"), - route_plan: self - .instruction - .route_plan - .clone() - .expect("route_plan is not set"), - quoted_out_amount: self - .instruction - .quoted_out_amount - .clone() - .expect("quoted_out_amount is not set"), - slippage_bps: self - .instruction - .slippage_bps - .clone() - .expect("slippage_bps is not set"), - platform_fee_bps: self - .instruction - .platform_fee_bps - .clone() - .expect("platform_fee_bps is not set"), - }; - let instruction = SharedAccountsRouteWithTokenLedgerCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - program_authority: self - .instruction - .program_authority - .expect("program_authority is not set"), - - user_transfer_authority: self - .instruction - .user_transfer_authority - .expect("user_transfer_authority is not set"), - - source_token_account: self - .instruction - .source_token_account - .expect("source_token_account is not set"), - - program_source_token_account: self - .instruction - .program_source_token_account - .expect("program_source_token_account is not set"), - - program_destination_token_account: self - .instruction - .program_destination_token_account - .expect("program_destination_token_account is not set"), - - destination_token_account: self - .instruction - .destination_token_account - .expect("destination_token_account is not set"), - - source_mint: self - .instruction - .source_mint - .expect("source_mint is not set"), - - destination_mint: self - .instruction - .destination_mint - .expect("destination_mint is not set"), - - platform_fee_account: self.instruction.platform_fee_account, - - token2022_program: self.instruction.token2022_program, - - token_ledger: self - .instruction - .token_ledger - .expect("token_ledger is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SharedAccountsRouteWithTokenLedgerCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - program_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - user_transfer_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - program_source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - program_destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - source_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_ledger: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - id: Option, - route_plan: Option>, - quoted_out_amount: Option, - slippage_bps: Option, - platform_fee_bps: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/mod.rs b/crates/jupiter-swap-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/jupiter-swap-parser/src/generated_sdk/programs.rs b/crates/jupiter-swap-parser/src/generated_sdk/programs.rs deleted file mode 100644 index e3d73867..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `jupiter` program ID. -pub const JUPITER_ID: Pubkey = pubkey!("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"); diff --git a/crates/jupiter-swap-parser/src/generated_sdk/shared.rs b/crates/jupiter-swap-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/types/accounts_type.rs b/crates/jupiter-swap-parser/src/generated_sdk/types/accounts_type.rs deleted file mode 100644 index 7e59bef9..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/types/accounts_type.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum AccountsType { - TransferHookA, - TransferHookB, - TransferHookReward, - TransferHookInput, - TransferHookIntermediate, - TransferHookOutput, - SupplementalTickArrays, - SupplementalTickArraysOne, - SupplementalTickArraysTwo, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/types/fee_event.rs b/crates/jupiter-swap-parser/src/generated_sdk/types/fee_event.rs deleted file mode 100644 index dde2832e..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/types/fee_event.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FeeEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub amount: u64, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/types/mod.rs b/crates/jupiter-swap-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index 33ed11e3..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#accounts_type; -pub(crate) mod r#fee_event; -pub(crate) mod r#remaining_accounts_info; -pub(crate) mod r#remaining_accounts_slice; -pub(crate) mod r#route_plan_step; -pub(crate) mod r#side; -pub(crate) mod r#swap; -pub(crate) mod r#swap_event; - -pub use self::{ - r#accounts_type::*, r#fee_event::*, r#remaining_accounts_info::*, - r#remaining_accounts_slice::*, r#route_plan_step::*, r#side::*, r#swap::*, r#swap_event::*, -}; diff --git a/crates/jupiter-swap-parser/src/generated_sdk/types/remaining_accounts_info.rs b/crates/jupiter-swap-parser/src/generated_sdk/types/remaining_accounts_info.rs deleted file mode 100644 index d8a464a1..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/types/remaining_accounts_info.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsSlice; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemainingAccountsInfo { - pub slices: Vec, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/types/remaining_accounts_slice.rs b/crates/jupiter-swap-parser/src/generated_sdk/types/remaining_accounts_slice.rs deleted file mode 100644 index b96d81aa..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/types/remaining_accounts_slice.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::AccountsType; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemainingAccountsSlice { - pub accounts_type: AccountsType, - pub length: u8, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/types/route_plan_step.rs b/crates/jupiter-swap-parser/src/generated_sdk/types/route_plan_step.rs deleted file mode 100644 index b14466d4..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/types/route_plan_step.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::Swap; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RoutePlanStep { - pub swap: Swap, - pub percent: u8, - pub input_index: u8, - pub output_index: u8, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/types/side.rs b/crates/jupiter-swap-parser/src/generated_sdk/types/side.rs deleted file mode 100644 index 61f0e4af..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/types/side.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum Side { - Bid, - Ask, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/types/swap.rs b/crates/jupiter-swap-parser/src/generated_sdk/types/swap.rs deleted file mode 100644 index bface6b7..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/types/swap.rs +++ /dev/null @@ -1,182 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{RemainingAccountsInfo, Side}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum Swap { - Saber, - SaberAddDecimalsDeposit, - SaberAddDecimalsWithdraw, - TokenSwap, - Sencha, - Step, - Cropper, - Raydium, - Crema { - a_to_b: bool, - }, - Lifinity, - Mercurial, - Cykura, - Serum { - side: Side, - }, - MarinadeDeposit, - MarinadeUnstake, - Aldrin { - side: Side, - }, - AldrinV2 { - side: Side, - }, - Whirlpool { - a_to_b: bool, - }, - Invariant { - x_to_y: bool, - }, - Meteora, - GooseFX, - DeltaFi { - stable: bool, - }, - Balansol, - MarcoPolo { - x_to_y: bool, - }, - Dradex { - side: Side, - }, - LifinityV2, - RaydiumClmm, - Openbook { - side: Side, - }, - Phoenix { - side: Side, - }, - Symmetry { - from_token_id: u64, - to_token_id: u64, - }, - TokenSwapV2, - HeliumTreasuryManagementRedeemV0, - StakeDexStakeWrappedSol, - StakeDexSwapViaStake { - bridge_stake_seed: u32, - }, - GooseFXV2, - Perps, - PerpsAddLiquidity, - PerpsRemoveLiquidity, - MeteoraDlmm, - OpenBookV2 { - side: Side, - }, - RaydiumClmmV2, - StakeDexPrefundWithdrawStakeAndDepositStake { - bridge_stake_seed: u32, - }, - Clone { - pool_index: u8, - quantity_is_input: bool, - quantity_is_collateral: bool, - }, - SanctumS { - src_lst_value_calc_accs: u8, - dst_lst_value_calc_accs: u8, - src_lst_index: u32, - dst_lst_index: u32, - }, - SanctumSAddLiquidity { - lst_value_calc_accs: u8, - lst_index: u32, - }, - SanctumSRemoveLiquidity { - lst_value_calc_accs: u8, - lst_index: u32, - }, - RaydiumCP, - WhirlpoolSwapV2 { - a_to_b: bool, - remaining_accounts_info: Option, - }, - OneIntro, - PumpdotfunWrappedBuy, - PumpdotfunWrappedSell, - PerpsV2, - PerpsV2AddLiquidity, - PerpsV2RemoveLiquidity, - MoonshotWrappedBuy, - MoonshotWrappedSell, - StabbleStableSwap, - StabbleWeightedSwap, - Obric { - x_to_y: bool, - }, - FoxBuyFromEstimatedCost, - FoxClaimPartial { - is_y: bool, - }, - SolFi { - is_quote_to_base: bool, - }, - SolayerDelegateNoInit, - SolayerUndelegateNoInit, - TokenMill { - side: Side, - }, - DaosFunBuy, - DaosFunSell, - ZeroFi, - StakeDexWithdrawWrappedSol, - VirtualsBuy, - VirtualsSell, - Perena { - in_index: u8, - out_index: u8, - }, - PumpdotfunAmmBuy, - PumpdotfunAmmSell, - Gamma, - MeteoraDlmmSwapV2 { - remaining_accounts_info: RemainingAccountsInfo, - }, - Woofi, - MeteoraDammV2, - MeteoraDynamicBondingCurveSwap, - StabbleStableSwapV2, - StabbleWeightedSwapV2, - RaydiumLaunchlabBuy { - share_fee_rate: u64, - }, - RaydiumLaunchlabSell { - share_fee_rate: u64, - }, - BoopdotfunWrappedBuy, - BoopdotfunWrappedSell, - Plasma { - side: Side, - }, - GoonFi { - is_bid: bool, - blacklist_bump: u8, - }, - HumidiFi { - swap_id: u64, - is_base_to_quote: bool, - }, - MeteoraDynamicBondingCurveSwapWithRemainingAccounts, - TesseraV { - side: Side, - }, - RaydiumStable, -} diff --git a/crates/jupiter-swap-parser/src/generated_sdk/types/swap_event.rs b/crates/jupiter-swap-parser/src/generated_sdk/types/swap_event.rs deleted file mode 100644 index 735e43c4..00000000 --- a/crates/jupiter-swap-parser/src/generated_sdk/types/swap_event.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub amm: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub input_mint: Pubkey, - pub input_amount: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub output_mint: Pubkey, - pub output_amount: u64, -} diff --git a/crates/jupiter-swap-parser/src/lib.rs b/crates/jupiter-swap-parser/src/lib.rs deleted file mode 100644 index 1007eb0a..00000000 --- a/crates/jupiter-swap-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = JUPITER_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.jupiter_swap"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/kamino-limit-orders-parser/Cargo.toml b/crates/kamino-limit-orders-parser/Cargo.toml deleted file mode 100644 index f6968c3a..00000000 --- a/crates/kamino-limit-orders-parser/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "yellowstone-vixen-kamino-limit-orders-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Kamino Limit Orders program" -license.workspace = true -repository.workspace = true -authors.workspace = true - - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info = { workspace = true } -solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction = { workspace = true } -solana-msg = { workspace = true } -solana-program-entrypoint = { workspace = true } -solana-program-error = { workspace = true } -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true diff --git a/crates/kamino-limit-orders-parser/build.rs b/crates/kamino-limit-orders-parser/build.rs deleted file mode 100644 index 52fa96d1..00000000 --- a/crates/kamino-limit-orders-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/kamino_limit_orders.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/kamino-limit-orders-parser/idl.json b/crates/kamino-limit-orders-parser/idl.json deleted file mode 100644 index 206f92f3..00000000 --- a/crates/kamino-limit-orders-parser/idl.json +++ /dev/null @@ -1,1586 +0,0 @@ -{ - "version": "0.1.0", - "name": "limo", - "metadata": { - "address": "LiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF" - }, - "instructions": [ - { - "name": "initializeGlobalConfig", - "accounts": [ - { - "name": "adminAuthority", - "isMut": true, - "isSigner": true - }, - { - "name": "pdaAuthority", - "isMut": true, - "isSigner": false - }, - { - "name": "globalConfig", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "initializeVault", - "accounts": [ - { - "name": "payer", - "isMut": true, - "isSigner": true - }, - { - "name": "globalConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "pdaAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "mint", - "isMut": false, - "isSigner": false - }, - { - "name": "vault", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "createOrder", - "accounts": [ - { - "name": "maker", - "isMut": true, - "isSigner": true - }, - { - "name": "globalConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "pdaAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "order", - "isMut": true, - "isSigner": false - }, - { - "name": "inputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "outputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "makerAta", - "isMut": true, - "isSigner": false - }, - { - "name": "inputVault", - "isMut": true, - "isSigner": false - }, - { - "name": "inputTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "outputTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "inputAmount", - "type": "u64" - }, - { - "name": "outputAmount", - "type": "u64" - }, - { - "name": "orderType", - "type": "u8" - } - ] - }, - { - "name": "closeOrderAndClaimTip", - "accounts": [ - { - "name": "maker", - "isMut": true, - "isSigner": true - }, - { - "name": "order", - "isMut": true, - "isSigner": false - }, - { - "name": "globalConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "pdaAuthority", - "isMut": true, - "isSigner": false - }, - { - "name": "inputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "outputMint", - "isMut": false, - "isSigner": false, - "docs": ["- required only for indexing the order state from the instruction"] - }, - { - "name": "makerInputAta", - "isMut": true, - "isSigner": false - }, - { - "name": "inputVault", - "isMut": true, - "isSigner": false - }, - { - "name": "inputTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "takeOrder", - "accounts": [ - { - "name": "taker", - "isMut": true, - "isSigner": true - }, - { - "name": "maker", - "isMut": true, - "isSigner": false - }, - { - "name": "globalConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "pdaAuthority", - "isMut": true, - "isSigner": false - }, - { - "name": "order", - "isMut": true, - "isSigner": false - }, - { - "name": "inputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "outputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "inputVault", - "isMut": true, - "isSigner": false - }, - { - "name": "takerInputAta", - "isMut": true, - "isSigner": false - }, - { - "name": "takerOutputAta", - "isMut": true, - "isSigner": false - }, - { - "name": "intermediaryOutputTokenAccount", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "makerOutputAta", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "expressRelay", - "isMut": false, - "isSigner": false - }, - { - "name": "expressRelayMetadata", - "isMut": false, - "isSigner": false - }, - { - "name": "sysvarInstructions", - "isMut": false, - "isSigner": false - }, - { - "name": "permission", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "configRouter", - "isMut": false, - "isSigner": false - }, - { - "name": "inputTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "outputTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "inputAmount", - "type": "u64" - }, - { - "name": "minOutputAmount", - "type": "u64" - }, - { - "name": "tipAmountPermissionlessTaking", - "type": "u64" - } - ] - }, - { - "name": "flashTakeOrderStart", - "accounts": [ - { - "name": "taker", - "isMut": true, - "isSigner": true - }, - { - "name": "maker", - "isMut": true, - "isSigner": false - }, - { - "name": "globalConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "pdaAuthority", - "isMut": true, - "isSigner": false - }, - { - "name": "order", - "isMut": true, - "isSigner": false - }, - { - "name": "inputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "outputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "inputVault", - "isMut": true, - "isSigner": false - }, - { - "name": "takerInputAta", - "isMut": true, - "isSigner": false - }, - { - "name": "takerOutputAta", - "isMut": true, - "isSigner": false - }, - { - "name": "intermediaryOutputTokenAccount", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "makerOutputAta", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "expressRelay", - "isMut": false, - "isSigner": false - }, - { - "name": "expressRelayMetadata", - "isMut": false, - "isSigner": false - }, - { - "name": "sysvarInstructions", - "isMut": false, - "isSigner": false - }, - { - "name": "permission", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "configRouter", - "isMut": false, - "isSigner": false - }, - { - "name": "inputTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "outputTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "inputAmount", - "type": "u64" - }, - { - "name": "minOutputAmount", - "type": "u64" - }, - { - "name": "tipAmountPermissionlessTaking", - "type": "u64" - } - ] - }, - { - "name": "flashTakeOrderEnd", - "accounts": [ - { - "name": "taker", - "isMut": true, - "isSigner": true - }, - { - "name": "maker", - "isMut": true, - "isSigner": false - }, - { - "name": "globalConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "pdaAuthority", - "isMut": true, - "isSigner": false - }, - { - "name": "order", - "isMut": true, - "isSigner": false - }, - { - "name": "inputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "outputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "inputVault", - "isMut": true, - "isSigner": false - }, - { - "name": "takerInputAta", - "isMut": true, - "isSigner": false - }, - { - "name": "takerOutputAta", - "isMut": true, - "isSigner": false - }, - { - "name": "intermediaryOutputTokenAccount", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "makerOutputAta", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "expressRelay", - "isMut": false, - "isSigner": false - }, - { - "name": "expressRelayMetadata", - "isMut": false, - "isSigner": false - }, - { - "name": "sysvarInstructions", - "isMut": false, - "isSigner": false - }, - { - "name": "permission", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "configRouter", - "isMut": false, - "isSigner": false - }, - { - "name": "inputTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "outputTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "inputAmount", - "type": "u64" - }, - { - "name": "minOutputAmount", - "type": "u64" - }, - { - "name": "tipAmountPermissionlessTaking", - "type": "u64" - } - ] - }, - { - "name": "updateGlobalConfig", - "accounts": [ - { - "name": "adminAuthority", - "isMut": true, - "isSigner": true - }, - { - "name": "globalConfig", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "mode", - "type": "u16" - }, - { - "name": "value", - "type": { - "array": ["u8", 128] - } - } - ] - }, - { - "name": "updateGlobalConfigAdmin", - "accounts": [ - { - "name": "adminAuthorityCached", - "isMut": false, - "isSigner": true - }, - { - "name": "globalConfig", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "withdrawHostTip", - "accounts": [ - { - "name": "adminAuthority", - "isMut": true, - "isSigner": true - }, - { - "name": "globalConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "pdaAuthority", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "logUserSwapBalancesStart", - "accounts": [ - { - "name": "baseAccounts", - "accounts": [ - { - "name": "maker", - "isMut": false, - "isSigner": true - }, - { - "name": "inputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "outputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "inputTa", - "isMut": false, - "isSigner": false - }, - { - "name": "outputTa", - "isMut": false, - "isSigner": false - }, - { - "name": "pdaReferrer", - "isMut": false, - "isSigner": false, - "isOptional": true, - "docs": ["if it's not the pda it doesn't matter"] - }, - { - "name": "swapProgramId", - "isMut": false, - "isSigner": false - } - ] - }, - { - "name": "userSwapBalanceState", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "sysvarInstructions", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "logUserSwapBalancesEnd", - "accounts": [ - { - "name": "baseAccounts", - "accounts": [ - { - "name": "maker", - "isMut": false, - "isSigner": true - }, - { - "name": "inputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "outputMint", - "isMut": false, - "isSigner": false - }, - { - "name": "inputTa", - "isMut": false, - "isSigner": false - }, - { - "name": "outputTa", - "isMut": false, - "isSigner": false - }, - { - "name": "pdaReferrer", - "isMut": false, - "isSigner": false, - "isOptional": true, - "docs": ["if it's not the pda it doesn't matter"] - }, - { - "name": "swapProgramId", - "isMut": false, - "isSigner": false - } - ] - }, - { - "name": "userSwapBalanceState", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "sysvarInstructions", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "simulatedSwapAmountOut", - "type": "u64" - }, - { - "name": "simulatedTs", - "type": "u64" - }, - { - "name": "minimumAmountOut", - "type": "u64" - }, - { - "name": "swapAmountIn", - "type": "u64" - }, - { - "name": "simulatedAmountOutNextBest", - "type": "u64" - }, - { - "name": "aggregator", - "type": "u8" - }, - { - "name": "nextBestAggregator", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": ["u8", 2] - } - } - ] - } - ], - "accounts": [ - { - "name": "Order", - "type": { - "kind": "struct", - "fields": [ - { - "name": "globalConfig", - "type": "publicKey" - }, - { - "name": "maker", - "type": "publicKey" - }, - { - "name": "inputMint", - "type": "publicKey" - }, - { - "name": "inputMintProgramId", - "type": "publicKey" - }, - { - "name": "outputMint", - "type": "publicKey" - }, - { - "name": "outputMintProgramId", - "type": "publicKey" - }, - { - "name": "initialInputAmount", - "docs": ["The amount of input token the maker wants to swap"], - "type": "u64" - }, - { - "name": "expectedOutputAmount", - "docs": ["The amount of output token the maker wants to receive"], - "type": "u64" - }, - { - "name": "remainingInputAmount", - "docs": ["The amount of input token remaining to be swapped"], - "type": "u64" - }, - { - "name": "filledOutputAmount", - "docs": ["The amount of output token that the maker has received so far"], - "type": "u64" - }, - { - "name": "tipAmount", - "docs": [ - "The amount of tips the maker is due to receive for this order -", - "in lamports, stored in the pda_authority account" - ], - "type": "u64" - }, - { - "name": "numberOfFills", - "docs": ["The number of times the order has been filled"], - "type": "u64" - }, - { - "name": "orderType", - "type": "u8" - }, - { - "name": "status", - "type": "u8" - }, - { - "name": "inVaultBump", - "type": "u8" - }, - { - "name": "flashIxLock", - "docs": [ - "This is normally set to 0, but can be set to 1 to indicate that the", - "order is part of a flash operation, in whcih case the order can not be", - "modified until the flash operation is completed." - ], - "type": "u8" - }, - { - "name": "padding0", - "type": { - "array": ["u8", 4] - } - }, - { - "name": "lastUpdatedTimestamp", - "type": "u64" - }, - { - "name": "flashStartTakerOutputBalance", - "docs": [ - "This is only used for flash operations, and is set to the blanance on the start", - "operation, and than back to 0 on the end operation. It is used to compute the difference", - "between start and end balances in order to compute the amount received from a potential swap" - ], - "type": "u64" - }, - { - "name": "padding", - "type": { - "array": ["u64", 19] - } - } - ] - } - }, - { - "name": "UserSwapBalancesState", - "type": { - "kind": "struct", - "fields": [ - { - "name": "userLamports", - "type": "u64" - }, - { - "name": "inputTaBalance", - "type": "u64" - }, - { - "name": "outputTaBalance", - "type": "u64" - } - ] - } - }, - { - "name": "GlobalConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "emergencyMode", - "type": "u8" - }, - { - "name": "flashTakeOrderBlocked", - "type": "u8" - }, - { - "name": "newOrdersBlocked", - "type": "u8" - }, - { - "name": "ordersTakingBlocked", - "type": "u8" - }, - { - "name": "hostFeeBps", - "type": "u16" - }, - { - "name": "isOrderTakingPermissionless", - "type": "u8" - }, - { - "name": "padding0", - "type": { - "array": ["u8", 1] - } - }, - { - "name": "orderCloseDelaySeconds", - "docs": ["The number of seconds after an order has been updated before it can be closed"], - "type": "u64" - }, - { - "name": "padding1", - "type": { - "array": ["u64", 9] - } - }, - { - "name": "pdaAuthorityPreviousLamportsBalance", - "docs": [ - "The total amount of lamports that were present in the pda_authority last", - "time a program instructions which alters the pda_authority account was", - "executed" - ], - "type": "u64" - }, - { - "name": "totalTipAmount", - "docs": [ - "The total amount of tips that have been paid out - should be at least", - "as much as the total lamports present in the pda_authority account" - ], - "type": "u64" - }, - { - "name": "hostTipAmount", - "docs": [ - "The amount of tips the host is due to receive -", - "in lamports, stored in the pda_authority account" - ], - "type": "u64" - }, - { - "name": "pdaAuthority", - "type": "publicKey" - }, - { - "name": "pdaAuthorityBump", - "type": "u64" - }, - { - "name": "adminAuthority", - "type": "publicKey" - }, - { - "name": "adminAuthorityCached", - "type": "publicKey" - }, - { - "name": "txnFeeCost", - "type": "u64" - }, - { - "name": "ataCreationCost", - "type": "u64" - }, - { - "name": "padding2", - "type": { - "array": ["u64", 241] - } - } - ] - } - } - ], - "types": [ - { - "name": "OrderStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Active" - }, - { - "name": "Filled" - }, - { - "name": "Cancelled" - } - ] - } - }, - { - "name": "OrderType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Vanilla" - } - ] - } - }, - { - "name": "UpdateGlobalConfigMode", - "type": { - "kind": "enum", - "variants": [ - { - "name": "UpdateEmergencyMode" - }, - { - "name": "UpdateFlashTakeOrderBlocked" - }, - { - "name": "UpdateBlockNewOrders" - }, - { - "name": "UpdateBlockOrderTaking" - }, - { - "name": "UpdateHostFeeBps" - }, - { - "name": "UpdateAdminAuthorityCached" - }, - { - "name": "UpdateOrderTakingPermissionless" - }, - { - "name": "UpdateOrderCloseDelaySeconds" - }, - { - "name": "UpdateTxnFeeCost" - }, - { - "name": "UpdateAtaCreationCost" - } - ] - } - }, - { - "name": "UpdateGlobalConfigValue", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Bool", - "fields": ["bool"] - }, - { - "name": "U16", - "fields": ["u16"] - }, - { - "name": "U64", - "fields": ["u64"] - }, - { - "name": "Pubkey", - "fields": ["publicKey"] - } - ] - } - } - ], - "events": [ - { - "name": "OrderDisplay", - "fields": [ - { - "name": "initialInputAmount", - "type": "u64", - "index": false - }, - { - "name": "expectedOutputAmount", - "type": "u64", - "index": false - }, - { - "name": "remainingInputAmount", - "type": "u64", - "index": false - }, - { - "name": "filledOutputAmount", - "type": "u64", - "index": false - }, - { - "name": "tipAmount", - "type": "u64", - "index": false - }, - { - "name": "numberOfFills", - "type": "u64", - "index": false - }, - { - "name": "onEventOutputAmountFilled", - "type": "u64", - "index": false - }, - { - "name": "onEventTipAmount", - "type": "u64", - "index": false - }, - { - "name": "orderType", - "type": "u8", - "index": false - }, - { - "name": "status", - "type": "u8", - "index": false - }, - { - "name": "lastUpdatedTimestamp", - "type": "u64", - "index": false - } - ] - }, - { - "name": "UserSwapBalanceDiffs", - "fields": [ - { - "name": "userLamportsBefore", - "type": "u64", - "index": false - }, - { - "name": "inputTaBalanceBefore", - "type": "u64", - "index": false - }, - { - "name": "outputTaBalanceBefore", - "type": "u64", - "index": false - }, - { - "name": "userLamportsAfter", - "type": "u64", - "index": false - }, - { - "name": "inputTaBalanceAfter", - "type": "u64", - "index": false - }, - { - "name": "outputTaBalanceAfter", - "type": "u64", - "index": false - }, - { - "name": "swapProgram", - "type": "publicKey", - "index": false - }, - { - "name": "simulatedSwapAmountOut", - "type": "u64", - "index": false - }, - { - "name": "simulatedTs", - "type": "u64", - "index": false - }, - { - "name": "minimumAmountOut", - "type": "u64", - "index": false - }, - { - "name": "swapAmountIn", - "type": "u64", - "index": false - }, - { - "name": "simulatedAmountOutNextBest", - "type": "u64", - "index": false - }, - { - "name": "aggregator", - "type": "u8", - "index": false - }, - { - "name": "nextBestAggregator", - "type": "u8", - "index": false - } - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "OrderCanNotBeCanceled", - "msg": "Order can't be canceled" - }, - { - "code": 6001, - "name": "OrderNotActive", - "msg": "Order not active" - }, - { - "code": 6002, - "name": "InvalidAdminAuthority", - "msg": "Invalid admin authority" - }, - { - "code": 6003, - "name": "InvalidPdaAuthority", - "msg": "Invalid pda authority" - }, - { - "code": 6004, - "name": "InvalidConfigOption", - "msg": "Invalid config option" - }, - { - "code": 6005, - "name": "InvalidOrderOwner", - "msg": "Order owner account is not the order owner" - }, - { - "code": 6006, - "name": "OutOfRangeIntegralConversion", - "msg": "Out of range integral conversion attempted" - }, - { - "code": 6007, - "name": "InvalidFlag", - "msg": "Invalid boolean flag, valid values are 0 and 1" - }, - { - "code": 6008, - "name": "MathOverflow", - "msg": "Mathematical operation with overflow" - }, - { - "code": 6009, - "name": "OrderInputAmountInvalid", - "msg": "Order input amount invalid" - }, - { - "code": 6010, - "name": "OrderOutputAmountInvalid", - "msg": "Order output amount invalid" - }, - { - "code": 6011, - "name": "InvalidHostFee", - "msg": "Host fee bps must be between 0 and 10000" - }, - { - "code": 6012, - "name": "IntegerOverflow", - "msg": "Conversion between integers failed" - }, - { - "code": 6013, - "name": "InvalidTipBalance", - "msg": "Tip balance less than accounted tip" - }, - { - "code": 6014, - "name": "InvalidTipTransferAmount", - "msg": "Tip transfer amount is less than expected" - }, - { - "code": 6015, - "name": "InvalidHostTipBalance", - "msg": "Host tup amount is less than accounted for" - }, - { - "code": 6016, - "name": "OrderWithinFlashOperation", - "msg": "Order within flash operation - all otehr actions are blocked" - }, - { - "code": 6017, - "name": "CPINotAllowed", - "msg": "CPI not allowed" - }, - { - "code": 6018, - "name": "FlashTakeOrderBlocked", - "msg": "Flash take_order is blocked" - }, - { - "code": 6019, - "name": "FlashTxWithUnexpectedIxs", - "msg": "Some unexpected instructions are present in the tx. Either before or after the flash ixs, or some ix target the same program between" - }, - { - "code": 6020, - "name": "FlashIxsNotEnded", - "msg": "Flash ixs initiated without the closing ix in the transaction" - }, - { - "code": 6021, - "name": "FlashIxsNotStarted", - "msg": "Flash ixs ended without the starting ix in the transaction" - }, - { - "code": 6022, - "name": "FlashIxsAccountMismatch", - "msg": "Some accounts differ between the two flash ixs" - }, - { - "code": 6023, - "name": "FlashIxsArgsMismatch", - "msg": "Some args differ between the two flash ixs" - }, - { - "code": 6024, - "name": "OrderNotWithinFlashOperation", - "msg": "Order is not within flash operation" - }, - { - "code": 6025, - "name": "EmergencyModeEnabled", - "msg": "Emergency mode is enabled" - }, - { - "code": 6026, - "name": "CreatingNewOrdersBlocked", - "msg": "Creating new ordersis blocked" - }, - { - "code": 6027, - "name": "OrderTakingBlocked", - "msg": "Orders taking is blocked" - }, - { - "code": 6028, - "name": "OrderInputAmountTooLarge", - "msg": "Order input amount larger than the remaining" - }, - { - "code": 6029, - "name": "PermissionRequiredPermissionlessNotEnabled", - "msg": "Permissionless order taking not enabled, please provide permission account" - }, - { - "code": 6030, - "name": "PermissionDoesNotMatchOrder", - "msg": "Permission address does not match order address" - }, - { - "code": 6031, - "name": "InvalidAtaAddress", - "msg": "Invalid ata address" - }, - { - "code": 6032, - "name": "MakerOutputAtaRequired", - "msg": "Maker output ata required when output mint is not WSOL" - }, - { - "code": 6033, - "name": "IntermediaryOutputTokenAccountRequired", - "msg": "Intermediary output token account required when output mint is WSOL" - }, - { - "code": 6034, - "name": "NotEnoughBalanceForRent", - "msg": "Not enough balance for rent" - }, - { - "code": 6035, - "name": "NotEnoughTimePassedSinceLastUpdate", - "msg": "Order can not be closed - Not enough time passed since last update" - }, - { - "code": 6036, - "name": "OrderSameMint", - "msg": "Order input and output mints are the same" - }, - { - "code": 6037, - "name": "UnsupportedTokenExtension", - "msg": "Mint has a token (2022) extension that is not supported" - }, - { - "code": 6038, - "name": "InvalidTokenAccount", - "msg": "Can't have an spl token mint with a t22 account" - }, - { - "code": 6039, - "name": "OrderTypeInvalid", - "msg": "The order type is invalid" - }, - { - "code": 6040, - "name": "UninitializedTokenAccount", - "msg": "Token account is not initialized" - }, - { - "code": 6041, - "name": "InvalidTokenAccountOwner", - "msg": "Account is not owned by the token program" - }, - { - "code": 6042, - "name": "InvalidAccount", - "msg": "Account is not a valid token account" - }, - { - "code": 6043, - "name": "InvalidTokenMint", - "msg": "Token account has incorrect mint" - }, - { - "code": 6044, - "name": "InvalidTokenAuthority", - "msg": "Token account has incorrect authority" - } - ] -} diff --git a/crates/kamino-limit-orders-parser/proto/kamino_limit_orders.proto b/crates/kamino-limit-orders-parser/proto/kamino_limit_orders.proto deleted file mode 100644 index e9156adb..00000000 --- a/crates/kamino-limit-orders-parser/proto/kamino_limit_orders.proto +++ /dev/null @@ -1,412 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.kamino_limit_orders; - -message UpdateGlobalConfigValueBool { - bool field_0 = 1; -} - -message UpdateGlobalConfigValueU16 { - uint32 field_0 = 1; -} - -message UpdateGlobalConfigValueU64 { - uint64 field_0 = 1; -} - -message UpdateGlobalConfigValuePubkey { - string field_0 = 1; -} - -message InitializeGlobalConfigIx { - InitializeGlobalConfigIxAccounts accounts = 1; -} - -message InitializeVaultIx { - InitializeVaultIxAccounts accounts = 1; -} - -message CreateOrderIx { - CreateOrderIxAccounts accounts = 1; - CreateOrderIxData data = 2; -} - -message CloseOrderAndClaimTipIx { - CloseOrderAndClaimTipIxAccounts accounts = 1; -} - -message TakeOrderIx { - TakeOrderIxAccounts accounts = 1; - TakeOrderIxData data = 2; -} - -message FlashTakeOrderStartIx { - FlashTakeOrderStartIxAccounts accounts = 1; - FlashTakeOrderStartIxData data = 2; -} - -message FlashTakeOrderEndIx { - FlashTakeOrderEndIxAccounts accounts = 1; - FlashTakeOrderEndIxData data = 2; -} - -message UpdateGlobalConfigIx { - UpdateGlobalConfigIxAccounts accounts = 1; - UpdateGlobalConfigIxData data = 2; -} - -message UpdateGlobalConfigAdminIx { - UpdateGlobalConfigAdminIxAccounts accounts = 1; -} - -message WithdrawHostTipIx { - WithdrawHostTipIxAccounts accounts = 1; -} - -message LogUserSwapBalancesStartIx { - LogUserSwapBalancesStartIxAccounts accounts = 1; -} - -message LogUserSwapBalancesEndIx { - LogUserSwapBalancesEndIxAccounts accounts = 1; - LogUserSwapBalancesEndIxData data = 2; -} - - -enum OrderStatus { - OrderStatusActive = 0; - OrderStatusFilled = 1; - OrderStatusCancelled = 2; -} - -enum OrderType { - OrderTypeVanilla = 0; -} - -enum UpdateGlobalConfigMode { - UpdateGlobalConfigModeUpdateEmergencyMode = 0; - UpdateGlobalConfigModeUpdateFlashTakeOrderBlocked = 1; - UpdateGlobalConfigModeUpdateBlockNewOrders = 2; - UpdateGlobalConfigModeUpdateBlockOrderTaking = 3; - UpdateGlobalConfigModeUpdateHostFeeBps = 4; - UpdateGlobalConfigModeUpdateAdminAuthorityCached = 5; - UpdateGlobalConfigModeUpdateOrderTakingPermissionless = 6; - UpdateGlobalConfigModeUpdateOrderCloseDelaySeconds = 7; - UpdateGlobalConfigModeUpdateTxnFeeCost = 8; - UpdateGlobalConfigModeUpdateAtaCreationCost = 9; -} - -message UpdateGlobalConfigValue { - oneof variant{ - UpdateGlobalConfigValueBool bool = 1; - UpdateGlobalConfigValueU16 u16 = 2; - UpdateGlobalConfigValueU64 u64 = 3; - UpdateGlobalConfigValuePubkey pubkey = 4; - } -} - - -message Order { - string global_config = 1; - string maker = 2; - string input_mint = 3; - string input_mint_program_id = 4; - string output_mint = 5; - string output_mint_program_id = 6; - uint64 initial_input_amount = 7; - uint64 expected_output_amount = 8; - uint64 remaining_input_amount = 9; - uint64 filled_output_amount = 10; - uint64 tip_amount = 11; - uint64 number_of_fills = 12; - uint32 order_type = 13; - uint32 status = 14; - uint32 in_vault_bump = 15; - uint32 flash_ix_lock = 16; - repeated uint32 padding0 = 17; - uint64 last_updated_timestamp = 18; - uint64 flash_start_taker_output_balance = 19; - repeated uint64 padding = 20; -} - -message UserSwapBalancesState { - uint64 user_lamports = 1; - uint64 input_ta_balance = 2; - uint64 output_ta_balance = 3; -} - -message GlobalConfig { - uint32 emergency_mode = 1; - uint32 flash_take_order_blocked = 2; - uint32 new_orders_blocked = 3; - uint32 orders_taking_blocked = 4; - uint32 host_fee_bps = 5; - uint32 is_order_taking_permissionless = 6; - repeated uint32 padding0 = 7; - uint64 order_close_delay_seconds = 8; - repeated uint64 padding1 = 9; - uint64 pda_authority_previous_lamports_balance = 10; - uint64 total_tip_amount = 11; - uint64 host_tip_amount = 12; - string pda_authority = 13; - uint64 pda_authority_bump = 14; - string admin_authority = 15; - string admin_authority_cached = 16; - uint64 txn_fee_cost = 17; - uint64 ata_creation_cost = 18; - repeated uint64 padding2 = 19; -} - - -message InitializeGlobalConfigIxAccounts { - string admin_authority = 1; - string pda_authority = 2; - string global_config = 3; -} - - -message InitializeVaultIxAccounts { - string payer = 1; - string global_config = 2; - string pda_authority = 3; - string mint = 4; - string vault = 5; - string token_program = 6; - string system_program = 7; -} - - -message CreateOrderIxAccounts { - string maker = 1; - string global_config = 2; - string pda_authority = 3; - string order = 4; - string input_mint = 5; - string output_mint = 6; - string maker_ata = 7; - string input_vault = 8; - string input_token_program = 9; - string output_token_program = 10; - string system_program = 11; - string event_authority = 12; - string program = 13; -} - -message CreateOrderIxData { - uint64 input_amount = 1; - uint64 output_amount = 2; - uint32 order_type = 3; -} - -message CloseOrderAndClaimTipIxAccounts { - string maker = 1; - string order = 2; - string global_config = 3; - string pda_authority = 4; - string input_mint = 5; - string output_mint = 6; - string maker_input_ata = 7; - string input_vault = 8; - string input_token_program = 9; - string system_program = 10; - string event_authority = 11; - string program = 12; -} - - -message TakeOrderIxAccounts { - string taker = 1; - string maker = 2; - string global_config = 3; - string pda_authority = 4; - string order = 5; - string input_mint = 6; - string output_mint = 7; - string input_vault = 8; - string taker_input_ata = 9; - string taker_output_ata = 10; - optional string intermediary_output_token_account = 11; - optional string maker_output_ata = 12; - string express_relay = 13; - string express_relay_metadata = 14; - string sysvar_instructions = 15; - optional string permission = 16; - string config_router = 17; - string input_token_program = 18; - string output_token_program = 19; - string rent = 20; - string system_program = 21; - string event_authority = 22; - string program = 23; -} - -message TakeOrderIxData { - uint64 input_amount = 1; - uint64 min_output_amount = 2; - uint64 tip_amount_permissionless_taking = 3; -} - -message FlashTakeOrderStartIxAccounts { - string taker = 1; - string maker = 2; - string global_config = 3; - string pda_authority = 4; - string order = 5; - string input_mint = 6; - string output_mint = 7; - string input_vault = 8; - string taker_input_ata = 9; - string taker_output_ata = 10; - optional string intermediary_output_token_account = 11; - optional string maker_output_ata = 12; - string express_relay = 13; - string express_relay_metadata = 14; - string sysvar_instructions = 15; - optional string permission = 16; - string config_router = 17; - string input_token_program = 18; - string output_token_program = 19; - string system_program = 20; - string rent = 21; - string event_authority = 22; - string program = 23; -} - -message FlashTakeOrderStartIxData { - uint64 input_amount = 1; - uint64 min_output_amount = 2; - uint64 tip_amount_permissionless_taking = 3; -} - -message FlashTakeOrderEndIxAccounts { - string taker = 1; - string maker = 2; - string global_config = 3; - string pda_authority = 4; - string order = 5; - string input_mint = 6; - string output_mint = 7; - string input_vault = 8; - string taker_input_ata = 9; - string taker_output_ata = 10; - optional string intermediary_output_token_account = 11; - optional string maker_output_ata = 12; - string express_relay = 13; - string express_relay_metadata = 14; - string sysvar_instructions = 15; - optional string permission = 16; - string config_router = 17; - string input_token_program = 18; - string output_token_program = 19; - string system_program = 20; - string rent = 21; - string event_authority = 22; - string program = 23; -} - -message FlashTakeOrderEndIxData { - uint64 input_amount = 1; - uint64 min_output_amount = 2; - uint64 tip_amount_permissionless_taking = 3; -} - -message UpdateGlobalConfigIxAccounts { - string admin_authority = 1; - string global_config = 2; -} - -message UpdateGlobalConfigIxData { - uint32 mode = 1; - repeated uint32 value = 2; -} - -message UpdateGlobalConfigAdminIxAccounts { - string admin_authority_cached = 1; - string global_config = 2; -} - - -message WithdrawHostTipIxAccounts { - string admin_authority = 1; - string global_config = 2; - string pda_authority = 3; - string system_program = 4; -} - - -message LogUserSwapBalancesStartIxAccounts { - string maker = 1; - string input_mint = 2; - string output_mint = 3; - string input_ta = 4; - string output_ta = 5; - optional string pda_referrer = 6; - string swap_program_id = 7; - string user_swap_balance_state = 8; - string system_program = 9; - string rent = 10; - string sysvar_instructions = 11; - string event_authority = 12; - string program = 13; -} - - -message LogUserSwapBalancesEndIxAccounts { - string maker = 1; - string input_mint = 2; - string output_mint = 3; - string input_ta = 4; - string output_ta = 5; - optional string pda_referrer = 6; - string swap_program_id = 7; - string user_swap_balance_state = 8; - string system_program = 9; - string rent = 10; - string sysvar_instructions = 11; - string event_authority = 12; - string program = 13; -} - -message LogUserSwapBalancesEndIxData { - uint64 simulated_swap_amount_out = 1; - uint64 simulated_ts = 2; - uint64 minimum_amount_out = 3; - uint64 swap_amount_in = 4; - uint64 simulated_amount_out_next_best = 5; - uint32 aggregator = 6; - uint32 next_best_aggregator = 7; - repeated uint32 padding = 8; -} - - -message ProgramState { - oneof state_oneof { - Order order = 1; - UserSwapBalancesState user_swap_balances_state = 2; - GlobalConfig global_config = 3; - } -} - -message ProgramIxs { - oneof ix_oneof { - InitializeGlobalConfigIx initialize_global_config = 1; - InitializeVaultIx initialize_vault = 2; - CreateOrderIx create_order = 3; - CloseOrderAndClaimTipIx close_order_and_claim_tip = 4; - TakeOrderIx take_order = 5; - FlashTakeOrderStartIx flash_take_order_start = 6; - FlashTakeOrderEndIx flash_take_order_end = 7; - UpdateGlobalConfigIx update_global_config = 8; - UpdateGlobalConfigAdminIx update_global_config_admin = 9; - WithdrawHostTipIx withdraw_host_tip = 10; - LogUserSwapBalancesStartIx log_user_swap_balances_start = 11; - LogUserSwapBalancesEndIx log_user_swap_balances_end = 12; - } -} - diff --git a/crates/kamino-limit-orders-parser/src/generated_parser/accounts_parser.rs b/crates/kamino-limit-orders-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index a3fe7189..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,210 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{GlobalConfig, Order, UserSwapBalancesState}, - deserialize_checked, ID, -}; - -/// Limo Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum LimoProgramState { - Order(Order), - UserSwapBalancesState(UserSwapBalancesState), - GlobalConfig(GlobalConfig), -} - -impl LimoProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [134, 173, 223, 185, 77, 86, 28, 51] => Ok(LimoProgramState::Order( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [140, 228, 152, 62, 231, 27, 245, 198] => Ok(LimoProgramState::UserSwapBalancesState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [149, 8, 156, 202, 160, 252, 176, 217] => Ok(LimoProgramState::GlobalConfig( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = LimoProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "limo::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = LimoProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, LimoProgramState, Order}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for Order { - fn into_proto(self) -> proto_def::Order { - proto_def::Order { - global_config: self.global_config.to_string(), - maker: self.maker.to_string(), - input_mint: self.input_mint.to_string(), - input_mint_program_id: self.input_mint_program_id.to_string(), - output_mint: self.output_mint.to_string(), - output_mint_program_id: self.output_mint_program_id.to_string(), - initial_input_amount: self.initial_input_amount, - expected_output_amount: self.expected_output_amount, - remaining_input_amount: self.remaining_input_amount, - filled_output_amount: self.filled_output_amount, - tip_amount: self.tip_amount, - number_of_fills: self.number_of_fills, - order_type: self.order_type.into(), - status: self.status.into(), - in_vault_bump: self.in_vault_bump.into(), - flash_ix_lock: self.flash_ix_lock.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - last_updated_timestamp: self.last_updated_timestamp, - flash_start_taker_output_balance: self.flash_start_taker_output_balance, - padding: self.padding.to_vec(), - } - } - } - use super::UserSwapBalancesState; - impl IntoProto for UserSwapBalancesState { - fn into_proto(self) -> proto_def::UserSwapBalancesState { - proto_def::UserSwapBalancesState { - user_lamports: self.user_lamports, - input_ta_balance: self.input_ta_balance, - output_ta_balance: self.output_ta_balance, - } - } - } - use super::GlobalConfig; - impl IntoProto for GlobalConfig { - fn into_proto(self) -> proto_def::GlobalConfig { - proto_def::GlobalConfig { - emergency_mode: self.emergency_mode.into(), - flash_take_order_blocked: self.flash_take_order_blocked.into(), - new_orders_blocked: self.new_orders_blocked.into(), - orders_taking_blocked: self.orders_taking_blocked.into(), - host_fee_bps: self.host_fee_bps.into(), - is_order_taking_permissionless: self.is_order_taking_permissionless.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - order_close_delay_seconds: self.order_close_delay_seconds, - padding1: self.padding1.to_vec(), - pda_authority_previous_lamports_balance: self - .pda_authority_previous_lamports_balance, - total_tip_amount: self.total_tip_amount, - host_tip_amount: self.host_tip_amount, - pda_authority: self.pda_authority.to_string(), - pda_authority_bump: self.pda_authority_bump, - admin_authority: self.admin_authority.to_string(), - admin_authority_cached: self.admin_authority_cached.to_string(), - txn_fee_cost: self.txn_fee_cost, - ata_creation_cost: self.ata_creation_cost, - padding2: self.padding2.to_vec(), - } - } - } - - impl IntoProto for LimoProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - LimoProgramState::Order(data) => { - proto_def::program_state::StateOneof::Order(data.into_proto()) - }, - LimoProgramState::UserSwapBalancesState(data) => { - proto_def::program_state::StateOneof::UserSwapBalancesState(data.into_proto()) - }, - LimoProgramState::GlobalConfig(data) => { - proto_def::program_state::StateOneof::GlobalConfig(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/kamino-limit-orders-parser/src/generated_parser/instructions_parser.rs b/crates/kamino-limit-orders-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index c25dde7c..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,861 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - CloseOrderAndClaimTip as CloseOrderAndClaimTipIxAccounts, - CreateOrder as CreateOrderIxAccounts, CreateOrderInstructionArgs as CreateOrderIxData, - FlashTakeOrderEnd as FlashTakeOrderEndIxAccounts, - FlashTakeOrderEndInstructionArgs as FlashTakeOrderEndIxData, - FlashTakeOrderStart as FlashTakeOrderStartIxAccounts, - FlashTakeOrderStartInstructionArgs as FlashTakeOrderStartIxData, - InitializeGlobalConfig as InitializeGlobalConfigIxAccounts, - InitializeVault as InitializeVaultIxAccounts, - LogUserSwapBalancesEnd as LogUserSwapBalancesEndIxAccounts, - LogUserSwapBalancesEndInstructionArgs as LogUserSwapBalancesEndIxData, - LogUserSwapBalancesStart as LogUserSwapBalancesStartIxAccounts, - TakeOrder as TakeOrderIxAccounts, TakeOrderInstructionArgs as TakeOrderIxData, - UpdateGlobalConfig as UpdateGlobalConfigIxAccounts, - UpdateGlobalConfigAdmin as UpdateGlobalConfigAdminIxAccounts, - UpdateGlobalConfigInstructionArgs as UpdateGlobalConfigIxData, - WithdrawHostTip as WithdrawHostTipIxAccounts, - }, - ID, -}; - -/// Limo Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum LimoProgramIx { - InitializeGlobalConfig(InitializeGlobalConfigIxAccounts), - InitializeVault(InitializeVaultIxAccounts), - CreateOrder(CreateOrderIxAccounts, CreateOrderIxData), - CloseOrderAndClaimTip(CloseOrderAndClaimTipIxAccounts), - TakeOrder(TakeOrderIxAccounts, TakeOrderIxData), - FlashTakeOrderStart(FlashTakeOrderStartIxAccounts, FlashTakeOrderStartIxData), - FlashTakeOrderEnd(FlashTakeOrderEndIxAccounts, FlashTakeOrderEndIxData), - UpdateGlobalConfig(UpdateGlobalConfigIxAccounts, UpdateGlobalConfigIxData), - UpdateGlobalConfigAdmin(UpdateGlobalConfigAdminIxAccounts), - WithdrawHostTip(WithdrawHostTipIxAccounts), - LogUserSwapBalancesStart(LogUserSwapBalancesStartIxAccounts), - LogUserSwapBalancesEnd( - LogUserSwapBalancesEndIxAccounts, - LogUserSwapBalancesEndIxData, - ), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = LimoProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "Limo::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [113, 216, 122, 131, 225, 209, 22, 55] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeGlobalConfigIxAccounts { - admin_authority: next_account(accounts)?, - pda_authority: next_account(accounts)?, - global_config: next_account(accounts)?, - }; - Ok(LimoProgramIx::InitializeGlobalConfig(ix_accounts)) - }, - [48, 191, 163, 44, 71, 129, 63, 164] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeVaultIxAccounts { - payer: next_account(accounts)?, - global_config: next_account(accounts)?, - pda_authority: next_account(accounts)?, - mint: next_account(accounts)?, - vault: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(LimoProgramIx::InitializeVault(ix_accounts)) - }, - [141, 54, 37, 207, 237, 210, 250, 215] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateOrderIxAccounts { - maker: next_account(accounts)?, - global_config: next_account(accounts)?, - pda_authority: next_account(accounts)?, - order: next_account(accounts)?, - input_mint: next_account(accounts)?, - output_mint: next_account(accounts)?, - maker_ata: next_account(accounts)?, - input_vault: next_account(accounts)?, - input_token_program: next_account(accounts)?, - output_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: CreateOrderIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LimoProgramIx::CreateOrder(ix_accounts, de_ix_data)) - }, - [244, 27, 12, 226, 45, 247, 230, 43] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CloseOrderAndClaimTipIxAccounts { - maker: next_account(accounts)?, - order: next_account(accounts)?, - global_config: next_account(accounts)?, - pda_authority: next_account(accounts)?, - input_mint: next_account(accounts)?, - output_mint: next_account(accounts)?, - maker_input_ata: next_account(accounts)?, - input_vault: next_account(accounts)?, - input_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(LimoProgramIx::CloseOrderAndClaimTip(ix_accounts)) - }, - [163, 208, 20, 172, 223, 65, 255, 228] => { - let expected_accounts_len = 23; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = TakeOrderIxAccounts { - taker: next_account(accounts)?, - maker: next_account(accounts)?, - global_config: next_account(accounts)?, - pda_authority: next_account(accounts)?, - order: next_account(accounts)?, - input_mint: next_account(accounts)?, - output_mint: next_account(accounts)?, - input_vault: next_account(accounts)?, - taker_input_ata: next_account(accounts)?, - taker_output_ata: next_account(accounts)?, - intermediary_output_token_account: next_program_id_optional_account(accounts)?, - maker_output_ata: next_program_id_optional_account(accounts)?, - express_relay: next_account(accounts)?, - express_relay_metadata: next_account(accounts)?, - sysvar_instructions: next_account(accounts)?, - permission: next_program_id_optional_account(accounts)?, - config_router: next_account(accounts)?, - input_token_program: next_account(accounts)?, - output_token_program: next_account(accounts)?, - rent: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: TakeOrderIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LimoProgramIx::TakeOrder(ix_accounts, de_ix_data)) - }, - [126, 53, 176, 15, 39, 103, 97, 243] => { - let expected_accounts_len = 23; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = FlashTakeOrderStartIxAccounts { - taker: next_account(accounts)?, - maker: next_account(accounts)?, - global_config: next_account(accounts)?, - pda_authority: next_account(accounts)?, - order: next_account(accounts)?, - input_mint: next_account(accounts)?, - output_mint: next_account(accounts)?, - input_vault: next_account(accounts)?, - taker_input_ata: next_account(accounts)?, - taker_output_ata: next_account(accounts)?, - intermediary_output_token_account: next_program_id_optional_account(accounts)?, - maker_output_ata: next_program_id_optional_account(accounts)?, - express_relay: next_account(accounts)?, - express_relay_metadata: next_account(accounts)?, - sysvar_instructions: next_account(accounts)?, - permission: next_program_id_optional_account(accounts)?, - config_router: next_account(accounts)?, - input_token_program: next_account(accounts)?, - output_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: FlashTakeOrderStartIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LimoProgramIx::FlashTakeOrderStart(ix_accounts, de_ix_data)) - }, - [206, 242, 215, 187, 134, 33, 224, 148] => { - let expected_accounts_len = 23; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = FlashTakeOrderEndIxAccounts { - taker: next_account(accounts)?, - maker: next_account(accounts)?, - global_config: next_account(accounts)?, - pda_authority: next_account(accounts)?, - order: next_account(accounts)?, - input_mint: next_account(accounts)?, - output_mint: next_account(accounts)?, - input_vault: next_account(accounts)?, - taker_input_ata: next_account(accounts)?, - taker_output_ata: next_account(accounts)?, - intermediary_output_token_account: next_program_id_optional_account(accounts)?, - maker_output_ata: next_program_id_optional_account(accounts)?, - express_relay: next_account(accounts)?, - express_relay_metadata: next_account(accounts)?, - sysvar_instructions: next_account(accounts)?, - permission: next_program_id_optional_account(accounts)?, - config_router: next_account(accounts)?, - input_token_program: next_account(accounts)?, - output_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: FlashTakeOrderEndIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LimoProgramIx::FlashTakeOrderEnd(ix_accounts, de_ix_data)) - }, - [164, 84, 130, 189, 111, 58, 250, 200] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateGlobalConfigIxAccounts { - admin_authority: next_account(accounts)?, - global_config: next_account(accounts)?, - }; - let de_ix_data: UpdateGlobalConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LimoProgramIx::UpdateGlobalConfig(ix_accounts, de_ix_data)) - }, - [184, 87, 23, 193, 156, 238, 175, 119] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateGlobalConfigAdminIxAccounts { - admin_authority_cached: next_account(accounts)?, - global_config: next_account(accounts)?, - }; - Ok(LimoProgramIx::UpdateGlobalConfigAdmin(ix_accounts)) - }, - [140, 246, 105, 165, 80, 85, 143, 18] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawHostTipIxAccounts { - admin_authority: next_account(accounts)?, - global_config: next_account(accounts)?, - pda_authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(LimoProgramIx::WithdrawHostTip(ix_accounts)) - }, - [133, 108, 23, 15, 226, 215, 176, 95] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = LogUserSwapBalancesStartIxAccounts { - maker: next_account(accounts)?, - input_mint: next_account(accounts)?, - output_mint: next_account(accounts)?, - input_ta: next_account(accounts)?, - output_ta: next_account(accounts)?, - pda_referrer: next_program_id_optional_account(accounts)?, - swap_program_id: next_account(accounts)?, - user_swap_balance_state: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - sysvar_instructions: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(LimoProgramIx::LogUserSwapBalancesStart(ix_accounts)) - }, - [140, 42, 198, 82, 147, 144, 44, 113] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = LogUserSwapBalancesEndIxAccounts { - maker: next_account(accounts)?, - input_mint: next_account(accounts)?, - output_mint: next_account(accounts)?, - input_ta: next_account(accounts)?, - output_ta: next_account(accounts)?, - pda_referrer: next_program_id_optional_account(accounts)?, - swap_program_id: next_account(accounts)?, - user_swap_balance_state: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - sysvar_instructions: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: LogUserSwapBalancesEndIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LimoProgramIx::LogUserSwapBalancesEnd( - ix_accounts, - de_ix_data, - )) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{InitializeGlobalConfigIxAccounts, InstructionParser, LimoProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for InitializeGlobalConfigIxAccounts { - fn into_proto(self) -> proto_def::InitializeGlobalConfigIxAccounts { - proto_def::InitializeGlobalConfigIxAccounts { - admin_authority: self.admin_authority.to_string(), - pda_authority: self.pda_authority.to_string(), - global_config: self.global_config.to_string(), - } - } - } - use super::InitializeVaultIxAccounts; - impl IntoProto for InitializeVaultIxAccounts { - fn into_proto(self) -> proto_def::InitializeVaultIxAccounts { - proto_def::InitializeVaultIxAccounts { - payer: self.payer.to_string(), - global_config: self.global_config.to_string(), - pda_authority: self.pda_authority.to_string(), - mint: self.mint.to_string(), - vault: self.vault.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreateOrderIxAccounts; - impl IntoProto for CreateOrderIxAccounts { - fn into_proto(self) -> proto_def::CreateOrderIxAccounts { - proto_def::CreateOrderIxAccounts { - maker: self.maker.to_string(), - global_config: self.global_config.to_string(), - pda_authority: self.pda_authority.to_string(), - order: self.order.to_string(), - input_mint: self.input_mint.to_string(), - output_mint: self.output_mint.to_string(), - maker_ata: self.maker_ata.to_string(), - input_vault: self.input_vault.to_string(), - input_token_program: self.input_token_program.to_string(), - output_token_program: self.output_token_program.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateOrderIxData; - impl IntoProto for CreateOrderIxData { - fn into_proto(self) -> proto_def::CreateOrderIxData { - proto_def::CreateOrderIxData { - input_amount: self.input_amount, - output_amount: self.output_amount, - order_type: self.order_type.into(), - } - } - } - use super::CloseOrderAndClaimTipIxAccounts; - impl IntoProto for CloseOrderAndClaimTipIxAccounts { - fn into_proto(self) -> proto_def::CloseOrderAndClaimTipIxAccounts { - proto_def::CloseOrderAndClaimTipIxAccounts { - maker: self.maker.to_string(), - order: self.order.to_string(), - global_config: self.global_config.to_string(), - pda_authority: self.pda_authority.to_string(), - input_mint: self.input_mint.to_string(), - output_mint: self.output_mint.to_string(), - maker_input_ata: self.maker_input_ata.to_string(), - input_vault: self.input_vault.to_string(), - input_token_program: self.input_token_program.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::TakeOrderIxAccounts; - impl IntoProto for TakeOrderIxAccounts { - fn into_proto(self) -> proto_def::TakeOrderIxAccounts { - proto_def::TakeOrderIxAccounts { - taker: self.taker.to_string(), - maker: self.maker.to_string(), - global_config: self.global_config.to_string(), - pda_authority: self.pda_authority.to_string(), - order: self.order.to_string(), - input_mint: self.input_mint.to_string(), - output_mint: self.output_mint.to_string(), - input_vault: self.input_vault.to_string(), - taker_input_ata: self.taker_input_ata.to_string(), - taker_output_ata: self.taker_output_ata.to_string(), - intermediary_output_token_account: self - .intermediary_output_token_account - .map(|p| p.to_string()), - maker_output_ata: self.maker_output_ata.map(|p| p.to_string()), - express_relay: self.express_relay.to_string(), - express_relay_metadata: self.express_relay_metadata.to_string(), - sysvar_instructions: self.sysvar_instructions.to_string(), - permission: self.permission.map(|p| p.to_string()), - config_router: self.config_router.to_string(), - input_token_program: self.input_token_program.to_string(), - output_token_program: self.output_token_program.to_string(), - rent: self.rent.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::TakeOrderIxData; - impl IntoProto for TakeOrderIxData { - fn into_proto(self) -> proto_def::TakeOrderIxData { - proto_def::TakeOrderIxData { - input_amount: self.input_amount, - min_output_amount: self.min_output_amount, - tip_amount_permissionless_taking: self.tip_amount_permissionless_taking, - } - } - } - use super::FlashTakeOrderStartIxAccounts; - impl IntoProto for FlashTakeOrderStartIxAccounts { - fn into_proto(self) -> proto_def::FlashTakeOrderStartIxAccounts { - proto_def::FlashTakeOrderStartIxAccounts { - taker: self.taker.to_string(), - maker: self.maker.to_string(), - global_config: self.global_config.to_string(), - pda_authority: self.pda_authority.to_string(), - order: self.order.to_string(), - input_mint: self.input_mint.to_string(), - output_mint: self.output_mint.to_string(), - input_vault: self.input_vault.to_string(), - taker_input_ata: self.taker_input_ata.to_string(), - taker_output_ata: self.taker_output_ata.to_string(), - intermediary_output_token_account: self - .intermediary_output_token_account - .map(|p| p.to_string()), - maker_output_ata: self.maker_output_ata.map(|p| p.to_string()), - express_relay: self.express_relay.to_string(), - express_relay_metadata: self.express_relay_metadata.to_string(), - sysvar_instructions: self.sysvar_instructions.to_string(), - permission: self.permission.map(|p| p.to_string()), - config_router: self.config_router.to_string(), - input_token_program: self.input_token_program.to_string(), - output_token_program: self.output_token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::FlashTakeOrderStartIxData; - impl IntoProto for FlashTakeOrderStartIxData { - fn into_proto(self) -> proto_def::FlashTakeOrderStartIxData { - proto_def::FlashTakeOrderStartIxData { - input_amount: self.input_amount, - min_output_amount: self.min_output_amount, - tip_amount_permissionless_taking: self.tip_amount_permissionless_taking, - } - } - } - use super::FlashTakeOrderEndIxAccounts; - impl IntoProto for FlashTakeOrderEndIxAccounts { - fn into_proto(self) -> proto_def::FlashTakeOrderEndIxAccounts { - proto_def::FlashTakeOrderEndIxAccounts { - taker: self.taker.to_string(), - maker: self.maker.to_string(), - global_config: self.global_config.to_string(), - pda_authority: self.pda_authority.to_string(), - order: self.order.to_string(), - input_mint: self.input_mint.to_string(), - output_mint: self.output_mint.to_string(), - input_vault: self.input_vault.to_string(), - taker_input_ata: self.taker_input_ata.to_string(), - taker_output_ata: self.taker_output_ata.to_string(), - intermediary_output_token_account: self - .intermediary_output_token_account - .map(|p| p.to_string()), - maker_output_ata: self.maker_output_ata.map(|p| p.to_string()), - express_relay: self.express_relay.to_string(), - express_relay_metadata: self.express_relay_metadata.to_string(), - sysvar_instructions: self.sysvar_instructions.to_string(), - permission: self.permission.map(|p| p.to_string()), - config_router: self.config_router.to_string(), - input_token_program: self.input_token_program.to_string(), - output_token_program: self.output_token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::FlashTakeOrderEndIxData; - impl IntoProto for FlashTakeOrderEndIxData { - fn into_proto(self) -> proto_def::FlashTakeOrderEndIxData { - proto_def::FlashTakeOrderEndIxData { - input_amount: self.input_amount, - min_output_amount: self.min_output_amount, - tip_amount_permissionless_taking: self.tip_amount_permissionless_taking, - } - } - } - use super::UpdateGlobalConfigIxAccounts; - impl IntoProto for UpdateGlobalConfigIxAccounts { - fn into_proto(self) -> proto_def::UpdateGlobalConfigIxAccounts { - proto_def::UpdateGlobalConfigIxAccounts { - admin_authority: self.admin_authority.to_string(), - global_config: self.global_config.to_string(), - } - } - } - use super::UpdateGlobalConfigIxData; - impl IntoProto for UpdateGlobalConfigIxData { - fn into_proto(self) -> proto_def::UpdateGlobalConfigIxData { - proto_def::UpdateGlobalConfigIxData { - mode: self.mode.into(), - value: self.value.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::UpdateGlobalConfigAdminIxAccounts; - impl IntoProto for UpdateGlobalConfigAdminIxAccounts { - fn into_proto(self) -> proto_def::UpdateGlobalConfigAdminIxAccounts { - proto_def::UpdateGlobalConfigAdminIxAccounts { - admin_authority_cached: self.admin_authority_cached.to_string(), - global_config: self.global_config.to_string(), - } - } - } - use super::WithdrawHostTipIxAccounts; - impl IntoProto for WithdrawHostTipIxAccounts { - fn into_proto(self) -> proto_def::WithdrawHostTipIxAccounts { - proto_def::WithdrawHostTipIxAccounts { - admin_authority: self.admin_authority.to_string(), - global_config: self.global_config.to_string(), - pda_authority: self.pda_authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::LogUserSwapBalancesStartIxAccounts; - impl IntoProto - for LogUserSwapBalancesStartIxAccounts - { - fn into_proto(self) -> proto_def::LogUserSwapBalancesStartIxAccounts { - proto_def::LogUserSwapBalancesStartIxAccounts { - maker: self.maker.to_string(), - input_mint: self.input_mint.to_string(), - output_mint: self.output_mint.to_string(), - input_ta: self.input_ta.to_string(), - output_ta: self.output_ta.to_string(), - pda_referrer: self.pda_referrer.map(|p| p.to_string()), - swap_program_id: self.swap_program_id.to_string(), - user_swap_balance_state: self.user_swap_balance_state.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - sysvar_instructions: self.sysvar_instructions.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::LogUserSwapBalancesEndIxAccounts; - impl IntoProto for LogUserSwapBalancesEndIxAccounts { - fn into_proto(self) -> proto_def::LogUserSwapBalancesEndIxAccounts { - proto_def::LogUserSwapBalancesEndIxAccounts { - maker: self.maker.to_string(), - input_mint: self.input_mint.to_string(), - output_mint: self.output_mint.to_string(), - input_ta: self.input_ta.to_string(), - output_ta: self.output_ta.to_string(), - pda_referrer: self.pda_referrer.map(|p| p.to_string()), - swap_program_id: self.swap_program_id.to_string(), - user_swap_balance_state: self.user_swap_balance_state.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - sysvar_instructions: self.sysvar_instructions.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::LogUserSwapBalancesEndIxData; - impl IntoProto for LogUserSwapBalancesEndIxData { - fn into_proto(self) -> proto_def::LogUserSwapBalancesEndIxData { - proto_def::LogUserSwapBalancesEndIxData { - simulated_swap_amount_out: self.simulated_swap_amount_out, - simulated_ts: self.simulated_ts, - minimum_amount_out: self.minimum_amount_out, - swap_amount_in: self.swap_amount_in, - simulated_amount_out_next_best: self.simulated_amount_out_next_best, - aggregator: self.aggregator.into(), - next_best_aggregator: self.next_best_aggregator.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - - impl IntoProto for LimoProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - LimoProgramIx::InitializeGlobalConfig(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeGlobalConfig( - proto_def::InitializeGlobalConfigIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - LimoProgramIx::InitializeVault(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeVault( - proto_def::InitializeVaultIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - LimoProgramIx::CreateOrder(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateOrder( - proto_def::CreateOrderIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - LimoProgramIx::CloseOrderAndClaimTip(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CloseOrderAndClaimTip( - proto_def::CloseOrderAndClaimTipIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - LimoProgramIx::TakeOrder(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::TakeOrder( - proto_def::TakeOrderIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - LimoProgramIx::FlashTakeOrderStart(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::FlashTakeOrderStart( - proto_def::FlashTakeOrderStartIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - LimoProgramIx::FlashTakeOrderEnd(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::FlashTakeOrderEnd( - proto_def::FlashTakeOrderEndIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - LimoProgramIx::UpdateGlobalConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateGlobalConfig( - proto_def::UpdateGlobalConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - LimoProgramIx::UpdateGlobalConfigAdmin(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateGlobalConfigAdmin( - proto_def::UpdateGlobalConfigAdminIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - LimoProgramIx::WithdrawHostTip(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::WithdrawHostTip( - proto_def::WithdrawHostTipIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - LimoProgramIx::LogUserSwapBalancesStart(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::LogUserSwapBalancesStart( - proto_def::LogUserSwapBalancesStartIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - LimoProgramIx::LogUserSwapBalancesEnd(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::LogUserSwapBalancesEnd( - proto_def::LogUserSwapBalancesEndIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/kamino-limit-orders-parser/src/generated_parser/mod.rs b/crates/kamino-limit-orders-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/kamino-limit-orders-parser/src/generated_parser/proto_helpers.rs b/crates/kamino-limit-orders-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index bce7061c..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use proto_def::update_global_config_value; - - use crate::{proto_def, types::UpdateGlobalConfigValue}; - impl IntoProto for UpdateGlobalConfigValue { - fn into_proto(self) -> proto_def::UpdateGlobalConfigValue { - let variant = match self { - UpdateGlobalConfigValue::Bool(field_0) => { - update_global_config_value::Variant::Bool( - proto_def::UpdateGlobalConfigValueBool { field_0 }, - ) - }, - UpdateGlobalConfigValue::U16(field_0) => update_global_config_value::Variant::U16( - proto_def::UpdateGlobalConfigValueU16 { - field_0: field_0.into(), - }, - ), - UpdateGlobalConfigValue::U64(field_0) => update_global_config_value::Variant::U64( - proto_def::UpdateGlobalConfigValueU64 { field_0 }, - ), - UpdateGlobalConfigValue::Pubkey(field_0) => { - update_global_config_value::Variant::Pubkey( - proto_def::UpdateGlobalConfigValuePubkey { - field_0: field_0.to_string(), - }, - ) - }, - }; - - proto_def::UpdateGlobalConfigValue { - variant: Some(variant), - } - } - } -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/global_config.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/global_config.rs deleted file mode 100644 index a75b9462..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/global_config.rs +++ /dev/null @@ -1,167 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct GlobalConfig { - pub discriminator: [u8; 8], - pub emergency_mode: u8, - pub flash_take_order_blocked: u8, - pub new_orders_blocked: u8, - pub orders_taking_blocked: u8, - pub host_fee_bps: u16, - pub is_order_taking_permissionless: u8, - pub padding0: [u8; 1], - /// The number of seconds after an order has been updated before it can be closed - pub order_close_delay_seconds: u64, - pub padding1: [u64; 9], - /// The total amount of lamports that were present in the pda_authority last - /// time a program instructions which alters the pda_authority account was - /// executed - pub pda_authority_previous_lamports_balance: u64, - /// The total amount of tips that have been paid out - should be at least - /// as much as the total lamports present in the pda_authority account - pub total_tip_amount: u64, - /// The amount of tips the host is due to receive - - /// in lamports, stored in the pda_authority account - pub host_tip_amount: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pda_authority: Pubkey, - pub pda_authority_bump: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub admin_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub admin_authority_cached: Pubkey, - pub txn_fee_cost: u64, - pub ata_creation_cost: u64, - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub padding2: [u64; 241], -} - -impl GlobalConfig { - pub const LEN: usize = 2168; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for GlobalConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_global_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_global_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_global_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = GlobalConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_global_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_global_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_global_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = GlobalConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for GlobalConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for GlobalConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for GlobalConfig { - fn owner() -> Pubkey { crate::LIMO_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for GlobalConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for GlobalConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/mod.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index 13d54a32..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#global_config; -pub(crate) mod r#order; -pub(crate) mod r#user_swap_balances_state; - -pub use self::{r#global_config::*, r#order::*, r#user_swap_balances_state::*}; diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/order.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/order.rs deleted file mode 100644 index a5306ebf..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/order.rs +++ /dev/null @@ -1,184 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Order { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub global_config: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub maker: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub input_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub input_mint_program_id: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub output_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub output_mint_program_id: Pubkey, - /// The amount of input token the maker wants to swap - pub initial_input_amount: u64, - /// The amount of output token the maker wants to receive - pub expected_output_amount: u64, - /// The amount of input token remaining to be swapped - pub remaining_input_amount: u64, - /// The amount of output token that the maker has received so far - pub filled_output_amount: u64, - /// The amount of tips the maker is due to receive for this order - - /// in lamports, stored in the pda_authority account - pub tip_amount: u64, - /// The number of times the order has been filled - pub number_of_fills: u64, - pub order_type: u8, - pub status: u8, - pub in_vault_bump: u8, - /// This is normally set to 0, but can be set to 1 to indicate that the - /// order is part of a flash operation, in whcih case the order can not be - /// modified until the flash operation is completed. - pub flash_ix_lock: u8, - pub padding0: [u8; 4], - pub last_updated_timestamp: u64, - /// This is only used for flash operations, and is set to the blanance on the start - /// operation, and than back to 0 on the end operation. It is used to compute the difference - /// between start and end balances in order to compute the amount received from a potential swap - pub flash_start_taker_output_balance: u64, - pub padding: [u64; 19], -} - -impl Order { - pub const LEN: usize = 424; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Order { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_order( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_order(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_order( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Order::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_order( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_order(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_order( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Order::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Order { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Order {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Order { - fn owner() -> Pubkey { crate::LIMO_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Order {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Order { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/user_swap_balances_state.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/user_swap_balances_state.rs deleted file mode 100644 index d5badd02..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/accounts/user_swap_balances_state.rs +++ /dev/null @@ -1,130 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UserSwapBalancesState { - pub discriminator: [u8; 8], - pub user_lamports: u64, - pub input_ta_balance: u64, - pub output_ta_balance: u64, -} - -impl UserSwapBalancesState { - pub const LEN: usize = 32; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for UserSwapBalancesState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_user_swap_balances_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_user_swap_balances_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_user_swap_balances_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = UserSwapBalancesState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_user_swap_balances_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_user_swap_balances_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_user_swap_balances_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = UserSwapBalancesState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for UserSwapBalancesState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for UserSwapBalancesState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for UserSwapBalancesState { - fn owner() -> Pubkey { crate::LIMO_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for UserSwapBalancesState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for UserSwapBalancesState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/errors/limo.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/errors/limo.rs deleted file mode 100644 index 54217335..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/errors/limo.rs +++ /dev/null @@ -1,163 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum LimoError { - /// 6000 - Order can't be canceled - #[error("Order can't be canceled")] - OrderCanNotBeCanceled = 0x1770, - /// 6001 - Order not active - #[error("Order not active")] - OrderNotActive = 0x1771, - /// 6002 - Invalid admin authority - #[error("Invalid admin authority")] - InvalidAdminAuthority = 0x1772, - /// 6003 - Invalid pda authority - #[error("Invalid pda authority")] - InvalidPdaAuthority = 0x1773, - /// 6004 - Invalid config option - #[error("Invalid config option")] - InvalidConfigOption = 0x1774, - /// 6005 - Order owner account is not the order owner - #[error("Order owner account is not the order owner")] - InvalidOrderOwner = 0x1775, - /// 6006 - Out of range integral conversion attempted - #[error("Out of range integral conversion attempted")] - OutOfRangeIntegralConversion = 0x1776, - /// 6007 - Invalid boolean flag, valid values are 0 and 1 - #[error("Invalid boolean flag, valid values are 0 and 1")] - InvalidFlag = 0x1777, - /// 6008 - Mathematical operation with overflow - #[error("Mathematical operation with overflow")] - MathOverflow = 0x1778, - /// 6009 - Order input amount invalid - #[error("Order input amount invalid")] - OrderInputAmountInvalid = 0x1779, - /// 6010 - Order output amount invalid - #[error("Order output amount invalid")] - OrderOutputAmountInvalid = 0x177a, - /// 6011 - Host fee bps must be between 0 and 10000 - #[error("Host fee bps must be between 0 and 10000")] - InvalidHostFee = 0x177b, - /// 6012 - Conversion between integers failed - #[error("Conversion between integers failed")] - IntegerOverflow = 0x177c, - /// 6013 - Tip balance less than accounted tip - #[error("Tip balance less than accounted tip")] - InvalidTipBalance = 0x177d, - /// 6014 - Tip transfer amount is less than expected - #[error("Tip transfer amount is less than expected")] - InvalidTipTransferAmount = 0x177e, - /// 6015 - Host tup amount is less than accounted for - #[error("Host tup amount is less than accounted for")] - InvalidHostTipBalance = 0x177f, - /// 6016 - Order within flash operation - all otehr actions are blocked - #[error("Order within flash operation - all otehr actions are blocked")] - OrderWithinFlashOperation = 0x1780, - /// 6017 - CPI not allowed - #[error("CPI not allowed")] - CPINotAllowed = 0x1781, - /// 6018 - Flash take_order is blocked - #[error("Flash take_order is blocked")] - FlashTakeOrderBlocked = 0x1782, - /// 6019 - Some unexpected instructions are present in the tx. Either before or after the flash ixs, or some ix target the same program between - #[error( - "Some unexpected instructions are present in the tx. Either before or after the flash \ - ixs, or some ix target the same program between" - )] - FlashTxWithUnexpectedIxs = 0x1783, - /// 6020 - Flash ixs initiated without the closing ix in the transaction - #[error("Flash ixs initiated without the closing ix in the transaction")] - FlashIxsNotEnded = 0x1784, - /// 6021 - Flash ixs ended without the starting ix in the transaction - #[error("Flash ixs ended without the starting ix in the transaction")] - FlashIxsNotStarted = 0x1785, - /// 6022 - Some accounts differ between the two flash ixs - #[error("Some accounts differ between the two flash ixs")] - FlashIxsAccountMismatch = 0x1786, - /// 6023 - Some args differ between the two flash ixs - #[error("Some args differ between the two flash ixs")] - FlashIxsArgsMismatch = 0x1787, - /// 6024 - Order is not within flash operation - #[error("Order is not within flash operation")] - OrderNotWithinFlashOperation = 0x1788, - /// 6025 - Emergency mode is enabled - #[error("Emergency mode is enabled")] - EmergencyModeEnabled = 0x1789, - /// 6026 - Creating new ordersis blocked - #[error("Creating new ordersis blocked")] - CreatingNewOrdersBlocked = 0x178a, - /// 6027 - Orders taking is blocked - #[error("Orders taking is blocked")] - OrderTakingBlocked = 0x178b, - /// 6028 - Order input amount larger than the remaining - #[error("Order input amount larger than the remaining")] - OrderInputAmountTooLarge = 0x178c, - /// 6029 - Permissionless order taking not enabled, please provide permission account - #[error("Permissionless order taking not enabled, please provide permission account")] - PermissionRequiredPermissionlessNotEnabled = 0x178d, - /// 6030 - Permission address does not match order address - #[error("Permission address does not match order address")] - PermissionDoesNotMatchOrder = 0x178e, - /// 6031 - Invalid ata address - #[error("Invalid ata address")] - InvalidAtaAddress = 0x178f, - /// 6032 - Maker output ata required when output mint is not WSOL - #[error("Maker output ata required when output mint is not WSOL")] - MakerOutputAtaRequired = 0x1790, - /// 6033 - Intermediary output token account required when output mint is WSOL - #[error("Intermediary output token account required when output mint is WSOL")] - IntermediaryOutputTokenAccountRequired = 0x1791, - /// 6034 - Not enough balance for rent - #[error("Not enough balance for rent")] - NotEnoughBalanceForRent = 0x1792, - /// 6035 - Order can not be closed - Not enough time passed since last update - #[error("Order can not be closed - Not enough time passed since last update")] - NotEnoughTimePassedSinceLastUpdate = 0x1793, - /// 6036 - Order input and output mints are the same - #[error("Order input and output mints are the same")] - OrderSameMint = 0x1794, - /// 6037 - Mint has a token (2022) extension that is not supported - #[error("Mint has a token (2022) extension that is not supported")] - UnsupportedTokenExtension = 0x1795, - /// 6038 - Can't have an spl token mint with a t22 account - #[error("Can't have an spl token mint with a t22 account")] - InvalidTokenAccount = 0x1796, - /// 6039 - The order type is invalid - #[error("The order type is invalid")] - OrderTypeInvalid = 0x1797, - /// 6040 - Token account is not initialized - #[error("Token account is not initialized")] - UninitializedTokenAccount = 0x1798, - /// 6041 - Account is not owned by the token program - #[error("Account is not owned by the token program")] - InvalidTokenAccountOwner = 0x1799, - /// 6042 - Account is not a valid token account - #[error("Account is not a valid token account")] - InvalidAccount = 0x179a, - /// 6043 - Token account has incorrect mint - #[error("Token account has incorrect mint")] - InvalidTokenMint = 0x179b, - /// 6044 - Token account has incorrect authority - #[error("Token account has incorrect authority")] - InvalidTokenAuthority = 0x179c, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for LimoError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for LimoError { - fn type_of() -> &'static str { "LimoError" } -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/errors/mod.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 0a6fda1b..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod limo; - -pub use self::limo::LimoError; diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/close_order_and_claim_tip.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/close_order_and_claim_tip.rs deleted file mode 100644 index 3b39ea38..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/close_order_and_claim_tip.rs +++ /dev/null @@ -1,719 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CloseOrderAndClaimTip { - pub maker: solana_pubkey::Pubkey, - - pub order: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub pda_authority: solana_pubkey::Pubkey, - - pub input_mint: solana_pubkey::Pubkey, - /// - required only for indexing the order state from the instruction - pub output_mint: solana_pubkey::Pubkey, - - pub maker_input_ata: solana_pubkey::Pubkey, - - pub input_vault: solana_pubkey::Pubkey, - - pub input_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CloseOrderAndClaimTip { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.maker, true)); - accounts.push(solana_instruction::AccountMeta::new(self.order, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pda_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.maker_input_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CloseOrderAndClaimTipInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseOrderAndClaimTipInstructionData { - discriminator: [u8; 8], -} - -impl CloseOrderAndClaimTipInstructionData { - pub fn new() -> Self { - Self { - discriminator: [244, 27, 12, 226, 45, 247, 230, 43], - } - } -} - -impl Default for CloseOrderAndClaimTipInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CloseOrderAndClaimTip`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` maker -/// 1. `[writable]` order -/// 2. `[writable]` global_config -/// 3. `[writable]` pda_authority -/// 4. `[]` input_mint -/// 5. `[]` output_mint -/// 6. `[writable]` maker_input_ata -/// 7. `[writable]` input_vault -/// 8. `[]` input_token_program -/// 9. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CloseOrderAndClaimTipBuilder { - maker: Option, - order: Option, - global_config: Option, - pda_authority: Option, - input_mint: Option, - output_mint: Option, - maker_input_ata: Option, - input_vault: Option, - input_token_program: Option, - system_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CloseOrderAndClaimTipBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn maker(&mut self, maker: solana_pubkey::Pubkey) -> &mut Self { - self.maker = Some(maker); - self - } - - #[inline(always)] - pub fn order(&mut self, order: solana_pubkey::Pubkey) -> &mut Self { - self.order = Some(order); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority(&mut self, pda_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn input_mint(&mut self, input_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_mint = Some(input_mint); - self - } - - /// - required only for indexing the order state from the instruction - #[inline(always)] - pub fn output_mint(&mut self, output_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn maker_input_ata(&mut self, maker_input_ata: solana_pubkey::Pubkey) -> &mut Self { - self.maker_input_ata = Some(maker_input_ata); - self - } - - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn input_token_program(&mut self, input_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_program = Some(input_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CloseOrderAndClaimTip { - maker: self.maker.expect("maker is not set"), - order: self.order.expect("order is not set"), - global_config: self.global_config.expect("global_config is not set"), - pda_authority: self.pda_authority.expect("pda_authority is not set"), - input_mint: self.input_mint.expect("input_mint is not set"), - output_mint: self.output_mint.expect("output_mint is not set"), - maker_input_ata: self.maker_input_ata.expect("maker_input_ata is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - input_token_program: self - .input_token_program - .expect("input_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_order_and_claim_tip` CPI accounts. -pub struct CloseOrderAndClaimTipCpiAccounts<'a, 'b> { - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub order: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - /// - required only for indexing the order state from the instruction - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub maker_input_ata: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_order_and_claim_tip` CPI instruction. -pub struct CloseOrderAndClaimTipCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub order: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - /// - required only for indexing the order state from the instruction - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub maker_input_ata: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CloseOrderAndClaimTipCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CloseOrderAndClaimTipCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - maker: accounts.maker, - order: accounts.order, - global_config: accounts.global_config, - pda_authority: accounts.pda_authority, - input_mint: accounts.input_mint, - output_mint: accounts.output_mint, - maker_input_ata: accounts.maker_input_ata, - input_vault: accounts.input_vault, - input_token_program: accounts.input_token_program, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.maker.key, true)); - accounts.push(solana_instruction::AccountMeta::new(*self.order.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pda_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.maker_input_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CloseOrderAndClaimTipInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.maker.clone()); - account_infos.push(self.order.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.pda_authority.clone()); - account_infos.push(self.input_mint.clone()); - account_infos.push(self.output_mint.clone()); - account_infos.push(self.maker_input_ata.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.input_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CloseOrderAndClaimTip` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` maker -/// 1. `[writable]` order -/// 2. `[writable]` global_config -/// 3. `[writable]` pda_authority -/// 4. `[]` input_mint -/// 5. `[]` output_mint -/// 6. `[writable]` maker_input_ata -/// 7. `[writable]` input_vault -/// 8. `[]` input_token_program -/// 9. `[]` system_program -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug)] -pub struct CloseOrderAndClaimTipCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CloseOrderAndClaimTipCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CloseOrderAndClaimTipCpiBuilderInstruction { - __program: program, - maker: None, - order: None, - global_config: None, - pda_authority: None, - input_mint: None, - output_mint: None, - maker_input_ata: None, - input_vault: None, - input_token_program: None, - system_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn maker(&mut self, maker: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.maker = Some(maker); - self - } - - #[inline(always)] - pub fn order(&mut self, order: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.order = Some(order); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority( - &mut self, - pda_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn input_mint( - &mut self, - input_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_mint = Some(input_mint); - self - } - - /// - required only for indexing the order state from the instruction - #[inline(always)] - pub fn output_mint( - &mut self, - output_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn maker_input_ata( - &mut self, - maker_input_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.maker_input_ata = Some(maker_input_ata); - self - } - - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn input_token_program( - &mut self, - input_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_program = Some(input_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CloseOrderAndClaimTipCpi { - __program: self.instruction.__program, - - maker: self.instruction.maker.expect("maker is not set"), - - order: self.instruction.order.expect("order is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - pda_authority: self - .instruction - .pda_authority - .expect("pda_authority is not set"), - - input_mint: self.instruction.input_mint.expect("input_mint is not set"), - - output_mint: self - .instruction - .output_mint - .expect("output_mint is not set"), - - maker_input_ata: self - .instruction - .maker_input_ata - .expect("maker_input_ata is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - input_token_program: self - .instruction - .input_token_program - .expect("input_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CloseOrderAndClaimTipCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - maker: Option<&'b solana_account_info::AccountInfo<'a>>, - order: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pda_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - input_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - maker_input_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/create_order.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/create_order.rs deleted file mode 100644 index 987dd960..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/create_order.rs +++ /dev/null @@ -1,843 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateOrder { - pub maker: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub pda_authority: solana_pubkey::Pubkey, - - pub order: solana_pubkey::Pubkey, - - pub input_mint: solana_pubkey::Pubkey, - - pub output_mint: solana_pubkey::Pubkey, - - pub maker_ata: solana_pubkey::Pubkey, - - pub input_vault: solana_pubkey::Pubkey, - - pub input_token_program: solana_pubkey::Pubkey, - - pub output_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreateOrder { - pub fn instruction(&self, args: CreateOrderInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateOrderInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.maker, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pda_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.order, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.maker_ata, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateOrderInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateOrderInstructionData { - discriminator: [u8; 8], -} - -impl CreateOrderInstructionData { - pub fn new() -> Self { - Self { - discriminator: [141, 54, 37, 207, 237, 210, 250, 215], - } - } -} - -impl Default for CreateOrderInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateOrderInstructionArgs { - pub input_amount: u64, - pub output_amount: u64, - pub order_type: u8, -} - -/// Instruction builder for `CreateOrder`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` maker -/// 1. `[writable]` global_config -/// 2. `[]` pda_authority -/// 3. `[writable]` order -/// 4. `[]` input_mint -/// 5. `[]` output_mint -/// 6. `[writable]` maker_ata -/// 7. `[writable]` input_vault -/// 8. `[]` input_token_program -/// 9. `[]` output_token_program -/// 10. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreateOrderBuilder { - maker: Option, - global_config: Option, - pda_authority: Option, - order: Option, - input_mint: Option, - output_mint: Option, - maker_ata: Option, - input_vault: Option, - input_token_program: Option, - output_token_program: Option, - system_program: Option, - event_authority: Option, - program: Option, - input_amount: Option, - output_amount: Option, - order_type: Option, - __remaining_accounts: Vec, -} - -impl CreateOrderBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn maker(&mut self, maker: solana_pubkey::Pubkey) -> &mut Self { - self.maker = Some(maker); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority(&mut self, pda_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn order(&mut self, order: solana_pubkey::Pubkey) -> &mut Self { - self.order = Some(order); - self - } - - #[inline(always)] - pub fn input_mint(&mut self, input_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint(&mut self, output_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn maker_ata(&mut self, maker_ata: solana_pubkey::Pubkey) -> &mut Self { - self.maker_ata = Some(maker_ata); - self - } - - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn input_token_program(&mut self, input_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_program = Some(input_token_program); - self - } - - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_program = Some(output_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn input_amount(&mut self, input_amount: u64) -> &mut Self { - self.input_amount = Some(input_amount); - self - } - - #[inline(always)] - pub fn output_amount(&mut self, output_amount: u64) -> &mut Self { - self.output_amount = Some(output_amount); - self - } - - #[inline(always)] - pub fn order_type(&mut self, order_type: u8) -> &mut Self { - self.order_type = Some(order_type); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateOrder { - maker: self.maker.expect("maker is not set"), - global_config: self.global_config.expect("global_config is not set"), - pda_authority: self.pda_authority.expect("pda_authority is not set"), - order: self.order.expect("order is not set"), - input_mint: self.input_mint.expect("input_mint is not set"), - output_mint: self.output_mint.expect("output_mint is not set"), - maker_ata: self.maker_ata.expect("maker_ata is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - input_token_program: self - .input_token_program - .expect("input_token_program is not set"), - output_token_program: self - .output_token_program - .expect("output_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = CreateOrderInstructionArgs { - input_amount: self.input_amount.clone().expect("input_amount is not set"), - output_amount: self - .output_amount - .clone() - .expect("output_amount is not set"), - order_type: self.order_type.clone().expect("order_type is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_order` CPI accounts. -pub struct CreateOrderCpiAccounts<'a, 'b> { - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub order: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub maker_ata: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_order` CPI instruction. -pub struct CreateOrderCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub order: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub maker_ata: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateOrderInstructionArgs, -} - -impl<'a, 'b> CreateOrderCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateOrderCpiAccounts<'a, 'b>, - args: CreateOrderInstructionArgs, - ) -> Self { - Self { - __program: program, - maker: accounts.maker, - global_config: accounts.global_config, - pda_authority: accounts.pda_authority, - order: accounts.order, - input_mint: accounts.input_mint, - output_mint: accounts.output_mint, - maker_ata: accounts.maker_ata, - input_vault: accounts.input_vault, - input_token_program: accounts.input_token_program, - output_token_program: accounts.output_token_program, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.maker.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pda_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.order.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.maker_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateOrderInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.maker.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.pda_authority.clone()); - account_infos.push(self.order.clone()); - account_infos.push(self.input_mint.clone()); - account_infos.push(self.output_mint.clone()); - account_infos.push(self.maker_ata.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.input_token_program.clone()); - account_infos.push(self.output_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateOrder` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` maker -/// 1. `[writable]` global_config -/// 2. `[]` pda_authority -/// 3. `[writable]` order -/// 4. `[]` input_mint -/// 5. `[]` output_mint -/// 6. `[writable]` maker_ata -/// 7. `[writable]` input_vault -/// 8. `[]` input_token_program -/// 9. `[]` output_token_program -/// 10. `[]` system_program -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug)] -pub struct CreateOrderCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateOrderCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateOrderCpiBuilderInstruction { - __program: program, - maker: None, - global_config: None, - pda_authority: None, - order: None, - input_mint: None, - output_mint: None, - maker_ata: None, - input_vault: None, - input_token_program: None, - output_token_program: None, - system_program: None, - event_authority: None, - program: None, - input_amount: None, - output_amount: None, - order_type: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn maker(&mut self, maker: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.maker = Some(maker); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority( - &mut self, - pda_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn order(&mut self, order: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.order = Some(order); - self - } - - #[inline(always)] - pub fn input_mint( - &mut self, - input_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint( - &mut self, - output_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn maker_ata(&mut self, maker_ata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.maker_ata = Some(maker_ata); - self - } - - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn input_token_program( - &mut self, - input_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_program = Some(input_token_program); - self - } - - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_program = Some(output_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn input_amount(&mut self, input_amount: u64) -> &mut Self { - self.instruction.input_amount = Some(input_amount); - self - } - - #[inline(always)] - pub fn output_amount(&mut self, output_amount: u64) -> &mut Self { - self.instruction.output_amount = Some(output_amount); - self - } - - #[inline(always)] - pub fn order_type(&mut self, order_type: u8) -> &mut Self { - self.instruction.order_type = Some(order_type); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateOrderInstructionArgs { - input_amount: self - .instruction - .input_amount - .clone() - .expect("input_amount is not set"), - output_amount: self - .instruction - .output_amount - .clone() - .expect("output_amount is not set"), - order_type: self - .instruction - .order_type - .clone() - .expect("order_type is not set"), - }; - let instruction = CreateOrderCpi { - __program: self.instruction.__program, - - maker: self.instruction.maker.expect("maker is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - pda_authority: self - .instruction - .pda_authority - .expect("pda_authority is not set"), - - order: self.instruction.order.expect("order is not set"), - - input_mint: self.instruction.input_mint.expect("input_mint is not set"), - - output_mint: self - .instruction - .output_mint - .expect("output_mint is not set"), - - maker_ata: self.instruction.maker_ata.expect("maker_ata is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - input_token_program: self - .instruction - .input_token_program - .expect("input_token_program is not set"), - - output_token_program: self - .instruction - .output_token_program - .expect("output_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateOrderCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - maker: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pda_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - order: Option<&'b solana_account_info::AccountInfo<'a>>, - input_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - maker_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - input_amount: Option, - output_amount: Option, - order_type: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/flash_take_order_end.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/flash_take_order_end.rs deleted file mode 100644 index 53e15fbe..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/flash_take_order_end.rs +++ /dev/null @@ -1,1326 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct FlashTakeOrderEnd { - pub taker: solana_pubkey::Pubkey, - - pub maker: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub pda_authority: solana_pubkey::Pubkey, - - pub order: solana_pubkey::Pubkey, - - pub input_mint: solana_pubkey::Pubkey, - - pub output_mint: solana_pubkey::Pubkey, - - pub input_vault: solana_pubkey::Pubkey, - - pub taker_input_ata: solana_pubkey::Pubkey, - - pub taker_output_ata: solana_pubkey::Pubkey, - - pub intermediary_output_token_account: Option, - - pub maker_output_ata: Option, - - pub express_relay: solana_pubkey::Pubkey, - - pub express_relay_metadata: solana_pubkey::Pubkey, - - pub sysvar_instructions: solana_pubkey::Pubkey, - - pub permission: Option, - - pub config_router: solana_pubkey::Pubkey, - - pub input_token_program: solana_pubkey::Pubkey, - - pub output_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl FlashTakeOrderEnd { - pub fn instruction( - &self, - args: FlashTakeOrderEndInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: FlashTakeOrderEndInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(23 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.taker, true)); - accounts.push(solana_instruction::AccountMeta::new(self.maker, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pda_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.order, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.taker_input_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.taker_output_ata, - false, - )); - if let Some(intermediary_output_token_account) = self.intermediary_output_token_account { - accounts.push(solana_instruction::AccountMeta::new( - intermediary_output_token_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - if let Some(maker_output_ata) = self.maker_output_ata { - accounts.push(solana_instruction::AccountMeta::new( - maker_output_ata, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.express_relay, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.express_relay_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sysvar_instructions, - false, - )); - if let Some(permission) = self.permission { - accounts.push(solana_instruction::AccountMeta::new_readonly( - permission, false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config_router, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&FlashTakeOrderEndInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FlashTakeOrderEndInstructionData { - discriminator: [u8; 8], -} - -impl FlashTakeOrderEndInstructionData { - pub fn new() -> Self { - Self { - discriminator: [206, 242, 215, 187, 134, 33, 224, 148], - } - } -} - -impl Default for FlashTakeOrderEndInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FlashTakeOrderEndInstructionArgs { - pub input_amount: u64, - pub min_output_amount: u64, - pub tip_amount_permissionless_taking: u64, -} - -/// Instruction builder for `FlashTakeOrderEnd`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` taker -/// 1. `[writable]` maker -/// 2. `[writable]` global_config -/// 3. `[writable]` pda_authority -/// 4. `[writable]` order -/// 5. `[]` input_mint -/// 6. `[]` output_mint -/// 7. `[writable]` input_vault -/// 8. `[writable]` taker_input_ata -/// 9. `[writable]` taker_output_ata -/// 10. `[writable, optional]` intermediary_output_token_account -/// 11. `[writable, optional]` maker_output_ata -/// 12. `[]` express_relay -/// 13. `[]` express_relay_metadata -/// 14. `[optional]` sysvar_instructions (default to `Sysvar1nstructions1111111111111111111111111`) -/// 15. `[optional]` permission -/// 16. `[]` config_router -/// 17. `[]` input_token_program -/// 18. `[]` output_token_program -/// 19. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 20. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 21. `[]` event_authority -/// 22. `[]` program -#[derive(Clone, Debug, Default)] -pub struct FlashTakeOrderEndBuilder { - taker: Option, - maker: Option, - global_config: Option, - pda_authority: Option, - order: Option, - input_mint: Option, - output_mint: Option, - input_vault: Option, - taker_input_ata: Option, - taker_output_ata: Option, - intermediary_output_token_account: Option, - maker_output_ata: Option, - express_relay: Option, - express_relay_metadata: Option, - sysvar_instructions: Option, - permission: Option, - config_router: Option, - input_token_program: Option, - output_token_program: Option, - system_program: Option, - rent: Option, - event_authority: Option, - program: Option, - input_amount: Option, - min_output_amount: Option, - tip_amount_permissionless_taking: Option, - __remaining_accounts: Vec, -} - -impl FlashTakeOrderEndBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn taker(&mut self, taker: solana_pubkey::Pubkey) -> &mut Self { - self.taker = Some(taker); - self - } - - #[inline(always)] - pub fn maker(&mut self, maker: solana_pubkey::Pubkey) -> &mut Self { - self.maker = Some(maker); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority(&mut self, pda_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn order(&mut self, order: solana_pubkey::Pubkey) -> &mut Self { - self.order = Some(order); - self - } - - #[inline(always)] - pub fn input_mint(&mut self, input_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint(&mut self, output_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn taker_input_ata(&mut self, taker_input_ata: solana_pubkey::Pubkey) -> &mut Self { - self.taker_input_ata = Some(taker_input_ata); - self - } - - #[inline(always)] - pub fn taker_output_ata(&mut self, taker_output_ata: solana_pubkey::Pubkey) -> &mut Self { - self.taker_output_ata = Some(taker_output_ata); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn intermediary_output_token_account( - &mut self, - intermediary_output_token_account: Option, - ) -> &mut Self { - self.intermediary_output_token_account = intermediary_output_token_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn maker_output_ata( - &mut self, - maker_output_ata: Option, - ) -> &mut Self { - self.maker_output_ata = maker_output_ata; - self - } - - #[inline(always)] - pub fn express_relay(&mut self, express_relay: solana_pubkey::Pubkey) -> &mut Self { - self.express_relay = Some(express_relay); - self - } - - #[inline(always)] - pub fn express_relay_metadata( - &mut self, - express_relay_metadata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.express_relay_metadata = Some(express_relay_metadata); - self - } - - /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` - #[inline(always)] - pub fn sysvar_instructions(&mut self, sysvar_instructions: solana_pubkey::Pubkey) -> &mut Self { - self.sysvar_instructions = Some(sysvar_instructions); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn permission(&mut self, permission: Option) -> &mut Self { - self.permission = permission; - self - } - - #[inline(always)] - pub fn config_router(&mut self, config_router: solana_pubkey::Pubkey) -> &mut Self { - self.config_router = Some(config_router); - self - } - - #[inline(always)] - pub fn input_token_program(&mut self, input_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_program = Some(input_token_program); - self - } - - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_program = Some(output_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn input_amount(&mut self, input_amount: u64) -> &mut Self { - self.input_amount = Some(input_amount); - self - } - - #[inline(always)] - pub fn min_output_amount(&mut self, min_output_amount: u64) -> &mut Self { - self.min_output_amount = Some(min_output_amount); - self - } - - #[inline(always)] - pub fn tip_amount_permissionless_taking( - &mut self, - tip_amount_permissionless_taking: u64, - ) -> &mut Self { - self.tip_amount_permissionless_taking = Some(tip_amount_permissionless_taking); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = FlashTakeOrderEnd { - taker: self.taker.expect("taker is not set"), - maker: self.maker.expect("maker is not set"), - global_config: self.global_config.expect("global_config is not set"), - pda_authority: self.pda_authority.expect("pda_authority is not set"), - order: self.order.expect("order is not set"), - input_mint: self.input_mint.expect("input_mint is not set"), - output_mint: self.output_mint.expect("output_mint is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - taker_input_ata: self.taker_input_ata.expect("taker_input_ata is not set"), - taker_output_ata: self.taker_output_ata.expect("taker_output_ata is not set"), - intermediary_output_token_account: self.intermediary_output_token_account, - maker_output_ata: self.maker_output_ata, - express_relay: self.express_relay.expect("express_relay is not set"), - express_relay_metadata: self - .express_relay_metadata - .expect("express_relay_metadata is not set"), - sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_pubkey::pubkey!( - "Sysvar1nstructions1111111111111111111111111" - )), - permission: self.permission, - config_router: self.config_router.expect("config_router is not set"), - input_token_program: self - .input_token_program - .expect("input_token_program is not set"), - output_token_program: self - .output_token_program - .expect("output_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = FlashTakeOrderEndInstructionArgs { - input_amount: self.input_amount.clone().expect("input_amount is not set"), - min_output_amount: self - .min_output_amount - .clone() - .expect("min_output_amount is not set"), - tip_amount_permissionless_taking: self - .tip_amount_permissionless_taking - .clone() - .expect("tip_amount_permissionless_taking is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `flash_take_order_end` CPI accounts. -pub struct FlashTakeOrderEndCpiAccounts<'a, 'b> { - pub taker: &'b solana_account_info::AccountInfo<'a>, - - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub order: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub taker_input_ata: &'b solana_account_info::AccountInfo<'a>, - - pub taker_output_ata: &'b solana_account_info::AccountInfo<'a>, - - pub intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub express_relay: &'b solana_account_info::AccountInfo<'a>, - - pub express_relay_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - - pub permission: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub config_router: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `flash_take_order_end` CPI instruction. -pub struct FlashTakeOrderEndCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub taker: &'b solana_account_info::AccountInfo<'a>, - - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub order: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub taker_input_ata: &'b solana_account_info::AccountInfo<'a>, - - pub taker_output_ata: &'b solana_account_info::AccountInfo<'a>, - - pub intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub express_relay: &'b solana_account_info::AccountInfo<'a>, - - pub express_relay_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - - pub permission: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub config_router: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: FlashTakeOrderEndInstructionArgs, -} - -impl<'a, 'b> FlashTakeOrderEndCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: FlashTakeOrderEndCpiAccounts<'a, 'b>, - args: FlashTakeOrderEndInstructionArgs, - ) -> Self { - Self { - __program: program, - taker: accounts.taker, - maker: accounts.maker, - global_config: accounts.global_config, - pda_authority: accounts.pda_authority, - order: accounts.order, - input_mint: accounts.input_mint, - output_mint: accounts.output_mint, - input_vault: accounts.input_vault, - taker_input_ata: accounts.taker_input_ata, - taker_output_ata: accounts.taker_output_ata, - intermediary_output_token_account: accounts.intermediary_output_token_account, - maker_output_ata: accounts.maker_output_ata, - express_relay: accounts.express_relay, - express_relay_metadata: accounts.express_relay_metadata, - sysvar_instructions: accounts.sysvar_instructions, - permission: accounts.permission, - config_router: accounts.config_router, - input_token_program: accounts.input_token_program, - output_token_program: accounts.output_token_program, - system_program: accounts.system_program, - rent: accounts.rent, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(23 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.taker.key, true)); - accounts.push(solana_instruction::AccountMeta::new(*self.maker.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pda_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.order.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.taker_input_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.taker_output_ata.key, - false, - )); - if let Some(intermediary_output_token_account) = self.intermediary_output_token_account { - accounts.push(solana_instruction::AccountMeta::new( - *intermediary_output_token_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - if let Some(maker_output_ata) = self.maker_output_ata { - accounts.push(solana_instruction::AccountMeta::new( - *maker_output_ata.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.express_relay.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.express_relay_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sysvar_instructions.key, - false, - )); - if let Some(permission) = self.permission { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *permission.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config_router.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&FlashTakeOrderEndInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(24 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.taker.clone()); - account_infos.push(self.maker.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.pda_authority.clone()); - account_infos.push(self.order.clone()); - account_infos.push(self.input_mint.clone()); - account_infos.push(self.output_mint.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.taker_input_ata.clone()); - account_infos.push(self.taker_output_ata.clone()); - if let Some(intermediary_output_token_account) = self.intermediary_output_token_account { - account_infos.push(intermediary_output_token_account.clone()); - } - if let Some(maker_output_ata) = self.maker_output_ata { - account_infos.push(maker_output_ata.clone()); - } - account_infos.push(self.express_relay.clone()); - account_infos.push(self.express_relay_metadata.clone()); - account_infos.push(self.sysvar_instructions.clone()); - if let Some(permission) = self.permission { - account_infos.push(permission.clone()); - } - account_infos.push(self.config_router.clone()); - account_infos.push(self.input_token_program.clone()); - account_infos.push(self.output_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `FlashTakeOrderEnd` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` taker -/// 1. `[writable]` maker -/// 2. `[writable]` global_config -/// 3. `[writable]` pda_authority -/// 4. `[writable]` order -/// 5. `[]` input_mint -/// 6. `[]` output_mint -/// 7. `[writable]` input_vault -/// 8. `[writable]` taker_input_ata -/// 9. `[writable]` taker_output_ata -/// 10. `[writable, optional]` intermediary_output_token_account -/// 11. `[writable, optional]` maker_output_ata -/// 12. `[]` express_relay -/// 13. `[]` express_relay_metadata -/// 14. `[]` sysvar_instructions -/// 15. `[optional]` permission -/// 16. `[]` config_router -/// 17. `[]` input_token_program -/// 18. `[]` output_token_program -/// 19. `[]` system_program -/// 20. `[]` rent -/// 21. `[]` event_authority -/// 22. `[]` program -#[derive(Clone, Debug)] -pub struct FlashTakeOrderEndCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> FlashTakeOrderEndCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(FlashTakeOrderEndCpiBuilderInstruction { - __program: program, - taker: None, - maker: None, - global_config: None, - pda_authority: None, - order: None, - input_mint: None, - output_mint: None, - input_vault: None, - taker_input_ata: None, - taker_output_ata: None, - intermediary_output_token_account: None, - maker_output_ata: None, - express_relay: None, - express_relay_metadata: None, - sysvar_instructions: None, - permission: None, - config_router: None, - input_token_program: None, - output_token_program: None, - system_program: None, - rent: None, - event_authority: None, - program: None, - input_amount: None, - min_output_amount: None, - tip_amount_permissionless_taking: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn taker(&mut self, taker: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.taker = Some(taker); - self - } - - #[inline(always)] - pub fn maker(&mut self, maker: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.maker = Some(maker); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority( - &mut self, - pda_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn order(&mut self, order: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.order = Some(order); - self - } - - #[inline(always)] - pub fn input_mint( - &mut self, - input_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint( - &mut self, - output_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn taker_input_ata( - &mut self, - taker_input_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.taker_input_ata = Some(taker_input_ata); - self - } - - #[inline(always)] - pub fn taker_output_ata( - &mut self, - taker_output_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.taker_output_ata = Some(taker_output_ata); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn intermediary_output_token_account( - &mut self, - intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.intermediary_output_token_account = intermediary_output_token_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn maker_output_ata( - &mut self, - maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.maker_output_ata = maker_output_ata; - self - } - - #[inline(always)] - pub fn express_relay( - &mut self, - express_relay: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.express_relay = Some(express_relay); - self - } - - #[inline(always)] - pub fn express_relay_metadata( - &mut self, - express_relay_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.express_relay_metadata = Some(express_relay_metadata); - self - } - - #[inline(always)] - pub fn sysvar_instructions( - &mut self, - sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.sysvar_instructions = Some(sysvar_instructions); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn permission( - &mut self, - permission: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.permission = permission; - self - } - - #[inline(always)] - pub fn config_router( - &mut self, - config_router: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_router = Some(config_router); - self - } - - #[inline(always)] - pub fn input_token_program( - &mut self, - input_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_program = Some(input_token_program); - self - } - - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_program = Some(output_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn input_amount(&mut self, input_amount: u64) -> &mut Self { - self.instruction.input_amount = Some(input_amount); - self - } - - #[inline(always)] - pub fn min_output_amount(&mut self, min_output_amount: u64) -> &mut Self { - self.instruction.min_output_amount = Some(min_output_amount); - self - } - - #[inline(always)] - pub fn tip_amount_permissionless_taking( - &mut self, - tip_amount_permissionless_taking: u64, - ) -> &mut Self { - self.instruction.tip_amount_permissionless_taking = Some(tip_amount_permissionless_taking); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = FlashTakeOrderEndInstructionArgs { - input_amount: self - .instruction - .input_amount - .clone() - .expect("input_amount is not set"), - min_output_amount: self - .instruction - .min_output_amount - .clone() - .expect("min_output_amount is not set"), - tip_amount_permissionless_taking: self - .instruction - .tip_amount_permissionless_taking - .clone() - .expect("tip_amount_permissionless_taking is not set"), - }; - let instruction = FlashTakeOrderEndCpi { - __program: self.instruction.__program, - - taker: self.instruction.taker.expect("taker is not set"), - - maker: self.instruction.maker.expect("maker is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - pda_authority: self - .instruction - .pda_authority - .expect("pda_authority is not set"), - - order: self.instruction.order.expect("order is not set"), - - input_mint: self.instruction.input_mint.expect("input_mint is not set"), - - output_mint: self - .instruction - .output_mint - .expect("output_mint is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - taker_input_ata: self - .instruction - .taker_input_ata - .expect("taker_input_ata is not set"), - - taker_output_ata: self - .instruction - .taker_output_ata - .expect("taker_output_ata is not set"), - - intermediary_output_token_account: self.instruction.intermediary_output_token_account, - - maker_output_ata: self.instruction.maker_output_ata, - - express_relay: self - .instruction - .express_relay - .expect("express_relay is not set"), - - express_relay_metadata: self - .instruction - .express_relay_metadata - .expect("express_relay_metadata is not set"), - - sysvar_instructions: self - .instruction - .sysvar_instructions - .expect("sysvar_instructions is not set"), - - permission: self.instruction.permission, - - config_router: self - .instruction - .config_router - .expect("config_router is not set"), - - input_token_program: self - .instruction - .input_token_program - .expect("input_token_program is not set"), - - output_token_program: self - .instruction - .output_token_program - .expect("output_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct FlashTakeOrderEndCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - taker: Option<&'b solana_account_info::AccountInfo<'a>>, - maker: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pda_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - order: Option<&'b solana_account_info::AccountInfo<'a>>, - input_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - taker_input_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - taker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - express_relay: Option<&'b solana_account_info::AccountInfo<'a>>, - express_relay_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - sysvar_instructions: Option<&'b solana_account_info::AccountInfo<'a>>, - permission: Option<&'b solana_account_info::AccountInfo<'a>>, - config_router: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - input_amount: Option, - min_output_amount: Option, - tip_amount_permissionless_taking: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/flash_take_order_start.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/flash_take_order_start.rs deleted file mode 100644 index 0eb00adf..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/flash_take_order_start.rs +++ /dev/null @@ -1,1326 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct FlashTakeOrderStart { - pub taker: solana_pubkey::Pubkey, - - pub maker: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub pda_authority: solana_pubkey::Pubkey, - - pub order: solana_pubkey::Pubkey, - - pub input_mint: solana_pubkey::Pubkey, - - pub output_mint: solana_pubkey::Pubkey, - - pub input_vault: solana_pubkey::Pubkey, - - pub taker_input_ata: solana_pubkey::Pubkey, - - pub taker_output_ata: solana_pubkey::Pubkey, - - pub intermediary_output_token_account: Option, - - pub maker_output_ata: Option, - - pub express_relay: solana_pubkey::Pubkey, - - pub express_relay_metadata: solana_pubkey::Pubkey, - - pub sysvar_instructions: solana_pubkey::Pubkey, - - pub permission: Option, - - pub config_router: solana_pubkey::Pubkey, - - pub input_token_program: solana_pubkey::Pubkey, - - pub output_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl FlashTakeOrderStart { - pub fn instruction( - &self, - args: FlashTakeOrderStartInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: FlashTakeOrderStartInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(23 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.taker, true)); - accounts.push(solana_instruction::AccountMeta::new(self.maker, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pda_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.order, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.taker_input_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.taker_output_ata, - false, - )); - if let Some(intermediary_output_token_account) = self.intermediary_output_token_account { - accounts.push(solana_instruction::AccountMeta::new( - intermediary_output_token_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - if let Some(maker_output_ata) = self.maker_output_ata { - accounts.push(solana_instruction::AccountMeta::new( - maker_output_ata, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.express_relay, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.express_relay_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sysvar_instructions, - false, - )); - if let Some(permission) = self.permission { - accounts.push(solana_instruction::AccountMeta::new_readonly( - permission, false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config_router, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&FlashTakeOrderStartInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FlashTakeOrderStartInstructionData { - discriminator: [u8; 8], -} - -impl FlashTakeOrderStartInstructionData { - pub fn new() -> Self { - Self { - discriminator: [126, 53, 176, 15, 39, 103, 97, 243], - } - } -} - -impl Default for FlashTakeOrderStartInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FlashTakeOrderStartInstructionArgs { - pub input_amount: u64, - pub min_output_amount: u64, - pub tip_amount_permissionless_taking: u64, -} - -/// Instruction builder for `FlashTakeOrderStart`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` taker -/// 1. `[writable]` maker -/// 2. `[writable]` global_config -/// 3. `[writable]` pda_authority -/// 4. `[writable]` order -/// 5. `[]` input_mint -/// 6. `[]` output_mint -/// 7. `[writable]` input_vault -/// 8. `[writable]` taker_input_ata -/// 9. `[writable]` taker_output_ata -/// 10. `[writable, optional]` intermediary_output_token_account -/// 11. `[writable, optional]` maker_output_ata -/// 12. `[]` express_relay -/// 13. `[]` express_relay_metadata -/// 14. `[optional]` sysvar_instructions (default to `Sysvar1nstructions1111111111111111111111111`) -/// 15. `[optional]` permission -/// 16. `[]` config_router -/// 17. `[]` input_token_program -/// 18. `[]` output_token_program -/// 19. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 20. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 21. `[]` event_authority -/// 22. `[]` program -#[derive(Clone, Debug, Default)] -pub struct FlashTakeOrderStartBuilder { - taker: Option, - maker: Option, - global_config: Option, - pda_authority: Option, - order: Option, - input_mint: Option, - output_mint: Option, - input_vault: Option, - taker_input_ata: Option, - taker_output_ata: Option, - intermediary_output_token_account: Option, - maker_output_ata: Option, - express_relay: Option, - express_relay_metadata: Option, - sysvar_instructions: Option, - permission: Option, - config_router: Option, - input_token_program: Option, - output_token_program: Option, - system_program: Option, - rent: Option, - event_authority: Option, - program: Option, - input_amount: Option, - min_output_amount: Option, - tip_amount_permissionless_taking: Option, - __remaining_accounts: Vec, -} - -impl FlashTakeOrderStartBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn taker(&mut self, taker: solana_pubkey::Pubkey) -> &mut Self { - self.taker = Some(taker); - self - } - - #[inline(always)] - pub fn maker(&mut self, maker: solana_pubkey::Pubkey) -> &mut Self { - self.maker = Some(maker); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority(&mut self, pda_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn order(&mut self, order: solana_pubkey::Pubkey) -> &mut Self { - self.order = Some(order); - self - } - - #[inline(always)] - pub fn input_mint(&mut self, input_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint(&mut self, output_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn taker_input_ata(&mut self, taker_input_ata: solana_pubkey::Pubkey) -> &mut Self { - self.taker_input_ata = Some(taker_input_ata); - self - } - - #[inline(always)] - pub fn taker_output_ata(&mut self, taker_output_ata: solana_pubkey::Pubkey) -> &mut Self { - self.taker_output_ata = Some(taker_output_ata); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn intermediary_output_token_account( - &mut self, - intermediary_output_token_account: Option, - ) -> &mut Self { - self.intermediary_output_token_account = intermediary_output_token_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn maker_output_ata( - &mut self, - maker_output_ata: Option, - ) -> &mut Self { - self.maker_output_ata = maker_output_ata; - self - } - - #[inline(always)] - pub fn express_relay(&mut self, express_relay: solana_pubkey::Pubkey) -> &mut Self { - self.express_relay = Some(express_relay); - self - } - - #[inline(always)] - pub fn express_relay_metadata( - &mut self, - express_relay_metadata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.express_relay_metadata = Some(express_relay_metadata); - self - } - - /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` - #[inline(always)] - pub fn sysvar_instructions(&mut self, sysvar_instructions: solana_pubkey::Pubkey) -> &mut Self { - self.sysvar_instructions = Some(sysvar_instructions); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn permission(&mut self, permission: Option) -> &mut Self { - self.permission = permission; - self - } - - #[inline(always)] - pub fn config_router(&mut self, config_router: solana_pubkey::Pubkey) -> &mut Self { - self.config_router = Some(config_router); - self - } - - #[inline(always)] - pub fn input_token_program(&mut self, input_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_program = Some(input_token_program); - self - } - - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_program = Some(output_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn input_amount(&mut self, input_amount: u64) -> &mut Self { - self.input_amount = Some(input_amount); - self - } - - #[inline(always)] - pub fn min_output_amount(&mut self, min_output_amount: u64) -> &mut Self { - self.min_output_amount = Some(min_output_amount); - self - } - - #[inline(always)] - pub fn tip_amount_permissionless_taking( - &mut self, - tip_amount_permissionless_taking: u64, - ) -> &mut Self { - self.tip_amount_permissionless_taking = Some(tip_amount_permissionless_taking); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = FlashTakeOrderStart { - taker: self.taker.expect("taker is not set"), - maker: self.maker.expect("maker is not set"), - global_config: self.global_config.expect("global_config is not set"), - pda_authority: self.pda_authority.expect("pda_authority is not set"), - order: self.order.expect("order is not set"), - input_mint: self.input_mint.expect("input_mint is not set"), - output_mint: self.output_mint.expect("output_mint is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - taker_input_ata: self.taker_input_ata.expect("taker_input_ata is not set"), - taker_output_ata: self.taker_output_ata.expect("taker_output_ata is not set"), - intermediary_output_token_account: self.intermediary_output_token_account, - maker_output_ata: self.maker_output_ata, - express_relay: self.express_relay.expect("express_relay is not set"), - express_relay_metadata: self - .express_relay_metadata - .expect("express_relay_metadata is not set"), - sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_pubkey::pubkey!( - "Sysvar1nstructions1111111111111111111111111" - )), - permission: self.permission, - config_router: self.config_router.expect("config_router is not set"), - input_token_program: self - .input_token_program - .expect("input_token_program is not set"), - output_token_program: self - .output_token_program - .expect("output_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = FlashTakeOrderStartInstructionArgs { - input_amount: self.input_amount.clone().expect("input_amount is not set"), - min_output_amount: self - .min_output_amount - .clone() - .expect("min_output_amount is not set"), - tip_amount_permissionless_taking: self - .tip_amount_permissionless_taking - .clone() - .expect("tip_amount_permissionless_taking is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `flash_take_order_start` CPI accounts. -pub struct FlashTakeOrderStartCpiAccounts<'a, 'b> { - pub taker: &'b solana_account_info::AccountInfo<'a>, - - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub order: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub taker_input_ata: &'b solana_account_info::AccountInfo<'a>, - - pub taker_output_ata: &'b solana_account_info::AccountInfo<'a>, - - pub intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub express_relay: &'b solana_account_info::AccountInfo<'a>, - - pub express_relay_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - - pub permission: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub config_router: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `flash_take_order_start` CPI instruction. -pub struct FlashTakeOrderStartCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub taker: &'b solana_account_info::AccountInfo<'a>, - - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub order: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub taker_input_ata: &'b solana_account_info::AccountInfo<'a>, - - pub taker_output_ata: &'b solana_account_info::AccountInfo<'a>, - - pub intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub express_relay: &'b solana_account_info::AccountInfo<'a>, - - pub express_relay_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - - pub permission: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub config_router: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: FlashTakeOrderStartInstructionArgs, -} - -impl<'a, 'b> FlashTakeOrderStartCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: FlashTakeOrderStartCpiAccounts<'a, 'b>, - args: FlashTakeOrderStartInstructionArgs, - ) -> Self { - Self { - __program: program, - taker: accounts.taker, - maker: accounts.maker, - global_config: accounts.global_config, - pda_authority: accounts.pda_authority, - order: accounts.order, - input_mint: accounts.input_mint, - output_mint: accounts.output_mint, - input_vault: accounts.input_vault, - taker_input_ata: accounts.taker_input_ata, - taker_output_ata: accounts.taker_output_ata, - intermediary_output_token_account: accounts.intermediary_output_token_account, - maker_output_ata: accounts.maker_output_ata, - express_relay: accounts.express_relay, - express_relay_metadata: accounts.express_relay_metadata, - sysvar_instructions: accounts.sysvar_instructions, - permission: accounts.permission, - config_router: accounts.config_router, - input_token_program: accounts.input_token_program, - output_token_program: accounts.output_token_program, - system_program: accounts.system_program, - rent: accounts.rent, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(23 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.taker.key, true)); - accounts.push(solana_instruction::AccountMeta::new(*self.maker.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pda_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.order.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.taker_input_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.taker_output_ata.key, - false, - )); - if let Some(intermediary_output_token_account) = self.intermediary_output_token_account { - accounts.push(solana_instruction::AccountMeta::new( - *intermediary_output_token_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - if let Some(maker_output_ata) = self.maker_output_ata { - accounts.push(solana_instruction::AccountMeta::new( - *maker_output_ata.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.express_relay.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.express_relay_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sysvar_instructions.key, - false, - )); - if let Some(permission) = self.permission { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *permission.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config_router.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&FlashTakeOrderStartInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(24 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.taker.clone()); - account_infos.push(self.maker.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.pda_authority.clone()); - account_infos.push(self.order.clone()); - account_infos.push(self.input_mint.clone()); - account_infos.push(self.output_mint.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.taker_input_ata.clone()); - account_infos.push(self.taker_output_ata.clone()); - if let Some(intermediary_output_token_account) = self.intermediary_output_token_account { - account_infos.push(intermediary_output_token_account.clone()); - } - if let Some(maker_output_ata) = self.maker_output_ata { - account_infos.push(maker_output_ata.clone()); - } - account_infos.push(self.express_relay.clone()); - account_infos.push(self.express_relay_metadata.clone()); - account_infos.push(self.sysvar_instructions.clone()); - if let Some(permission) = self.permission { - account_infos.push(permission.clone()); - } - account_infos.push(self.config_router.clone()); - account_infos.push(self.input_token_program.clone()); - account_infos.push(self.output_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `FlashTakeOrderStart` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` taker -/// 1. `[writable]` maker -/// 2. `[writable]` global_config -/// 3. `[writable]` pda_authority -/// 4. `[writable]` order -/// 5. `[]` input_mint -/// 6. `[]` output_mint -/// 7. `[writable]` input_vault -/// 8. `[writable]` taker_input_ata -/// 9. `[writable]` taker_output_ata -/// 10. `[writable, optional]` intermediary_output_token_account -/// 11. `[writable, optional]` maker_output_ata -/// 12. `[]` express_relay -/// 13. `[]` express_relay_metadata -/// 14. `[]` sysvar_instructions -/// 15. `[optional]` permission -/// 16. `[]` config_router -/// 17. `[]` input_token_program -/// 18. `[]` output_token_program -/// 19. `[]` system_program -/// 20. `[]` rent -/// 21. `[]` event_authority -/// 22. `[]` program -#[derive(Clone, Debug)] -pub struct FlashTakeOrderStartCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> FlashTakeOrderStartCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(FlashTakeOrderStartCpiBuilderInstruction { - __program: program, - taker: None, - maker: None, - global_config: None, - pda_authority: None, - order: None, - input_mint: None, - output_mint: None, - input_vault: None, - taker_input_ata: None, - taker_output_ata: None, - intermediary_output_token_account: None, - maker_output_ata: None, - express_relay: None, - express_relay_metadata: None, - sysvar_instructions: None, - permission: None, - config_router: None, - input_token_program: None, - output_token_program: None, - system_program: None, - rent: None, - event_authority: None, - program: None, - input_amount: None, - min_output_amount: None, - tip_amount_permissionless_taking: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn taker(&mut self, taker: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.taker = Some(taker); - self - } - - #[inline(always)] - pub fn maker(&mut self, maker: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.maker = Some(maker); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority( - &mut self, - pda_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn order(&mut self, order: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.order = Some(order); - self - } - - #[inline(always)] - pub fn input_mint( - &mut self, - input_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint( - &mut self, - output_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn taker_input_ata( - &mut self, - taker_input_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.taker_input_ata = Some(taker_input_ata); - self - } - - #[inline(always)] - pub fn taker_output_ata( - &mut self, - taker_output_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.taker_output_ata = Some(taker_output_ata); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn intermediary_output_token_account( - &mut self, - intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.intermediary_output_token_account = intermediary_output_token_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn maker_output_ata( - &mut self, - maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.maker_output_ata = maker_output_ata; - self - } - - #[inline(always)] - pub fn express_relay( - &mut self, - express_relay: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.express_relay = Some(express_relay); - self - } - - #[inline(always)] - pub fn express_relay_metadata( - &mut self, - express_relay_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.express_relay_metadata = Some(express_relay_metadata); - self - } - - #[inline(always)] - pub fn sysvar_instructions( - &mut self, - sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.sysvar_instructions = Some(sysvar_instructions); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn permission( - &mut self, - permission: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.permission = permission; - self - } - - #[inline(always)] - pub fn config_router( - &mut self, - config_router: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_router = Some(config_router); - self - } - - #[inline(always)] - pub fn input_token_program( - &mut self, - input_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_program = Some(input_token_program); - self - } - - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_program = Some(output_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn input_amount(&mut self, input_amount: u64) -> &mut Self { - self.instruction.input_amount = Some(input_amount); - self - } - - #[inline(always)] - pub fn min_output_amount(&mut self, min_output_amount: u64) -> &mut Self { - self.instruction.min_output_amount = Some(min_output_amount); - self - } - - #[inline(always)] - pub fn tip_amount_permissionless_taking( - &mut self, - tip_amount_permissionless_taking: u64, - ) -> &mut Self { - self.instruction.tip_amount_permissionless_taking = Some(tip_amount_permissionless_taking); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = FlashTakeOrderStartInstructionArgs { - input_amount: self - .instruction - .input_amount - .clone() - .expect("input_amount is not set"), - min_output_amount: self - .instruction - .min_output_amount - .clone() - .expect("min_output_amount is not set"), - tip_amount_permissionless_taking: self - .instruction - .tip_amount_permissionless_taking - .clone() - .expect("tip_amount_permissionless_taking is not set"), - }; - let instruction = FlashTakeOrderStartCpi { - __program: self.instruction.__program, - - taker: self.instruction.taker.expect("taker is not set"), - - maker: self.instruction.maker.expect("maker is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - pda_authority: self - .instruction - .pda_authority - .expect("pda_authority is not set"), - - order: self.instruction.order.expect("order is not set"), - - input_mint: self.instruction.input_mint.expect("input_mint is not set"), - - output_mint: self - .instruction - .output_mint - .expect("output_mint is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - taker_input_ata: self - .instruction - .taker_input_ata - .expect("taker_input_ata is not set"), - - taker_output_ata: self - .instruction - .taker_output_ata - .expect("taker_output_ata is not set"), - - intermediary_output_token_account: self.instruction.intermediary_output_token_account, - - maker_output_ata: self.instruction.maker_output_ata, - - express_relay: self - .instruction - .express_relay - .expect("express_relay is not set"), - - express_relay_metadata: self - .instruction - .express_relay_metadata - .expect("express_relay_metadata is not set"), - - sysvar_instructions: self - .instruction - .sysvar_instructions - .expect("sysvar_instructions is not set"), - - permission: self.instruction.permission, - - config_router: self - .instruction - .config_router - .expect("config_router is not set"), - - input_token_program: self - .instruction - .input_token_program - .expect("input_token_program is not set"), - - output_token_program: self - .instruction - .output_token_program - .expect("output_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct FlashTakeOrderStartCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - taker: Option<&'b solana_account_info::AccountInfo<'a>>, - maker: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pda_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - order: Option<&'b solana_account_info::AccountInfo<'a>>, - input_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - taker_input_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - taker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - express_relay: Option<&'b solana_account_info::AccountInfo<'a>>, - express_relay_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - sysvar_instructions: Option<&'b solana_account_info::AccountInfo<'a>>, - permission: Option<&'b solana_account_info::AccountInfo<'a>>, - config_router: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - input_amount: Option, - min_output_amount: Option, - tip_amount_permissionless_taking: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/initialize_global_config.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/initialize_global_config.rs deleted file mode 100644 index df147039..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/initialize_global_config.rs +++ /dev/null @@ -1,367 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeGlobalConfig { - pub admin_authority: solana_pubkey::Pubkey, - - pub pda_authority: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, -} - -impl InitializeGlobalConfig { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.admin_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pda_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeGlobalConfigInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeGlobalConfigInstructionData { - discriminator: [u8; 8], -} - -impl InitializeGlobalConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [113, 216, 122, 131, 225, 209, 22, 55], - } - } -} - -impl Default for InitializeGlobalConfigInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `InitializeGlobalConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` admin_authority -/// 1. `[writable]` pda_authority -/// 2. `[writable]` global_config -#[derive(Clone, Debug, Default)] -pub struct InitializeGlobalConfigBuilder { - admin_authority: Option, - pda_authority: Option, - global_config: Option, - __remaining_accounts: Vec, -} - -impl InitializeGlobalConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn admin_authority(&mut self, admin_authority: solana_pubkey::Pubkey) -> &mut Self { - self.admin_authority = Some(admin_authority); - self - } - - #[inline(always)] - pub fn pda_authority(&mut self, pda_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeGlobalConfig { - admin_authority: self.admin_authority.expect("admin_authority is not set"), - pda_authority: self.pda_authority.expect("pda_authority is not set"), - global_config: self.global_config.expect("global_config is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize_global_config` CPI accounts. -pub struct InitializeGlobalConfigCpiAccounts<'a, 'b> { - pub admin_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_global_config` CPI instruction. -pub struct InitializeGlobalConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub admin_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializeGlobalConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeGlobalConfigCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - admin_authority: accounts.admin_authority, - pda_authority: accounts.pda_authority, - global_config: accounts.global_config, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.admin_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pda_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializeGlobalConfigInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.admin_authority.clone()); - account_infos.push(self.pda_authority.clone()); - account_infos.push(self.global_config.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeGlobalConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` admin_authority -/// 1. `[writable]` pda_authority -/// 2. `[writable]` global_config -#[derive(Clone, Debug)] -pub struct InitializeGlobalConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeGlobalConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeGlobalConfigCpiBuilderInstruction { - __program: program, - admin_authority: None, - pda_authority: None, - global_config: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn admin_authority( - &mut self, - admin_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.admin_authority = Some(admin_authority); - self - } - - #[inline(always)] - pub fn pda_authority( - &mut self, - pda_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializeGlobalConfigCpi { - __program: self.instruction.__program, - - admin_authority: self - .instruction - .admin_authority - .expect("admin_authority is not set"), - - pda_authority: self - .instruction - .pda_authority - .expect("pda_authority is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeGlobalConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - admin_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pda_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/initialize_vault.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/initialize_vault.rs deleted file mode 100644 index bb978fa2..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/initialize_vault.rs +++ /dev/null @@ -1,510 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeVault { - pub payer: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub pda_authority: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub vault: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeVault { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pda_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeVaultInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeVaultInstructionData { - discriminator: [u8; 8], -} - -impl InitializeVaultInstructionData { - pub fn new() -> Self { - Self { - discriminator: [48, 191, 163, 44, 71, 129, 63, 164], - } - } -} - -impl Default for InitializeVaultInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `InitializeVault`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[writable]` global_config -/// 2. `[]` pda_authority -/// 3. `[]` mint -/// 4. `[writable]` vault -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeVaultBuilder { - payer: Option, - global_config: Option, - pda_authority: Option, - mint: Option, - vault: Option, - token_program: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl InitializeVaultBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority(&mut self, pda_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeVault { - payer: self.payer.expect("payer is not set"), - global_config: self.global_config.expect("global_config is not set"), - pda_authority: self.pda_authority.expect("pda_authority is not set"), - mint: self.mint.expect("mint is not set"), - vault: self.vault.expect("vault is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize_vault` CPI accounts. -pub struct InitializeVaultCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_vault` CPI instruction. -pub struct InitializeVaultCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializeVaultCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeVaultCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - global_config: accounts.global_config, - pda_authority: accounts.pda_authority, - mint: accounts.mint, - vault: accounts.vault, - token_program: accounts.token_program, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pda_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializeVaultInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.pda_authority.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeVault` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[writable]` global_config -/// 2. `[]` pda_authority -/// 3. `[]` mint -/// 4. `[writable]` vault -/// 5. `[]` token_program -/// 6. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeVaultCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeVaultCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeVaultCpiBuilderInstruction { - __program: program, - payer: None, - global_config: None, - pda_authority: None, - mint: None, - vault: None, - token_program: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority( - &mut self, - pda_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializeVaultCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - pda_authority: self - .instruction - .pda_authority - .expect("pda_authority is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - vault: self.instruction.vault.expect("vault is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeVaultCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pda_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/log_user_swap_balances_end.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/log_user_swap_balances_end.rs deleted file mode 100644 index 2c05f735..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/log_user_swap_balances_end.rs +++ /dev/null @@ -1,1002 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct LogUserSwapBalancesEnd { - pub maker: solana_pubkey::Pubkey, - - pub input_mint: solana_pubkey::Pubkey, - - pub output_mint: solana_pubkey::Pubkey, - - pub input_ta: solana_pubkey::Pubkey, - - pub output_ta: solana_pubkey::Pubkey, - /// if it's not the pda it doesn't matter - pub pda_referrer: Option, - - pub swap_program_id: solana_pubkey::Pubkey, - - pub user_swap_balance_state: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub sysvar_instructions: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl LogUserSwapBalancesEnd { - pub fn instruction( - &self, - args: LogUserSwapBalancesEndInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: LogUserSwapBalancesEndInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.maker, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_ta, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_ta, - false, - )); - if let Some(pda_referrer) = self.pda_referrer { - accounts.push(solana_instruction::AccountMeta::new_readonly( - pda_referrer, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.swap_program_id, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_swap_balance_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sysvar_instructions, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&LogUserSwapBalancesEndInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LogUserSwapBalancesEndInstructionData { - discriminator: [u8; 8], -} - -impl LogUserSwapBalancesEndInstructionData { - pub fn new() -> Self { - Self { - discriminator: [140, 42, 198, 82, 147, 144, 44, 113], - } - } -} - -impl Default for LogUserSwapBalancesEndInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LogUserSwapBalancesEndInstructionArgs { - pub simulated_swap_amount_out: u64, - pub simulated_ts: u64, - pub minimum_amount_out: u64, - pub swap_amount_in: u64, - pub simulated_amount_out_next_best: u64, - pub aggregator: u8, - pub next_best_aggregator: u8, - pub padding: [u8; 2], -} - -/// Instruction builder for `LogUserSwapBalancesEnd`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` maker -/// 1. `[]` input_mint -/// 2. `[]` output_mint -/// 3. `[]` input_ta -/// 4. `[]` output_ta -/// 5. `[optional]` pda_referrer -/// 6. `[]` swap_program_id -/// 7. `[writable]` user_swap_balance_state -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 10. `[optional]` sysvar_instructions (default to `Sysvar1nstructions1111111111111111111111111`) -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug, Default)] -pub struct LogUserSwapBalancesEndBuilder { - maker: Option, - input_mint: Option, - output_mint: Option, - input_ta: Option, - output_ta: Option, - pda_referrer: Option, - swap_program_id: Option, - user_swap_balance_state: Option, - system_program: Option, - rent: Option, - sysvar_instructions: Option, - event_authority: Option, - program: Option, - simulated_swap_amount_out: Option, - simulated_ts: Option, - minimum_amount_out: Option, - swap_amount_in: Option, - simulated_amount_out_next_best: Option, - aggregator: Option, - next_best_aggregator: Option, - padding: Option<[u8; 2]>, - __remaining_accounts: Vec, -} - -impl LogUserSwapBalancesEndBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn maker(&mut self, maker: solana_pubkey::Pubkey) -> &mut Self { - self.maker = Some(maker); - self - } - - #[inline(always)] - pub fn input_mint(&mut self, input_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint(&mut self, output_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn input_ta(&mut self, input_ta: solana_pubkey::Pubkey) -> &mut Self { - self.input_ta = Some(input_ta); - self - } - - #[inline(always)] - pub fn output_ta(&mut self, output_ta: solana_pubkey::Pubkey) -> &mut Self { - self.output_ta = Some(output_ta); - self - } - - /// `[optional account]` - /// if it's not the pda it doesn't matter - #[inline(always)] - pub fn pda_referrer(&mut self, pda_referrer: Option) -> &mut Self { - self.pda_referrer = pda_referrer; - self - } - - #[inline(always)] - pub fn swap_program_id(&mut self, swap_program_id: solana_pubkey::Pubkey) -> &mut Self { - self.swap_program_id = Some(swap_program_id); - self - } - - #[inline(always)] - pub fn user_swap_balance_state( - &mut self, - user_swap_balance_state: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_swap_balance_state = Some(user_swap_balance_state); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` - #[inline(always)] - pub fn sysvar_instructions(&mut self, sysvar_instructions: solana_pubkey::Pubkey) -> &mut Self { - self.sysvar_instructions = Some(sysvar_instructions); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn simulated_swap_amount_out(&mut self, simulated_swap_amount_out: u64) -> &mut Self { - self.simulated_swap_amount_out = Some(simulated_swap_amount_out); - self - } - - #[inline(always)] - pub fn simulated_ts(&mut self, simulated_ts: u64) -> &mut Self { - self.simulated_ts = Some(simulated_ts); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.minimum_amount_out = Some(minimum_amount_out); - self - } - - #[inline(always)] - pub fn swap_amount_in(&mut self, swap_amount_in: u64) -> &mut Self { - self.swap_amount_in = Some(swap_amount_in); - self - } - - #[inline(always)] - pub fn simulated_amount_out_next_best( - &mut self, - simulated_amount_out_next_best: u64, - ) -> &mut Self { - self.simulated_amount_out_next_best = Some(simulated_amount_out_next_best); - self - } - - #[inline(always)] - pub fn aggregator(&mut self, aggregator: u8) -> &mut Self { - self.aggregator = Some(aggregator); - self - } - - #[inline(always)] - pub fn next_best_aggregator(&mut self, next_best_aggregator: u8) -> &mut Self { - self.next_best_aggregator = Some(next_best_aggregator); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 2]) -> &mut Self { - self.padding = Some(padding); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = LogUserSwapBalancesEnd { - maker: self.maker.expect("maker is not set"), - input_mint: self.input_mint.expect("input_mint is not set"), - output_mint: self.output_mint.expect("output_mint is not set"), - input_ta: self.input_ta.expect("input_ta is not set"), - output_ta: self.output_ta.expect("output_ta is not set"), - pda_referrer: self.pda_referrer, - swap_program_id: self.swap_program_id.expect("swap_program_id is not set"), - user_swap_balance_state: self - .user_swap_balance_state - .expect("user_swap_balance_state is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_pubkey::pubkey!( - "Sysvar1nstructions1111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = LogUserSwapBalancesEndInstructionArgs { - simulated_swap_amount_out: self - .simulated_swap_amount_out - .clone() - .expect("simulated_swap_amount_out is not set"), - simulated_ts: self.simulated_ts.clone().expect("simulated_ts is not set"), - minimum_amount_out: self - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - swap_amount_in: self - .swap_amount_in - .clone() - .expect("swap_amount_in is not set"), - simulated_amount_out_next_best: self - .simulated_amount_out_next_best - .clone() - .expect("simulated_amount_out_next_best is not set"), - aggregator: self.aggregator.clone().expect("aggregator is not set"), - next_best_aggregator: self - .next_best_aggregator - .clone() - .expect("next_best_aggregator is not set"), - padding: self.padding.clone().expect("padding is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `log_user_swap_balances_end` CPI accounts. -pub struct LogUserSwapBalancesEndCpiAccounts<'a, 'b> { - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub input_ta: &'b solana_account_info::AccountInfo<'a>, - - pub output_ta: &'b solana_account_info::AccountInfo<'a>, - /// if it's not the pda it doesn't matter - pub pda_referrer: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub swap_program_id: &'b solana_account_info::AccountInfo<'a>, - - pub user_swap_balance_state: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `log_user_swap_balances_end` CPI instruction. -pub struct LogUserSwapBalancesEndCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub input_ta: &'b solana_account_info::AccountInfo<'a>, - - pub output_ta: &'b solana_account_info::AccountInfo<'a>, - /// if it's not the pda it doesn't matter - pub pda_referrer: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub swap_program_id: &'b solana_account_info::AccountInfo<'a>, - - pub user_swap_balance_state: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: LogUserSwapBalancesEndInstructionArgs, -} - -impl<'a, 'b> LogUserSwapBalancesEndCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: LogUserSwapBalancesEndCpiAccounts<'a, 'b>, - args: LogUserSwapBalancesEndInstructionArgs, - ) -> Self { - Self { - __program: program, - maker: accounts.maker, - input_mint: accounts.input_mint, - output_mint: accounts.output_mint, - input_ta: accounts.input_ta, - output_ta: accounts.output_ta, - pda_referrer: accounts.pda_referrer, - swap_program_id: accounts.swap_program_id, - user_swap_balance_state: accounts.user_swap_balance_state, - system_program: accounts.system_program, - rent: accounts.rent, - sysvar_instructions: accounts.sysvar_instructions, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.maker.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_ta.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_ta.key, - false, - )); - if let Some(pda_referrer) = self.pda_referrer { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *pda_referrer.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.swap_program_id.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_swap_balance_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sysvar_instructions.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&LogUserSwapBalancesEndInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.maker.clone()); - account_infos.push(self.input_mint.clone()); - account_infos.push(self.output_mint.clone()); - account_infos.push(self.input_ta.clone()); - account_infos.push(self.output_ta.clone()); - if let Some(pda_referrer) = self.pda_referrer { - account_infos.push(pda_referrer.clone()); - } - account_infos.push(self.swap_program_id.clone()); - account_infos.push(self.user_swap_balance_state.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.sysvar_instructions.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `LogUserSwapBalancesEnd` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` maker -/// 1. `[]` input_mint -/// 2. `[]` output_mint -/// 3. `[]` input_ta -/// 4. `[]` output_ta -/// 5. `[optional]` pda_referrer -/// 6. `[]` swap_program_id -/// 7. `[writable]` user_swap_balance_state -/// 8. `[]` system_program -/// 9. `[]` rent -/// 10. `[]` sysvar_instructions -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug)] -pub struct LogUserSwapBalancesEndCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> LogUserSwapBalancesEndCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(LogUserSwapBalancesEndCpiBuilderInstruction { - __program: program, - maker: None, - input_mint: None, - output_mint: None, - input_ta: None, - output_ta: None, - pda_referrer: None, - swap_program_id: None, - user_swap_balance_state: None, - system_program: None, - rent: None, - sysvar_instructions: None, - event_authority: None, - program: None, - simulated_swap_amount_out: None, - simulated_ts: None, - minimum_amount_out: None, - swap_amount_in: None, - simulated_amount_out_next_best: None, - aggregator: None, - next_best_aggregator: None, - padding: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn maker(&mut self, maker: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.maker = Some(maker); - self - } - - #[inline(always)] - pub fn input_mint( - &mut self, - input_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint( - &mut self, - output_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn input_ta(&mut self, input_ta: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.input_ta = Some(input_ta); - self - } - - #[inline(always)] - pub fn output_ta(&mut self, output_ta: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.output_ta = Some(output_ta); - self - } - - /// `[optional account]` - /// if it's not the pda it doesn't matter - #[inline(always)] - pub fn pda_referrer( - &mut self, - pda_referrer: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.pda_referrer = pda_referrer; - self - } - - #[inline(always)] - pub fn swap_program_id( - &mut self, - swap_program_id: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.swap_program_id = Some(swap_program_id); - self - } - - #[inline(always)] - pub fn user_swap_balance_state( - &mut self, - user_swap_balance_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_swap_balance_state = Some(user_swap_balance_state); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn sysvar_instructions( - &mut self, - sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.sysvar_instructions = Some(sysvar_instructions); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn simulated_swap_amount_out(&mut self, simulated_swap_amount_out: u64) -> &mut Self { - self.instruction.simulated_swap_amount_out = Some(simulated_swap_amount_out); - self - } - - #[inline(always)] - pub fn simulated_ts(&mut self, simulated_ts: u64) -> &mut Self { - self.instruction.simulated_ts = Some(simulated_ts); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.instruction.minimum_amount_out = Some(minimum_amount_out); - self - } - - #[inline(always)] - pub fn swap_amount_in(&mut self, swap_amount_in: u64) -> &mut Self { - self.instruction.swap_amount_in = Some(swap_amount_in); - self - } - - #[inline(always)] - pub fn simulated_amount_out_next_best( - &mut self, - simulated_amount_out_next_best: u64, - ) -> &mut Self { - self.instruction.simulated_amount_out_next_best = Some(simulated_amount_out_next_best); - self - } - - #[inline(always)] - pub fn aggregator(&mut self, aggregator: u8) -> &mut Self { - self.instruction.aggregator = Some(aggregator); - self - } - - #[inline(always)] - pub fn next_best_aggregator(&mut self, next_best_aggregator: u8) -> &mut Self { - self.instruction.next_best_aggregator = Some(next_best_aggregator); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 2]) -> &mut Self { - self.instruction.padding = Some(padding); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = LogUserSwapBalancesEndInstructionArgs { - simulated_swap_amount_out: self - .instruction - .simulated_swap_amount_out - .clone() - .expect("simulated_swap_amount_out is not set"), - simulated_ts: self - .instruction - .simulated_ts - .clone() - .expect("simulated_ts is not set"), - minimum_amount_out: self - .instruction - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - swap_amount_in: self - .instruction - .swap_amount_in - .clone() - .expect("swap_amount_in is not set"), - simulated_amount_out_next_best: self - .instruction - .simulated_amount_out_next_best - .clone() - .expect("simulated_amount_out_next_best is not set"), - aggregator: self - .instruction - .aggregator - .clone() - .expect("aggregator is not set"), - next_best_aggregator: self - .instruction - .next_best_aggregator - .clone() - .expect("next_best_aggregator is not set"), - padding: self - .instruction - .padding - .clone() - .expect("padding is not set"), - }; - let instruction = LogUserSwapBalancesEndCpi { - __program: self.instruction.__program, - - maker: self.instruction.maker.expect("maker is not set"), - - input_mint: self.instruction.input_mint.expect("input_mint is not set"), - - output_mint: self - .instruction - .output_mint - .expect("output_mint is not set"), - - input_ta: self.instruction.input_ta.expect("input_ta is not set"), - - output_ta: self.instruction.output_ta.expect("output_ta is not set"), - - pda_referrer: self.instruction.pda_referrer, - - swap_program_id: self - .instruction - .swap_program_id - .expect("swap_program_id is not set"), - - user_swap_balance_state: self - .instruction - .user_swap_balance_state - .expect("user_swap_balance_state is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - sysvar_instructions: self - .instruction - .sysvar_instructions - .expect("sysvar_instructions is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct LogUserSwapBalancesEndCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - maker: Option<&'b solana_account_info::AccountInfo<'a>>, - input_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - input_ta: Option<&'b solana_account_info::AccountInfo<'a>>, - output_ta: Option<&'b solana_account_info::AccountInfo<'a>>, - pda_referrer: Option<&'b solana_account_info::AccountInfo<'a>>, - swap_program_id: Option<&'b solana_account_info::AccountInfo<'a>>, - user_swap_balance_state: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - sysvar_instructions: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - simulated_swap_amount_out: Option, - simulated_ts: Option, - minimum_amount_out: Option, - swap_amount_in: Option, - simulated_amount_out_next_best: Option, - aggregator: Option, - next_best_aggregator: Option, - padding: Option<[u8; 2]>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/log_user_swap_balances_start.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/log_user_swap_balances_start.rs deleted file mode 100644 index d92ba08e..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/log_user_swap_balances_start.rs +++ /dev/null @@ -1,783 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct LogUserSwapBalancesStart { - pub maker: solana_pubkey::Pubkey, - - pub input_mint: solana_pubkey::Pubkey, - - pub output_mint: solana_pubkey::Pubkey, - - pub input_ta: solana_pubkey::Pubkey, - - pub output_ta: solana_pubkey::Pubkey, - /// if it's not the pda it doesn't matter - pub pda_referrer: Option, - - pub swap_program_id: solana_pubkey::Pubkey, - - pub user_swap_balance_state: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub sysvar_instructions: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl LogUserSwapBalancesStart { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.maker, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_ta, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_ta, - false, - )); - if let Some(pda_referrer) = self.pda_referrer { - accounts.push(solana_instruction::AccountMeta::new_readonly( - pda_referrer, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.swap_program_id, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_swap_balance_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sysvar_instructions, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&LogUserSwapBalancesStartInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LogUserSwapBalancesStartInstructionData { - discriminator: [u8; 8], -} - -impl LogUserSwapBalancesStartInstructionData { - pub fn new() -> Self { - Self { - discriminator: [133, 108, 23, 15, 226, 215, 176, 95], - } - } -} - -impl Default for LogUserSwapBalancesStartInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `LogUserSwapBalancesStart`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` maker -/// 1. `[]` input_mint -/// 2. `[]` output_mint -/// 3. `[]` input_ta -/// 4. `[]` output_ta -/// 5. `[optional]` pda_referrer -/// 6. `[]` swap_program_id -/// 7. `[writable]` user_swap_balance_state -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 10. `[optional]` sysvar_instructions (default to `Sysvar1nstructions1111111111111111111111111`) -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug, Default)] -pub struct LogUserSwapBalancesStartBuilder { - maker: Option, - input_mint: Option, - output_mint: Option, - input_ta: Option, - output_ta: Option, - pda_referrer: Option, - swap_program_id: Option, - user_swap_balance_state: Option, - system_program: Option, - rent: Option, - sysvar_instructions: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl LogUserSwapBalancesStartBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn maker(&mut self, maker: solana_pubkey::Pubkey) -> &mut Self { - self.maker = Some(maker); - self - } - - #[inline(always)] - pub fn input_mint(&mut self, input_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint(&mut self, output_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn input_ta(&mut self, input_ta: solana_pubkey::Pubkey) -> &mut Self { - self.input_ta = Some(input_ta); - self - } - - #[inline(always)] - pub fn output_ta(&mut self, output_ta: solana_pubkey::Pubkey) -> &mut Self { - self.output_ta = Some(output_ta); - self - } - - /// `[optional account]` - /// if it's not the pda it doesn't matter - #[inline(always)] - pub fn pda_referrer(&mut self, pda_referrer: Option) -> &mut Self { - self.pda_referrer = pda_referrer; - self - } - - #[inline(always)] - pub fn swap_program_id(&mut self, swap_program_id: solana_pubkey::Pubkey) -> &mut Self { - self.swap_program_id = Some(swap_program_id); - self - } - - #[inline(always)] - pub fn user_swap_balance_state( - &mut self, - user_swap_balance_state: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_swap_balance_state = Some(user_swap_balance_state); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` - #[inline(always)] - pub fn sysvar_instructions(&mut self, sysvar_instructions: solana_pubkey::Pubkey) -> &mut Self { - self.sysvar_instructions = Some(sysvar_instructions); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = LogUserSwapBalancesStart { - maker: self.maker.expect("maker is not set"), - input_mint: self.input_mint.expect("input_mint is not set"), - output_mint: self.output_mint.expect("output_mint is not set"), - input_ta: self.input_ta.expect("input_ta is not set"), - output_ta: self.output_ta.expect("output_ta is not set"), - pda_referrer: self.pda_referrer, - swap_program_id: self.swap_program_id.expect("swap_program_id is not set"), - user_swap_balance_state: self - .user_swap_balance_state - .expect("user_swap_balance_state is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_pubkey::pubkey!( - "Sysvar1nstructions1111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `log_user_swap_balances_start` CPI accounts. -pub struct LogUserSwapBalancesStartCpiAccounts<'a, 'b> { - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub input_ta: &'b solana_account_info::AccountInfo<'a>, - - pub output_ta: &'b solana_account_info::AccountInfo<'a>, - /// if it's not the pda it doesn't matter - pub pda_referrer: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub swap_program_id: &'b solana_account_info::AccountInfo<'a>, - - pub user_swap_balance_state: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `log_user_swap_balances_start` CPI instruction. -pub struct LogUserSwapBalancesStartCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub input_ta: &'b solana_account_info::AccountInfo<'a>, - - pub output_ta: &'b solana_account_info::AccountInfo<'a>, - /// if it's not the pda it doesn't matter - pub pda_referrer: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub swap_program_id: &'b solana_account_info::AccountInfo<'a>, - - pub user_swap_balance_state: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> LogUserSwapBalancesStartCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: LogUserSwapBalancesStartCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - maker: accounts.maker, - input_mint: accounts.input_mint, - output_mint: accounts.output_mint, - input_ta: accounts.input_ta, - output_ta: accounts.output_ta, - pda_referrer: accounts.pda_referrer, - swap_program_id: accounts.swap_program_id, - user_swap_balance_state: accounts.user_swap_balance_state, - system_program: accounts.system_program, - rent: accounts.rent, - sysvar_instructions: accounts.sysvar_instructions, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.maker.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_ta.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_ta.key, - false, - )); - if let Some(pda_referrer) = self.pda_referrer { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *pda_referrer.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.swap_program_id.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_swap_balance_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sysvar_instructions.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&LogUserSwapBalancesStartInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.maker.clone()); - account_infos.push(self.input_mint.clone()); - account_infos.push(self.output_mint.clone()); - account_infos.push(self.input_ta.clone()); - account_infos.push(self.output_ta.clone()); - if let Some(pda_referrer) = self.pda_referrer { - account_infos.push(pda_referrer.clone()); - } - account_infos.push(self.swap_program_id.clone()); - account_infos.push(self.user_swap_balance_state.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.sysvar_instructions.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `LogUserSwapBalancesStart` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` maker -/// 1. `[]` input_mint -/// 2. `[]` output_mint -/// 3. `[]` input_ta -/// 4. `[]` output_ta -/// 5. `[optional]` pda_referrer -/// 6. `[]` swap_program_id -/// 7. `[writable]` user_swap_balance_state -/// 8. `[]` system_program -/// 9. `[]` rent -/// 10. `[]` sysvar_instructions -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug)] -pub struct LogUserSwapBalancesStartCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> LogUserSwapBalancesStartCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(LogUserSwapBalancesStartCpiBuilderInstruction { - __program: program, - maker: None, - input_mint: None, - output_mint: None, - input_ta: None, - output_ta: None, - pda_referrer: None, - swap_program_id: None, - user_swap_balance_state: None, - system_program: None, - rent: None, - sysvar_instructions: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn maker(&mut self, maker: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.maker = Some(maker); - self - } - - #[inline(always)] - pub fn input_mint( - &mut self, - input_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint( - &mut self, - output_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn input_ta(&mut self, input_ta: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.input_ta = Some(input_ta); - self - } - - #[inline(always)] - pub fn output_ta(&mut self, output_ta: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.output_ta = Some(output_ta); - self - } - - /// `[optional account]` - /// if it's not the pda it doesn't matter - #[inline(always)] - pub fn pda_referrer( - &mut self, - pda_referrer: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.pda_referrer = pda_referrer; - self - } - - #[inline(always)] - pub fn swap_program_id( - &mut self, - swap_program_id: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.swap_program_id = Some(swap_program_id); - self - } - - #[inline(always)] - pub fn user_swap_balance_state( - &mut self, - user_swap_balance_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_swap_balance_state = Some(user_swap_balance_state); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn sysvar_instructions( - &mut self, - sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.sysvar_instructions = Some(sysvar_instructions); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = LogUserSwapBalancesStartCpi { - __program: self.instruction.__program, - - maker: self.instruction.maker.expect("maker is not set"), - - input_mint: self.instruction.input_mint.expect("input_mint is not set"), - - output_mint: self - .instruction - .output_mint - .expect("output_mint is not set"), - - input_ta: self.instruction.input_ta.expect("input_ta is not set"), - - output_ta: self.instruction.output_ta.expect("output_ta is not set"), - - pda_referrer: self.instruction.pda_referrer, - - swap_program_id: self - .instruction - .swap_program_id - .expect("swap_program_id is not set"), - - user_swap_balance_state: self - .instruction - .user_swap_balance_state - .expect("user_swap_balance_state is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - sysvar_instructions: self - .instruction - .sysvar_instructions - .expect("sysvar_instructions is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct LogUserSwapBalancesStartCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - maker: Option<&'b solana_account_info::AccountInfo<'a>>, - input_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - input_ta: Option<&'b solana_account_info::AccountInfo<'a>>, - output_ta: Option<&'b solana_account_info::AccountInfo<'a>>, - pda_referrer: Option<&'b solana_account_info::AccountInfo<'a>>, - swap_program_id: Option<&'b solana_account_info::AccountInfo<'a>>, - user_swap_balance_state: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - sysvar_instructions: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/mod.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index ef60af5c..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#close_order_and_claim_tip; -pub(crate) mod r#create_order; -pub(crate) mod r#flash_take_order_end; -pub(crate) mod r#flash_take_order_start; -pub(crate) mod r#initialize_global_config; -pub(crate) mod r#initialize_vault; -pub(crate) mod r#log_user_swap_balances_end; -pub(crate) mod r#log_user_swap_balances_start; -pub(crate) mod r#take_order; -pub(crate) mod r#update_global_config; -pub(crate) mod r#update_global_config_admin; -pub(crate) mod r#withdraw_host_tip; - -pub use self::{ - r#close_order_and_claim_tip::*, r#create_order::*, r#flash_take_order_end::*, - r#flash_take_order_start::*, r#initialize_global_config::*, r#initialize_vault::*, - r#log_user_swap_balances_end::*, r#log_user_swap_balances_start::*, r#take_order::*, - r#update_global_config::*, r#update_global_config_admin::*, r#withdraw_host_tip::*, -}; diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/take_order.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/take_order.rs deleted file mode 100644 index 6dd87c18..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/take_order.rs +++ /dev/null @@ -1,1323 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct TakeOrder { - pub taker: solana_pubkey::Pubkey, - - pub maker: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub pda_authority: solana_pubkey::Pubkey, - - pub order: solana_pubkey::Pubkey, - - pub input_mint: solana_pubkey::Pubkey, - - pub output_mint: solana_pubkey::Pubkey, - - pub input_vault: solana_pubkey::Pubkey, - - pub taker_input_ata: solana_pubkey::Pubkey, - - pub taker_output_ata: solana_pubkey::Pubkey, - - pub intermediary_output_token_account: Option, - - pub maker_output_ata: Option, - - pub express_relay: solana_pubkey::Pubkey, - - pub express_relay_metadata: solana_pubkey::Pubkey, - - pub sysvar_instructions: solana_pubkey::Pubkey, - - pub permission: Option, - - pub config_router: solana_pubkey::Pubkey, - - pub input_token_program: solana_pubkey::Pubkey, - - pub output_token_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl TakeOrder { - pub fn instruction(&self, args: TakeOrderInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: TakeOrderInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(23 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.taker, true)); - accounts.push(solana_instruction::AccountMeta::new(self.maker, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pda_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.order, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.taker_input_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.taker_output_ata, - false, - )); - if let Some(intermediary_output_token_account) = self.intermediary_output_token_account { - accounts.push(solana_instruction::AccountMeta::new( - intermediary_output_token_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - if let Some(maker_output_ata) = self.maker_output_ata { - accounts.push(solana_instruction::AccountMeta::new( - maker_output_ata, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.express_relay, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.express_relay_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sysvar_instructions, - false, - )); - if let Some(permission) = self.permission { - accounts.push(solana_instruction::AccountMeta::new_readonly( - permission, false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config_router, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&TakeOrderInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TakeOrderInstructionData { - discriminator: [u8; 8], -} - -impl TakeOrderInstructionData { - pub fn new() -> Self { - Self { - discriminator: [163, 208, 20, 172, 223, 65, 255, 228], - } - } -} - -impl Default for TakeOrderInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TakeOrderInstructionArgs { - pub input_amount: u64, - pub min_output_amount: u64, - pub tip_amount_permissionless_taking: u64, -} - -/// Instruction builder for `TakeOrder`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` taker -/// 1. `[writable]` maker -/// 2. `[writable]` global_config -/// 3. `[writable]` pda_authority -/// 4. `[writable]` order -/// 5. `[]` input_mint -/// 6. `[]` output_mint -/// 7. `[writable]` input_vault -/// 8. `[writable]` taker_input_ata -/// 9. `[writable]` taker_output_ata -/// 10. `[writable, optional]` intermediary_output_token_account -/// 11. `[writable, optional]` maker_output_ata -/// 12. `[]` express_relay -/// 13. `[]` express_relay_metadata -/// 14. `[optional]` sysvar_instructions (default to `Sysvar1nstructions1111111111111111111111111`) -/// 15. `[optional]` permission -/// 16. `[]` config_router -/// 17. `[]` input_token_program -/// 18. `[]` output_token_program -/// 19. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 20. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 21. `[]` event_authority -/// 22. `[]` program -#[derive(Clone, Debug, Default)] -pub struct TakeOrderBuilder { - taker: Option, - maker: Option, - global_config: Option, - pda_authority: Option, - order: Option, - input_mint: Option, - output_mint: Option, - input_vault: Option, - taker_input_ata: Option, - taker_output_ata: Option, - intermediary_output_token_account: Option, - maker_output_ata: Option, - express_relay: Option, - express_relay_metadata: Option, - sysvar_instructions: Option, - permission: Option, - config_router: Option, - input_token_program: Option, - output_token_program: Option, - rent: Option, - system_program: Option, - event_authority: Option, - program: Option, - input_amount: Option, - min_output_amount: Option, - tip_amount_permissionless_taking: Option, - __remaining_accounts: Vec, -} - -impl TakeOrderBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn taker(&mut self, taker: solana_pubkey::Pubkey) -> &mut Self { - self.taker = Some(taker); - self - } - - #[inline(always)] - pub fn maker(&mut self, maker: solana_pubkey::Pubkey) -> &mut Self { - self.maker = Some(maker); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority(&mut self, pda_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn order(&mut self, order: solana_pubkey::Pubkey) -> &mut Self { - self.order = Some(order); - self - } - - #[inline(always)] - pub fn input_mint(&mut self, input_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint(&mut self, output_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn taker_input_ata(&mut self, taker_input_ata: solana_pubkey::Pubkey) -> &mut Self { - self.taker_input_ata = Some(taker_input_ata); - self - } - - #[inline(always)] - pub fn taker_output_ata(&mut self, taker_output_ata: solana_pubkey::Pubkey) -> &mut Self { - self.taker_output_ata = Some(taker_output_ata); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn intermediary_output_token_account( - &mut self, - intermediary_output_token_account: Option, - ) -> &mut Self { - self.intermediary_output_token_account = intermediary_output_token_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn maker_output_ata( - &mut self, - maker_output_ata: Option, - ) -> &mut Self { - self.maker_output_ata = maker_output_ata; - self - } - - #[inline(always)] - pub fn express_relay(&mut self, express_relay: solana_pubkey::Pubkey) -> &mut Self { - self.express_relay = Some(express_relay); - self - } - - #[inline(always)] - pub fn express_relay_metadata( - &mut self, - express_relay_metadata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.express_relay_metadata = Some(express_relay_metadata); - self - } - - /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` - #[inline(always)] - pub fn sysvar_instructions(&mut self, sysvar_instructions: solana_pubkey::Pubkey) -> &mut Self { - self.sysvar_instructions = Some(sysvar_instructions); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn permission(&mut self, permission: Option) -> &mut Self { - self.permission = permission; - self - } - - #[inline(always)] - pub fn config_router(&mut self, config_router: solana_pubkey::Pubkey) -> &mut Self { - self.config_router = Some(config_router); - self - } - - #[inline(always)] - pub fn input_token_program(&mut self, input_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_program = Some(input_token_program); - self - } - - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_program = Some(output_token_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn input_amount(&mut self, input_amount: u64) -> &mut Self { - self.input_amount = Some(input_amount); - self - } - - #[inline(always)] - pub fn min_output_amount(&mut self, min_output_amount: u64) -> &mut Self { - self.min_output_amount = Some(min_output_amount); - self - } - - #[inline(always)] - pub fn tip_amount_permissionless_taking( - &mut self, - tip_amount_permissionless_taking: u64, - ) -> &mut Self { - self.tip_amount_permissionless_taking = Some(tip_amount_permissionless_taking); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = TakeOrder { - taker: self.taker.expect("taker is not set"), - maker: self.maker.expect("maker is not set"), - global_config: self.global_config.expect("global_config is not set"), - pda_authority: self.pda_authority.expect("pda_authority is not set"), - order: self.order.expect("order is not set"), - input_mint: self.input_mint.expect("input_mint is not set"), - output_mint: self.output_mint.expect("output_mint is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - taker_input_ata: self.taker_input_ata.expect("taker_input_ata is not set"), - taker_output_ata: self.taker_output_ata.expect("taker_output_ata is not set"), - intermediary_output_token_account: self.intermediary_output_token_account, - maker_output_ata: self.maker_output_ata, - express_relay: self.express_relay.expect("express_relay is not set"), - express_relay_metadata: self - .express_relay_metadata - .expect("express_relay_metadata is not set"), - sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_pubkey::pubkey!( - "Sysvar1nstructions1111111111111111111111111" - )), - permission: self.permission, - config_router: self.config_router.expect("config_router is not set"), - input_token_program: self - .input_token_program - .expect("input_token_program is not set"), - output_token_program: self - .output_token_program - .expect("output_token_program is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = TakeOrderInstructionArgs { - input_amount: self.input_amount.clone().expect("input_amount is not set"), - min_output_amount: self - .min_output_amount - .clone() - .expect("min_output_amount is not set"), - tip_amount_permissionless_taking: self - .tip_amount_permissionless_taking - .clone() - .expect("tip_amount_permissionless_taking is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `take_order` CPI accounts. -pub struct TakeOrderCpiAccounts<'a, 'b> { - pub taker: &'b solana_account_info::AccountInfo<'a>, - - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub order: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub taker_input_ata: &'b solana_account_info::AccountInfo<'a>, - - pub taker_output_ata: &'b solana_account_info::AccountInfo<'a>, - - pub intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub express_relay: &'b solana_account_info::AccountInfo<'a>, - - pub express_relay_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - - pub permission: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub config_router: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `take_order` CPI instruction. -pub struct TakeOrderCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub taker: &'b solana_account_info::AccountInfo<'a>, - - pub maker: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub order: &'b solana_account_info::AccountInfo<'a>, - - pub input_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_mint: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub taker_input_ata: &'b solana_account_info::AccountInfo<'a>, - - pub taker_output_ata: &'b solana_account_info::AccountInfo<'a>, - - pub intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub express_relay: &'b solana_account_info::AccountInfo<'a>, - - pub express_relay_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - - pub permission: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub config_router: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: TakeOrderInstructionArgs, -} - -impl<'a, 'b> TakeOrderCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: TakeOrderCpiAccounts<'a, 'b>, - args: TakeOrderInstructionArgs, - ) -> Self { - Self { - __program: program, - taker: accounts.taker, - maker: accounts.maker, - global_config: accounts.global_config, - pda_authority: accounts.pda_authority, - order: accounts.order, - input_mint: accounts.input_mint, - output_mint: accounts.output_mint, - input_vault: accounts.input_vault, - taker_input_ata: accounts.taker_input_ata, - taker_output_ata: accounts.taker_output_ata, - intermediary_output_token_account: accounts.intermediary_output_token_account, - maker_output_ata: accounts.maker_output_ata, - express_relay: accounts.express_relay, - express_relay_metadata: accounts.express_relay_metadata, - sysvar_instructions: accounts.sysvar_instructions, - permission: accounts.permission, - config_router: accounts.config_router, - input_token_program: accounts.input_token_program, - output_token_program: accounts.output_token_program, - rent: accounts.rent, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(23 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.taker.key, true)); - accounts.push(solana_instruction::AccountMeta::new(*self.maker.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pda_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.order.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.taker_input_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.taker_output_ata.key, - false, - )); - if let Some(intermediary_output_token_account) = self.intermediary_output_token_account { - accounts.push(solana_instruction::AccountMeta::new( - *intermediary_output_token_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - if let Some(maker_output_ata) = self.maker_output_ata { - accounts.push(solana_instruction::AccountMeta::new( - *maker_output_ata.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.express_relay.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.express_relay_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sysvar_instructions.key, - false, - )); - if let Some(permission) = self.permission { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *permission.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LIMO_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config_router.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&TakeOrderInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(24 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.taker.clone()); - account_infos.push(self.maker.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.pda_authority.clone()); - account_infos.push(self.order.clone()); - account_infos.push(self.input_mint.clone()); - account_infos.push(self.output_mint.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.taker_input_ata.clone()); - account_infos.push(self.taker_output_ata.clone()); - if let Some(intermediary_output_token_account) = self.intermediary_output_token_account { - account_infos.push(intermediary_output_token_account.clone()); - } - if let Some(maker_output_ata) = self.maker_output_ata { - account_infos.push(maker_output_ata.clone()); - } - account_infos.push(self.express_relay.clone()); - account_infos.push(self.express_relay_metadata.clone()); - account_infos.push(self.sysvar_instructions.clone()); - if let Some(permission) = self.permission { - account_infos.push(permission.clone()); - } - account_infos.push(self.config_router.clone()); - account_infos.push(self.input_token_program.clone()); - account_infos.push(self.output_token_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `TakeOrder` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` taker -/// 1. `[writable]` maker -/// 2. `[writable]` global_config -/// 3. `[writable]` pda_authority -/// 4. `[writable]` order -/// 5. `[]` input_mint -/// 6. `[]` output_mint -/// 7. `[writable]` input_vault -/// 8. `[writable]` taker_input_ata -/// 9. `[writable]` taker_output_ata -/// 10. `[writable, optional]` intermediary_output_token_account -/// 11. `[writable, optional]` maker_output_ata -/// 12. `[]` express_relay -/// 13. `[]` express_relay_metadata -/// 14. `[]` sysvar_instructions -/// 15. `[optional]` permission -/// 16. `[]` config_router -/// 17. `[]` input_token_program -/// 18. `[]` output_token_program -/// 19. `[]` rent -/// 20. `[]` system_program -/// 21. `[]` event_authority -/// 22. `[]` program -#[derive(Clone, Debug)] -pub struct TakeOrderCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> TakeOrderCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(TakeOrderCpiBuilderInstruction { - __program: program, - taker: None, - maker: None, - global_config: None, - pda_authority: None, - order: None, - input_mint: None, - output_mint: None, - input_vault: None, - taker_input_ata: None, - taker_output_ata: None, - intermediary_output_token_account: None, - maker_output_ata: None, - express_relay: None, - express_relay_metadata: None, - sysvar_instructions: None, - permission: None, - config_router: None, - input_token_program: None, - output_token_program: None, - rent: None, - system_program: None, - event_authority: None, - program: None, - input_amount: None, - min_output_amount: None, - tip_amount_permissionless_taking: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn taker(&mut self, taker: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.taker = Some(taker); - self - } - - #[inline(always)] - pub fn maker(&mut self, maker: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.maker = Some(maker); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority( - &mut self, - pda_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn order(&mut self, order: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.order = Some(order); - self - } - - #[inline(always)] - pub fn input_mint( - &mut self, - input_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_mint = Some(input_mint); - self - } - - #[inline(always)] - pub fn output_mint( - &mut self, - output_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_mint = Some(output_mint); - self - } - - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn taker_input_ata( - &mut self, - taker_input_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.taker_input_ata = Some(taker_input_ata); - self - } - - #[inline(always)] - pub fn taker_output_ata( - &mut self, - taker_output_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.taker_output_ata = Some(taker_output_ata); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn intermediary_output_token_account( - &mut self, - intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.intermediary_output_token_account = intermediary_output_token_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn maker_output_ata( - &mut self, - maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.maker_output_ata = maker_output_ata; - self - } - - #[inline(always)] - pub fn express_relay( - &mut self, - express_relay: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.express_relay = Some(express_relay); - self - } - - #[inline(always)] - pub fn express_relay_metadata( - &mut self, - express_relay_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.express_relay_metadata = Some(express_relay_metadata); - self - } - - #[inline(always)] - pub fn sysvar_instructions( - &mut self, - sysvar_instructions: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.sysvar_instructions = Some(sysvar_instructions); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn permission( - &mut self, - permission: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.permission = permission; - self - } - - #[inline(always)] - pub fn config_router( - &mut self, - config_router: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_router = Some(config_router); - self - } - - #[inline(always)] - pub fn input_token_program( - &mut self, - input_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_program = Some(input_token_program); - self - } - - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_program = Some(output_token_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn input_amount(&mut self, input_amount: u64) -> &mut Self { - self.instruction.input_amount = Some(input_amount); - self - } - - #[inline(always)] - pub fn min_output_amount(&mut self, min_output_amount: u64) -> &mut Self { - self.instruction.min_output_amount = Some(min_output_amount); - self - } - - #[inline(always)] - pub fn tip_amount_permissionless_taking( - &mut self, - tip_amount_permissionless_taking: u64, - ) -> &mut Self { - self.instruction.tip_amount_permissionless_taking = Some(tip_amount_permissionless_taking); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = TakeOrderInstructionArgs { - input_amount: self - .instruction - .input_amount - .clone() - .expect("input_amount is not set"), - min_output_amount: self - .instruction - .min_output_amount - .clone() - .expect("min_output_amount is not set"), - tip_amount_permissionless_taking: self - .instruction - .tip_amount_permissionless_taking - .clone() - .expect("tip_amount_permissionless_taking is not set"), - }; - let instruction = TakeOrderCpi { - __program: self.instruction.__program, - - taker: self.instruction.taker.expect("taker is not set"), - - maker: self.instruction.maker.expect("maker is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - pda_authority: self - .instruction - .pda_authority - .expect("pda_authority is not set"), - - order: self.instruction.order.expect("order is not set"), - - input_mint: self.instruction.input_mint.expect("input_mint is not set"), - - output_mint: self - .instruction - .output_mint - .expect("output_mint is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - taker_input_ata: self - .instruction - .taker_input_ata - .expect("taker_input_ata is not set"), - - taker_output_ata: self - .instruction - .taker_output_ata - .expect("taker_output_ata is not set"), - - intermediary_output_token_account: self.instruction.intermediary_output_token_account, - - maker_output_ata: self.instruction.maker_output_ata, - - express_relay: self - .instruction - .express_relay - .expect("express_relay is not set"), - - express_relay_metadata: self - .instruction - .express_relay_metadata - .expect("express_relay_metadata is not set"), - - sysvar_instructions: self - .instruction - .sysvar_instructions - .expect("sysvar_instructions is not set"), - - permission: self.instruction.permission, - - config_router: self - .instruction - .config_router - .expect("config_router is not set"), - - input_token_program: self - .instruction - .input_token_program - .expect("input_token_program is not set"), - - output_token_program: self - .instruction - .output_token_program - .expect("output_token_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct TakeOrderCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - taker: Option<&'b solana_account_info::AccountInfo<'a>>, - maker: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pda_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - order: Option<&'b solana_account_info::AccountInfo<'a>>, - input_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - taker_input_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - taker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - intermediary_output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - maker_output_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - express_relay: Option<&'b solana_account_info::AccountInfo<'a>>, - express_relay_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - sysvar_instructions: Option<&'b solana_account_info::AccountInfo<'a>>, - permission: Option<&'b solana_account_info::AccountInfo<'a>>, - config_router: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - input_amount: Option, - min_output_amount: Option, - tip_amount_permissionless_taking: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/update_global_config.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/update_global_config.rs deleted file mode 100644 index 7d53e7df..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/update_global_config.rs +++ /dev/null @@ -1,383 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateGlobalConfig { - pub admin_authority: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, -} - -impl UpdateGlobalConfig { - pub fn instruction( - &self, - args: UpdateGlobalConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateGlobalConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.admin_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateGlobalConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateGlobalConfigInstructionData { - discriminator: [u8; 8], -} - -impl UpdateGlobalConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [164, 84, 130, 189, 111, 58, 250, 200], - } - } -} - -impl Default for UpdateGlobalConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateGlobalConfigInstructionArgs { - pub mode: u16, - pub value: [u8; 128], -} - -/// Instruction builder for `UpdateGlobalConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` admin_authority -/// 1. `[writable]` global_config -#[derive(Clone, Debug, Default)] -pub struct UpdateGlobalConfigBuilder { - admin_authority: Option, - global_config: Option, - mode: Option, - value: Option<[u8; 128]>, - __remaining_accounts: Vec, -} - -impl UpdateGlobalConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn admin_authority(&mut self, admin_authority: solana_pubkey::Pubkey) -> &mut Self { - self.admin_authority = Some(admin_authority); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn mode(&mut self, mode: u16) -> &mut Self { - self.mode = Some(mode); - self - } - - #[inline(always)] - pub fn value(&mut self, value: [u8; 128]) -> &mut Self { - self.value = Some(value); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateGlobalConfig { - admin_authority: self.admin_authority.expect("admin_authority is not set"), - global_config: self.global_config.expect("global_config is not set"), - }; - let args = UpdateGlobalConfigInstructionArgs { - mode: self.mode.clone().expect("mode is not set"), - value: self.value.clone().expect("value is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_global_config` CPI accounts. -pub struct UpdateGlobalConfigCpiAccounts<'a, 'b> { - pub admin_authority: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_global_config` CPI instruction. -pub struct UpdateGlobalConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub admin_authority: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateGlobalConfigInstructionArgs, -} - -impl<'a, 'b> UpdateGlobalConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateGlobalConfigCpiAccounts<'a, 'b>, - args: UpdateGlobalConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - admin_authority: accounts.admin_authority, - global_config: accounts.global_config, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.admin_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateGlobalConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.admin_authority.clone()); - account_infos.push(self.global_config.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateGlobalConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` admin_authority -/// 1. `[writable]` global_config -#[derive(Clone, Debug)] -pub struct UpdateGlobalConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateGlobalConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateGlobalConfigCpiBuilderInstruction { - __program: program, - admin_authority: None, - global_config: None, - mode: None, - value: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn admin_authority( - &mut self, - admin_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.admin_authority = Some(admin_authority); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn mode(&mut self, mode: u16) -> &mut Self { - self.instruction.mode = Some(mode); - self - } - - #[inline(always)] - pub fn value(&mut self, value: [u8; 128]) -> &mut Self { - self.instruction.value = Some(value); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateGlobalConfigInstructionArgs { - mode: self.instruction.mode.clone().expect("mode is not set"), - value: self.instruction.value.clone().expect("value is not set"), - }; - let instruction = UpdateGlobalConfigCpi { - __program: self.instruction.__program, - - admin_authority: self - .instruction - .admin_authority - .expect("admin_authority is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateGlobalConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - admin_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - mode: Option, - value: Option<[u8; 128]>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/update_global_config_admin.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/update_global_config_admin.rs deleted file mode 100644 index b6f1a155..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/update_global_config_admin.rs +++ /dev/null @@ -1,330 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateGlobalConfigAdmin { - pub admin_authority_cached: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, -} - -impl UpdateGlobalConfigAdmin { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin_authority_cached, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&UpdateGlobalConfigAdminInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateGlobalConfigAdminInstructionData { - discriminator: [u8; 8], -} - -impl UpdateGlobalConfigAdminInstructionData { - pub fn new() -> Self { - Self { - discriminator: [184, 87, 23, 193, 156, 238, 175, 119], - } - } -} - -impl Default for UpdateGlobalConfigAdminInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `UpdateGlobalConfigAdmin`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` admin_authority_cached -/// 1. `[writable]` global_config -#[derive(Clone, Debug, Default)] -pub struct UpdateGlobalConfigAdminBuilder { - admin_authority_cached: Option, - global_config: Option, - __remaining_accounts: Vec, -} - -impl UpdateGlobalConfigAdminBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn admin_authority_cached( - &mut self, - admin_authority_cached: solana_pubkey::Pubkey, - ) -> &mut Self { - self.admin_authority_cached = Some(admin_authority_cached); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateGlobalConfigAdmin { - admin_authority_cached: self - .admin_authority_cached - .expect("admin_authority_cached is not set"), - global_config: self.global_config.expect("global_config is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `update_global_config_admin` CPI accounts. -pub struct UpdateGlobalConfigAdminCpiAccounts<'a, 'b> { - pub admin_authority_cached: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_global_config_admin` CPI instruction. -pub struct UpdateGlobalConfigAdminCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub admin_authority_cached: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> UpdateGlobalConfigAdminCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateGlobalConfigAdminCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - admin_authority_cached: accounts.admin_authority_cached, - global_config: accounts.global_config, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin_authority_cached.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&UpdateGlobalConfigAdminInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.admin_authority_cached.clone()); - account_infos.push(self.global_config.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateGlobalConfigAdmin` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` admin_authority_cached -/// 1. `[writable]` global_config -#[derive(Clone, Debug)] -pub struct UpdateGlobalConfigAdminCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateGlobalConfigAdminCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateGlobalConfigAdminCpiBuilderInstruction { - __program: program, - admin_authority_cached: None, - global_config: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn admin_authority_cached( - &mut self, - admin_authority_cached: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.admin_authority_cached = Some(admin_authority_cached); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = UpdateGlobalConfigAdminCpi { - __program: self.instruction.__program, - - admin_authority_cached: self - .instruction - .admin_authority_cached - .expect("admin_authority_cached is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateGlobalConfigAdminCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - admin_authority_cached: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/withdraw_host_tip.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/withdraw_host_tip.rs deleted file mode 100644 index 18d7e497..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/instructions/withdraw_host_tip.rs +++ /dev/null @@ -1,412 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct WithdrawHostTip { - pub admin_authority: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub pda_authority: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl WithdrawHostTip { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.admin_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pda_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&WithdrawHostTipInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawHostTipInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawHostTipInstructionData { - pub fn new() -> Self { - Self { - discriminator: [140, 246, 105, 165, 80, 85, 143, 18], - } - } -} - -impl Default for WithdrawHostTipInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `WithdrawHostTip`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` admin_authority -/// 1. `[writable]` global_config -/// 2. `[writable]` pda_authority -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct WithdrawHostTipBuilder { - admin_authority: Option, - global_config: Option, - pda_authority: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl WithdrawHostTipBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn admin_authority(&mut self, admin_authority: solana_pubkey::Pubkey) -> &mut Self { - self.admin_authority = Some(admin_authority); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority(&mut self, pda_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pda_authority = Some(pda_authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = WithdrawHostTip { - admin_authority: self.admin_authority.expect("admin_authority is not set"), - global_config: self.global_config.expect("global_config is not set"), - pda_authority: self.pda_authority.expect("pda_authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `withdraw_host_tip` CPI accounts. -pub struct WithdrawHostTipCpiAccounts<'a, 'b> { - pub admin_authority: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw_host_tip` CPI instruction. -pub struct WithdrawHostTipCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub admin_authority: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub pda_authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> WithdrawHostTipCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawHostTipCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - admin_authority: accounts.admin_authority, - global_config: accounts.global_config, - pda_authority: accounts.pda_authority, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.admin_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pda_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&WithdrawHostTipInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LIMO_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.admin_authority.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.pda_authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `WithdrawHostTip` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` admin_authority -/// 1. `[writable]` global_config -/// 2. `[writable]` pda_authority -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct WithdrawHostTipCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawHostTipCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawHostTipCpiBuilderInstruction { - __program: program, - admin_authority: None, - global_config: None, - pda_authority: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn admin_authority( - &mut self, - admin_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.admin_authority = Some(admin_authority); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn pda_authority( - &mut self, - pda_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pda_authority = Some(pda_authority); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = WithdrawHostTipCpi { - __program: self.instruction.__program, - - admin_authority: self - .instruction - .admin_authority - .expect("admin_authority is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - pda_authority: self - .instruction - .pda_authority - .expect("pda_authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawHostTipCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - admin_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pda_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/mod.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/programs.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 1246844b..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `limo` program ID. -pub const LIMO_ID: Pubkey = pubkey!("LiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF"); diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/shared.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/types/mod.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index 5a41a9cf..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#order_status; -pub(crate) mod r#order_type; -pub(crate) mod r#update_global_config_mode; -pub(crate) mod r#update_global_config_value; - -pub use self::{ - r#order_status::*, r#order_type::*, r#update_global_config_mode::*, - r#update_global_config_value::*, -}; diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/types/order_status.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/types/order_status.rs deleted file mode 100644 index 79564286..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/types/order_status.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum OrderStatus { - Active, - Filled, - Cancelled, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/types/order_type.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/types/order_type.rs deleted file mode 100644 index f2df2756..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/types/order_type.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum OrderType { - Vanilla, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/types/update_global_config_mode.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/types/update_global_config_mode.rs deleted file mode 100644 index 2cab1b05..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/types/update_global_config_mode.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum UpdateGlobalConfigMode { - UpdateEmergencyMode, - UpdateFlashTakeOrderBlocked, - UpdateBlockNewOrders, - UpdateBlockOrderTaking, - UpdateHostFeeBps, - UpdateAdminAuthorityCached, - UpdateOrderTakingPermissionless, - UpdateOrderCloseDelaySeconds, - UpdateTxnFeeCost, - UpdateAtaCreationCost, -} diff --git a/crates/kamino-limit-orders-parser/src/generated_sdk/types/update_global_config_value.rs b/crates/kamino-limit-orders-parser/src/generated_sdk/types/update_global_config_value.rs deleted file mode 100644 index cedf22a4..00000000 --- a/crates/kamino-limit-orders-parser/src/generated_sdk/types/update_global_config_value.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum UpdateGlobalConfigValue { - Bool(bool), - U16(u16), - U64(u64), - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - Pubkey(Pubkey), -} diff --git a/crates/kamino-limit-orders-parser/src/lib.rs b/crates/kamino-limit-orders-parser/src/lib.rs deleted file mode 100644 index 8a6dc4b5..00000000 --- a/crates/kamino-limit-orders-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = LIMO_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.kamino_limit_orders"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/meteora-amm-parser/Cargo.toml b/crates/meteora-amm-parser/Cargo.toml deleted file mode 100644 index 90f3e337..00000000 --- a/crates/meteora-amm-parser/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "yellowstone-vixen-meteora-amm-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Meteora AMM program" -license.workspace = true -repository.workspace = true -authors.workspace = true - - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info = { workspace = true } -solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction = { workspace = true } -solana-msg = { workspace = true } -solana-program-entrypoint = { workspace = true } -solana-program-error = { workspace = true } -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true diff --git a/crates/meteora-amm-parser/build.rs b/crates/meteora-amm-parser/build.rs deleted file mode 100644 index 0a93daf0..00000000 --- a/crates/meteora-amm-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/meteora_amm.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/meteora-amm-parser/idl.json b/crates/meteora-amm-parser/idl.json deleted file mode 100644 index a7bf2f71..00000000 --- a/crates/meteora-amm-parser/idl.json +++ /dev/null @@ -1,7436 +0,0 @@ -{ - "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": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "AddLiquidityParameters" - } - } - } - ] - }, - { - "name": "claim_partner_fee", - "discriminator": [ - 97, - 206, - 39, - 105, - 94, - 94, - 126, - 148 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "pool", - "writable": true - }, - { - "name": "token_a_account", - "docs": [ - "The treasury token a account" - ], - "writable": true - }, - { - "name": "token_b_account", - "docs": [ - "The treasury token b account" - ], - "writable": true - }, - { - "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] - }, - { - "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] - }, - { - "name": "partner", - "signer": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_a_program", - "docs": [ - "Token a program" - ] - }, - { - "name": "token_b_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "max_amount_a", - "type": "u64" - }, - { - "name": "max_amount_b", - "type": "u64" - } - ] - }, - { - "name": "claim_position_fee", - "discriminator": [ - 180, - 38, - 154, - 17, - 133, - 33, - 162, - 211 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "pool", - "relations": [ - "position" - ] - }, - { - "name": "position", - "writable": true - }, - { - "name": "token_a_account", - "docs": [ - "The user token a account" - ], - "writable": true - }, - { - "name": "token_b_account", - "docs": [ - "The user token b account" - ], - "writable": true - }, - { - "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] - }, - { - "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] - }, - { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] - }, - { - "name": "owner", - "docs": [ - "owner of position" - ], - "signer": true - }, - { - "name": "token_a_program", - "docs": [ - "Token a program" - ] - }, - { - "name": "token_b_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "claim_protocol_fee", - "discriminator": [ - 165, - 228, - 133, - 48, - 99, - 249, - 255, - 33 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "pool", - "writable": true - }, - { - "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] - }, - { - "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] - }, - { - "name": "token_a_account", - "docs": [ - "The treasury token a account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 48, - 9, - 89, - 123, - 106, - 114, - 131, - 251, - 50, - 173, - 254, - 250, - 10, - 80, - 160, - 84, - 143, - 100, - 81, - 249, - 134, - 112, - 30, - 213, - 50, - 166, - 239, - 78, - 53, - 175, - 188, - 85 - ] - }, - { - "kind": "account", - "path": "token_a_program" - }, - { - "kind": "account", - "path": "token_a_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "token_b_account", - "docs": [ - "The treasury token b account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 48, - 9, - 89, - 123, - 106, - 114, - 131, - 251, - 50, - 173, - 254, - 250, - 10, - 80, - 160, - 84, - 143, - 100, - 81, - 249, - 134, - 112, - 30, - 213, - 50, - 166, - 239, - 78, - 53, - 175, - 188, - 85 - ] - }, - { - "kind": "account", - "path": "token_b_program" - }, - { - "kind": "account", - "path": "token_b_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "claim_fee_operator", - "docs": [ - "Claim fee operator" - ] - }, - { - "name": "operator", - "docs": [ - "Operator" - ], - "signer": true, - "relations": [ - "claim_fee_operator" - ] - }, - { - "name": "token_a_program", - "docs": [ - "Token a program" - ] - }, - { - "name": "token_b_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "max_amount_a", - "type": "u64" - }, - { - "name": "max_amount_b", - "type": "u64" - } - ] - }, - { - "name": "claim_reward", - "discriminator": [ - 149, - 95, - 181, - 242, - 94, - 90, - 158, - 162 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "pool", - "writable": true, - "relations": [ - "position" - ] - }, - { - "name": "position", - "writable": true - }, - { - "name": "reward_vault", - "docs": [ - "The vault token account for reward token" - ], - "writable": true - }, - { - "name": "reward_mint" - }, - { - "name": "user_token_account", - "writable": true - }, - { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] - }, - { - "name": "owner", - "docs": [ - "owner of position" - ], - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "reward_index", - "type": "u8" - }, - { - "name": "skip_reward", - "type": "u8" - } - ] - }, - { - "name": "close_claim_fee_operator", - "discriminator": [ - 38, - 134, - 82, - 216, - 95, - 124, - 17, - 99 - ], - "accounts": [ - { - "name": "claim_fee_operator", - "writable": true - }, - { - "name": "rent_receiver", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "close_config", - "discriminator": [ - 145, - 9, - 72, - 157, - 95, - 125, - 61, - 85 - ], - "accounts": [ - { - "name": "config", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "rent_receiver", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "close_position", - "discriminator": [ - 123, - 134, - 81, - 0, - 49, - 68, - 98, - 98 - ], - "accounts": [ - { - "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], - "writable": true - }, - { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ], - "writable": true - }, - { - "name": "pool", - "writable": true, - "relations": [ - "position" - ] - }, - { - "name": "position", - "writable": true - }, - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "rent_receiver", - "writable": true - }, - { - "name": "owner", - "docs": [ - "Owner of position" - ], - "signer": true - }, - { - "name": "token_program", - "docs": [ - "Program to create NFT mint/token account and transfer for token22 account" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "close_token_badge", - "discriminator": [ - 108, - 146, - 86, - 110, - 179, - 254, - 10, - 104 - ], - "accounts": [ - { - "name": "token_badge", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "rent_receiver", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "create_claim_fee_operator", - "discriminator": [ - 169, - 62, - 207, - 107, - 58, - 187, - 162, - 109 - ], - "accounts": [ - { - "name": "claim_fee_operator", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 102, - 95, - 111, - 112, - 101, - 114, - 97, - 116, - 111, - 114 - ] - }, - { - "kind": "account", - "path": "operator" - } - ] - } - }, - { - "name": "operator" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "create_config", - "docs": [ - "ADMIN FUNCTIONS /////" - ], - "discriminator": [ - 201, - 207, - 243, - 114, - 75, - 111, - 47, - 189 - ], - "accounts": [ - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "arg", - "path": "index" - } - ] - } - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "index", - "type": "u64" - }, - { - "name": "config_parameters", - "type": { - "defined": { - "name": "StaticConfigParameters" - } - } - } - ] - }, - { - "name": "create_dynamic_config", - "discriminator": [ - 81, - 251, - 122, - 78, - 66, - 57, - 208, - 82 - ], - "accounts": [ - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "arg", - "path": "index" - } - ] - } - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "index", - "type": "u64" - }, - { - "name": "config_parameters", - "type": { - "defined": { - "name": "DynamicConfigParameters" - } - } - } - ] - }, - { - "name": "create_position", - "discriminator": [ - 48, - 215, - 197, - 153, - 96, - 203, - 180, - 133 - ], - "accounts": [ - { - "name": "owner" - }, - { - "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], - "writable": true, - "signer": true - }, - { - "name": "position_nft_account", - "docs": [ - "position nft account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110, - 95, - 110, - 102, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "position_nft_mint" - } - ] - } - }, - { - "name": "pool", - "writable": true - }, - { - "name": "position", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110 - ] - }, - { - "kind": "account", - "path": "position_nft_mint" - } - ] - } - }, - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "payer", - "docs": [ - "Address paying to create the position. Can be anyone" - ], - "writable": true, - "signer": true - }, - { - "name": "token_program", - "docs": [ - "Program to create NFT mint/token account and transfer for token22 account" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "create_token_badge", - "discriminator": [ - 88, - 206, - 0, - 91, - 60, - 175, - 151, - 118 - ], - "accounts": [ - { - "name": "token_badge", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 98, - 97, - 100, - 103, - 101 - ] - }, - { - "kind": "account", - "path": "token_mint" - } - ] - } - }, - { - "name": "token_mint" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "fund_reward", - "discriminator": [ - 188, - 50, - 249, - 165, - 93, - 151, - 38, - 63 - ], - "accounts": [ - { - "name": "pool", - "writable": true - }, - { - "name": "reward_vault", - "writable": true - }, - { - "name": "reward_mint" - }, - { - "name": "funder_token_account", - "writable": true - }, - { - "name": "funder", - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "reward_index", - "type": "u8" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "carry_forward", - "type": "bool" - } - ] - }, - { - "name": "initialize_customizable_pool", - "discriminator": [ - 20, - 161, - 241, - 24, - 189, - 221, - 180, - 2 - ], - "accounts": [ - { - "name": "creator" - }, - { - "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], - "writable": true, - "signer": true - }, - { - "name": "position_nft_account", - "docs": [ - "position nft account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110, - 95, - 110, - 102, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "position_nft_mint" - } - ] - } - }, - { - "name": "payer", - "docs": [ - "Address paying to create the pool. Can be anyone" - ], - "writable": true, - "signer": true - }, - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "pool", - "docs": [ - "Initialize an account to store the pool state" - ], - "writable": true - }, - { - "name": "position", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110 - ] - }, - { - "kind": "account", - "path": "position_nft_mint" - } - ] - } - }, - { - "name": "token_a_mint", - "docs": [ - "Token a mint" - ] - }, - { - "name": "token_b_mint", - "docs": [ - "Token b mint" - ] - }, - { - "name": "token_a_vault", - "docs": [ - "Token a vault for the pool" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_a_mint" - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "token_b_vault", - "docs": [ - "Token b vault for the pool" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_b_mint" - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "payer_token_a", - "docs": [ - "payer token a account" - ], - "writable": true - }, - { - "name": "payer_token_b", - "docs": [ - "creator token b account" - ], - "writable": true - }, - { - "name": "token_a_program", - "docs": [ - "Program to create mint account and mint tokens" - ] - }, - { - "name": "token_b_program", - "docs": [ - "Program to create mint account and mint tokens" - ] - }, - { - "name": "token_2022_program", - "docs": [ - "Program to create NFT mint/token account and transfer for token22 account" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "InitializeCustomizablePoolParameters" - } - } - } - ] - }, - { - "name": "initialize_pool", - "docs": [ - "USER FUNCTIONS ////" - ], - "discriminator": [ - 95, - 180, - 10, - 172, - 84, - 174, - 232, - 40 - ], - "accounts": [ - { - "name": "creator" - }, - { - "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], - "writable": true, - "signer": true - }, - { - "name": "position_nft_account", - "docs": [ - "position nft account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110, - 95, - 110, - 102, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "position_nft_mint" - } - ] - } - }, - { - "name": "payer", - "docs": [ - "Address paying to create the pool. Can be anyone" - ], - "writable": true, - "signer": true - }, - { - "name": "config", - "docs": [ - "Which config the pool belongs to." - ] - }, - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "pool", - "docs": [ - "Initialize an account to store the pool state" - ], - "writable": true - }, - { - "name": "position", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110 - ] - }, - { - "kind": "account", - "path": "position_nft_mint" - } - ] - } - }, - { - "name": "token_a_mint", - "docs": [ - "Token a mint" - ] - }, - { - "name": "token_b_mint", - "docs": [ - "Token b mint" - ] - }, - { - "name": "token_a_vault", - "docs": [ - "Token a vault for the pool" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_a_mint" - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "token_b_vault", - "docs": [ - "Token b vault for the pool" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_b_mint" - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "payer_token_a", - "docs": [ - "payer token a account" - ], - "writable": true - }, - { - "name": "payer_token_b", - "docs": [ - "creator token b account" - ], - "writable": true - }, - { - "name": "token_a_program", - "docs": [ - "Program to create mint account and mint tokens" - ] - }, - { - "name": "token_b_program", - "docs": [ - "Program to create mint account and mint tokens" - ] - }, - { - "name": "token_2022_program", - "docs": [ - "Program to create NFT mint/token account and transfer for token22 account" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "InitializePoolParameters" - } - } - } - ] - }, - { - "name": "initialize_pool_with_dynamic_config", - "discriminator": [ - 149, - 82, - 72, - 197, - 253, - 252, - 68, - 15 - ], - "accounts": [ - { - "name": "creator" - }, - { - "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], - "writable": true, - "signer": true - }, - { - "name": "position_nft_account", - "docs": [ - "position nft account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110, - 95, - 110, - 102, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "position_nft_mint" - } - ] - } - }, - { - "name": "payer", - "docs": [ - "Address paying to create the pool. Can be anyone" - ], - "writable": true, - "signer": true - }, - { - "name": "pool_creator_authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "docs": [ - "Which config the pool belongs to." - ] - }, - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "pool", - "docs": [ - "Initialize an account to store the pool state" - ], - "writable": true - }, - { - "name": "position", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110 - ] - }, - { - "kind": "account", - "path": "position_nft_mint" - } - ] - } - }, - { - "name": "token_a_mint", - "docs": [ - "Token a mint" - ] - }, - { - "name": "token_b_mint", - "docs": [ - "Token b mint" - ] - }, - { - "name": "token_a_vault", - "docs": [ - "Token a vault for the pool" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_a_mint" - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "token_b_vault", - "docs": [ - "Token b vault for the pool" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "token_b_mint" - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "payer_token_a", - "docs": [ - "payer token a account" - ], - "writable": true - }, - { - "name": "payer_token_b", - "docs": [ - "creator token b account" - ], - "writable": true - }, - { - "name": "token_a_program", - "docs": [ - "Program to create mint account and mint tokens" - ] - }, - { - "name": "token_b_program", - "docs": [ - "Program to create mint account and mint tokens" - ] - }, - { - "name": "token_2022_program", - "docs": [ - "Program to create NFT mint/token account and transfer for token22 account" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "InitializeCustomizablePoolParameters" - } - } - } - ] - }, - { - "name": "initialize_reward", - "discriminator": [ - 95, - 135, - 192, - 196, - 242, - 129, - 230, - 68 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "pool", - "writable": true - }, - { - "name": "reward_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 119, - 97, - 114, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool" - }, - { - "kind": "arg", - "path": "reward_index" - } - ] - } - }, - { - "name": "reward_mint" - }, - { - "name": "signer", - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "reward_index", - "type": "u8" - }, - { - "name": "reward_duration", - "type": "u64" - }, - { - "name": "funder", - "type": "pubkey" - } - ] - }, - { - "name": "lock_position", - "discriminator": [ - 227, - 62, - 2, - 252, - 247, - 10, - 171, - 185 - ], - "accounts": [ - { - "name": "pool", - "relations": [ - "position" - ] - }, - { - "name": "position", - "writable": true - }, - { - "name": "vesting", - "writable": true, - "signer": true - }, - { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] - }, - { - "name": "owner", - "docs": [ - "owner of position" - ], - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "VestingParameters" - } - } - } - ] - }, - { - "name": "permanent_lock_position", - "discriminator": [ - 165, - 176, - 125, - 6, - 231, - 171, - 186, - 213 - ], - "accounts": [ - { - "name": "pool", - "writable": true, - "relations": [ - "position" - ] - }, - { - "name": "position", - "writable": true - }, - { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] - }, - { - "name": "owner", - "docs": [ - "owner of position" - ], - "signer": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "permanent_lock_liquidity", - "type": "u128" - } - ] - }, - { - "name": "refresh_vesting", - "discriminator": [ - 9, - 94, - 216, - 14, - 116, - 204, - 247, - 0 - ], - "accounts": [ - { - "name": "pool", - "relations": [ - "position" - ] - }, - { - "name": "position", - "writable": true - }, - { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] - }, - { - "name": "owner" - } - ], - "args": [] - }, - { - "name": "remove_all_liquidity", - "discriminator": [ - 10, - 51, - 61, - 35, - 112, - 105, - 24, - 85 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "pool", - "writable": true, - "relations": [ - "position" - ] - }, - { - "name": "position", - "writable": true - }, - { - "name": "token_a_account", - "docs": [ - "The user token a account" - ], - "writable": true - }, - { - "name": "token_b_account", - "docs": [ - "The user token b account" - ], - "writable": true - }, - { - "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] - }, - { - "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] - }, - { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] - }, - { - "name": "owner", - "docs": [ - "owner of position" - ], - "signer": true - }, - { - "name": "token_a_program", - "docs": [ - "Token a program" - ] - }, - { - "name": "token_b_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "token_a_amount_threshold", - "type": "u64" - }, - { - "name": "token_b_amount_threshold", - "type": "u64" - } - ] - }, - { - "name": "remove_liquidity", - "discriminator": [ - 80, - 85, - 209, - 72, - 24, - 206, - 177, - 108 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, - { - "name": "pool", - "writable": true, - "relations": [ - "position" - ] - }, - { - "name": "position", - "writable": true - }, - { - "name": "token_a_account", - "docs": [ - "The user token a account" - ], - "writable": true - }, - { - "name": "token_b_account", - "docs": [ - "The user token b account" - ], - "writable": true - }, - { - "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] - }, - { - "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] - }, - { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] - }, - { - "name": "owner", - "docs": [ - "owner of position" - ], - "signer": true - }, - { - "name": "token_a_program", - "docs": [ - "Token a program" - ] - }, - { - "name": "token_b_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "RemoveLiquidityParameters" - } - } - } - ] - }, - { - "name": "set_pool_status", - "discriminator": [ - 112, - 87, - 135, - 223, - 83, - 204, - 132, - 53 - ], - "accounts": [ - { - "name": "pool", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "status", - "type": "u8" - } - ] - }, - { - "name": "split_position", - "discriminator": [ - 172, - 241, - 221, - 138, - 161, - 29, - 253, - 42 - ], - "accounts": [ - { - "name": "pool", - "writable": true, - "relations": [ - "first_position", - "second_position" - ] - }, - { - "name": "first_position", - "docs": [ - "The first position" - ], - "writable": true - }, - { - "name": "first_position_nft_account", - "docs": [ - "The token account for position nft" - ] - }, - { - "name": "second_position", - "docs": [ - "The second position" - ], - "writable": true - }, - { - "name": "second_position_nft_account", - "docs": [ - "The token account for position nft" - ] - }, - { - "name": "first_owner", - "docs": [ - "Owner of first position" - ], - "signer": true - }, - { - "name": "second_owner", - "docs": [ - "Owner of second position" - ], - "signer": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SplitPositionParameters" - } - } - } - ] - }, - { - "name": "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": [ - "Config pubkey" - ], - "type": "pubkey" - }, - { - "name": "admin", - "docs": [ - "admin pk" - ], - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtClosePosition", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "position_nft_mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtCreateClaimFeeOperator", - "docs": [ - "Create claim fee operator" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "operator", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtCreateConfig", - "docs": [ - "Create static config" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_fees", - "type": { - "defined": { - "name": "PoolFeeParameters" - } - } - }, - { - "name": "vault_config_key", - "type": "pubkey" - }, - { - "name": "pool_creator_authority", - "type": "pubkey" - }, - { - "name": "activation_type", - "type": "u8" - }, - { - "name": "sqrt_min_price", - "type": "u128" - }, - { - "name": "sqrt_max_price", - "type": "u128" - }, - { - "name": "collect_fee_mode", - "type": "u8" - }, - { - "name": "index", - "type": "u64" - }, - { - "name": "config", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtCreateDynamicConfig", - "docs": [ - "Create dynamic config" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "config", - "type": "pubkey" - }, - { - "name": "pool_creator_authority", - "type": "pubkey" - }, - { - "name": "index", - "type": "u64" - } - ] - } - }, - { - "name": "EvtCreatePosition", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "position_nft_mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtCreateTokenBadge", - "docs": [ - "Create token badge" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtFundReward", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "funder", - "type": "pubkey" - }, - { - "name": "mint_reward", - "type": "pubkey" - }, - { - "name": "reward_index", - "type": "u8" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "transfer_fee_excluded_amount_in", - "type": "u64" - }, - { - "name": "reward_duration_end", - "type": "u64" - }, - { - "name": "pre_reward_rate", - "type": "u128" - }, - { - "name": "post_reward_rate", - "type": "u128" - } - ] - } - }, - { - "name": "EvtInitializePool", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "token_a_mint", - "type": "pubkey" - }, - { - "name": "token_b_mint", - "type": "pubkey" - }, - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "payer", - "type": "pubkey" - }, - { - "name": "alpha_vault", - "type": "pubkey" - }, - { - "name": "pool_fees", - "type": { - "defined": { - "name": "PoolFeeParameters" - } - } - }, - { - "name": "sqrt_min_price", - "type": "u128" - }, - { - "name": "sqrt_max_price", - "type": "u128" - }, - { - "name": "activation_type", - "type": "u8" - }, - { - "name": "collect_fee_mode", - "type": "u8" - }, - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "sqrt_price", - "type": "u128" - }, - { - "name": "activation_point", - "type": "u64" - }, - { - "name": "token_a_flag", - "type": "u8" - }, - { - "name": "token_b_flag", - "type": "u8" - }, - { - "name": "token_a_amount", - "type": "u64" - }, - { - "name": "token_b_amount", - "type": "u64" - }, - { - "name": "total_amount_a", - "type": "u64" - }, - { - "name": "total_amount_b", - "type": "u64" - }, - { - "name": "pool_type", - "type": "u8" - } - ] - } - }, - { - "name": "EvtInitializeReward", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "reward_mint", - "type": "pubkey" - }, - { - "name": "funder", - "type": "pubkey" - }, - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "reward_index", - "type": "u8" - }, - { - "name": "reward_duration", - "type": "u64" - } - ] - } - }, - { - "name": "EvtLiquidityChange", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "token_a_amount", - "type": "u64" - }, - { - "name": "token_b_amount", - "type": "u64" - }, - { - "name": "transfer_fee_included_token_a_amount", - "type": "u64" - }, - { - "name": "transfer_fee_included_token_b_amount", - "type": "u64" - }, - { - "name": "reserve_a_amount", - "type": "u64" - }, - { - "name": "reserve_b_amount", - "type": "u64" - }, - { - "name": "liquidity_delta", - "type": "u128" - }, - { - "name": "token_a_amount_threshold", - "type": "u64" - }, - { - "name": "token_b_amount_threshold", - "type": "u64" - }, - { - "name": "change_type", - "type": "u8" - } - ] - } - }, - { - "name": "EvtLockPosition", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "vesting", - "type": "pubkey" - }, - { - "name": "cliff_point", - "type": "u64" - }, - { - "name": "period_frequency", - "type": "u64" - }, - { - "name": "cliff_unlock_liquidity", - "type": "u128" - }, - { - "name": "liquidity_per_period", - "type": "u128" - }, - { - "name": "number_of_period", - "type": "u16" - } - ] - } - }, - { - "name": "EvtPermanentLockPosition", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "lock_liquidity_amount", - "type": "u128" - }, - { - "name": "total_permanent_locked_liquidity", - "type": "u128" - } - ] - } - }, - { - "name": "EvtRemoveLiquidity", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "params", - "type": { - "defined": { - "name": "RemoveLiquidityParameters" - } - } - }, - { - "name": "token_a_amount", - "type": "u64" - }, - { - "name": "token_b_amount", - "type": "u64" - } - ] - } - }, - { - "name": "EvtSetPoolStatus", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "status", - "type": "u8" - } - ] - } - }, - { - "name": "EvtSplitPosition2", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "first_owner", - "type": "pubkey" - }, - { - "name": "second_owner", - "type": "pubkey" - }, - { - "name": "first_position", - "type": "pubkey" - }, - { - "name": "second_position", - "type": "pubkey" - }, - { - "name": "current_sqrt_price", - "type": "u128" - }, - { - "name": "amount_splits", - "type": { - "defined": { - "name": "SplitAmountInfo" - } - } - }, - { - "name": "first_position_info", - "type": { - "defined": { - "name": "SplitPositionInfo" - } - } - }, - { - "name": "second_position_info", - "type": { - "defined": { - "name": "SplitPositionInfo" - } - } - }, - { - "name": "split_position_parameters", - "type": { - "defined": { - "name": "SplitPositionParameters2" - } - } - } - ] - } - }, - { - "name": "EvtSwap", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "trade_direction", - "type": "u8" - }, - { - "name": "has_referral", - "type": "bool" - }, - { - "name": "params", - "type": { - "defined": { - "name": "SwapParameters" - } - } - }, - { - "name": "swap_result", - "type": { - "defined": { - "name": "SwapResult" - } - } - }, - { - "name": "actual_amount_in", - "type": "u64" - }, - { - "name": "current_timestamp", - "type": "u64" - } - ] - } - }, - { - "name": "EvtSwap2", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "trade_direction", - "type": "u8" - }, - { - "name": "collect_fee_mode", - "type": "u8" - }, - { - "name": "has_referral", - "type": "bool" - }, - { - "name": "params", - "type": { - "defined": { - "name": "SwapParameters2" - } - } - }, - { - "name": "swap_result", - "type": { - "defined": { - "name": "SwapResult2" - } - } - }, - { - "name": "included_transfer_fee_amount_in", - "type": "u64" - }, - { - "name": "included_transfer_fee_amount_out", - "type": "u64" - }, - { - "name": "excluded_transfer_fee_amount_out", - "type": "u64" - }, - { - "name": "current_timestamp", - "type": "u64" - }, - { - "name": "reserve_a_amount", - "type": "u64" - }, - { - "name": "reserve_b_amount", - "type": "u64" - } - ] - } - }, - { - "name": "EvtUpdateRewardDuration", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "reward_index", - "type": "u8" - }, - { - "name": "old_reward_duration", - "type": "u64" - }, - { - "name": "new_reward_duration", - "type": "u64" - } - ] - } - }, - { - "name": "EvtUpdateRewardFunder", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "reward_index", - "type": "u8" - }, - { - "name": "old_funder", - "type": "pubkey" - }, - { - "name": "new_funder", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtWithdrawIneligibleReward", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "reward_mint", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "InitializeCustomizablePoolParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_fees", - "docs": [ - "pool fees" - ], - "type": { - "defined": { - "name": "PoolFeeParameters" - } - } - }, - { - "name": "sqrt_min_price", - "docs": [ - "sqrt min price" - ], - "type": "u128" - }, - { - "name": "sqrt_max_price", - "docs": [ - "sqrt max price" - ], - "type": "u128" - }, - { - "name": "has_alpha_vault", - "docs": [ - "has alpha vault" - ], - "type": "bool" - }, - { - "name": "liquidity", - "docs": [ - "initialize liquidity" - ], - "type": "u128" - }, - { - "name": "sqrt_price", - "docs": [ - "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value" - ], - "type": "u128" - }, - { - "name": "activation_type", - "docs": [ - "activation type" - ], - "type": "u8" - }, - { - "name": "collect_fee_mode", - "docs": [ - "collect fee mode" - ], - "type": "u8" - }, - { - "name": "activation_point", - "docs": [ - "activation point" - ], - "type": { - "option": "u64" - } - } - ] - } - }, - { - "name": "InitializePoolParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "liquidity", - "docs": [ - "initialize liquidity" - ], - "type": "u128" - }, - { - "name": "sqrt_price", - "docs": [ - "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value" - ], - "type": "u128" - }, - { - "name": "activation_point", - "docs": [ - "activation point" - ], - "type": { - "option": "u64" - } - } - ] - } - }, - { - "name": "Pool", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_fees", - "docs": [ - "Pool fee" - ], - "type": { - "defined": { - "name": "PoolFeesStruct" - } - } - }, - { - "name": "token_a_mint", - "docs": [ - "token a mint" - ], - "type": "pubkey" - }, - { - "name": "token_b_mint", - "docs": [ - "token b mint" - ], - "type": "pubkey" - }, - { - "name": "token_a_vault", - "docs": [ - "token a vault" - ], - "type": "pubkey" - }, - { - "name": "token_b_vault", - "docs": [ - "token b vault" - ], - "type": "pubkey" - }, - { - "name": "whitelisted_vault", - "docs": [ - "Whitelisted vault to be able to buy pool before activation_point" - ], - "type": "pubkey" - }, - { - "name": "partner", - "docs": [ - "partner" - ], - "type": "pubkey" - }, - { - "name": "liquidity", - "docs": [ - "liquidity share" - ], - "type": "u128" - }, - { - "name": "_padding", - "docs": [ - "padding, previous reserve amount, be careful to use that field" - ], - "type": "u128" - }, - { - "name": "protocol_a_fee", - "docs": [ - "protocol a fee" - ], - "type": "u64" - }, - { - "name": "protocol_b_fee", - "docs": [ - "protocol b fee" - ], - "type": "u64" - }, - { - "name": "partner_a_fee", - "docs": [ - "partner a fee" - ], - "type": "u64" - }, - { - "name": "partner_b_fee", - "docs": [ - "partner b fee" - ], - "type": "u64" - }, - { - "name": "sqrt_min_price", - "docs": [ - "min price" - ], - "type": "u128" - }, - { - "name": "sqrt_max_price", - "docs": [ - "max price" - ], - "type": "u128" - }, - { - "name": "sqrt_price", - "docs": [ - "current price" - ], - "type": "u128" - }, - { - "name": "activation_point", - "docs": [ - "Activation point, can be slot or timestamp" - ], - "type": "u64" - }, - { - "name": "activation_type", - "docs": [ - "Activation type, 0 means by slot, 1 means by timestamp" - ], - "type": "u8" - }, - { - "name": "pool_status", - "docs": [ - "pool status, 0: enable, 1 disable" - ], - "type": "u8" - }, - { - "name": "token_a_flag", - "docs": [ - "token a flag" - ], - "type": "u8" - }, - { - "name": "token_b_flag", - "docs": [ - "token b flag" - ], - "type": "u8" - }, - { - "name": "collect_fee_mode", - "docs": [ - "0 is collect fee in both token, 1 only collect fee in token a, 2 only collect fee in token b" - ], - "type": "u8" - }, - { - "name": "pool_type", - "docs": [ - "pool type" - ], - "type": "u8" - }, - { - "name": "version", - "docs": [ - "pool version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%" - ], - "type": "u8" - }, - { - "name": "_padding_0", - "docs": [ - "padding" - ], - "type": "u8" - }, - { - "name": "fee_a_per_liquidity", - "docs": [ - "cumulative" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "fee_b_per_liquidity", - "docs": [ - "cumulative" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "permanent_lock_liquidity", - "type": "u128" - }, - { - "name": "metrics", - "docs": [ - "metrics" - ], - "type": { - "defined": { - "name": "PoolMetrics" - } - } - }, - { - "name": "creator", - "docs": [ - "pool creator" - ], - "type": "pubkey" - }, - { - "name": "_padding_1", - "docs": [ - "Padding for further use" - ], - "type": { - "array": [ - "u64", - 6 - ] - } - }, - { - "name": "reward_infos", - "docs": [ - "Farming reward information" - ], - "type": { - "array": [ - { - "defined": { - "name": "RewardInfo" - } - }, - 2 - ] - } - } - ] - } - }, - { - "name": "PoolFeeParameters", - "docs": [ - "Information regarding fee charges" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "base_fee", - "docs": [ - "Base fee" - ], - "type": { - "defined": { - "name": "BaseFeeParameters" - } - } - }, - { - "name": "padding", - "docs": [ - "padding" - ], - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "dynamic_fee", - "docs": [ - "dynamic fee" - ], - "type": { - "option": { - "defined": { - "name": "DynamicFeeParameters" - } - } - } - } - ] - } - }, - { - "name": "PoolFeesConfig", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "base_fee", - "type": { - "defined": { - "name": "BaseFeeConfig" - } - } - }, - { - "name": "dynamic_fee", - "type": { - "defined": { - "name": "DynamicFeeConfig" - } - } - }, - { - "name": "protocol_fee_percent", - "type": "u8" - }, - { - "name": "partner_fee_percent", - "type": "u8" - }, - { - "name": "referral_fee_percent", - "type": "u8" - }, - { - "name": "padding_0", - "type": { - "array": [ - "u8", - 5 - ] - } - }, - { - "name": "padding_1", - "type": { - "array": [ - "u64", - 5 - ] - } - } - ] - } - }, - { - "name": "PoolFeesStruct", - "docs": [ - "Information regarding fee charges", - "trading_fee = amount * trade_fee_numerator / denominator", - "protocol_fee = trading_fee * protocol_fee_percentage / 100", - "referral_fee = protocol_fee * referral_percentage / 100", - "partner_fee = (protocol_fee - referral_fee) * partner_fee_percentage / denominator" - ], - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "base_fee", - "docs": [ - "Trade fees are extra token amounts that are held inside the token", - "accounts during a trade, making the value of liquidity tokens rise.", - "Trade fee numerator" - ], - "type": { - "defined": { - "name": "BaseFeeStruct" - } - } - }, - { - "name": "protocol_fee_percent", - "docs": [ - "Protocol trading fees are extra token amounts that are held inside the token", - "accounts during a trade, with the equivalent in pool tokens minted to", - "the protocol of the program.", - "Protocol trade fee numerator" - ], - "type": "u8" - }, - { - "name": "partner_fee_percent", - "docs": [ - "partner fee" - ], - "type": "u8" - }, - { - "name": "referral_fee_percent", - "docs": [ - "referral fee" - ], - "type": "u8" - }, - { - "name": "padding_0", - "docs": [ - "padding" - ], - "type": { - "array": [ - "u8", - 5 - ] - } - }, - { - "name": "dynamic_fee", - "docs": [ - "dynamic fee" - ], - "type": { - "defined": { - "name": "DynamicFeeStruct" - } - } - }, - { - "name": "padding_1", - "docs": [ - "padding" - ], - "type": { - "array": [ - "u64", - 2 - ] - } - } - ] - } - }, - { - "name": "PoolMetrics", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "total_lp_a_fee", - "type": "u128" - }, - { - "name": "total_lp_b_fee", - "type": "u128" - }, - { - "name": "total_protocol_a_fee", - "type": "u64" - }, - { - "name": "total_protocol_b_fee", - "type": "u64" - }, - { - "name": "total_partner_a_fee", - "type": "u64" - }, - { - "name": "total_partner_b_fee", - "type": "u64" - }, - { - "name": "total_position", - "type": "u64" - }, - { - "name": "padding", - "type": "u64" - } - ] - } - }, - { - "name": "Position", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "nft_mint", - "docs": [ - "nft mint" - ], - "type": "pubkey" - }, - { - "name": "fee_a_per_token_checkpoint", - "docs": [ - "fee a checkpoint" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "fee_b_per_token_checkpoint", - "docs": [ - "fee b checkpoint" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "fee_a_pending", - "docs": [ - "fee a pending" - ], - "type": "u64" - }, - { - "name": "fee_b_pending", - "docs": [ - "fee b pending" - ], - "type": "u64" - }, - { - "name": "unlocked_liquidity", - "docs": [ - "unlock liquidity" - ], - "type": "u128" - }, - { - "name": "vested_liquidity", - "docs": [ - "vesting liquidity" - ], - "type": "u128" - }, - { - "name": "permanent_locked_liquidity", - "docs": [ - "permanent locked liquidity" - ], - "type": "u128" - }, - { - "name": "metrics", - "docs": [ - "metrics" - ], - "type": { - "defined": { - "name": "PositionMetrics" - } - } - }, - { - "name": "reward_infos", - "docs": [ - "Farming reward information" - ], - "type": { - "array": [ - { - "defined": { - "name": "UserRewardInfo" - } - }, - 2 - ] - } - }, - { - "name": "padding", - "docs": [ - "padding for future usage" - ], - "type": { - "array": [ - "u128", - 6 - ] - } - } - ] - } - }, - { - "name": "PositionMetrics", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "total_claimed_a_fee", - "type": "u64" - }, - { - "name": "total_claimed_b_fee", - "type": "u64" - } - ] - } - }, - { - "name": "RemoveLiquidityParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "liquidity_delta", - "docs": [ - "delta liquidity" - ], - "type": "u128" - }, - { - "name": "token_a_amount_threshold", - "docs": [ - "minimum token a amount" - ], - "type": "u64" - }, - { - "name": "token_b_amount_threshold", - "docs": [ - "minimum token b amount" - ], - "type": "u64" - } - ] - } - }, - { - "name": "RewardInfo", - "docs": [ - "Stores the state relevant for tracking liquidity mining rewards" - ], - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "initialized", - "docs": [ - "Indicates if the reward has been initialized" - ], - "type": "u8" - }, - { - "name": "reward_token_flag", - "docs": [ - "reward token flag" - ], - "type": "u8" - }, - { - "name": "_padding_0", - "docs": [ - "padding" - ], - "type": { - "array": [ - "u8", - 6 - ] - } - }, - { - "name": "_padding_1", - "docs": [ - "Padding to ensure `reward_rate: u128` is 16-byte aligned" - ], - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "mint", - "docs": [ - "Reward token mint." - ], - "type": "pubkey" - }, - { - "name": "vault", - "docs": [ - "Reward vault token account." - ], - "type": "pubkey" - }, - { - "name": "funder", - "docs": [ - "Authority account that allows to fund rewards" - ], - "type": "pubkey" - }, - { - "name": "reward_duration", - "docs": [ - "reward duration" - ], - "type": "u64" - }, - { - "name": "reward_duration_end", - "docs": [ - "reward duration end" - ], - "type": "u64" - }, - { - "name": "reward_rate", - "docs": [ - "reward rate" - ], - "type": "u128" - }, - { - "name": "reward_per_token_stored", - "docs": [ - "Reward per token stored" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "last_update_time", - "docs": [ - "The last time reward states were updated." - ], - "type": "u64" - }, - { - "name": "cumulative_seconds_with_empty_liquidity_reward", - "docs": [ - "Accumulated seconds when the farm distributed rewards but the bin was empty.", - "These rewards will be carried over to the next reward time window." - ], - "type": "u64" - } - ] - } - }, - { - "name": "SplitAmountInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "permanent_locked_liquidity", - "type": "u128" - }, - { - "name": "unlocked_liquidity", - "type": "u128" - }, - { - "name": "fee_a", - "type": "u64" - }, - { - "name": "fee_b", - "type": "u64" - }, - { - "name": "reward_0", - "type": "u64" - }, - { - "name": "reward_1", - "type": "u64" - } - ] - } - }, - { - "name": "SplitPositionInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "fee_a", - "type": "u64" - }, - { - "name": "fee_b", - "type": "u64" - }, - { - "name": "reward_0", - "type": "u64" - }, - { - "name": "reward_1", - "type": "u64" - } - ] - } - }, - { - "name": "SplitPositionParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "unlocked_liquidity_percentage", - "docs": [ - "Percentage of unlocked liquidity to split to the second position" - ], - "type": "u8" - }, - { - "name": "permanent_locked_liquidity_percentage", - "docs": [ - "Percentage of permanent locked liquidity to split to the second position" - ], - "type": "u8" - }, - { - "name": "fee_a_percentage", - "docs": [ - "Percentage of fee A pending to split to the second position" - ], - "type": "u8" - }, - { - "name": "fee_b_percentage", - "docs": [ - "Percentage of fee B pending to split to the second position" - ], - "type": "u8" - }, - { - "name": "reward_0_percentage", - "docs": [ - "Percentage of reward 0 pending to split to the second position" - ], - "type": "u8" - }, - { - "name": "reward_1_percentage", - "docs": [ - "Percentage of reward 1 pending to split to the second position" - ], - "type": "u8" - }, - { - "name": "padding", - "docs": [ - "padding for future" - ], - "type": { - "array": [ - "u8", - 16 - ] - } - } - ] - } - }, - { - "name": "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": "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" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "reward_per_token_checkpoint", - "docs": [ - "The latest update reward checkpoint" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "reward_pendings", - "docs": [ - "Current pending rewards" - ], - "type": "u64" - }, - { - "name": "total_claimed_rewards", - "docs": [ - "Total claimed rewards" - ], - "type": "u64" - } - ] - } - }, - { - "name": "Vesting", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "position", - "type": "pubkey" - }, - { - "name": "cliff_point", - "type": "u64" - }, - { - "name": "period_frequency", - "type": "u64" - }, - { - "name": "cliff_unlock_liquidity", - "type": "u128" - }, - { - "name": "liquidity_per_period", - "type": "u128" - }, - { - "name": "total_released_liquidity", - "type": "u128" - }, - { - "name": "number_of_period", - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 14 - ] - } - }, - { - "name": "padding2", - "type": { - "array": [ - "u128", - 4 - ] - } - } - ] - } - }, - { - "name": "VestingParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "cliff_point", - "type": { - "option": "u64" - } - }, - { - "name": "period_frequency", - "type": "u64" - }, - { - "name": "cliff_unlock_liquidity", - "type": "u128" - }, - { - "name": "liquidity_per_period", - "type": "u128" - }, - { - "name": "number_of_period", - "type": "u16" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/crates/meteora-amm-parser/proto/meteora_amm.proto b/crates/meteora-amm-parser/proto/meteora_amm.proto deleted file mode 100644 index e738b746..00000000 --- a/crates/meteora-amm-parser/proto/meteora_amm.proto +++ /dev/null @@ -1,1299 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.meteora_amm; - -message AddLiquidityIx { - AddLiquidityIxAccounts accounts = 1; - AddLiquidityIxData data = 2; -} - -message ClaimPartnerFeeIx { - ClaimPartnerFeeIxAccounts accounts = 1; - ClaimPartnerFeeIxData data = 2; -} - -message ClaimPositionFeeIx { - ClaimPositionFeeIxAccounts accounts = 1; -} - -message ClaimProtocolFeeIx { - ClaimProtocolFeeIxAccounts accounts = 1; - ClaimProtocolFeeIxData data = 2; -} - -message ClaimRewardIx { - ClaimRewardIxAccounts accounts = 1; - ClaimRewardIxData data = 2; -} - -message CloseClaimFeeOperatorIx { - CloseClaimFeeOperatorIxAccounts accounts = 1; -} - -message CloseConfigIx { - CloseConfigIxAccounts accounts = 1; -} - -message ClosePositionIx { - ClosePositionIxAccounts accounts = 1; -} - -message CloseTokenBadgeIx { - CloseTokenBadgeIxAccounts accounts = 1; -} - -message CreateClaimFeeOperatorIx { - CreateClaimFeeOperatorIxAccounts accounts = 1; -} - -message CreateConfigIx { - CreateConfigIxAccounts accounts = 1; - CreateConfigIxData data = 2; -} - -message CreateDynamicConfigIx { - CreateDynamicConfigIxAccounts accounts = 1; - CreateDynamicConfigIxData data = 2; -} - -message CreatePositionIx { - CreatePositionIxAccounts accounts = 1; -} - -message CreateTokenBadgeIx { - CreateTokenBadgeIxAccounts accounts = 1; -} - -message FundRewardIx { - FundRewardIxAccounts accounts = 1; - FundRewardIxData data = 2; -} - -message InitializeCustomizablePoolIx { - InitializeCustomizablePoolIxAccounts accounts = 1; - InitializeCustomizablePoolIxData data = 2; -} - -message InitializePoolIx { - InitializePoolIxAccounts accounts = 1; - InitializePoolIxData data = 2; -} - -message InitializePoolWithDynamicConfigIx { - InitializePoolWithDynamicConfigIxAccounts accounts = 1; - InitializePoolWithDynamicConfigIxData data = 2; -} - -message InitializeRewardIx { - InitializeRewardIxAccounts accounts = 1; - InitializeRewardIxData data = 2; -} - -message LockPositionIx { - LockPositionIxAccounts accounts = 1; - LockPositionIxData data = 2; -} - -message PermanentLockPositionIx { - PermanentLockPositionIxAccounts accounts = 1; - PermanentLockPositionIxData data = 2; -} - -message RefreshVestingIx { - RefreshVestingIxAccounts accounts = 1; -} - -message RemoveAllLiquidityIx { - RemoveAllLiquidityIxAccounts accounts = 1; - RemoveAllLiquidityIxData data = 2; -} - -message RemoveLiquidityIx { - RemoveLiquidityIxAccounts accounts = 1; - RemoveLiquidityIxData data = 2; -} - -message SetPoolStatusIx { - SetPoolStatusIxAccounts accounts = 1; - SetPoolStatusIxData data = 2; -} - -message SplitPositionIx { - SplitPositionIxAccounts accounts = 1; - SplitPositionIxData data = 2; -} - -message SplitPosition2Ix { - SplitPosition2IxAccounts accounts = 1; - SplitPosition2IxData data = 2; -} - -message SwapIx { - SwapIxAccounts accounts = 1; - SwapIxData data = 2; -} - -message Swap2Ix { - Swap2IxAccounts accounts = 1; - Swap2IxData data = 2; -} - -message UpdateRewardDurationIx { - UpdateRewardDurationIxAccounts accounts = 1; - UpdateRewardDurationIxData data = 2; -} - -message UpdateRewardFunderIx { - UpdateRewardFunderIxAccounts accounts = 1; - UpdateRewardFunderIxData data = 2; -} - -message WithdrawIneligibleRewardIx { - WithdrawIneligibleRewardIxAccounts accounts = 1; - WithdrawIneligibleRewardIxData data = 2; -} - - -message AddLiquidityParameters { - string liquidity_delta = 1; - uint64 token_a_amount_threshold = 2; - uint64 token_b_amount_threshold = 3; -} - -message BaseFeeConfig { - uint64 cliff_fee_numerator = 1; - uint32 base_fee_mode = 2; - repeated uint32 padding = 3; - uint32 first_factor = 4; - repeated uint32 second_factor = 5; - uint64 third_factor = 6; -} - -message BaseFeeParameters { - uint64 cliff_fee_numerator = 1; - uint32 first_factor = 2; - repeated uint32 second_factor = 3; - uint64 third_factor = 4; - uint32 base_fee_mode = 5; -} - -message BaseFeeStruct { - uint64 cliff_fee_numerator = 1; - uint32 base_fee_mode = 2; - repeated uint32 padding0 = 3; - uint32 first_factor = 4; - repeated uint32 second_factor = 5; - uint64 third_factor = 6; - uint64 padding1 = 7; -} - -message DynamicFeeConfig { - uint32 initialized = 1; - repeated uint32 padding = 2; - uint32 max_volatility_accumulator = 3; - uint32 variable_fee_control = 4; - uint32 bin_step = 5; - uint32 filter_period = 6; - uint32 decay_period = 7; - uint32 reduction_factor = 8; - repeated uint32 padding1 = 9; - string bin_step_u128 = 10; -} - -message DynamicFeeParameters { - uint32 bin_step = 1; - string bin_step_u128 = 2; - uint32 filter_period = 3; - uint32 decay_period = 4; - uint32 reduction_factor = 5; - uint32 max_volatility_accumulator = 6; - uint32 variable_fee_control = 7; -} - -message DynamicFeeStruct { - uint32 initialized = 1; - repeated uint32 padding = 2; - uint32 max_volatility_accumulator = 3; - uint32 variable_fee_control = 4; - uint32 bin_step = 5; - uint32 filter_period = 6; - uint32 decay_period = 7; - uint32 reduction_factor = 8; - uint64 last_update_timestamp = 9; - string bin_step_u128 = 10; - string sqrt_price_reference = 11; - string volatility_accumulator = 12; - string volatility_reference = 13; -} - -message EvtAddLiquidity { - string pool = 1; - string position = 2; - string owner = 3; - AddLiquidityParameters params = 4; - uint64 token_a_amount = 5; - uint64 token_b_amount = 6; - uint64 total_amount_a = 7; - uint64 total_amount_b = 8; -} - -message EvtClaimPartnerFee { - string pool = 1; - uint64 token_a_amount = 2; - uint64 token_b_amount = 3; -} - -message EvtClaimPositionFee { - string pool = 1; - string position = 2; - string owner = 3; - uint64 fee_a_claimed = 4; - uint64 fee_b_claimed = 5; -} - -message EvtClaimProtocolFee { - string pool = 1; - uint64 token_a_amount = 2; - uint64 token_b_amount = 3; -} - -message EvtClaimReward { - string pool = 1; - string position = 2; - string owner = 3; - string mint_reward = 4; - uint32 reward_index = 5; - uint64 total_reward = 6; -} - -message EvtCloseClaimFeeOperator { - string claim_fee_operator = 1; - string operator = 2; -} - -message EvtCloseConfig { - string config = 1; - string admin = 2; -} - -message EvtClosePosition { - string pool = 1; - string owner = 2; - string position = 3; - string position_nft_mint = 4; -} - -message EvtCreateClaimFeeOperator { - string operator = 1; -} - -message EvtCreateConfig { - PoolFeeParameters pool_fees = 1; - string vault_config_key = 2; - string pool_creator_authority = 3; - uint32 activation_type = 4; - string sqrt_min_price = 5; - string sqrt_max_price = 6; - uint32 collect_fee_mode = 7; - uint64 index = 8; - string config = 9; -} - -message EvtCreateDynamicConfig { - string config = 1; - string pool_creator_authority = 2; - uint64 index = 3; -} - -message EvtCreatePosition { - string pool = 1; - string owner = 2; - string position = 3; - string position_nft_mint = 4; -} - -message EvtCreateTokenBadge { - string token_mint = 1; -} - -message EvtFundReward { - string pool = 1; - string funder = 2; - string mint_reward = 3; - uint32 reward_index = 4; - uint64 amount = 5; - uint64 transfer_fee_excluded_amount_in = 6; - uint64 reward_duration_end = 7; - string pre_reward_rate = 8; - string post_reward_rate = 9; -} - -message EvtInitializePool { - string pool = 1; - string token_a_mint = 2; - string token_b_mint = 3; - string creator = 4; - string payer = 5; - string alpha_vault = 6; - PoolFeeParameters pool_fees = 7; - string sqrt_min_price = 8; - string sqrt_max_price = 9; - uint32 activation_type = 10; - uint32 collect_fee_mode = 11; - string liquidity = 12; - string sqrt_price = 13; - uint64 activation_point = 14; - uint32 token_a_flag = 15; - uint32 token_b_flag = 16; - uint64 token_a_amount = 17; - uint64 token_b_amount = 18; - uint64 total_amount_a = 19; - uint64 total_amount_b = 20; - uint32 pool_type = 21; -} - -message EvtInitializeReward { - string pool = 1; - string reward_mint = 2; - string funder = 3; - string creator = 4; - uint32 reward_index = 5; - uint64 reward_duration = 6; -} - -message EvtLiquidityChange { - string pool = 1; - string position = 2; - string owner = 3; - uint64 token_a_amount = 4; - uint64 token_b_amount = 5; - uint64 transfer_fee_included_token_a_amount = 6; - uint64 transfer_fee_included_token_b_amount = 7; - uint64 reserve_a_amount = 8; - uint64 reserve_b_amount = 9; - string liquidity_delta = 10; - uint64 token_a_amount_threshold = 11; - uint64 token_b_amount_threshold = 12; - uint32 change_type = 13; -} - -message EvtLockPosition { - string pool = 1; - string position = 2; - string owner = 3; - string vesting = 4; - uint64 cliff_point = 5; - uint64 period_frequency = 6; - string cliff_unlock_liquidity = 7; - string liquidity_per_period = 8; - uint32 number_of_period = 9; -} - -message EvtPermanentLockPosition { - string pool = 1; - string position = 2; - string lock_liquidity_amount = 3; - string total_permanent_locked_liquidity = 4; -} - -message EvtRemoveLiquidity { - string pool = 1; - string position = 2; - string owner = 3; - RemoveLiquidityParameters params = 4; - uint64 token_a_amount = 5; - uint64 token_b_amount = 6; -} - -message EvtSetPoolStatus { - string pool = 1; - uint32 status = 2; -} - -message EvtSplitPosition2 { - string pool = 1; - string first_owner = 2; - string second_owner = 3; - string first_position = 4; - string second_position = 5; - string current_sqrt_price = 6; - SplitAmountInfo amount_splits = 7; - SplitPositionInfo first_position_info = 8; - SplitPositionInfo second_position_info = 9; - SplitPositionParameters2 split_position_parameters = 10; -} - -message EvtSwap { - string pool = 1; - uint32 trade_direction = 2; - bool has_referral = 3; - SwapParameters params = 4; - SwapResult swap_result = 5; - uint64 actual_amount_in = 6; - uint64 current_timestamp = 7; -} - -message EvtSwap2 { - string pool = 1; - uint32 trade_direction = 2; - uint32 collect_fee_mode = 3; - bool has_referral = 4; - SwapParameters2 params = 5; - SwapResult2 swap_result = 6; - uint64 included_transfer_fee_amount_in = 7; - uint64 included_transfer_fee_amount_out = 8; - uint64 excluded_transfer_fee_amount_out = 9; - uint64 current_timestamp = 10; - uint64 reserve_a_amount = 11; - uint64 reserve_b_amount = 12; -} - -message EvtUpdateRewardDuration { - string pool = 1; - uint32 reward_index = 2; - uint64 old_reward_duration = 3; - uint64 new_reward_duration = 4; -} - -message EvtUpdateRewardFunder { - string pool = 1; - uint32 reward_index = 2; - string old_funder = 3; - string new_funder = 4; -} - -message EvtWithdrawIneligibleReward { - string pool = 1; - string reward_mint = 2; - uint64 amount = 3; -} - -message InitializeCustomizablePoolParameters { - PoolFeeParameters pool_fees = 1; - string sqrt_min_price = 2; - string sqrt_max_price = 3; - bool has_alpha_vault = 4; - string liquidity = 5; - string sqrt_price = 6; - uint32 activation_type = 7; - uint32 collect_fee_mode = 8; - optional uint64 activation_point = 9; -} - -message PoolFeeParameters { - BaseFeeParameters base_fee = 1; - repeated uint32 padding = 2; - optional DynamicFeeParameters dynamic_fee = 3; -} - -message PoolFeesConfig { - BaseFeeConfig base_fee = 1; - DynamicFeeConfig dynamic_fee = 2; - uint32 protocol_fee_percent = 3; - uint32 partner_fee_percent = 4; - uint32 referral_fee_percent = 5; - repeated uint32 padding0 = 6; - repeated uint64 padding1 = 7; -} - -message PoolFeesStruct { - BaseFeeStruct base_fee = 1; - uint32 protocol_fee_percent = 2; - uint32 partner_fee_percent = 3; - uint32 referral_fee_percent = 4; - repeated uint32 padding0 = 5; - DynamicFeeStruct dynamic_fee = 6; - repeated uint64 padding1 = 7; -} - -message PoolMetrics { - string total_lp_a_fee = 1; - string total_lp_b_fee = 2; - uint64 total_protocol_a_fee = 3; - uint64 total_protocol_b_fee = 4; - uint64 total_partner_a_fee = 5; - uint64 total_partner_b_fee = 6; - uint64 total_position = 7; - uint64 padding = 8; -} - -message PositionMetrics { - uint64 total_claimed_a_fee = 1; - uint64 total_claimed_b_fee = 2; -} - -message RemoveLiquidityParameters { - string liquidity_delta = 1; - uint64 token_a_amount_threshold = 2; - uint64 token_b_amount_threshold = 3; -} - -message RewardInfo { - uint32 initialized = 1; - uint32 reward_token_flag = 2; - repeated uint32 padding0 = 3; - repeated uint32 padding1 = 4; - string mint = 5; - string vault = 6; - string funder = 7; - uint64 reward_duration = 8; - uint64 reward_duration_end = 9; - string reward_rate = 10; - repeated uint32 reward_per_token_stored = 11; - uint64 last_update_time = 12; - uint64 cumulative_seconds_with_empty_liquidity_reward = 13; -} - -message SplitAmountInfo { - string permanent_locked_liquidity = 1; - string unlocked_liquidity = 2; - uint64 fee_a = 3; - uint64 fee_b = 4; - uint64 reward0 = 5; - uint64 reward1 = 6; -} - -message SplitPositionInfo { - string liquidity = 1; - uint64 fee_a = 2; - uint64 fee_b = 3; - uint64 reward0 = 4; - uint64 reward1 = 5; -} - -message SplitPositionParameters2 { - uint32 unlocked_liquidity_numerator = 1; - uint32 permanent_locked_liquidity_numerator = 2; - uint32 fee_a_numerator = 3; - uint32 fee_b_numerator = 4; - uint32 reward0_numerator = 5; - uint32 reward1_numerator = 6; -} - -message SwapParameters { - uint64 amount_in = 1; - uint64 minimum_amount_out = 2; -} - -message SwapParameters2 { - uint64 amount0 = 1; - uint64 amount1 = 2; - uint32 swap_mode = 3; -} - -message SwapResult { - uint64 output_amount = 1; - string next_sqrt_price = 2; - uint64 lp_fee = 3; - uint64 protocol_fee = 4; - uint64 partner_fee = 5; - uint64 referral_fee = 6; -} - -message SwapResult2 { - uint64 included_fee_input_amount = 1; - uint64 excluded_fee_input_amount = 2; - uint64 amount_left = 3; - uint64 output_amount = 4; - string next_sqrt_price = 5; - uint64 trading_fee = 6; - uint64 protocol_fee = 7; - uint64 partner_fee = 8; - uint64 referral_fee = 9; -} - -message UserRewardInfo { - repeated uint32 reward_per_token_checkpoint = 1; - uint64 reward_pendings = 2; - uint64 total_claimed_rewards = 3; -} - - -message ClaimFeeOperator { - string operator = 1; - repeated uint32 padding = 2; -} - -message Config { - string vault_config_key = 1; - string pool_creator_authority = 2; - PoolFeesConfig pool_fees = 3; - uint32 activation_type = 4; - uint32 collect_fee_mode = 5; - uint32 config_type = 6; - repeated uint32 padding0 = 7; - uint64 index = 8; - string sqrt_min_price = 9; - string sqrt_max_price = 10; - repeated uint64 padding1 = 11; -} - -message Pool { - PoolFeesStruct pool_fees = 1; - string token_a_mint = 2; - string token_b_mint = 3; - string token_a_vault = 4; - string token_b_vault = 5; - string whitelisted_vault = 6; - string partner = 7; - string liquidity = 8; - string padding = 9; - uint64 protocol_a_fee = 10; - uint64 protocol_b_fee = 11; - uint64 partner_a_fee = 12; - uint64 partner_b_fee = 13; - string sqrt_min_price = 14; - string sqrt_max_price = 15; - string sqrt_price = 16; - uint64 activation_point = 17; - uint32 activation_type = 18; - uint32 pool_status = 19; - uint32 token_a_flag = 20; - uint32 token_b_flag = 21; - uint32 collect_fee_mode = 22; - uint32 pool_type = 23; - uint32 version = 24; - uint32 padding0 = 25; - repeated uint32 fee_a_per_liquidity = 26; - repeated uint32 fee_b_per_liquidity = 27; - string permanent_lock_liquidity = 28; - PoolMetrics metrics = 29; - string creator = 30; - repeated uint64 padding1 = 31; - repeated RewardInfo reward_infos = 32; -} - -message Position { - string pool = 1; - string nft_mint = 2; - repeated uint32 fee_a_per_token_checkpoint = 3; - repeated uint32 fee_b_per_token_checkpoint = 4; - uint64 fee_a_pending = 5; - uint64 fee_b_pending = 6; - string unlocked_liquidity = 7; - string vested_liquidity = 8; - string permanent_locked_liquidity = 9; - PositionMetrics metrics = 10; - repeated UserRewardInfo reward_infos = 11; - repeated string padding = 12; -} - -message TokenBadge { - string token_mint = 1; - repeated uint32 padding = 2; -} - -message Vesting { - string position = 1; - uint64 cliff_point = 2; - uint64 period_frequency = 3; - string cliff_unlock_liquidity = 4; - string liquidity_per_period = 5; - string total_released_liquidity = 6; - uint32 number_of_period = 7; - repeated uint32 padding = 8; - repeated string padding2 = 9; -} - - -message AddLiquidityIxAccounts { - string pool = 1; - string position = 2; - string token_a_account = 3; - string token_b_account = 4; - string token_a_vault = 5; - string token_b_vault = 6; - string token_a_mint = 7; - string token_b_mint = 8; - string position_nft_account = 9; - string owner = 10; - string token_a_program = 11; - string token_b_program = 12; - string event_authority = 13; - string program = 14; -} - -message AddLiquidityIxData { - AddLiquidityParameters params = 1; -} - -message ClaimPartnerFeeIxAccounts { - string pool_authority = 1; - string pool = 2; - string token_a_account = 3; - string token_b_account = 4; - string token_a_vault = 5; - string token_b_vault = 6; - string token_a_mint = 7; - string token_b_mint = 8; - string partner = 9; - string token_a_program = 10; - string token_b_program = 11; - string event_authority = 12; - string program = 13; -} - -message ClaimPartnerFeeIxData { - uint64 max_amount_a = 1; - uint64 max_amount_b = 2; -} - -message ClaimPositionFeeIxAccounts { - string pool_authority = 1; - string pool = 2; - string position = 3; - string token_a_account = 4; - string token_b_account = 5; - string token_a_vault = 6; - string token_b_vault = 7; - string token_a_mint = 8; - string token_b_mint = 9; - string position_nft_account = 10; - string owner = 11; - string token_a_program = 12; - string token_b_program = 13; - string event_authority = 14; - string program = 15; -} - - -message ClaimProtocolFeeIxAccounts { - string pool_authority = 1; - string pool = 2; - string token_a_vault = 3; - string token_b_vault = 4; - string token_a_mint = 5; - string token_b_mint = 6; - string token_a_account = 7; - string token_b_account = 8; - string claim_fee_operator = 9; - string operator = 10; - string token_a_program = 11; - string token_b_program = 12; - string event_authority = 13; - string program = 14; -} - -message ClaimProtocolFeeIxData { - uint64 max_amount_a = 1; - uint64 max_amount_b = 2; -} - -message ClaimRewardIxAccounts { - string pool_authority = 1; - string pool = 2; - string position = 3; - string reward_vault = 4; - string reward_mint = 5; - string user_token_account = 6; - string position_nft_account = 7; - string owner = 8; - string token_program = 9; - string event_authority = 10; - string program = 11; -} - -message ClaimRewardIxData { - uint32 reward_index = 1; - uint32 skip_reward = 2; -} - -message CloseClaimFeeOperatorIxAccounts { - string claim_fee_operator = 1; - string rent_receiver = 2; - string admin = 3; - string event_authority = 4; - string program = 5; -} - - -message CloseConfigIxAccounts { - string config = 1; - string admin = 2; - string rent_receiver = 3; - string event_authority = 4; - string program = 5; -} - - -message ClosePositionIxAccounts { - string position_nft_mint = 1; - string position_nft_account = 2; - string pool = 3; - string position = 4; - string pool_authority = 5; - string rent_receiver = 6; - string owner = 7; - string token_program = 8; - string event_authority = 9; - string program = 10; -} - - -message CloseTokenBadgeIxAccounts { - string token_badge = 1; - string admin = 2; - string rent_receiver = 3; - string event_authority = 4; - string program = 5; -} - - -message CreateClaimFeeOperatorIxAccounts { - string claim_fee_operator = 1; - string operator = 2; - string admin = 3; - string system_program = 4; - string event_authority = 5; - string program = 6; -} - - -message CreateConfigIxAccounts { - string config = 1; - string admin = 2; - string system_program = 3; - string event_authority = 4; - string program = 5; -} - -message CreateConfigIxData { - uint64 index = 1; - PoolFeeParameters pool_fees = 2; - string sqrt_min_price = 3; - string sqrt_max_price = 4; - string vault_config_key = 5; - string pool_creator_authority = 6; - uint32 activation_type = 7; - uint32 collect_fee_mode = 8; -} - -message CreateDynamicConfigIxAccounts { - string config = 1; - string admin = 2; - string system_program = 3; - string event_authority = 4; - string program = 5; -} - -message CreateDynamicConfigIxData { - uint64 index = 1; - string pool_creator_authority = 2; -} - -message CreatePositionIxAccounts { - string owner = 1; - string position_nft_mint = 2; - string position_nft_account = 3; - string pool = 4; - string position = 5; - string pool_authority = 6; - string payer = 7; - string token_program = 8; - string system_program = 9; - string event_authority = 10; - string program = 11; -} - - -message CreateTokenBadgeIxAccounts { - string token_badge = 1; - string token_mint = 2; - string admin = 3; - string system_program = 4; - string event_authority = 5; - string program = 6; -} - - -message FundRewardIxAccounts { - string pool = 1; - string reward_vault = 2; - string reward_mint = 3; - string funder_token_account = 4; - string funder = 5; - string token_program = 6; - string event_authority = 7; - string program = 8; -} - -message FundRewardIxData { - uint32 reward_index = 1; - uint64 amount = 2; - bool carry_forward = 3; -} - -message InitializeCustomizablePoolIxAccounts { - string creator = 1; - string position_nft_mint = 2; - string position_nft_account = 3; - string payer = 4; - string pool_authority = 5; - string pool = 6; - string position = 7; - string token_a_mint = 8; - string token_b_mint = 9; - string token_a_vault = 10; - string token_b_vault = 11; - string payer_token_a = 12; - string payer_token_b = 13; - string token_a_program = 14; - string token_b_program = 15; - string token2022_program = 16; - string system_program = 17; - string event_authority = 18; - string program = 19; -} - -message InitializeCustomizablePoolIxData { - InitializeCustomizablePoolParameters params = 1; -} - -message InitializePoolIxAccounts { - string creator = 1; - string position_nft_mint = 2; - string position_nft_account = 3; - string payer = 4; - string config = 5; - string pool_authority = 6; - string pool = 7; - string position = 8; - string token_a_mint = 9; - string token_b_mint = 10; - string token_a_vault = 11; - string token_b_vault = 12; - string payer_token_a = 13; - string payer_token_b = 14; - string token_a_program = 15; - string token_b_program = 16; - string token2022_program = 17; - string system_program = 18; - string event_authority = 19; - string program = 20; -} - -message InitializePoolIxData { - string liquidity = 1; - string sqrt_price = 2; - optional uint64 activation_point = 3; -} - -message InitializePoolWithDynamicConfigIxAccounts { - string creator = 1; - string position_nft_mint = 2; - string position_nft_account = 3; - string payer = 4; - string pool_creator_authority = 5; - string config = 6; - string pool_authority = 7; - string pool = 8; - string position = 9; - string token_a_mint = 10; - string token_b_mint = 11; - string token_a_vault = 12; - string token_b_vault = 13; - string payer_token_a = 14; - string payer_token_b = 15; - string token_a_program = 16; - string token_b_program = 17; - string token2022_program = 18; - string system_program = 19; - string event_authority = 20; - string program = 21; -} - -message InitializePoolWithDynamicConfigIxData { - InitializeCustomizablePoolParameters params = 1; -} - -message InitializeRewardIxAccounts { - string pool_authority = 1; - string pool = 2; - string reward_vault = 3; - string reward_mint = 4; - string signer = 5; - string payer = 6; - string token_program = 7; - string system_program = 8; - string event_authority = 9; - string program = 10; -} - -message InitializeRewardIxData { - uint32 reward_index = 1; - uint64 reward_duration = 2; - string funder = 3; -} - -message LockPositionIxAccounts { - string pool = 1; - string position = 2; - string vesting = 3; - string position_nft_account = 4; - string owner = 5; - string payer = 6; - string system_program = 7; - string event_authority = 8; - string program = 9; -} - -message LockPositionIxData { - optional uint64 cliff_point = 1; - uint64 period_frequency = 2; - string cliff_unlock_liquidity = 3; - string liquidity_per_period = 4; - uint32 number_of_period = 5; -} - -message PermanentLockPositionIxAccounts { - string pool = 1; - string position = 2; - string position_nft_account = 3; - string owner = 4; - string event_authority = 5; - string program = 6; -} - -message PermanentLockPositionIxData { - string permanent_lock_liquidity = 1; -} - -message RefreshVestingIxAccounts { - string pool = 1; - string position = 2; - string position_nft_account = 3; - string owner = 4; -} - - -message RemoveAllLiquidityIxAccounts { - string pool_authority = 1; - string pool = 2; - string position = 3; - string token_a_account = 4; - string token_b_account = 5; - string token_a_vault = 6; - string token_b_vault = 7; - string token_a_mint = 8; - string token_b_mint = 9; - string position_nft_account = 10; - string owner = 11; - string token_a_program = 12; - string token_b_program = 13; - string event_authority = 14; - string program = 15; -} - -message RemoveAllLiquidityIxData { - uint64 token_a_amount_threshold = 1; - uint64 token_b_amount_threshold = 2; -} - -message RemoveLiquidityIxAccounts { - string pool_authority = 1; - string pool = 2; - string position = 3; - string token_a_account = 4; - string token_b_account = 5; - string token_a_vault = 6; - string token_b_vault = 7; - string token_a_mint = 8; - string token_b_mint = 9; - string position_nft_account = 10; - string owner = 11; - string token_a_program = 12; - string token_b_program = 13; - string event_authority = 14; - string program = 15; -} - -message RemoveLiquidityIxData { - RemoveLiquidityParameters params = 1; -} - -message SetPoolStatusIxAccounts { - string pool = 1; - string admin = 2; - string event_authority = 3; - string program = 4; -} - -message SetPoolStatusIxData { - uint32 status = 1; -} - -message SplitPositionIxAccounts { - string pool = 1; - string first_position = 2; - string first_position_nft_account = 3; - string second_position = 4; - string second_position_nft_account = 5; - string first_owner = 6; - string second_owner = 7; - string event_authority = 8; - string program = 9; -} - -message SplitPositionIxData { - uint32 unlocked_liquidity_percentage = 1; - uint32 permanent_locked_liquidity_percentage = 2; - uint32 fee_a_percentage = 3; - uint32 fee_b_percentage = 4; - uint32 reward0_percentage = 5; - uint32 reward1_percentage = 6; - repeated uint32 padding = 7; -} - -message SplitPosition2IxAccounts { - string pool = 1; - string first_position = 2; - string first_position_nft_account = 3; - string second_position = 4; - string second_position_nft_account = 5; - string first_owner = 6; - string second_owner = 7; - string event_authority = 8; - string program = 9; -} - -message SplitPosition2IxData { - uint32 numerator = 1; -} - -message SwapIxAccounts { - string pool_authority = 1; - string pool = 2; - string input_token_account = 3; - string output_token_account = 4; - string token_a_vault = 5; - string token_b_vault = 6; - string token_a_mint = 7; - string token_b_mint = 8; - string payer = 9; - string token_a_program = 10; - string token_b_program = 11; - optional string referral_token_account = 12; - string event_authority = 13; - string program = 14; -} - -message SwapIxData { - SwapParameters params = 1; -} - -message Swap2IxAccounts { - string pool_authority = 1; - string pool = 2; - string input_token_account = 3; - string output_token_account = 4; - string token_a_vault = 5; - string token_b_vault = 6; - string token_a_mint = 7; - string token_b_mint = 8; - string payer = 9; - string token_a_program = 10; - string token_b_program = 11; - optional string referral_token_account = 12; - string event_authority = 13; - string program = 14; -} - -message Swap2IxData { - SwapParameters2 params = 1; -} - -message UpdateRewardDurationIxAccounts { - string pool = 1; - string signer = 2; - string event_authority = 3; - string program = 4; -} - -message UpdateRewardDurationIxData { - uint32 reward_index = 1; - uint64 new_duration = 2; -} - -message UpdateRewardFunderIxAccounts { - string pool = 1; - string signer = 2; - string event_authority = 3; - string program = 4; -} - -message UpdateRewardFunderIxData { - uint32 reward_index = 1; - string new_funder = 2; -} - -message WithdrawIneligibleRewardIxAccounts { - string pool_authority = 1; - string pool = 2; - string reward_vault = 3; - string reward_mint = 4; - string funder_token_account = 5; - string funder = 6; - string token_program = 7; - string event_authority = 8; - string program = 9; -} - -message WithdrawIneligibleRewardIxData { - uint32 reward_index = 1; -} - - -message ProgramState { - oneof state_oneof { - ClaimFeeOperator claim_fee_operator = 1; - Config config = 2; - Pool pool = 3; - Position position = 4; - TokenBadge token_badge = 5; - Vesting vesting = 6; - } -} - -message ProgramIxs { - oneof ix_oneof { - AddLiquidityIx add_liquidity = 1; - ClaimPartnerFeeIx claim_partner_fee = 2; - ClaimPositionFeeIx claim_position_fee = 3; - ClaimProtocolFeeIx claim_protocol_fee = 4; - ClaimRewardIx claim_reward = 5; - CloseClaimFeeOperatorIx close_claim_fee_operator = 6; - CloseConfigIx close_config = 7; - ClosePositionIx close_position = 8; - CloseTokenBadgeIx close_token_badge = 9; - CreateClaimFeeOperatorIx create_claim_fee_operator = 10; - CreateConfigIx create_config = 11; - CreateDynamicConfigIx create_dynamic_config = 12; - CreatePositionIx create_position = 13; - CreateTokenBadgeIx create_token_badge = 14; - FundRewardIx fund_reward = 15; - InitializeCustomizablePoolIx initialize_customizable_pool = 16; - InitializePoolIx initialize_pool = 17; - InitializePoolWithDynamicConfigIx initialize_pool_with_dynamic_config = 18; - InitializeRewardIx initialize_reward = 19; - LockPositionIx lock_position = 20; - PermanentLockPositionIx permanent_lock_position = 21; - RefreshVestingIx refresh_vesting = 22; - RemoveAllLiquidityIx remove_all_liquidity = 23; - RemoveLiquidityIx remove_liquidity = 24; - SetPoolStatusIx set_pool_status = 25; - SplitPositionIx split_position = 26; - SplitPosition2Ix split_position2 = 27; - SwapIx swap = 28; - Swap2Ix swap2 = 29; - UpdateRewardDurationIx update_reward_duration = 30; - UpdateRewardFunderIx update_reward_funder = 31; - WithdrawIneligibleRewardIx withdraw_ineligible_reward = 32; - } -} - diff --git a/crates/meteora-amm-parser/src/generated_parser/accounts_parser.rs b/crates/meteora-amm-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index 7c34425d..00000000 --- a/crates/meteora-amm-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,301 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{ClaimFeeOperator, Config, Pool, Position, TokenBadge, Vesting}, - deserialize_checked, ID, -}; - -/// CpAmm Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum CpAmmProgramState { - ClaimFeeOperator(ClaimFeeOperator), - Config(Config), - Pool(Pool), - Position(Position), - TokenBadge(TokenBadge), - Vesting(Vesting), -} - -impl CpAmmProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [166, 48, 134, 86, 34, 200, 188, 150] => Ok(CpAmmProgramState::ClaimFeeOperator( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [155, 12, 170, 224, 30, 250, 204, 130] => Ok(CpAmmProgramState::Config( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [241, 154, 109, 4, 17, 177, 109, 188] => Ok(CpAmmProgramState::Pool( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [170, 188, 143, 228, 122, 64, 247, 208] => Ok(CpAmmProgramState::Position( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [116, 219, 204, 229, 249, 116, 255, 150] => Ok(CpAmmProgramState::TokenBadge( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [100, 149, 66, 138, 95, 200, 128, 241] => Ok(CpAmmProgramState::Vesting( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = CpAmmProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "cp_amm::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = CpAmmProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, ClaimFeeOperator, CpAmmProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for ClaimFeeOperator { - fn into_proto(self) -> proto_def::ClaimFeeOperator { - proto_def::ClaimFeeOperator { - operator: self.operator.to_string(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::Config; - impl IntoProto for Config { - fn into_proto(self) -> proto_def::Config { - proto_def::Config { - vault_config_key: self.vault_config_key.to_string(), - pool_creator_authority: self.pool_creator_authority.to_string(), - pool_fees: Some(self.pool_fees.into_proto()), - activation_type: self.activation_type.into(), - collect_fee_mode: self.collect_fee_mode.into(), - config_type: self.config_type.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - index: self.index, - sqrt_min_price: self.sqrt_min_price.to_string(), - sqrt_max_price: self.sqrt_max_price.to_string(), - padding1: self.padding1.to_vec(), - } - } - } - use super::Pool; - impl IntoProto for Pool { - fn into_proto(self) -> proto_def::Pool { - proto_def::Pool { - pool_fees: Some(self.pool_fees.into_proto()), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - whitelisted_vault: self.whitelisted_vault.to_string(), - partner: self.partner.to_string(), - liquidity: self.liquidity.to_string(), - padding: self.padding.to_string(), - protocol_a_fee: self.protocol_a_fee, - protocol_b_fee: self.protocol_b_fee, - partner_a_fee: self.partner_a_fee, - partner_b_fee: self.partner_b_fee, - sqrt_min_price: self.sqrt_min_price.to_string(), - sqrt_max_price: self.sqrt_max_price.to_string(), - sqrt_price: self.sqrt_price.to_string(), - activation_point: self.activation_point, - activation_type: self.activation_type.into(), - pool_status: self.pool_status.into(), - token_a_flag: self.token_a_flag.into(), - token_b_flag: self.token_b_flag.into(), - collect_fee_mode: self.collect_fee_mode.into(), - pool_type: self.pool_type.into(), - version: self.version.into(), - padding0: self.padding0.into(), - fee_a_per_liquidity: self - .fee_a_per_liquidity - .into_iter() - .map(|x| x.into()) - .collect(), - fee_b_per_liquidity: self - .fee_b_per_liquidity - .into_iter() - .map(|x| x.into()) - .collect(), - permanent_lock_liquidity: self.permanent_lock_liquidity.to_string(), - metrics: Some(self.metrics.into_proto()), - creator: self.creator.to_string(), - padding1: self.padding1.to_vec(), - reward_infos: self - .reward_infos - .into_iter() - .map(|x| x.into_proto()) - .collect(), - } - } - } - use super::Position; - impl IntoProto for Position { - fn into_proto(self) -> proto_def::Position { - proto_def::Position { - pool: self.pool.to_string(), - nft_mint: self.nft_mint.to_string(), - fee_a_per_token_checkpoint: self - .fee_a_per_token_checkpoint - .into_iter() - .map(|x| x.into()) - .collect(), - fee_b_per_token_checkpoint: self - .fee_b_per_token_checkpoint - .into_iter() - .map(|x| x.into()) - .collect(), - fee_a_pending: self.fee_a_pending, - fee_b_pending: self.fee_b_pending, - unlocked_liquidity: self.unlocked_liquidity.to_string(), - vested_liquidity: self.vested_liquidity.to_string(), - permanent_locked_liquidity: self.permanent_locked_liquidity.to_string(), - metrics: Some(self.metrics.into_proto()), - reward_infos: self - .reward_infos - .into_iter() - .map(|x| x.into_proto()) - .collect(), - padding: self.padding.into_iter().map(|x| x.to_string()).collect(), - } - } - } - use super::TokenBadge; - impl IntoProto for TokenBadge { - fn into_proto(self) -> proto_def::TokenBadge { - proto_def::TokenBadge { - token_mint: self.token_mint.to_string(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::Vesting; - impl IntoProto for Vesting { - fn into_proto(self) -> proto_def::Vesting { - proto_def::Vesting { - position: self.position.to_string(), - cliff_point: self.cliff_point, - period_frequency: self.period_frequency, - cliff_unlock_liquidity: self.cliff_unlock_liquidity.to_string(), - liquidity_per_period: self.liquidity_per_period.to_string(), - total_released_liquidity: self.total_released_liquidity.to_string(), - number_of_period: self.number_of_period.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - padding2: self.padding2.into_iter().map(|x| x.to_string()).collect(), - } - } - } - - impl IntoProto for CpAmmProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - CpAmmProgramState::ClaimFeeOperator(data) => { - proto_def::program_state::StateOneof::ClaimFeeOperator(data.into_proto()) - }, - CpAmmProgramState::Config(data) => { - proto_def::program_state::StateOneof::Config(data.into_proto()) - }, - CpAmmProgramState::Pool(data) => { - proto_def::program_state::StateOneof::Pool(data.into_proto()) - }, - CpAmmProgramState::Position(data) => { - proto_def::program_state::StateOneof::Position(data.into_proto()) - }, - CpAmmProgramState::TokenBadge(data) => { - proto_def::program_state::StateOneof::TokenBadge(data.into_proto()) - }, - CpAmmProgramState::Vesting(data) => { - proto_def::program_state::StateOneof::Vesting(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/meteora-amm-parser/src/generated_parser/instructions_parser.rs b/crates/meteora-amm-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index ceaaf865..00000000 --- a/crates/meteora-amm-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,1910 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - AddLiquidity as AddLiquidityIxAccounts, AddLiquidityInstructionArgs as AddLiquidityIxData, - ClaimPartnerFee as ClaimPartnerFeeIxAccounts, - ClaimPartnerFeeInstructionArgs as ClaimPartnerFeeIxData, - ClaimPositionFee as ClaimPositionFeeIxAccounts, - ClaimProtocolFee as ClaimProtocolFeeIxAccounts, - ClaimProtocolFeeInstructionArgs as ClaimProtocolFeeIxData, - ClaimReward as ClaimRewardIxAccounts, ClaimRewardInstructionArgs as ClaimRewardIxData, - CloseClaimFeeOperator as CloseClaimFeeOperatorIxAccounts, - CloseConfig as CloseConfigIxAccounts, ClosePosition as ClosePositionIxAccounts, - CloseTokenBadge as CloseTokenBadgeIxAccounts, - CreateClaimFeeOperator as CreateClaimFeeOperatorIxAccounts, - CreateConfig as CreateConfigIxAccounts, CreateConfigInstructionArgs as CreateConfigIxData, - CreateDynamicConfig as CreateDynamicConfigIxAccounts, - CreateDynamicConfigInstructionArgs as CreateDynamicConfigIxData, - CreatePosition as CreatePositionIxAccounts, CreateTokenBadge as CreateTokenBadgeIxAccounts, - FundReward as FundRewardIxAccounts, FundRewardInstructionArgs as FundRewardIxData, - InitializeCustomizablePool as InitializeCustomizablePoolIxAccounts, - InitializeCustomizablePoolInstructionArgs as InitializeCustomizablePoolIxData, - InitializePool as InitializePoolIxAccounts, - InitializePoolInstructionArgs as InitializePoolIxData, - InitializePoolWithDynamicConfig as InitializePoolWithDynamicConfigIxAccounts, - InitializePoolWithDynamicConfigInstructionArgs as InitializePoolWithDynamicConfigIxData, - InitializeReward as InitializeRewardIxAccounts, - InitializeRewardInstructionArgs as InitializeRewardIxData, - LockPosition as LockPositionIxAccounts, LockPositionInstructionArgs as LockPositionIxData, - PermanentLockPosition as PermanentLockPositionIxAccounts, - PermanentLockPositionInstructionArgs as PermanentLockPositionIxData, - RefreshVesting as RefreshVestingIxAccounts, - RemoveAllLiquidity as RemoveAllLiquidityIxAccounts, - RemoveAllLiquidityInstructionArgs as RemoveAllLiquidityIxData, - RemoveLiquidity as RemoveLiquidityIxAccounts, - RemoveLiquidityInstructionArgs as RemoveLiquidityIxData, - SetPoolStatus as SetPoolStatusIxAccounts, - SetPoolStatusInstructionArgs as SetPoolStatusIxData, - SplitPosition as SplitPositionIxAccounts, SplitPosition2 as SplitPosition2IxAccounts, - SplitPosition2InstructionArgs as SplitPosition2IxData, - SplitPositionInstructionArgs as SplitPositionIxData, Swap as SwapIxAccounts, - Swap2 as Swap2IxAccounts, Swap2InstructionArgs as Swap2IxData, - SwapInstructionArgs as SwapIxData, UpdateRewardDuration as UpdateRewardDurationIxAccounts, - UpdateRewardDurationInstructionArgs as UpdateRewardDurationIxData, - UpdateRewardFunder as UpdateRewardFunderIxAccounts, - UpdateRewardFunderInstructionArgs as UpdateRewardFunderIxData, - WithdrawIneligibleReward as WithdrawIneligibleRewardIxAccounts, - WithdrawIneligibleRewardInstructionArgs as WithdrawIneligibleRewardIxData, - }, - ID, -}; - -/// CpAmm Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum CpAmmProgramIx { - AddLiquidity(AddLiquidityIxAccounts, AddLiquidityIxData), - ClaimPartnerFee(ClaimPartnerFeeIxAccounts, ClaimPartnerFeeIxData), - ClaimPositionFee(ClaimPositionFeeIxAccounts), - ClaimProtocolFee(ClaimProtocolFeeIxAccounts, ClaimProtocolFeeIxData), - ClaimReward(ClaimRewardIxAccounts, ClaimRewardIxData), - CloseClaimFeeOperator(CloseClaimFeeOperatorIxAccounts), - CloseConfig(CloseConfigIxAccounts), - ClosePosition(ClosePositionIxAccounts), - CloseTokenBadge(CloseTokenBadgeIxAccounts), - CreateClaimFeeOperator(CreateClaimFeeOperatorIxAccounts), - CreateConfig(CreateConfigIxAccounts, CreateConfigIxData), - CreateDynamicConfig(CreateDynamicConfigIxAccounts, CreateDynamicConfigIxData), - CreatePosition(CreatePositionIxAccounts), - CreateTokenBadge(CreateTokenBadgeIxAccounts), - FundReward(FundRewardIxAccounts, FundRewardIxData), - InitializeCustomizablePool( - InitializeCustomizablePoolIxAccounts, - InitializeCustomizablePoolIxData, - ), - InitializePool(InitializePoolIxAccounts, InitializePoolIxData), - InitializePoolWithDynamicConfig( - InitializePoolWithDynamicConfigIxAccounts, - InitializePoolWithDynamicConfigIxData, - ), - InitializeReward(InitializeRewardIxAccounts, InitializeRewardIxData), - LockPosition(LockPositionIxAccounts, LockPositionIxData), - PermanentLockPosition(PermanentLockPositionIxAccounts, PermanentLockPositionIxData), - RefreshVesting(RefreshVestingIxAccounts), - RemoveAllLiquidity(RemoveAllLiquidityIxAccounts, RemoveAllLiquidityIxData), - RemoveLiquidity(RemoveLiquidityIxAccounts, RemoveLiquidityIxData), - SetPoolStatus(SetPoolStatusIxAccounts, SetPoolStatusIxData), - SplitPosition(SplitPositionIxAccounts, SplitPositionIxData), - SplitPosition2(SplitPosition2IxAccounts, SplitPosition2IxData), - Swap(SwapIxAccounts, SwapIxData), - Swap2(Swap2IxAccounts, Swap2IxData), - UpdateRewardDuration(UpdateRewardDurationIxAccounts, UpdateRewardDurationIxData), - UpdateRewardFunder(UpdateRewardFunderIxAccounts, UpdateRewardFunderIxData), - WithdrawIneligibleReward( - WithdrawIneligibleRewardIxAccounts, - WithdrawIneligibleRewardIxData, - ), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = CpAmmProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "CpAmm::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [181, 157, 89, 67, 143, 182, 52, 72] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddLiquidityIxAccounts { - pool: next_account(accounts)?, - position: next_account(accounts)?, - token_a_account: next_account(accounts)?, - token_b_account: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - owner: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: AddLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::AddLiquidity(ix_accounts, de_ix_data)) - }, - [97, 206, 39, 105, 94, 94, 126, 148] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimPartnerFeeIxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - token_a_account: next_account(accounts)?, - token_b_account: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - partner: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: ClaimPartnerFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::ClaimPartnerFee(ix_accounts, de_ix_data)) - }, - [180, 38, 154, 17, 133, 33, 162, 211] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimPositionFeeIxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - position: next_account(accounts)?, - token_a_account: next_account(accounts)?, - token_b_account: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - owner: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(CpAmmProgramIx::ClaimPositionFee(ix_accounts)) - }, - [165, 228, 133, 48, 99, 249, 255, 33] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimProtocolFeeIxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - token_a_account: next_account(accounts)?, - token_b_account: next_account(accounts)?, - claim_fee_operator: next_account(accounts)?, - operator: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: ClaimProtocolFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::ClaimProtocolFee(ix_accounts, de_ix_data)) - }, - [149, 95, 181, 242, 94, 90, 158, 162] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimRewardIxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - position: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_mint: next_account(accounts)?, - user_token_account: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - owner: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: ClaimRewardIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::ClaimReward(ix_accounts, de_ix_data)) - }, - [38, 134, 82, 216, 95, 124, 17, 99] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CloseClaimFeeOperatorIxAccounts { - claim_fee_operator: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - admin: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(CpAmmProgramIx::CloseClaimFeeOperator(ix_accounts)) - }, - [145, 9, 72, 157, 95, 125, 61, 85] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CloseConfigIxAccounts { - config: next_account(accounts)?, - admin: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(CpAmmProgramIx::CloseConfig(ix_accounts)) - }, - [123, 134, 81, 0, 49, 68, 98, 98] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClosePositionIxAccounts { - position_nft_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - pool: next_account(accounts)?, - position: next_account(accounts)?, - pool_authority: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - owner: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(CpAmmProgramIx::ClosePosition(ix_accounts)) - }, - [108, 146, 86, 110, 179, 254, 10, 104] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CloseTokenBadgeIxAccounts { - token_badge: next_account(accounts)?, - admin: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(CpAmmProgramIx::CloseTokenBadge(ix_accounts)) - }, - [169, 62, 207, 107, 58, 187, 162, 109] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateClaimFeeOperatorIxAccounts { - claim_fee_operator: next_account(accounts)?, - operator: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(CpAmmProgramIx::CreateClaimFeeOperator(ix_accounts)) - }, - [201, 207, 243, 114, 75, 111, 47, 189] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateConfigIxAccounts { - config: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: CreateConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::CreateConfig(ix_accounts, de_ix_data)) - }, - [81, 251, 122, 78, 66, 57, 208, 82] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateDynamicConfigIxAccounts { - config: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: CreateDynamicConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::CreateDynamicConfig(ix_accounts, de_ix_data)) - }, - [48, 215, 197, 153, 96, 203, 180, 133] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreatePositionIxAccounts { - owner: next_account(accounts)?, - position_nft_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - pool: next_account(accounts)?, - position: next_account(accounts)?, - pool_authority: next_account(accounts)?, - payer: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(CpAmmProgramIx::CreatePosition(ix_accounts)) - }, - [88, 206, 0, 91, 60, 175, 151, 118] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateTokenBadgeIxAccounts { - token_badge: next_account(accounts)?, - token_mint: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(CpAmmProgramIx::CreateTokenBadge(ix_accounts)) - }, - [188, 50, 249, 165, 93, 151, 38, 63] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = FundRewardIxAccounts { - pool: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_mint: next_account(accounts)?, - funder_token_account: next_account(accounts)?, - funder: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: FundRewardIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::FundReward(ix_accounts, de_ix_data)) - }, - [20, 161, 241, 24, 189, 221, 180, 2] => { - let expected_accounts_len = 19; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeCustomizablePoolIxAccounts { - creator: next_account(accounts)?, - position_nft_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - payer: next_account(accounts)?, - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - position: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - payer_token_a: next_account(accounts)?, - payer_token_b: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - token2022_program: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeCustomizablePoolIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::InitializeCustomizablePool( - ix_accounts, - de_ix_data, - )) - }, - [95, 180, 10, 172, 84, 174, 232, 40] => { - let expected_accounts_len = 20; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePoolIxAccounts { - creator: next_account(accounts)?, - position_nft_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - payer: next_account(accounts)?, - config: next_account(accounts)?, - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - position: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - payer_token_a: next_account(accounts)?, - payer_token_b: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - token2022_program: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializePoolIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::InitializePool(ix_accounts, de_ix_data)) - }, - [149, 82, 72, 197, 253, 252, 68, 15] => { - let expected_accounts_len = 21; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePoolWithDynamicConfigIxAccounts { - creator: next_account(accounts)?, - position_nft_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - payer: next_account(accounts)?, - pool_creator_authority: next_account(accounts)?, - config: next_account(accounts)?, - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - position: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - payer_token_a: next_account(accounts)?, - payer_token_b: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - token2022_program: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializePoolWithDynamicConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::InitializePoolWithDynamicConfig( - ix_accounts, - de_ix_data, - )) - }, - [95, 135, 192, 196, 242, 129, 230, 68] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeRewardIxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_mint: next_account(accounts)?, - signer: next_account(accounts)?, - payer: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeRewardIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::InitializeReward(ix_accounts, de_ix_data)) - }, - [227, 62, 2, 252, 247, 10, 171, 185] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = LockPositionIxAccounts { - pool: next_account(accounts)?, - position: next_account(accounts)?, - vesting: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - owner: next_account(accounts)?, - payer: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: LockPositionIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::LockPosition(ix_accounts, de_ix_data)) - }, - [165, 176, 125, 6, 231, 171, 186, 213] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = PermanentLockPositionIxAccounts { - pool: next_account(accounts)?, - position: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - owner: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: PermanentLockPositionIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::PermanentLockPosition( - ix_accounts, - de_ix_data, - )) - }, - [9, 94, 216, 14, 116, 204, 247, 0] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RefreshVestingIxAccounts { - pool: next_account(accounts)?, - position: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - owner: next_account(accounts)?, - }; - Ok(CpAmmProgramIx::RefreshVesting(ix_accounts)) - }, - [10, 51, 61, 35, 112, 105, 24, 85] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveAllLiquidityIxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - position: next_account(accounts)?, - token_a_account: next_account(accounts)?, - token_b_account: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - owner: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: RemoveAllLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::RemoveAllLiquidity(ix_accounts, de_ix_data)) - }, - [80, 85, 209, 72, 24, 206, 177, 108] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveLiquidityIxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - position: next_account(accounts)?, - token_a_account: next_account(accounts)?, - token_b_account: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - owner: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: RemoveLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::RemoveLiquidity(ix_accounts, de_ix_data)) - }, - [112, 87, 135, 223, 83, 204, 132, 53] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetPoolStatusIxAccounts { - pool: next_account(accounts)?, - admin: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SetPoolStatusIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::SetPoolStatus(ix_accounts, de_ix_data)) - }, - [172, 241, 221, 138, 161, 29, 253, 42] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SplitPositionIxAccounts { - pool: next_account(accounts)?, - first_position: next_account(accounts)?, - first_position_nft_account: next_account(accounts)?, - second_position: next_account(accounts)?, - second_position_nft_account: next_account(accounts)?, - first_owner: next_account(accounts)?, - second_owner: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SplitPositionIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::SplitPosition(ix_accounts, de_ix_data)) - }, - [221, 147, 228, 207, 140, 212, 17, 119] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SplitPosition2IxAccounts { - pool: next_account(accounts)?, - first_position: next_account(accounts)?, - first_position_nft_account: next_account(accounts)?, - second_position: next_account(accounts)?, - second_position_nft_account: next_account(accounts)?, - first_owner: next_account(accounts)?, - second_owner: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SplitPosition2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::SplitPosition2(ix_accounts, de_ix_data)) - }, - [248, 198, 158, 145, 225, 117, 135, 200] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapIxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - input_token_account: next_account(accounts)?, - output_token_account: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - payer: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - referral_token_account: next_program_id_optional_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SwapIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::Swap(ix_accounts, de_ix_data)) - }, - [65, 75, 63, 76, 235, 91, 91, 136] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = Swap2IxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - input_token_account: next_account(accounts)?, - output_token_account: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - payer: next_account(accounts)?, - token_a_program: next_account(accounts)?, - token_b_program: next_account(accounts)?, - referral_token_account: next_program_id_optional_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: Swap2IxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::Swap2(ix_accounts, de_ix_data)) - }, - [138, 174, 196, 169, 213, 235, 254, 107] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateRewardDurationIxAccounts { - pool: next_account(accounts)?, - signer: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: UpdateRewardDurationIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::UpdateRewardDuration( - ix_accounts, - de_ix_data, - )) - }, - [211, 28, 48, 32, 215, 160, 35, 23] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateRewardFunderIxAccounts { - pool: next_account(accounts)?, - signer: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: UpdateRewardFunderIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::UpdateRewardFunder(ix_accounts, de_ix_data)) - }, - [148, 206, 42, 195, 247, 49, 103, 8] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawIneligibleRewardIxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_mint: next_account(accounts)?, - funder_token_account: next_account(accounts)?, - funder: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: WithdrawIneligibleRewardIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(CpAmmProgramIx::WithdrawIneligibleReward( - ix_accounts, - de_ix_data, - )) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AddLiquidityIxAccounts, CpAmmProgramIx, InstructionParser}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for AddLiquidityIxAccounts { - fn into_proto(self) -> proto_def::AddLiquidityIxAccounts { - proto_def::AddLiquidityIxAccounts { - pool: self.pool.to_string(), - position: self.position.to_string(), - token_a_account: self.token_a_account.to_string(), - token_b_account: self.token_b_account.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - owner: self.owner.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::AddLiquidityIxData; - impl IntoProto for AddLiquidityIxData { - fn into_proto(self) -> proto_def::AddLiquidityIxData { - proto_def::AddLiquidityIxData { - params: Some(self.params.into_proto()), - } - } - } - use super::ClaimPartnerFeeIxAccounts; - impl IntoProto for ClaimPartnerFeeIxAccounts { - fn into_proto(self) -> proto_def::ClaimPartnerFeeIxAccounts { - proto_def::ClaimPartnerFeeIxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - token_a_account: self.token_a_account.to_string(), - token_b_account: self.token_b_account.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - partner: self.partner.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClaimPartnerFeeIxData; - impl IntoProto for ClaimPartnerFeeIxData { - fn into_proto(self) -> proto_def::ClaimPartnerFeeIxData { - proto_def::ClaimPartnerFeeIxData { - max_amount_a: self.max_amount_a, - max_amount_b: self.max_amount_b, - } - } - } - use super::ClaimPositionFeeIxAccounts; - impl IntoProto for ClaimPositionFeeIxAccounts { - fn into_proto(self) -> proto_def::ClaimPositionFeeIxAccounts { - proto_def::ClaimPositionFeeIxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - position: self.position.to_string(), - token_a_account: self.token_a_account.to_string(), - token_b_account: self.token_b_account.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - owner: self.owner.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClaimProtocolFeeIxAccounts; - impl IntoProto for ClaimProtocolFeeIxAccounts { - fn into_proto(self) -> proto_def::ClaimProtocolFeeIxAccounts { - proto_def::ClaimProtocolFeeIxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - token_a_account: self.token_a_account.to_string(), - token_b_account: self.token_b_account.to_string(), - claim_fee_operator: self.claim_fee_operator.to_string(), - operator: self.operator.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClaimProtocolFeeIxData; - impl IntoProto for ClaimProtocolFeeIxData { - fn into_proto(self) -> proto_def::ClaimProtocolFeeIxData { - proto_def::ClaimProtocolFeeIxData { - max_amount_a: self.max_amount_a, - max_amount_b: self.max_amount_b, - } - } - } - use super::ClaimRewardIxAccounts; - impl IntoProto for ClaimRewardIxAccounts { - fn into_proto(self) -> proto_def::ClaimRewardIxAccounts { - proto_def::ClaimRewardIxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - position: self.position.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_mint: self.reward_mint.to_string(), - user_token_account: self.user_token_account.to_string(), - position_nft_account: self.position_nft_account.to_string(), - owner: self.owner.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClaimRewardIxData; - impl IntoProto for ClaimRewardIxData { - fn into_proto(self) -> proto_def::ClaimRewardIxData { - proto_def::ClaimRewardIxData { - reward_index: self.reward_index.into(), - skip_reward: self.skip_reward.into(), - } - } - } - use super::CloseClaimFeeOperatorIxAccounts; - impl IntoProto for CloseClaimFeeOperatorIxAccounts { - fn into_proto(self) -> proto_def::CloseClaimFeeOperatorIxAccounts { - proto_def::CloseClaimFeeOperatorIxAccounts { - claim_fee_operator: self.claim_fee_operator.to_string(), - rent_receiver: self.rent_receiver.to_string(), - admin: self.admin.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CloseConfigIxAccounts; - impl IntoProto for CloseConfigIxAccounts { - fn into_proto(self) -> proto_def::CloseConfigIxAccounts { - proto_def::CloseConfigIxAccounts { - config: self.config.to_string(), - admin: self.admin.to_string(), - rent_receiver: self.rent_receiver.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClosePositionIxAccounts; - impl IntoProto for ClosePositionIxAccounts { - fn into_proto(self) -> proto_def::ClosePositionIxAccounts { - proto_def::ClosePositionIxAccounts { - position_nft_mint: self.position_nft_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - pool: self.pool.to_string(), - position: self.position.to_string(), - pool_authority: self.pool_authority.to_string(), - rent_receiver: self.rent_receiver.to_string(), - owner: self.owner.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CloseTokenBadgeIxAccounts; - impl IntoProto for CloseTokenBadgeIxAccounts { - fn into_proto(self) -> proto_def::CloseTokenBadgeIxAccounts { - proto_def::CloseTokenBadgeIxAccounts { - token_badge: self.token_badge.to_string(), - admin: self.admin.to_string(), - rent_receiver: self.rent_receiver.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateClaimFeeOperatorIxAccounts; - impl IntoProto for CreateClaimFeeOperatorIxAccounts { - fn into_proto(self) -> proto_def::CreateClaimFeeOperatorIxAccounts { - proto_def::CreateClaimFeeOperatorIxAccounts { - claim_fee_operator: self.claim_fee_operator.to_string(), - operator: self.operator.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateConfigIxAccounts; - impl IntoProto for CreateConfigIxAccounts { - fn into_proto(self) -> proto_def::CreateConfigIxAccounts { - proto_def::CreateConfigIxAccounts { - config: self.config.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateConfigIxData; - impl IntoProto for CreateConfigIxData { - fn into_proto(self) -> proto_def::CreateConfigIxData { - proto_def::CreateConfigIxData { - index: self.index, - pool_fees: Some(self.pool_fees.into_proto()), - sqrt_min_price: self.sqrt_min_price.to_string(), - sqrt_max_price: self.sqrt_max_price.to_string(), - vault_config_key: self.vault_config_key.to_string(), - pool_creator_authority: self.pool_creator_authority.to_string(), - activation_type: self.activation_type.into(), - collect_fee_mode: self.collect_fee_mode.into(), - } - } - } - use super::CreateDynamicConfigIxAccounts; - impl IntoProto for CreateDynamicConfigIxAccounts { - fn into_proto(self) -> proto_def::CreateDynamicConfigIxAccounts { - proto_def::CreateDynamicConfigIxAccounts { - config: self.config.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateDynamicConfigIxData; - impl IntoProto for CreateDynamicConfigIxData { - fn into_proto(self) -> proto_def::CreateDynamicConfigIxData { - proto_def::CreateDynamicConfigIxData { - index: self.index, - pool_creator_authority: self.pool_creator_authority.to_string(), - } - } - } - use super::CreatePositionIxAccounts; - impl IntoProto for CreatePositionIxAccounts { - fn into_proto(self) -> proto_def::CreatePositionIxAccounts { - proto_def::CreatePositionIxAccounts { - owner: self.owner.to_string(), - position_nft_mint: self.position_nft_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - pool: self.pool.to_string(), - position: self.position.to_string(), - pool_authority: self.pool_authority.to_string(), - payer: self.payer.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateTokenBadgeIxAccounts; - impl IntoProto for CreateTokenBadgeIxAccounts { - fn into_proto(self) -> proto_def::CreateTokenBadgeIxAccounts { - proto_def::CreateTokenBadgeIxAccounts { - token_badge: self.token_badge.to_string(), - token_mint: self.token_mint.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::FundRewardIxAccounts; - impl IntoProto for FundRewardIxAccounts { - fn into_proto(self) -> proto_def::FundRewardIxAccounts { - proto_def::FundRewardIxAccounts { - pool: self.pool.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_mint: self.reward_mint.to_string(), - funder_token_account: self.funder_token_account.to_string(), - funder: self.funder.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::FundRewardIxData; - impl IntoProto for FundRewardIxData { - fn into_proto(self) -> proto_def::FundRewardIxData { - proto_def::FundRewardIxData { - reward_index: self.reward_index.into(), - amount: self.amount, - carry_forward: self.carry_forward, - } - } - } - use super::InitializeCustomizablePoolIxAccounts; - impl IntoProto - for InitializeCustomizablePoolIxAccounts - { - fn into_proto(self) -> proto_def::InitializeCustomizablePoolIxAccounts { - proto_def::InitializeCustomizablePoolIxAccounts { - creator: self.creator.to_string(), - position_nft_mint: self.position_nft_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - payer: self.payer.to_string(), - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - position: self.position.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - payer_token_a: self.payer_token_a.to_string(), - payer_token_b: self.payer_token_b.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - token2022_program: self.token2022_program.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeCustomizablePoolIxData; - impl IntoProto for InitializeCustomizablePoolIxData { - fn into_proto(self) -> proto_def::InitializeCustomizablePoolIxData { - proto_def::InitializeCustomizablePoolIxData { - params: Some(self.params.into_proto()), - } - } - } - use super::InitializePoolIxAccounts; - impl IntoProto for InitializePoolIxAccounts { - fn into_proto(self) -> proto_def::InitializePoolIxAccounts { - proto_def::InitializePoolIxAccounts { - creator: self.creator.to_string(), - position_nft_mint: self.position_nft_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - payer: self.payer.to_string(), - config: self.config.to_string(), - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - position: self.position.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - payer_token_a: self.payer_token_a.to_string(), - payer_token_b: self.payer_token_b.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - token2022_program: self.token2022_program.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializePoolIxData; - impl IntoProto for InitializePoolIxData { - fn into_proto(self) -> proto_def::InitializePoolIxData { - proto_def::InitializePoolIxData { - liquidity: self.liquidity.to_string(), - sqrt_price: self.sqrt_price.to_string(), - activation_point: self.activation_point, - } - } - } - use super::InitializePoolWithDynamicConfigIxAccounts; - impl IntoProto - for InitializePoolWithDynamicConfigIxAccounts - { - fn into_proto(self) -> proto_def::InitializePoolWithDynamicConfigIxAccounts { - proto_def::InitializePoolWithDynamicConfigIxAccounts { - creator: self.creator.to_string(), - position_nft_mint: self.position_nft_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - payer: self.payer.to_string(), - pool_creator_authority: self.pool_creator_authority.to_string(), - config: self.config.to_string(), - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - position: self.position.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - payer_token_a: self.payer_token_a.to_string(), - payer_token_b: self.payer_token_b.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - token2022_program: self.token2022_program.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializePoolWithDynamicConfigIxData; - impl IntoProto - for InitializePoolWithDynamicConfigIxData - { - fn into_proto(self) -> proto_def::InitializePoolWithDynamicConfigIxData { - proto_def::InitializePoolWithDynamicConfigIxData { - params: Some(self.params.into_proto()), - } - } - } - use super::InitializeRewardIxAccounts; - impl IntoProto for InitializeRewardIxAccounts { - fn into_proto(self) -> proto_def::InitializeRewardIxAccounts { - proto_def::InitializeRewardIxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_mint: self.reward_mint.to_string(), - signer: self.signer.to_string(), - payer: self.payer.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeRewardIxData; - impl IntoProto for InitializeRewardIxData { - fn into_proto(self) -> proto_def::InitializeRewardIxData { - proto_def::InitializeRewardIxData { - reward_index: self.reward_index.into(), - reward_duration: self.reward_duration, - funder: self.funder.to_string(), - } - } - } - use super::LockPositionIxAccounts; - impl IntoProto for LockPositionIxAccounts { - fn into_proto(self) -> proto_def::LockPositionIxAccounts { - proto_def::LockPositionIxAccounts { - pool: self.pool.to_string(), - position: self.position.to_string(), - vesting: self.vesting.to_string(), - position_nft_account: self.position_nft_account.to_string(), - owner: self.owner.to_string(), - payer: self.payer.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::LockPositionIxData; - impl IntoProto for LockPositionIxData { - fn into_proto(self) -> proto_def::LockPositionIxData { - proto_def::LockPositionIxData { - cliff_point: self.cliff_point, - period_frequency: self.period_frequency, - cliff_unlock_liquidity: self.cliff_unlock_liquidity.to_string(), - liquidity_per_period: self.liquidity_per_period.to_string(), - number_of_period: self.number_of_period.into(), - } - } - } - use super::PermanentLockPositionIxAccounts; - impl IntoProto for PermanentLockPositionIxAccounts { - fn into_proto(self) -> proto_def::PermanentLockPositionIxAccounts { - proto_def::PermanentLockPositionIxAccounts { - pool: self.pool.to_string(), - position: self.position.to_string(), - position_nft_account: self.position_nft_account.to_string(), - owner: self.owner.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::PermanentLockPositionIxData; - impl IntoProto for PermanentLockPositionIxData { - fn into_proto(self) -> proto_def::PermanentLockPositionIxData { - proto_def::PermanentLockPositionIxData { - permanent_lock_liquidity: self.permanent_lock_liquidity.to_string(), - } - } - } - use super::RefreshVestingIxAccounts; - impl IntoProto for RefreshVestingIxAccounts { - fn into_proto(self) -> proto_def::RefreshVestingIxAccounts { - proto_def::RefreshVestingIxAccounts { - pool: self.pool.to_string(), - position: self.position.to_string(), - position_nft_account: self.position_nft_account.to_string(), - owner: self.owner.to_string(), - } - } - } - use super::RemoveAllLiquidityIxAccounts; - impl IntoProto for RemoveAllLiquidityIxAccounts { - fn into_proto(self) -> proto_def::RemoveAllLiquidityIxAccounts { - proto_def::RemoveAllLiquidityIxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - position: self.position.to_string(), - token_a_account: self.token_a_account.to_string(), - token_b_account: self.token_b_account.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - owner: self.owner.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::RemoveAllLiquidityIxData; - impl IntoProto for RemoveAllLiquidityIxData { - fn into_proto(self) -> proto_def::RemoveAllLiquidityIxData { - proto_def::RemoveAllLiquidityIxData { - token_a_amount_threshold: self.token_a_amount_threshold, - token_b_amount_threshold: self.token_b_amount_threshold, - } - } - } - use super::RemoveLiquidityIxAccounts; - impl IntoProto for RemoveLiquidityIxAccounts { - fn into_proto(self) -> proto_def::RemoveLiquidityIxAccounts { - proto_def::RemoveLiquidityIxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - position: self.position.to_string(), - token_a_account: self.token_a_account.to_string(), - token_b_account: self.token_b_account.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - owner: self.owner.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::RemoveLiquidityIxData; - impl IntoProto for RemoveLiquidityIxData { - fn into_proto(self) -> proto_def::RemoveLiquidityIxData { - proto_def::RemoveLiquidityIxData { - params: Some(self.params.into_proto()), - } - } - } - use super::SetPoolStatusIxAccounts; - impl IntoProto for SetPoolStatusIxAccounts { - fn into_proto(self) -> proto_def::SetPoolStatusIxAccounts { - proto_def::SetPoolStatusIxAccounts { - pool: self.pool.to_string(), - admin: self.admin.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SetPoolStatusIxData; - impl IntoProto for SetPoolStatusIxData { - fn into_proto(self) -> proto_def::SetPoolStatusIxData { - proto_def::SetPoolStatusIxData { - status: self.status.into(), - } - } - } - use super::SplitPositionIxAccounts; - impl IntoProto for SplitPositionIxAccounts { - fn into_proto(self) -> proto_def::SplitPositionIxAccounts { - proto_def::SplitPositionIxAccounts { - pool: self.pool.to_string(), - first_position: self.first_position.to_string(), - first_position_nft_account: self.first_position_nft_account.to_string(), - second_position: self.second_position.to_string(), - second_position_nft_account: self.second_position_nft_account.to_string(), - first_owner: self.first_owner.to_string(), - second_owner: self.second_owner.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SplitPositionIxData; - impl IntoProto for SplitPositionIxData { - fn into_proto(self) -> proto_def::SplitPositionIxData { - proto_def::SplitPositionIxData { - unlocked_liquidity_percentage: self.unlocked_liquidity_percentage.into(), - permanent_locked_liquidity_percentage: self - .permanent_locked_liquidity_percentage - .into(), - fee_a_percentage: self.fee_a_percentage.into(), - fee_b_percentage: self.fee_b_percentage.into(), - reward0_percentage: self.reward0_percentage.into(), - reward1_percentage: self.reward1_percentage.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::SplitPosition2IxAccounts; - impl IntoProto for SplitPosition2IxAccounts { - fn into_proto(self) -> proto_def::SplitPosition2IxAccounts { - proto_def::SplitPosition2IxAccounts { - pool: self.pool.to_string(), - first_position: self.first_position.to_string(), - first_position_nft_account: self.first_position_nft_account.to_string(), - second_position: self.second_position.to_string(), - second_position_nft_account: self.second_position_nft_account.to_string(), - first_owner: self.first_owner.to_string(), - second_owner: self.second_owner.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SplitPosition2IxData; - impl IntoProto for SplitPosition2IxData { - fn into_proto(self) -> proto_def::SplitPosition2IxData { - proto_def::SplitPosition2IxData { - numerator: self.numerator, - } - } - } - use super::SwapIxAccounts; - impl IntoProto for SwapIxAccounts { - fn into_proto(self) -> proto_def::SwapIxAccounts { - proto_def::SwapIxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - input_token_account: self.input_token_account.to_string(), - output_token_account: self.output_token_account.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - payer: self.payer.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - referral_token_account: self.referral_token_account.map(|p| p.to_string()), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SwapIxData; - impl IntoProto for SwapIxData { - fn into_proto(self) -> proto_def::SwapIxData { - proto_def::SwapIxData { - params: Some(self.params.into_proto()), - } - } - } - use super::Swap2IxAccounts; - impl IntoProto for Swap2IxAccounts { - fn into_proto(self) -> proto_def::Swap2IxAccounts { - proto_def::Swap2IxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - input_token_account: self.input_token_account.to_string(), - output_token_account: self.output_token_account.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - payer: self.payer.to_string(), - token_a_program: self.token_a_program.to_string(), - token_b_program: self.token_b_program.to_string(), - referral_token_account: self.referral_token_account.map(|p| p.to_string()), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::Swap2IxData; - impl IntoProto for Swap2IxData { - fn into_proto(self) -> proto_def::Swap2IxData { - proto_def::Swap2IxData { - params: Some(self.params.into_proto()), - } - } - } - use super::UpdateRewardDurationIxAccounts; - impl IntoProto for UpdateRewardDurationIxAccounts { - fn into_proto(self) -> proto_def::UpdateRewardDurationIxAccounts { - proto_def::UpdateRewardDurationIxAccounts { - pool: self.pool.to_string(), - signer: self.signer.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateRewardDurationIxData; - impl IntoProto for UpdateRewardDurationIxData { - fn into_proto(self) -> proto_def::UpdateRewardDurationIxData { - proto_def::UpdateRewardDurationIxData { - reward_index: self.reward_index.into(), - new_duration: self.new_duration, - } - } - } - use super::UpdateRewardFunderIxAccounts; - impl IntoProto for UpdateRewardFunderIxAccounts { - fn into_proto(self) -> proto_def::UpdateRewardFunderIxAccounts { - proto_def::UpdateRewardFunderIxAccounts { - pool: self.pool.to_string(), - signer: self.signer.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateRewardFunderIxData; - impl IntoProto for UpdateRewardFunderIxData { - fn into_proto(self) -> proto_def::UpdateRewardFunderIxData { - proto_def::UpdateRewardFunderIxData { - reward_index: self.reward_index.into(), - new_funder: self.new_funder.to_string(), - } - } - } - use super::WithdrawIneligibleRewardIxAccounts; - impl IntoProto - for WithdrawIneligibleRewardIxAccounts - { - fn into_proto(self) -> proto_def::WithdrawIneligibleRewardIxAccounts { - proto_def::WithdrawIneligibleRewardIxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_mint: self.reward_mint.to_string(), - funder_token_account: self.funder_token_account.to_string(), - funder: self.funder.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::WithdrawIneligibleRewardIxData; - impl IntoProto for WithdrawIneligibleRewardIxData { - fn into_proto(self) -> proto_def::WithdrawIneligibleRewardIxData { - proto_def::WithdrawIneligibleRewardIxData { - reward_index: self.reward_index.into(), - } - } - } - - impl IntoProto for CpAmmProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - CpAmmProgramIx::AddLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddLiquidity( - proto_def::AddLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::ClaimPartnerFee(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimPartnerFee( - proto_def::ClaimPartnerFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::ClaimPositionFee(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimPositionFee( - proto_def::ClaimPositionFeeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - CpAmmProgramIx::ClaimProtocolFee(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimProtocolFee( - proto_def::ClaimProtocolFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::ClaimReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimReward( - proto_def::ClaimRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::CloseClaimFeeOperator(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CloseClaimFeeOperator( - proto_def::CloseClaimFeeOperatorIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - CpAmmProgramIx::CloseConfig(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CloseConfig( - proto_def::CloseConfigIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - CpAmmProgramIx::ClosePosition(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClosePosition( - proto_def::ClosePositionIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - CpAmmProgramIx::CloseTokenBadge(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CloseTokenBadge( - proto_def::CloseTokenBadgeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - CpAmmProgramIx::CreateClaimFeeOperator(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateClaimFeeOperator( - proto_def::CreateClaimFeeOperatorIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - CpAmmProgramIx::CreateConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateConfig( - proto_def::CreateConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::CreateDynamicConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateDynamicConfig( - proto_def::CreateDynamicConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::CreatePosition(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreatePosition( - proto_def::CreatePositionIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - CpAmmProgramIx::CreateTokenBadge(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateTokenBadge( - proto_def::CreateTokenBadgeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - CpAmmProgramIx::FundReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::FundReward( - proto_def::FundRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::InitializeCustomizablePool(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeCustomizablePool( - proto_def::InitializeCustomizablePoolIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::InitializePool(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePool( - proto_def::InitializePoolIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::InitializePoolWithDynamicConfig(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::InitializePoolWithDynamicConfig( - proto_def::InitializePoolWithDynamicConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - CpAmmProgramIx::InitializeReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeReward( - proto_def::InitializeRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::LockPosition(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::LockPosition( - proto_def::LockPositionIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::PermanentLockPosition(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::PermanentLockPosition( - proto_def::PermanentLockPositionIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::RefreshVesting(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RefreshVesting( - proto_def::RefreshVestingIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - CpAmmProgramIx::RemoveAllLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveAllLiquidity( - proto_def::RemoveAllLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::RemoveLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveLiquidity( - proto_def::RemoveLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::SetPoolStatus(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetPoolStatus( - proto_def::SetPoolStatusIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::SplitPosition(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SplitPosition( - proto_def::SplitPositionIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::SplitPosition2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SplitPosition2( - proto_def::SplitPosition2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::Swap(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Swap(proto_def::SwapIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - CpAmmProgramIx::Swap2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Swap2(proto_def::Swap2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - CpAmmProgramIx::UpdateRewardDuration(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateRewardDuration( - proto_def::UpdateRewardDurationIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::UpdateRewardFunder(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateRewardFunder( - proto_def::UpdateRewardFunderIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - CpAmmProgramIx::WithdrawIneligibleReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::WithdrawIneligibleReward( - proto_def::WithdrawIneligibleRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/meteora-amm-parser/src/generated_parser/mod.rs b/crates/meteora-amm-parser/src/generated_parser/mod.rs deleted file mode 100644 index 974eb276..00000000 --- a/crates/meteora-amm-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -#[allow(unused_variables)] -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?discriminator, - ); - } - - Ok(account) -} diff --git a/crates/meteora-amm-parser/src/generated_parser/proto_helpers.rs b/crates/meteora-amm-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index 96d10678..00000000 --- a/crates/meteora-amm-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,677 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::AddLiquidityParameters}; - impl IntoProto for AddLiquidityParameters { - fn into_proto(self) -> proto_def::AddLiquidityParameters { - proto_def::AddLiquidityParameters { - liquidity_delta: self.liquidity_delta.to_string(), - token_a_amount_threshold: self.token_a_amount_threshold, - token_b_amount_threshold: self.token_b_amount_threshold, - } - } - } - use crate::types::BaseFeeConfig; - impl IntoProto for BaseFeeConfig { - fn into_proto(self) -> proto_def::BaseFeeConfig { - proto_def::BaseFeeConfig { - cliff_fee_numerator: self.cliff_fee_numerator, - base_fee_mode: self.base_fee_mode.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - first_factor: self.first_factor.into(), - second_factor: self.second_factor.into_iter().map(|x| x.into()).collect(), - third_factor: self.third_factor, - } - } - } - use crate::types::BaseFeeParameters; - impl IntoProto for BaseFeeParameters { - fn into_proto(self) -> proto_def::BaseFeeParameters { - proto_def::BaseFeeParameters { - cliff_fee_numerator: self.cliff_fee_numerator, - first_factor: self.first_factor.into(), - second_factor: self.second_factor.into_iter().map(|x| x.into()).collect(), - third_factor: self.third_factor, - base_fee_mode: self.base_fee_mode.into(), - } - } - } - use crate::types::BaseFeeStruct; - impl IntoProto for BaseFeeStruct { - fn into_proto(self) -> proto_def::BaseFeeStruct { - proto_def::BaseFeeStruct { - cliff_fee_numerator: self.cliff_fee_numerator, - base_fee_mode: self.base_fee_mode.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - first_factor: self.first_factor.into(), - second_factor: self.second_factor.into_iter().map(|x| x.into()).collect(), - third_factor: self.third_factor, - padding1: self.padding1, - } - } - } - use crate::types::DynamicFeeConfig; - impl IntoProto for DynamicFeeConfig { - fn into_proto(self) -> proto_def::DynamicFeeConfig { - proto_def::DynamicFeeConfig { - initialized: self.initialized.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - max_volatility_accumulator: self.max_volatility_accumulator, - variable_fee_control: self.variable_fee_control, - bin_step: self.bin_step.into(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - padding1: self.padding1.into_iter().map(|x| x.into()).collect(), - bin_step_u128: self.bin_step_u128.to_string(), - } - } - } - use crate::types::DynamicFeeParameters; - impl IntoProto for DynamicFeeParameters { - fn into_proto(self) -> proto_def::DynamicFeeParameters { - proto_def::DynamicFeeParameters { - bin_step: self.bin_step.into(), - bin_step_u128: self.bin_step_u128.to_string(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - max_volatility_accumulator: self.max_volatility_accumulator, - variable_fee_control: self.variable_fee_control, - } - } - } - use crate::types::DynamicFeeStruct; - impl IntoProto for DynamicFeeStruct { - fn into_proto(self) -> proto_def::DynamicFeeStruct { - proto_def::DynamicFeeStruct { - initialized: self.initialized.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - max_volatility_accumulator: self.max_volatility_accumulator, - variable_fee_control: self.variable_fee_control, - bin_step: self.bin_step.into(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - last_update_timestamp: self.last_update_timestamp, - bin_step_u128: self.bin_step_u128.to_string(), - sqrt_price_reference: self.sqrt_price_reference.to_string(), - volatility_accumulator: self.volatility_accumulator.to_string(), - volatility_reference: self.volatility_reference.to_string(), - } - } - } - use crate::types::EvtAddLiquidity; - impl IntoProto for EvtAddLiquidity { - fn into_proto(self) -> proto_def::EvtAddLiquidity { - proto_def::EvtAddLiquidity { - pool: self.pool.to_string(), - position: self.position.to_string(), - owner: self.owner.to_string(), - params: Some(self.params.into_proto()), - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - total_amount_a: self.total_amount_a, - total_amount_b: self.total_amount_b, - } - } - } - use crate::types::EvtClaimPartnerFee; - impl IntoProto for EvtClaimPartnerFee { - fn into_proto(self) -> proto_def::EvtClaimPartnerFee { - proto_def::EvtClaimPartnerFee { - pool: self.pool.to_string(), - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - } - } - } - use crate::types::EvtClaimPositionFee; - impl IntoProto for EvtClaimPositionFee { - fn into_proto(self) -> proto_def::EvtClaimPositionFee { - proto_def::EvtClaimPositionFee { - pool: self.pool.to_string(), - position: self.position.to_string(), - owner: self.owner.to_string(), - fee_a_claimed: self.fee_a_claimed, - fee_b_claimed: self.fee_b_claimed, - } - } - } - use crate::types::EvtClaimProtocolFee; - impl IntoProto for EvtClaimProtocolFee { - fn into_proto(self) -> proto_def::EvtClaimProtocolFee { - proto_def::EvtClaimProtocolFee { - pool: self.pool.to_string(), - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - } - } - } - use crate::types::EvtClaimReward; - impl IntoProto for EvtClaimReward { - fn into_proto(self) -> proto_def::EvtClaimReward { - proto_def::EvtClaimReward { - pool: self.pool.to_string(), - position: self.position.to_string(), - owner: self.owner.to_string(), - mint_reward: self.mint_reward.to_string(), - reward_index: self.reward_index.into(), - total_reward: self.total_reward, - } - } - } - use crate::types::EvtCloseClaimFeeOperator; - impl IntoProto for EvtCloseClaimFeeOperator { - fn into_proto(self) -> proto_def::EvtCloseClaimFeeOperator { - proto_def::EvtCloseClaimFeeOperator { - claim_fee_operator: self.claim_fee_operator.to_string(), - operator: self.operator.to_string(), - } - } - } - use crate::types::EvtCloseConfig; - impl IntoProto for EvtCloseConfig { - fn into_proto(self) -> proto_def::EvtCloseConfig { - proto_def::EvtCloseConfig { - config: self.config.to_string(), - admin: self.admin.to_string(), - } - } - } - use crate::types::EvtClosePosition; - impl IntoProto for EvtClosePosition { - fn into_proto(self) -> proto_def::EvtClosePosition { - proto_def::EvtClosePosition { - pool: self.pool.to_string(), - owner: self.owner.to_string(), - position: self.position.to_string(), - position_nft_mint: self.position_nft_mint.to_string(), - } - } - } - use crate::types::EvtCreateClaimFeeOperator; - impl IntoProto for EvtCreateClaimFeeOperator { - fn into_proto(self) -> proto_def::EvtCreateClaimFeeOperator { - proto_def::EvtCreateClaimFeeOperator { - operator: self.operator.to_string(), - } - } - } - use crate::types::EvtCreateConfig; - impl IntoProto for EvtCreateConfig { - fn into_proto(self) -> proto_def::EvtCreateConfig { - proto_def::EvtCreateConfig { - pool_fees: Some(self.pool_fees.into_proto()), - vault_config_key: self.vault_config_key.to_string(), - pool_creator_authority: self.pool_creator_authority.to_string(), - activation_type: self.activation_type.into(), - sqrt_min_price: self.sqrt_min_price.to_string(), - sqrt_max_price: self.sqrt_max_price.to_string(), - collect_fee_mode: self.collect_fee_mode.into(), - index: self.index, - config: self.config.to_string(), - } - } - } - use crate::types::EvtCreateDynamicConfig; - impl IntoProto for EvtCreateDynamicConfig { - fn into_proto(self) -> proto_def::EvtCreateDynamicConfig { - proto_def::EvtCreateDynamicConfig { - config: self.config.to_string(), - pool_creator_authority: self.pool_creator_authority.to_string(), - index: self.index, - } - } - } - use crate::types::EvtCreatePosition; - impl IntoProto for EvtCreatePosition { - fn into_proto(self) -> proto_def::EvtCreatePosition { - proto_def::EvtCreatePosition { - pool: self.pool.to_string(), - owner: self.owner.to_string(), - position: self.position.to_string(), - position_nft_mint: self.position_nft_mint.to_string(), - } - } - } - use crate::types::EvtCreateTokenBadge; - impl IntoProto for EvtCreateTokenBadge { - fn into_proto(self) -> proto_def::EvtCreateTokenBadge { - proto_def::EvtCreateTokenBadge { - token_mint: self.token_mint.to_string(), - } - } - } - use crate::types::EvtFundReward; - impl IntoProto for EvtFundReward { - fn into_proto(self) -> proto_def::EvtFundReward { - proto_def::EvtFundReward { - pool: self.pool.to_string(), - funder: self.funder.to_string(), - mint_reward: self.mint_reward.to_string(), - reward_index: self.reward_index.into(), - amount: self.amount, - transfer_fee_excluded_amount_in: self.transfer_fee_excluded_amount_in, - reward_duration_end: self.reward_duration_end, - pre_reward_rate: self.pre_reward_rate.to_string(), - post_reward_rate: self.post_reward_rate.to_string(), - } - } - } - use crate::types::EvtInitializePool; - impl IntoProto for EvtInitializePool { - fn into_proto(self) -> proto_def::EvtInitializePool { - proto_def::EvtInitializePool { - pool: self.pool.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - creator: self.creator.to_string(), - payer: self.payer.to_string(), - alpha_vault: self.alpha_vault.to_string(), - pool_fees: Some(self.pool_fees.into_proto()), - sqrt_min_price: self.sqrt_min_price.to_string(), - sqrt_max_price: self.sqrt_max_price.to_string(), - activation_type: self.activation_type.into(), - collect_fee_mode: self.collect_fee_mode.into(), - liquidity: self.liquidity.to_string(), - sqrt_price: self.sqrt_price.to_string(), - activation_point: self.activation_point, - token_a_flag: self.token_a_flag.into(), - token_b_flag: self.token_b_flag.into(), - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - total_amount_a: self.total_amount_a, - total_amount_b: self.total_amount_b, - pool_type: self.pool_type.into(), - } - } - } - use crate::types::EvtInitializeReward; - impl IntoProto for EvtInitializeReward { - fn into_proto(self) -> proto_def::EvtInitializeReward { - proto_def::EvtInitializeReward { - pool: self.pool.to_string(), - reward_mint: self.reward_mint.to_string(), - funder: self.funder.to_string(), - creator: self.creator.to_string(), - reward_index: self.reward_index.into(), - reward_duration: self.reward_duration, - } - } - } - use crate::types::EvtLiquidityChange; - impl IntoProto for EvtLiquidityChange { - fn into_proto(self) -> proto_def::EvtLiquidityChange { - proto_def::EvtLiquidityChange { - pool: self.pool.to_string(), - position: self.position.to_string(), - owner: self.owner.to_string(), - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - transfer_fee_included_token_a_amount: self.transfer_fee_included_token_a_amount, - transfer_fee_included_token_b_amount: self.transfer_fee_included_token_b_amount, - reserve_a_amount: self.reserve_a_amount, - reserve_b_amount: self.reserve_b_amount, - liquidity_delta: self.liquidity_delta.to_string(), - token_a_amount_threshold: self.token_a_amount_threshold, - token_b_amount_threshold: self.token_b_amount_threshold, - change_type: self.change_type.into(), - } - } - } - use crate::types::EvtLockPosition; - impl IntoProto for EvtLockPosition { - fn into_proto(self) -> proto_def::EvtLockPosition { - proto_def::EvtLockPosition { - pool: self.pool.to_string(), - position: self.position.to_string(), - owner: self.owner.to_string(), - vesting: self.vesting.to_string(), - cliff_point: self.cliff_point, - period_frequency: self.period_frequency, - cliff_unlock_liquidity: self.cliff_unlock_liquidity.to_string(), - liquidity_per_period: self.liquidity_per_period.to_string(), - number_of_period: self.number_of_period.into(), - } - } - } - use crate::types::EvtPermanentLockPosition; - impl IntoProto for EvtPermanentLockPosition { - fn into_proto(self) -> proto_def::EvtPermanentLockPosition { - proto_def::EvtPermanentLockPosition { - pool: self.pool.to_string(), - position: self.position.to_string(), - lock_liquidity_amount: self.lock_liquidity_amount.to_string(), - total_permanent_locked_liquidity: self.total_permanent_locked_liquidity.to_string(), - } - } - } - use crate::types::EvtRemoveLiquidity; - impl IntoProto for EvtRemoveLiquidity { - fn into_proto(self) -> proto_def::EvtRemoveLiquidity { - proto_def::EvtRemoveLiquidity { - pool: self.pool.to_string(), - position: self.position.to_string(), - owner: self.owner.to_string(), - params: Some(self.params.into_proto()), - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - } - } - } - use crate::types::EvtSetPoolStatus; - impl IntoProto for EvtSetPoolStatus { - fn into_proto(self) -> proto_def::EvtSetPoolStatus { - proto_def::EvtSetPoolStatus { - pool: self.pool.to_string(), - status: self.status.into(), - } - } - } - use crate::types::EvtSplitPosition2; - impl IntoProto for EvtSplitPosition2 { - fn into_proto(self) -> proto_def::EvtSplitPosition2 { - proto_def::EvtSplitPosition2 { - pool: self.pool.to_string(), - first_owner: self.first_owner.to_string(), - second_owner: self.second_owner.to_string(), - first_position: self.first_position.to_string(), - second_position: self.second_position.to_string(), - current_sqrt_price: self.current_sqrt_price.to_string(), - amount_splits: Some(self.amount_splits.into_proto()), - first_position_info: Some(self.first_position_info.into_proto()), - second_position_info: Some(self.second_position_info.into_proto()), - split_position_parameters: Some(self.split_position_parameters.into_proto()), - } - } - } - use crate::types::EvtSwap; - impl IntoProto for EvtSwap { - fn into_proto(self) -> proto_def::EvtSwap { - proto_def::EvtSwap { - pool: self.pool.to_string(), - trade_direction: self.trade_direction.into(), - has_referral: self.has_referral, - params: Some(self.params.into_proto()), - swap_result: Some(self.swap_result.into_proto()), - actual_amount_in: self.actual_amount_in, - current_timestamp: self.current_timestamp, - } - } - } - use crate::types::EvtSwap2; - impl IntoProto for EvtSwap2 { - fn into_proto(self) -> proto_def::EvtSwap2 { - proto_def::EvtSwap2 { - pool: self.pool.to_string(), - trade_direction: self.trade_direction.into(), - collect_fee_mode: self.collect_fee_mode.into(), - has_referral: self.has_referral, - params: Some(self.params.into_proto()), - swap_result: Some(self.swap_result.into_proto()), - included_transfer_fee_amount_in: self.included_transfer_fee_amount_in, - included_transfer_fee_amount_out: self.included_transfer_fee_amount_out, - excluded_transfer_fee_amount_out: self.excluded_transfer_fee_amount_out, - current_timestamp: self.current_timestamp, - reserve_a_amount: self.reserve_a_amount, - reserve_b_amount: self.reserve_b_amount, - } - } - } - use crate::types::EvtUpdateRewardDuration; - impl IntoProto for EvtUpdateRewardDuration { - fn into_proto(self) -> proto_def::EvtUpdateRewardDuration { - proto_def::EvtUpdateRewardDuration { - pool: self.pool.to_string(), - reward_index: self.reward_index.into(), - old_reward_duration: self.old_reward_duration, - new_reward_duration: self.new_reward_duration, - } - } - } - use crate::types::EvtUpdateRewardFunder; - impl IntoProto for EvtUpdateRewardFunder { - fn into_proto(self) -> proto_def::EvtUpdateRewardFunder { - proto_def::EvtUpdateRewardFunder { - pool: self.pool.to_string(), - reward_index: self.reward_index.into(), - old_funder: self.old_funder.to_string(), - new_funder: self.new_funder.to_string(), - } - } - } - use crate::types::EvtWithdrawIneligibleReward; - impl IntoProto for EvtWithdrawIneligibleReward { - fn into_proto(self) -> proto_def::EvtWithdrawIneligibleReward { - proto_def::EvtWithdrawIneligibleReward { - pool: self.pool.to_string(), - reward_mint: self.reward_mint.to_string(), - amount: self.amount, - } - } - } - use crate::types::InitializeCustomizablePoolParameters; - impl IntoProto - for InitializeCustomizablePoolParameters - { - fn into_proto(self) -> proto_def::InitializeCustomizablePoolParameters { - proto_def::InitializeCustomizablePoolParameters { - pool_fees: Some(self.pool_fees.into_proto()), - sqrt_min_price: self.sqrt_min_price.to_string(), - sqrt_max_price: self.sqrt_max_price.to_string(), - has_alpha_vault: self.has_alpha_vault, - liquidity: self.liquidity.to_string(), - sqrt_price: self.sqrt_price.to_string(), - activation_type: self.activation_type.into(), - collect_fee_mode: self.collect_fee_mode.into(), - activation_point: self.activation_point, - } - } - } - use crate::types::PoolFeeParameters; - impl IntoProto for PoolFeeParameters { - fn into_proto(self) -> proto_def::PoolFeeParameters { - proto_def::PoolFeeParameters { - base_fee: Some(self.base_fee.into_proto()), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - dynamic_fee: self.dynamic_fee.map(|x| x.into_proto()), - } - } - } - use crate::types::PoolFeesConfig; - impl IntoProto for PoolFeesConfig { - fn into_proto(self) -> proto_def::PoolFeesConfig { - proto_def::PoolFeesConfig { - base_fee: Some(self.base_fee.into_proto()), - dynamic_fee: Some(self.dynamic_fee.into_proto()), - protocol_fee_percent: self.protocol_fee_percent.into(), - partner_fee_percent: self.partner_fee_percent.into(), - referral_fee_percent: self.referral_fee_percent.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - padding1: self.padding1.to_vec(), - } - } - } - use crate::types::PoolFeesStruct; - impl IntoProto for PoolFeesStruct { - fn into_proto(self) -> proto_def::PoolFeesStruct { - proto_def::PoolFeesStruct { - base_fee: Some(self.base_fee.into_proto()), - protocol_fee_percent: self.protocol_fee_percent.into(), - partner_fee_percent: self.partner_fee_percent.into(), - referral_fee_percent: self.referral_fee_percent.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - dynamic_fee: Some(self.dynamic_fee.into_proto()), - padding1: self.padding1.to_vec(), - } - } - } - use crate::types::PoolMetrics; - impl IntoProto for PoolMetrics { - fn into_proto(self) -> proto_def::PoolMetrics { - proto_def::PoolMetrics { - total_lp_a_fee: self.total_lp_a_fee.to_string(), - total_lp_b_fee: self.total_lp_b_fee.to_string(), - total_protocol_a_fee: self.total_protocol_a_fee, - total_protocol_b_fee: self.total_protocol_b_fee, - total_partner_a_fee: self.total_partner_a_fee, - total_partner_b_fee: self.total_partner_b_fee, - total_position: self.total_position, - padding: self.padding, - } - } - } - use crate::types::PositionMetrics; - impl IntoProto for PositionMetrics { - fn into_proto(self) -> proto_def::PositionMetrics { - proto_def::PositionMetrics { - total_claimed_a_fee: self.total_claimed_a_fee, - total_claimed_b_fee: self.total_claimed_b_fee, - } - } - } - use crate::types::RemoveLiquidityParameters; - impl IntoProto for RemoveLiquidityParameters { - fn into_proto(self) -> proto_def::RemoveLiquidityParameters { - proto_def::RemoveLiquidityParameters { - liquidity_delta: self.liquidity_delta.to_string(), - token_a_amount_threshold: self.token_a_amount_threshold, - token_b_amount_threshold: self.token_b_amount_threshold, - } - } - } - use crate::types::RewardInfo; - impl IntoProto for RewardInfo { - fn into_proto(self) -> proto_def::RewardInfo { - proto_def::RewardInfo { - initialized: self.initialized.into(), - reward_token_flag: self.reward_token_flag.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - padding1: self.padding1.into_iter().map(|x| x.into()).collect(), - mint: self.mint.to_string(), - vault: self.vault.to_string(), - funder: self.funder.to_string(), - reward_duration: self.reward_duration, - reward_duration_end: self.reward_duration_end, - reward_rate: self.reward_rate.to_string(), - reward_per_token_stored: self - .reward_per_token_stored - .into_iter() - .map(|x| x.into()) - .collect(), - last_update_time: self.last_update_time, - cumulative_seconds_with_empty_liquidity_reward: self - .cumulative_seconds_with_empty_liquidity_reward, - } - } - } - use crate::types::SplitAmountInfo; - impl IntoProto for SplitAmountInfo { - fn into_proto(self) -> proto_def::SplitAmountInfo { - proto_def::SplitAmountInfo { - permanent_locked_liquidity: self.permanent_locked_liquidity.to_string(), - unlocked_liquidity: self.unlocked_liquidity.to_string(), - fee_a: self.fee_a, - fee_b: self.fee_b, - reward0: self.reward0, - reward1: self.reward1, - } - } - } - use crate::types::SplitPositionInfo; - impl IntoProto for SplitPositionInfo { - fn into_proto(self) -> proto_def::SplitPositionInfo { - proto_def::SplitPositionInfo { - liquidity: self.liquidity.to_string(), - fee_a: self.fee_a, - fee_b: self.fee_b, - reward0: self.reward0, - reward1: self.reward1, - } - } - } - use crate::types::SplitPositionParameters2; - impl IntoProto for SplitPositionParameters2 { - fn into_proto(self) -> proto_def::SplitPositionParameters2 { - proto_def::SplitPositionParameters2 { - unlocked_liquidity_numerator: self.unlocked_liquidity_numerator, - permanent_locked_liquidity_numerator: self.permanent_locked_liquidity_numerator, - fee_a_numerator: self.fee_a_numerator, - fee_b_numerator: self.fee_b_numerator, - reward0_numerator: self.reward0_numerator, - reward1_numerator: self.reward1_numerator, - } - } - } - use crate::types::SwapParameters; - impl IntoProto for SwapParameters { - fn into_proto(self) -> proto_def::SwapParameters { - proto_def::SwapParameters { - amount_in: self.amount_in, - minimum_amount_out: self.minimum_amount_out, - } - } - } - use crate::types::SwapParameters2; - impl IntoProto for SwapParameters2 { - fn into_proto(self) -> proto_def::SwapParameters2 { - proto_def::SwapParameters2 { - amount0: self.amount0, - amount1: self.amount1, - swap_mode: self.swap_mode.into(), - } - } - } - use crate::types::SwapResult; - impl IntoProto for SwapResult { - fn into_proto(self) -> proto_def::SwapResult { - proto_def::SwapResult { - output_amount: self.output_amount, - next_sqrt_price: self.next_sqrt_price.to_string(), - lp_fee: self.lp_fee, - protocol_fee: self.protocol_fee, - partner_fee: self.partner_fee, - referral_fee: self.referral_fee, - } - } - } - use crate::types::SwapResult2; - impl IntoProto for SwapResult2 { - fn into_proto(self) -> proto_def::SwapResult2 { - proto_def::SwapResult2 { - included_fee_input_amount: self.included_fee_input_amount, - excluded_fee_input_amount: self.excluded_fee_input_amount, - amount_left: self.amount_left, - output_amount: self.output_amount, - next_sqrt_price: self.next_sqrt_price.to_string(), - trading_fee: self.trading_fee, - protocol_fee: self.protocol_fee, - partner_fee: self.partner_fee, - referral_fee: self.referral_fee, - } - } - } - use crate::types::UserRewardInfo; - impl IntoProto for UserRewardInfo { - fn into_proto(self) -> proto_def::UserRewardInfo { - proto_def::UserRewardInfo { - reward_per_token_checkpoint: self - .reward_per_token_checkpoint - .into_iter() - .map(|x| x.into()) - .collect(), - reward_pendings: self.reward_pendings, - total_claimed_rewards: self.total_claimed_rewards, - } - } - } -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/accounts/claim_fee_operator.rs b/crates/meteora-amm-parser/src/generated_sdk/accounts/claim_fee_operator.rs deleted file mode 100644 index 71de0c51..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/accounts/claim_fee_operator.rs +++ /dev/null @@ -1,138 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimFeeOperator { - pub discriminator: [u8; 8], - /// operator - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub operator: Pubkey, - /// Reserve - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 128], -} - -pub const CLAIM_FEE_OPERATOR_DISCRIMINATOR: [u8; 8] = [166, 48, 134, 86, 34, 200, 188, 150]; - -impl ClaimFeeOperator { - pub const LEN: usize = 168; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for ClaimFeeOperator { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_claim_fee_operator(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = ClaimFeeOperator::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_claim_fee_operator(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = ClaimFeeOperator::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for ClaimFeeOperator { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for ClaimFeeOperator {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for ClaimFeeOperator { - fn owner() -> Pubkey { crate::CP_AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for ClaimFeeOperator {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for ClaimFeeOperator { - const DISCRIMINATOR: &[u8] = &[0; 8]; -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/accounts/config.rs b/crates/meteora-amm-parser/src/generated_sdk/accounts/config.rs deleted file mode 100644 index 72451f3f..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/accounts/config.rs +++ /dev/null @@ -1,162 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::PoolFeesConfig; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Config { - pub discriminator: [u8; 8], - /// Vault config key - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vault_config_key: Pubkey, - /// Only pool_creator_authority can use the current config to initialize new pool. When it's Pubkey::default, it's a public config. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_creator_authority: Pubkey, - /// Pool fee - pub pool_fees: PoolFeesConfig, - /// Activation type - pub activation_type: u8, - /// Collect fee mode - pub collect_fee_mode: u8, - /// Config type mode, 0 for static, 1 for dynamic - pub config_type: u8, - /// padding 0 - pub padding0: [u8; 5], - /// config index - pub index: u64, - /// sqrt min price - pub sqrt_min_price: u128, - /// sqrt max price - pub sqrt_max_price: u128, - /// Fee curve point - /// Padding for further use - pub padding1: [u64; 10], -} - -pub const CONFIG_DISCRIMINATOR: [u8; 8] = [155, 12, 170, 224, 30, 250, 204, 130]; - -impl Config { - pub const LEN: usize = 328; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Config { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Config::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Config::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Config { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Config {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Config { - fn owner() -> Pubkey { crate::CP_AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Config {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Config { - const DISCRIMINATOR: &[u8] = &[0; 8]; -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/accounts/mod.rs b/crates/meteora-amm-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index e2e22f34..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#claim_fee_operator; -pub(crate) mod r#config; -pub(crate) mod r#pool; -pub(crate) mod r#position; -pub(crate) mod r#token_badge; -pub(crate) mod r#vesting; - -pub use self::{ - r#claim_fee_operator::*, r#config::*, r#pool::*, r#position::*, r#token_badge::*, r#vesting::*, -}; diff --git a/crates/meteora-amm-parser/src/generated_sdk/accounts/pool.rs b/crates/meteora-amm-parser/src/generated_sdk/accounts/pool.rs deleted file mode 100644 index 4d405514..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/accounts/pool.rs +++ /dev/null @@ -1,222 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{PoolFeesStruct, PoolMetrics, RewardInfo}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Pool { - pub discriminator: [u8; 8], - /// Pool fee - pub pool_fees: PoolFeesStruct, - /// token a mint - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_a_mint: Pubkey, - /// token b mint - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_b_mint: Pubkey, - /// token a vault - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_a_vault: Pubkey, - /// token b vault - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_b_vault: Pubkey, - /// Whitelisted vault to be able to buy pool before activation_point - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whitelisted_vault: Pubkey, - /// partner - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub partner: Pubkey, - /// liquidity share - pub liquidity: u128, - /// padding, previous reserve amount, be careful to use that field - pub padding: u128, - /// protocol a fee - pub protocol_a_fee: u64, - /// protocol b fee - pub protocol_b_fee: u64, - /// partner a fee - pub partner_a_fee: u64, - /// partner b fee - pub partner_b_fee: u64, - /// min price - pub sqrt_min_price: u128, - /// max price - pub sqrt_max_price: u128, - /// current price - pub sqrt_price: u128, - /// Activation point, can be slot or timestamp - pub activation_point: u64, - /// Activation type, 0 means by slot, 1 means by timestamp - pub activation_type: u8, - /// pool status, 0: enable, 1 disable - pub pool_status: u8, - /// token a flag - pub token_a_flag: u8, - /// token b flag - pub token_b_flag: u8, - /// 0 is collect fee in both token, 1 only collect fee in token a, 2 only collect fee in token b - pub collect_fee_mode: u8, - /// pool type - pub pool_type: u8, - /// pool version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99% - pub version: u8, - /// padding - pub padding0: u8, - /// cumulative - pub fee_a_per_liquidity: [u8; 32], - /// cumulative - pub fee_b_per_liquidity: [u8; 32], - pub permanent_lock_liquidity: u128, - /// metrics - pub metrics: PoolMetrics, - /// pool creator - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - /// Padding for further use - pub padding1: [u64; 6], - /// Farming reward information - pub reward_infos: [RewardInfo; 2], -} - -pub const POOL_DISCRIMINATOR: [u8; 8] = [241, 154, 109, 4, 17, 177, 109, 188]; - -impl Pool { - pub const LEN: usize = 1112; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Pool { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_pool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_pool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_pool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Pool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_pool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_pool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_pool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Pool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Pool { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Pool {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Pool { - fn owner() -> Pubkey { crate::CP_AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Pool {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Pool { - const DISCRIMINATOR: &[u8] = &[0; 8]; -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/accounts/position.rs b/crates/meteora-amm-parser/src/generated_sdk/accounts/position.rs deleted file mode 100644 index dee8a04a..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/accounts/position.rs +++ /dev/null @@ -1,162 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{PositionMetrics, UserRewardInfo}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Position { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - /// nft mint - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub nft_mint: Pubkey, - /// fee a checkpoint - pub fee_a_per_token_checkpoint: [u8; 32], - /// fee b checkpoint - pub fee_b_per_token_checkpoint: [u8; 32], - /// fee a pending - pub fee_a_pending: u64, - /// fee b pending - pub fee_b_pending: u64, - /// unlock liquidity - pub unlocked_liquidity: u128, - /// vesting liquidity - pub vested_liquidity: u128, - /// permanent locked liquidity - pub permanent_locked_liquidity: u128, - /// metrics - pub metrics: PositionMetrics, - /// Farming reward information - pub reward_infos: [UserRewardInfo; 2], - /// padding for future usage - pub padding: [u128; 6], -} - -pub const POSITION_DISCRIMINATOR: [u8; 8] = [170, 188, 143, 228, 122, 64, 247, 208]; - -impl Position { - pub const LEN: usize = 408; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Position { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_position( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_position(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_position( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Position::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_position( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_position(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_position( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Position::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Position { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Position {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Position { - fn owner() -> Pubkey { crate::CP_AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Position {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Position { - const DISCRIMINATOR: &[u8] = &[0; 8]; -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/accounts/token_badge.rs b/crates/meteora-amm-parser/src/generated_sdk/accounts/token_badge.rs deleted file mode 100644 index 2ab78425..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/accounts/token_badge.rs +++ /dev/null @@ -1,138 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenBadge { - pub discriminator: [u8; 8], - /// token mint - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_mint: Pubkey, - /// Reserve - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 128], -} - -pub const TOKEN_BADGE_DISCRIMINATOR: [u8; 8] = [116, 219, 204, 229, 249, 116, 255, 150]; - -impl TokenBadge { - pub const LEN: usize = 168; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for TokenBadge { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_token_badge(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = TokenBadge::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_token_badge(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = TokenBadge::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for TokenBadge { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for TokenBadge {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for TokenBadge { - fn owner() -> Pubkey { crate::CP_AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for TokenBadge {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for TokenBadge { - const DISCRIMINATOR: &[u8] = &[0; 8]; -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/accounts/vesting.rs b/crates/meteora-amm-parser/src/generated_sdk/accounts/vesting.rs deleted file mode 100644 index 950f8467..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/accounts/vesting.rs +++ /dev/null @@ -1,142 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Vesting { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - pub cliff_point: u64, - pub period_frequency: u64, - pub cliff_unlock_liquidity: u128, - pub liquidity_per_period: u128, - pub total_released_liquidity: u128, - pub number_of_period: u16, - pub padding: [u8; 14], - pub padding2: [u128; 4], -} - -pub const VESTING_DISCRIMINATOR: [u8; 8] = [100, 149, 66, 138, 95, 200, 128, 241]; - -impl Vesting { - pub const LEN: usize = 184; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Vesting { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_vesting( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_vesting(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_vesting( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Vesting::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_vesting( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_vesting(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_vesting( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Vesting::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Vesting { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Vesting {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Vesting { - fn owner() -> Pubkey { crate::CP_AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Vesting {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Vesting { - const DISCRIMINATOR: &[u8] = &[0; 8]; -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/errors/cp_amm.rs b/crates/meteora-amm-parser/src/generated_sdk/errors/cp_amm.rs deleted file mode 100644 index 12480dec..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/errors/cp_amm.rs +++ /dev/null @@ -1,176 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum CpAmmError { - /// 6000 - Math operation overflow - #[error("Math operation overflow")] - MathOverflow = 0x1770, - /// 6001 - Invalid fee setup - #[error("Invalid fee setup")] - InvalidFee = 0x1771, - /// 6002 - Exceeded slippage tolerance - #[error("Exceeded slippage tolerance")] - ExceededSlippage = 0x1772, - /// 6003 - Pool disabled - #[error("Pool disabled")] - PoolDisabled = 0x1773, - /// 6004 - Exceeded max fee bps - #[error("Exceeded max fee bps")] - ExceedMaxFeeBps = 0x1774, - /// 6005 - Invalid admin - #[error("Invalid admin")] - InvalidAdmin = 0x1775, - /// 6006 - Amount is zero - #[error("Amount is zero")] - AmountIsZero = 0x1776, - /// 6007 - Type cast error - #[error("Type cast error")] - TypeCastFailed = 0x1777, - /// 6008 - Unable to modify activation point - #[error("Unable to modify activation point")] - UnableToModifyActivationPoint = 0x1778, - /// 6009 - Invalid authority to create the pool - #[error("Invalid authority to create the pool")] - InvalidAuthorityToCreateThePool = 0x1779, - /// 6010 - Invalid activation type - #[error("Invalid activation type")] - InvalidActivationType = 0x177a, - /// 6011 - Invalid activation point - #[error("Invalid activation point")] - InvalidActivationPoint = 0x177b, - /// 6012 - Quote token must be SOL,USDC - #[error("Quote token must be SOL,USDC")] - InvalidQuoteMint = 0x177c, - /// 6013 - Invalid fee curve - #[error("Invalid fee curve")] - InvalidFeeCurve = 0x177d, - /// 6014 - Invalid Price Range - #[error("Invalid Price Range")] - InvalidPriceRange = 0x177e, - /// 6015 - Trade is over price range - #[error("Trade is over price range")] - PriceRangeViolation = 0x177f, - /// 6016 - Invalid parameters - #[error("Invalid parameters")] - InvalidParameters = 0x1780, - /// 6017 - Invalid collect fee mode - #[error("Invalid collect fee mode")] - InvalidCollectFeeMode = 0x1781, - /// 6018 - Invalid input - #[error("Invalid input")] - InvalidInput = 0x1782, - /// 6019 - Cannot create token badge on supported mint - #[error("Cannot create token badge on supported mint")] - CannotCreateTokenBadgeOnSupportedMint = 0x1783, - /// 6020 - Invalid token badge - #[error("Invalid token badge")] - InvalidTokenBadge = 0x1784, - /// 6021 - Invalid minimum liquidity - #[error("Invalid minimum liquidity")] - InvalidMinimumLiquidity = 0x1785, - /// 6022 - Invalid vesting information - #[error("Invalid vesting information")] - InvalidVestingInfo = 0x1786, - /// 6023 - Insufficient liquidity - #[error("Insufficient liquidity")] - InsufficientLiquidity = 0x1787, - /// 6024 - Invalid vesting account - #[error("Invalid vesting account")] - InvalidVestingAccount = 0x1788, - /// 6025 - Invalid pool status - #[error("Invalid pool status")] - InvalidPoolStatus = 0x1789, - /// 6026 - Unsupported native mint token2022 - #[error("Unsupported native mint token2022")] - UnsupportNativeMintToken2022 = 0x178a, - /// 6027 - Invalid reward index - #[error("Invalid reward index")] - InvalidRewardIndex = 0x178b, - /// 6028 - Invalid reward duration - #[error("Invalid reward duration")] - InvalidRewardDuration = 0x178c, - /// 6029 - Reward already initialized - #[error("Reward already initialized")] - RewardInitialized = 0x178d, - /// 6030 - Reward not initialized - #[error("Reward not initialized")] - RewardUninitialized = 0x178e, - /// 6031 - Invalid reward vault - #[error("Invalid reward vault")] - InvalidRewardVault = 0x178f, - /// 6032 - Must withdraw ineligible reward - #[error("Must withdraw ineligible reward")] - MustWithdrawnIneligibleReward = 0x1790, - /// 6033 - Reward duration is the same - #[error("Reward duration is the same")] - IdenticalRewardDuration = 0x1791, - /// 6034 - Reward campaign in progress - #[error("Reward campaign in progress")] - RewardCampaignInProgress = 0x1792, - /// 6035 - Identical funder - #[error("Identical funder")] - IdenticalFunder = 0x1793, - /// 6036 - Invalid funder - #[error("Invalid funder")] - InvalidFunder = 0x1794, - /// 6037 - Reward not ended - #[error("Reward not ended")] - RewardNotEnded = 0x1795, - /// 6038 - Fee inverse is incorrect - #[error("Fee inverse is incorrect")] - FeeInverseIsIncorrect = 0x1796, - /// 6039 - Position is not empty - #[error("Position is not empty")] - PositionIsNotEmpty = 0x1797, - /// 6040 - Invalid pool creator authority - #[error("Invalid pool creator authority")] - InvalidPoolCreatorAuthority = 0x1798, - /// 6041 - Invalid config type - #[error("Invalid config type")] - InvalidConfigType = 0x1799, - /// 6042 - Invalid pool creator - #[error("Invalid pool creator")] - InvalidPoolCreator = 0x179a, - /// 6043 - Reward vault is frozen, must skip reward to proceed - #[error("Reward vault is frozen, must skip reward to proceed")] - RewardVaultFrozenSkipRequired = 0x179b, - /// 6044 - Invalid parameters for split position - #[error("Invalid parameters for split position")] - InvalidSplitPositionParameters = 0x179c, - /// 6045 - Unsupported split position has vesting lock - #[error("Unsupported split position has vesting lock")] - UnsupportPositionHasVestingLock = 0x179d, - /// 6046 - Same position - #[error("Same position")] - SamePosition = 0x179e, - /// 6047 - Invalid base fee mode - #[error("Invalid base fee mode")] - InvalidBaseFeeMode = 0x179f, - /// 6048 - Invalid fee rate limiter - #[error("Invalid fee rate limiter")] - InvalidFeeRateLimiter = 0x17a0, - /// 6049 - Fail to validate single swap instruction in rate limiter - #[error("Fail to validate single swap instruction in rate limiter")] - FailToValidateSingleSwapInstruction = 0x17a1, - /// 6050 - Invalid fee scheduler - #[error("Invalid fee scheduler")] - InvalidFeeScheduler = 0x17a2, - /// 6051 - Undetermined error - #[error("Undetermined error")] - UndeterminedError = 0x17a3, - /// 6052 - Invalid pool version - #[error("Invalid pool version")] - InvalidPoolVersion = 0x17a4, -} - -impl From for solana_program_error::ProgramError { - fn from(e: CpAmmError) -> Self { solana_program_error::ProgramError::Custom(e as u32) } -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/errors/mod.rs b/crates/meteora-amm-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index b4594040..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod cp_amm; - -pub use self::cp_amm::CpAmmError; diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/add_liquidity.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/add_liquidity.rs deleted file mode 100644 index ac03b632..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/add_liquidity.rs +++ /dev/null @@ -1,864 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::AddLiquidityParameters; - -pub const ADD_LIQUIDITY_DISCRIMINATOR: [u8; 8] = [181, 157, 89, 67, 143, 182, 52, 72]; - -/// Accounts. -#[derive(Debug)] -pub struct AddLiquidity { - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - /// The user token a account - pub token_a_account: solana_pubkey::Pubkey, - /// The user token b account - pub token_b_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub token_a_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub token_b_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub token_a_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub token_b_mint: solana_pubkey::Pubkey, - /// The token account for nft - pub position_nft_account: solana_pubkey::Pubkey, - /// owner of position - pub owner: solana_pubkey::Pubkey, - /// Token a program - pub token_a_program: solana_pubkey::Pubkey, - /// Token b program - pub token_b_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl AddLiquidity { - pub fn instruction( - &self, - args: AddLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = AddLiquidityInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl AddLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [181, 157, 89, 67, 143, 182, 52, 72], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for AddLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityInstructionArgs { - pub params: AddLiquidityParameters, -} - -impl AddLiquidityInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `AddLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` position -/// 2. `[writable]` token_a_account -/// 3. `[writable]` token_b_account -/// 4. `[writable]` token_a_vault -/// 5. `[writable]` token_b_vault -/// 6. `[]` token_a_mint -/// 7. `[]` token_b_mint -/// 8. `[]` position_nft_account -/// 9. `[signer]` owner -/// 10. `[]` token_a_program -/// 11. `[]` token_b_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct AddLiquidityBuilder { - pool: Option, - position: Option, - token_a_account: Option, - token_b_account: Option, - token_a_vault: Option, - token_b_vault: Option, - token_a_mint: Option, - token_b_mint: Option, - position_nft_account: Option, - owner: Option, - token_a_program: Option, - token_b_program: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl AddLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// The user token a account - #[inline(always)] - pub fn token_a_account(&mut self, token_a_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_account = Some(token_a_account); - self - } - - /// The user token b account - #[inline(always)] - pub fn token_b_account(&mut self, token_b_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: AddLiquidityParameters) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddLiquidity { - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - token_a_account: self.token_a_account.expect("token_a_account is not set"), - token_b_account: self.token_b_account.expect("token_b_account is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - owner: self.owner.expect("owner is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = AddLiquidityInstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_liquidity` CPI accounts. -pub struct AddLiquidityCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The user token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_liquidity` CPI instruction. -pub struct AddLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The user token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddLiquidityInstructionArgs, -} - -impl<'a, 'b> AddLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddLiquidityCpiAccounts<'a, 'b>, - args: AddLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - position: accounts.position, - token_a_account: accounts.token_a_account, - token_b_account: accounts.token_b_account, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - position_nft_account: accounts.position_nft_account, - owner: accounts.owner, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = AddLiquidityInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.token_a_account.clone()); - account_infos.push(self.token_b_account.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` position -/// 2. `[writable]` token_a_account -/// 3. `[writable]` token_b_account -/// 4. `[writable]` token_a_vault -/// 5. `[writable]` token_b_vault -/// 6. `[]` token_a_mint -/// 7. `[]` token_b_mint -/// 8. `[]` position_nft_account -/// 9. `[signer]` owner -/// 10. `[]` token_a_program -/// 11. `[]` token_b_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct AddLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddLiquidityCpiBuilderInstruction { - __program: program, - pool: None, - position: None, - token_a_account: None, - token_b_account: None, - token_a_vault: None, - token_b_vault: None, - token_a_mint: None, - token_b_mint: None, - position_nft_account: None, - owner: None, - token_a_program: None, - token_b_program: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - /// The user token a account - #[inline(always)] - pub fn token_a_account( - &mut self, - token_a_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_account = Some(token_a_account); - self - } - - /// The user token b account - #[inline(always)] - pub fn token_b_account( - &mut self, - token_b_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: AddLiquidityParameters) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = AddLiquidityInstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = AddLiquidityCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - token_a_account: self - .instruction - .token_a_account - .expect("token_a_account is not set"), - - token_b_account: self - .instruction - .token_b_account - .expect("token_b_account is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_partner_fee.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_partner_fee.rs deleted file mode 100644 index 923abf78..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_partner_fee.rs +++ /dev/null @@ -1,850 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLAIM_PARTNER_FEE_DISCRIMINATOR: [u8; 8] = [97, 206, 39, 105, 94, 94, 126, 148]; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimPartnerFee { - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - /// The treasury token a account - pub token_a_account: solana_pubkey::Pubkey, - /// The treasury token b account - pub token_b_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub token_a_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub token_b_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub token_a_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub token_b_mint: solana_pubkey::Pubkey, - - pub partner: solana_pubkey::Pubkey, - /// Token a program - pub token_a_program: solana_pubkey::Pubkey, - /// Token b program - pub token_b_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimPartnerFee { - pub fn instruction( - &self, - args: ClaimPartnerFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimPartnerFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.partner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = ClaimPartnerFeeInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimPartnerFeeInstructionData { - discriminator: [u8; 8], -} - -impl ClaimPartnerFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [97, 206, 39, 105, 94, 94, 126, 148], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for ClaimPartnerFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimPartnerFeeInstructionArgs { - pub max_amount_a: u64, - pub max_amount_b: u64, -} - -impl ClaimPartnerFeeInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `ClaimPartnerFee`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 1. `[writable]` pool -/// 2. `[writable]` token_a_account -/// 3. `[writable]` token_b_account -/// 4. `[writable]` token_a_vault -/// 5. `[writable]` token_b_vault -/// 6. `[]` token_a_mint -/// 7. `[]` token_b_mint -/// 8. `[signer]` partner -/// 9. `[]` token_a_program -/// 10. `[]` token_b_program -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimPartnerFeeBuilder { - pool_authority: Option, - pool: Option, - token_a_account: Option, - token_b_account: Option, - token_a_vault: Option, - token_b_vault: Option, - token_a_mint: Option, - token_b_mint: Option, - partner: Option, - token_a_program: Option, - token_b_program: Option, - event_authority: Option, - program: Option, - max_amount_a: Option, - max_amount_b: Option, - __remaining_accounts: Vec, -} - -impl ClaimPartnerFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// The treasury token a account - #[inline(always)] - pub fn token_a_account(&mut self, token_a_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_account = Some(token_a_account); - self - } - - /// The treasury token b account - #[inline(always)] - pub fn token_b_account(&mut self, token_b_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - #[inline(always)] - pub fn partner(&mut self, partner: solana_pubkey::Pubkey) -> &mut Self { - self.partner = Some(partner); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn max_amount_a(&mut self, max_amount_a: u64) -> &mut Self { - self.max_amount_a = Some(max_amount_a); - self - } - - #[inline(always)] - pub fn max_amount_b(&mut self, max_amount_b: u64) -> &mut Self { - self.max_amount_b = Some(max_amount_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimPartnerFee { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - token_a_account: self.token_a_account.expect("token_a_account is not set"), - token_b_account: self.token_b_account.expect("token_b_account is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - partner: self.partner.expect("partner is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = ClaimPartnerFeeInstructionArgs { - max_amount_a: self.max_amount_a.clone().expect("max_amount_a is not set"), - max_amount_b: self.max_amount_b.clone().expect("max_amount_b is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim_partner_fee` CPI accounts. -pub struct ClaimPartnerFeeCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - - pub partner: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_partner_fee` CPI instruction. -pub struct ClaimPartnerFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - - pub partner: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimPartnerFeeInstructionArgs, -} - -impl<'a, 'b> ClaimPartnerFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimPartnerFeeCpiAccounts<'a, 'b>, - args: ClaimPartnerFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - token_a_account: accounts.token_a_account, - token_b_account: accounts.token_b_account, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - partner: accounts.partner, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.partner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = ClaimPartnerFeeInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.token_a_account.clone()); - account_infos.push(self.token_b_account.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.partner.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimPartnerFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[writable]` pool -/// 2. `[writable]` token_a_account -/// 3. `[writable]` token_b_account -/// 4. `[writable]` token_a_vault -/// 5. `[writable]` token_b_vault -/// 6. `[]` token_a_mint -/// 7. `[]` token_b_mint -/// 8. `[signer]` partner -/// 9. `[]` token_a_program -/// 10. `[]` token_b_program -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimPartnerFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimPartnerFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimPartnerFeeCpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - token_a_account: None, - token_b_account: None, - token_a_vault: None, - token_b_vault: None, - token_a_mint: None, - token_b_mint: None, - partner: None, - token_a_program: None, - token_b_program: None, - event_authority: None, - program: None, - max_amount_a: None, - max_amount_b: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// The treasury token a account - #[inline(always)] - pub fn token_a_account( - &mut self, - token_a_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_account = Some(token_a_account); - self - } - - /// The treasury token b account - #[inline(always)] - pub fn token_b_account( - &mut self, - token_b_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - #[inline(always)] - pub fn partner(&mut self, partner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.partner = Some(partner); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn max_amount_a(&mut self, max_amount_a: u64) -> &mut Self { - self.instruction.max_amount_a = Some(max_amount_a); - self - } - - #[inline(always)] - pub fn max_amount_b(&mut self, max_amount_b: u64) -> &mut Self { - self.instruction.max_amount_b = Some(max_amount_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = ClaimPartnerFeeInstructionArgs { - max_amount_a: self - .instruction - .max_amount_a - .clone() - .expect("max_amount_a is not set"), - max_amount_b: self - .instruction - .max_amount_b - .clone() - .expect("max_amount_b is not set"), - }; - let instruction = ClaimPartnerFeeCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - token_a_account: self - .instruction - .token_a_account - .expect("token_a_account is not set"), - - token_b_account: self - .instruction - .token_b_account - .expect("token_b_account is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - partner: self.instruction.partner.expect("partner is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimPartnerFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - partner: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - max_amount_a: Option, - max_amount_b: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_position_fee.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_position_fee.rs deleted file mode 100644 index 83cb69a4..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_position_fee.rs +++ /dev/null @@ -1,868 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLAIM_POSITION_FEE_DISCRIMINATOR: [u8; 8] = [180, 38, 154, 17, 133, 33, 162, 211]; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimPositionFee { - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - /// The user token a account - pub token_a_account: solana_pubkey::Pubkey, - /// The user token b account - pub token_b_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub token_a_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub token_b_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub token_a_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub token_b_mint: solana_pubkey::Pubkey, - /// The token account for nft - pub position_nft_account: solana_pubkey::Pubkey, - /// owner of position - pub owner: solana_pubkey::Pubkey, - /// Token a program - pub token_a_program: solana_pubkey::Pubkey, - /// Token b program - pub token_b_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimPositionFee { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = ClaimPositionFeeInstructionData::new().try_to_vec().unwrap(); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimPositionFeeInstructionData { - discriminator: [u8; 8], -} - -impl ClaimPositionFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [180, 38, 154, 17, 133, 33, 162, 211], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for ClaimPositionFeeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClaimPositionFee`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 1. `[]` pool -/// 2. `[writable]` position -/// 3. `[writable]` token_a_account -/// 4. `[writable]` token_b_account -/// 5. `[writable]` token_a_vault -/// 6. `[writable]` token_b_vault -/// 7. `[]` token_a_mint -/// 8. `[]` token_b_mint -/// 9. `[]` position_nft_account -/// 10. `[signer]` owner -/// 11. `[]` token_a_program -/// 12. `[]` token_b_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimPositionFeeBuilder { - pool_authority: Option, - pool: Option, - position: Option, - token_a_account: Option, - token_b_account: Option, - token_a_vault: Option, - token_b_vault: Option, - token_a_mint: Option, - token_b_mint: Option, - position_nft_account: Option, - owner: Option, - token_a_program: Option, - token_b_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl ClaimPositionFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// The user token a account - #[inline(always)] - pub fn token_a_account(&mut self, token_a_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_account = Some(token_a_account); - self - } - - /// The user token b account - #[inline(always)] - pub fn token_b_account(&mut self, token_b_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimPositionFee { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - token_a_account: self.token_a_account.expect("token_a_account is not set"), - token_b_account: self.token_b_account.expect("token_b_account is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - owner: self.owner.expect("owner is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `claim_position_fee` CPI accounts. -pub struct ClaimPositionFeeCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The user token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_position_fee` CPI instruction. -pub struct ClaimPositionFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The user token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClaimPositionFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimPositionFeeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - position: accounts.position, - token_a_account: accounts.token_a_account, - token_b_account: accounts.token_b_account, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - position_nft_account: accounts.position_nft_account, - owner: accounts.owner, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = ClaimPositionFeeInstructionData::new().try_to_vec().unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.token_a_account.clone()); - account_infos.push(self.token_b_account.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimPositionFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[]` pool -/// 2. `[writable]` position -/// 3. `[writable]` token_a_account -/// 4. `[writable]` token_b_account -/// 5. `[writable]` token_a_vault -/// 6. `[writable]` token_b_vault -/// 7. `[]` token_a_mint -/// 8. `[]` token_b_mint -/// 9. `[]` position_nft_account -/// 10. `[signer]` owner -/// 11. `[]` token_a_program -/// 12. `[]` token_b_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimPositionFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimPositionFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimPositionFeeCpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - position: None, - token_a_account: None, - token_b_account: None, - token_a_vault: None, - token_b_vault: None, - token_a_mint: None, - token_b_mint: None, - position_nft_account: None, - owner: None, - token_a_program: None, - token_b_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - /// The user token a account - #[inline(always)] - pub fn token_a_account( - &mut self, - token_a_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_account = Some(token_a_account); - self - } - - /// The user token b account - #[inline(always)] - pub fn token_b_account( - &mut self, - token_b_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let instruction = ClaimPositionFeeCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - token_a_account: self - .instruction - .token_a_account - .expect("token_a_account is not set"), - - token_b_account: self - .instruction - .token_b_account - .expect("token_b_account is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimPositionFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_protocol_fee.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_protocol_fee.rs deleted file mode 100644 index 0d889ff2..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_protocol_fee.rs +++ /dev/null @@ -1,898 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLAIM_PROTOCOL_FEE_DISCRIMINATOR: [u8; 8] = [165, 228, 133, 48, 99, 249, 255, 33]; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimProtocolFee { - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - /// The vault token account for input token - pub token_a_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub token_b_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub token_a_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub token_b_mint: solana_pubkey::Pubkey, - /// The treasury token a account - pub token_a_account: solana_pubkey::Pubkey, - /// The treasury token b account - pub token_b_account: solana_pubkey::Pubkey, - /// Claim fee operator - pub claim_fee_operator: solana_pubkey::Pubkey, - /// Operator - pub operator: solana_pubkey::Pubkey, - /// Token a program - pub token_a_program: solana_pubkey::Pubkey, - /// Token b program - pub token_b_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimProtocolFee { - pub fn instruction( - &self, - args: ClaimProtocolFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimProtocolFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.claim_fee_operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = ClaimProtocolFeeInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimProtocolFeeInstructionData { - discriminator: [u8; 8], -} - -impl ClaimProtocolFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [165, 228, 133, 48, 99, 249, 255, 33], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for ClaimProtocolFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimProtocolFeeInstructionArgs { - pub max_amount_a: u64, - pub max_amount_b: u64, -} - -impl ClaimProtocolFeeInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `ClaimProtocolFee`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 1. `[writable]` pool -/// 2. `[writable]` token_a_vault -/// 3. `[writable]` token_b_vault -/// 4. `[]` token_a_mint -/// 5. `[]` token_b_mint -/// 6. `[writable]` token_a_account -/// 7. `[writable]` token_b_account -/// 8. `[]` claim_fee_operator -/// 9. `[signer]` operator -/// 10. `[]` token_a_program -/// 11. `[]` token_b_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimProtocolFeeBuilder { - pool_authority: Option, - pool: Option, - token_a_vault: Option, - token_b_vault: Option, - token_a_mint: Option, - token_b_mint: Option, - token_a_account: Option, - token_b_account: Option, - claim_fee_operator: Option, - operator: Option, - token_a_program: Option, - token_b_program: Option, - event_authority: Option, - program: Option, - max_amount_a: Option, - max_amount_b: Option, - __remaining_accounts: Vec, -} - -impl ClaimProtocolFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// The treasury token a account - #[inline(always)] - pub fn token_a_account(&mut self, token_a_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_account = Some(token_a_account); - self - } - - /// The treasury token b account - #[inline(always)] - pub fn token_b_account(&mut self, token_b_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_account = Some(token_b_account); - self - } - - /// Claim fee operator - #[inline(always)] - pub fn claim_fee_operator(&mut self, claim_fee_operator: solana_pubkey::Pubkey) -> &mut Self { - self.claim_fee_operator = Some(claim_fee_operator); - self - } - - /// Operator - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn max_amount_a(&mut self, max_amount_a: u64) -> &mut Self { - self.max_amount_a = Some(max_amount_a); - self - } - - #[inline(always)] - pub fn max_amount_b(&mut self, max_amount_b: u64) -> &mut Self { - self.max_amount_b = Some(max_amount_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimProtocolFee { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - token_a_account: self.token_a_account.expect("token_a_account is not set"), - token_b_account: self.token_b_account.expect("token_b_account is not set"), - claim_fee_operator: self - .claim_fee_operator - .expect("claim_fee_operator is not set"), - operator: self.operator.expect("operator is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = ClaimProtocolFeeInstructionArgs { - max_amount_a: self.max_amount_a.clone().expect("max_amount_a is not set"), - max_amount_b: self.max_amount_b.clone().expect("max_amount_b is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim_protocol_fee` CPI accounts. -pub struct ClaimProtocolFeeCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// Claim fee operator - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - /// Operator - pub operator: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_protocol_fee` CPI instruction. -pub struct ClaimProtocolFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// Claim fee operator - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - /// Operator - pub operator: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimProtocolFeeInstructionArgs, -} - -impl<'a, 'b> ClaimProtocolFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimProtocolFeeCpiAccounts<'a, 'b>, - args: ClaimProtocolFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - token_a_account: accounts.token_a_account, - token_b_account: accounts.token_b_account, - claim_fee_operator: accounts.claim_fee_operator, - operator: accounts.operator, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.claim_fee_operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = ClaimProtocolFeeInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.token_a_account.clone()); - account_infos.push(self.token_b_account.clone()); - account_infos.push(self.claim_fee_operator.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimProtocolFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[writable]` pool -/// 2. `[writable]` token_a_vault -/// 3. `[writable]` token_b_vault -/// 4. `[]` token_a_mint -/// 5. `[]` token_b_mint -/// 6. `[writable]` token_a_account -/// 7. `[writable]` token_b_account -/// 8. `[]` claim_fee_operator -/// 9. `[signer]` operator -/// 10. `[]` token_a_program -/// 11. `[]` token_b_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimProtocolFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimProtocolFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimProtocolFeeCpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - token_a_vault: None, - token_b_vault: None, - token_a_mint: None, - token_b_mint: None, - token_a_account: None, - token_b_account: None, - claim_fee_operator: None, - operator: None, - token_a_program: None, - token_b_program: None, - event_authority: None, - program: None, - max_amount_a: None, - max_amount_b: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// The treasury token a account - #[inline(always)] - pub fn token_a_account( - &mut self, - token_a_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_account = Some(token_a_account); - self - } - - /// The treasury token b account - #[inline(always)] - pub fn token_b_account( - &mut self, - token_b_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_account = Some(token_b_account); - self - } - - /// Claim fee operator - #[inline(always)] - pub fn claim_fee_operator( - &mut self, - claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.claim_fee_operator = Some(claim_fee_operator); - self - } - - /// Operator - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn max_amount_a(&mut self, max_amount_a: u64) -> &mut Self { - self.instruction.max_amount_a = Some(max_amount_a); - self - } - - #[inline(always)] - pub fn max_amount_b(&mut self, max_amount_b: u64) -> &mut Self { - self.instruction.max_amount_b = Some(max_amount_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = ClaimProtocolFeeInstructionArgs { - max_amount_a: self - .instruction - .max_amount_a - .clone() - .expect("max_amount_a is not set"), - max_amount_b: self - .instruction - .max_amount_b - .clone() - .expect("max_amount_b is not set"), - }; - let instruction = ClaimProtocolFeeCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - token_a_account: self - .instruction - .token_a_account - .expect("token_a_account is not set"), - - token_b_account: self - .instruction - .token_b_account - .expect("token_b_account is not set"), - - claim_fee_operator: self - .instruction - .claim_fee_operator - .expect("claim_fee_operator is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimProtocolFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_account: Option<&'b solana_account_info::AccountInfo<'a>>, - claim_fee_operator: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - max_amount_a: Option, - max_amount_b: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_reward.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_reward.rs deleted file mode 100644 index a02172cf..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/claim_reward.rs +++ /dev/null @@ -1,753 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLAIM_REWARD_DISCRIMINATOR: [u8; 8] = [149, 95, 181, 242, 94, 90, 158, 162]; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimReward { - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - /// The vault token account for reward token - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub user_token_account: solana_pubkey::Pubkey, - /// The token account for nft - pub position_nft_account: solana_pubkey::Pubkey, - /// owner of position - pub owner: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimReward { - pub fn instruction(&self, args: ClaimRewardInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = ClaimRewardInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimRewardInstructionData { - discriminator: [u8; 8], -} - -impl ClaimRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [149, 95, 181, 242, 94, 90, 158, 162], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for ClaimRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimRewardInstructionArgs { - pub reward_index: u8, - pub skip_reward: u8, -} - -impl ClaimRewardInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `ClaimReward`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 1. `[writable]` pool -/// 2. `[writable]` position -/// 3. `[writable]` reward_vault -/// 4. `[]` reward_mint -/// 5. `[writable]` user_token_account -/// 6. `[]` position_nft_account -/// 7. `[signer]` owner -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[]` event_authority -/// 10. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimRewardBuilder { - pool_authority: Option, - pool: Option, - position: Option, - reward_vault: Option, - reward_mint: Option, - user_token_account: Option, - position_nft_account: Option, - owner: Option, - token_program: Option, - event_authority: Option, - program: Option, - reward_index: Option, - skip_reward: Option, - __remaining_accounts: Vec, -} - -impl ClaimRewardBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// The vault token account for reward token - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn user_token_account(&mut self, user_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_account = Some(user_token_account); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn skip_reward(&mut self, skip_reward: u8) -> &mut Self { - self.skip_reward = Some(skip_reward); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimReward { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - user_token_account: self - .user_token_account - .expect("user_token_account is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - owner: self.owner.expect("owner is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = ClaimRewardInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - skip_reward: self.skip_reward.clone().expect("skip_reward is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim_reward` CPI accounts. -pub struct ClaimRewardCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for reward token - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_reward` CPI instruction. -pub struct ClaimRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for reward token - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimRewardInstructionArgs, -} - -impl<'a, 'b> ClaimRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimRewardCpiAccounts<'a, 'b>, - args: ClaimRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - position: accounts.position, - reward_vault: accounts.reward_vault, - reward_mint: accounts.reward_mint, - user_token_account: accounts.user_token_account, - position_nft_account: accounts.position_nft_account, - owner: accounts.owner, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = ClaimRewardInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.user_token_account.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[writable]` pool -/// 2. `[writable]` position -/// 3. `[writable]` reward_vault -/// 4. `[]` reward_mint -/// 5. `[writable]` user_token_account -/// 6. `[]` position_nft_account -/// 7. `[signer]` owner -/// 8. `[]` token_program -/// 9. `[]` event_authority -/// 10. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimRewardCpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - position: None, - reward_vault: None, - reward_mint: None, - user_token_account: None, - position_nft_account: None, - owner: None, - token_program: None, - event_authority: None, - program: None, - reward_index: None, - skip_reward: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - /// The vault token account for reward token - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn user_token_account( - &mut self, - user_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_account = Some(user_token_account); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn skip_reward(&mut self, skip_reward: u8) -> &mut Self { - self.instruction.skip_reward = Some(skip_reward); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = ClaimRewardInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - skip_reward: self - .instruction - .skip_reward - .clone() - .expect("skip_reward is not set"), - }; - let instruction = ClaimRewardCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - user_token_account: self - .instruction - .user_token_account - .expect("user_token_account is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - skip_reward: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/close_claim_fee_operator.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/close_claim_fee_operator.rs deleted file mode 100644 index dc8dc4eb..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/close_claim_fee_operator.rs +++ /dev/null @@ -1,442 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLOSE_CLAIM_FEE_OPERATOR_DISCRIMINATOR: [u8; 8] = [38, 134, 82, 216, 95, 124, 17, 99]; - -/// Accounts. -#[derive(Debug)] -pub struct CloseClaimFeeOperator { - pub claim_fee_operator: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CloseClaimFeeOperator { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.claim_fee_operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = CloseClaimFeeOperatorInstructionData::new() - .try_to_vec() - .unwrap(); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseClaimFeeOperatorInstructionData { - discriminator: [u8; 8], -} - -impl CloseClaimFeeOperatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [38, 134, 82, 216, 95, 124, 17, 99], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for CloseClaimFeeOperatorInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CloseClaimFeeOperator`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[writable]` rent_receiver -/// 2. `[signer]` admin -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CloseClaimFeeOperatorBuilder { - claim_fee_operator: Option, - rent_receiver: Option, - admin: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CloseClaimFeeOperatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn claim_fee_operator(&mut self, claim_fee_operator: solana_pubkey::Pubkey) -> &mut Self { - self.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CloseClaimFeeOperator { - claim_fee_operator: self - .claim_fee_operator - .expect("claim_fee_operator is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - admin: self.admin.expect("admin is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_claim_fee_operator` CPI accounts. -pub struct CloseClaimFeeOperatorCpiAccounts<'a, 'b> { - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_claim_fee_operator` CPI instruction. -pub struct CloseClaimFeeOperatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CloseClaimFeeOperatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CloseClaimFeeOperatorCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - claim_fee_operator: accounts.claim_fee_operator, - rent_receiver: accounts.rent_receiver, - admin: accounts.admin, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.claim_fee_operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = CloseClaimFeeOperatorInstructionData::new() - .try_to_vec() - .unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.claim_fee_operator.clone()); - account_infos.push(self.rent_receiver.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CloseClaimFeeOperator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[writable]` rent_receiver -/// 2. `[signer]` admin -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct CloseClaimFeeOperatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CloseClaimFeeOperatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CloseClaimFeeOperatorCpiBuilderInstruction { - __program: program, - claim_fee_operator: None, - rent_receiver: None, - admin: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn claim_fee_operator( - &mut self, - claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let instruction = CloseClaimFeeOperatorCpi { - __program: self.instruction.__program, - - claim_fee_operator: self - .instruction - .claim_fee_operator - .expect("claim_fee_operator is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CloseClaimFeeOperatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - claim_fee_operator: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/close_config.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/close_config.rs deleted file mode 100644 index 530ee661..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/close_config.rs +++ /dev/null @@ -1,422 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLOSE_CONFIG_DISCRIMINATOR: [u8; 8] = [145, 9, 72, 157, 95, 125, 61, 85]; - -/// Accounts. -#[derive(Debug)] -pub struct CloseConfig { - pub config: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CloseConfig { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = CloseConfigInstructionData::new().try_to_vec().unwrap(); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseConfigInstructionData { - discriminator: [u8; 8], -} - -impl CloseConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [145, 9, 72, 157, 95, 125, 61, 85], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for CloseConfigInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CloseConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` admin -/// 2. `[writable]` rent_receiver -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CloseConfigBuilder { - config: Option, - admin: Option, - rent_receiver: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CloseConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CloseConfig { - config: self.config.expect("config is not set"), - admin: self.admin.expect("admin is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_config` CPI accounts. -pub struct CloseConfigCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_config` CPI instruction. -pub struct CloseConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CloseConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CloseConfigCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - config: accounts.config, - admin: accounts.admin, - rent_receiver: accounts.rent_receiver, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = CloseConfigInstructionData::new().try_to_vec().unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.rent_receiver.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CloseConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` admin -/// 2. `[writable]` rent_receiver -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct CloseConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CloseConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CloseConfigCpiBuilderInstruction { - __program: program, - config: None, - admin: None, - rent_receiver: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let instruction = CloseConfigCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CloseConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/close_position.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/close_position.rs deleted file mode 100644 index 4abb5d4b..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/close_position.rs +++ /dev/null @@ -1,648 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLOSE_POSITION_DISCRIMINATOR: [u8; 8] = [123, 134, 81, 0, 49, 68, 98, 98]; - -/// Accounts. -#[derive(Debug)] -pub struct ClosePosition { - /// position_nft_mint - pub position_nft_mint: solana_pubkey::Pubkey, - /// The token account for nft - pub position_nft_account: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, - /// Owner of position - pub owner: solana_pubkey::Pubkey, - /// Program to create NFT mint/token account and transfer for token22 account - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClosePosition { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = ClosePositionInstructionData::new().try_to_vec().unwrap(); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClosePositionInstructionData { - discriminator: [u8; 8], -} - -impl ClosePositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [123, 134, 81, 0, 49, 68, 98, 98], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for ClosePositionInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClosePosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position_nft_mint -/// 1. `[writable]` position_nft_account -/// 2. `[writable]` pool -/// 3. `[writable]` position -/// 4. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 5. `[writable]` rent_receiver -/// 6. `[signer]` owner -/// 7. `[optional]` token_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClosePositionBuilder { - position_nft_mint: Option, - position_nft_account: Option, - pool: Option, - position: Option, - pool_authority: Option, - rent_receiver: Option, - owner: Option, - token_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl ClosePositionBuilder { - pub fn new() -> Self { Self::default() } - - /// position_nft_mint - #[inline(always)] - pub fn position_nft_mint(&mut self, position_nft_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_mint = Some(position_nft_mint); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - /// Owner of position - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// Program to create NFT mint/token account and transfer for token22 account - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClosePosition { - position_nft_mint: self - .position_nft_mint - .expect("position_nft_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - owner: self.owner.expect("owner is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_position` CPI accounts. -pub struct ClosePositionCpiAccounts<'a, 'b> { - /// position_nft_mint - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - /// Owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT mint/token account and transfer for token22 account - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_position` CPI instruction. -pub struct ClosePositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// position_nft_mint - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - /// Owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT mint/token account and transfer for token22 account - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClosePositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClosePositionCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position_nft_mint: accounts.position_nft_mint, - position_nft_account: accounts.position_nft_account, - pool: accounts.pool, - position: accounts.position, - pool_authority: accounts.pool_authority, - rent_receiver: accounts.rent_receiver, - owner: accounts.owner, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = ClosePositionInstructionData::new().try_to_vec().unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position_nft_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.rent_receiver.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClosePosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position_nft_mint -/// 1. `[writable]` position_nft_account -/// 2. `[writable]` pool -/// 3. `[writable]` position -/// 4. `[]` pool_authority -/// 5. `[writable]` rent_receiver -/// 6. `[signer]` owner -/// 7. `[]` token_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct ClosePositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClosePositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClosePositionCpiBuilderInstruction { - __program: program, - position_nft_mint: None, - position_nft_account: None, - pool: None, - position: None, - pool_authority: None, - rent_receiver: None, - owner: None, - token_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// position_nft_mint - #[inline(always)] - pub fn position_nft_mint( - &mut self, - position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_mint = Some(position_nft_mint); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - /// Owner of position - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Program to create NFT mint/token account and transfer for token22 account - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let instruction = ClosePositionCpi { - __program: self.instruction.__program, - - position_nft_mint: self - .instruction - .position_nft_mint - .expect("position_nft_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClosePositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/close_token_badge.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/close_token_badge.rs deleted file mode 100644 index 35539f7e..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/close_token_badge.rs +++ /dev/null @@ -1,431 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLOSE_TOKEN_BADGE_DISCRIMINATOR: [u8; 8] = [108, 146, 86, 110, 179, 254, 10, 104]; - -/// Accounts. -#[derive(Debug)] -pub struct CloseTokenBadge { - pub token_badge: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CloseTokenBadge { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.token_badge, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = CloseTokenBadgeInstructionData::new().try_to_vec().unwrap(); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseTokenBadgeInstructionData { - discriminator: [u8; 8], -} - -impl CloseTokenBadgeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [108, 146, 86, 110, 179, 254, 10, 104], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for CloseTokenBadgeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CloseTokenBadge`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` token_badge -/// 1. `[writable, signer]` admin -/// 2. `[writable]` rent_receiver -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CloseTokenBadgeBuilder { - token_badge: Option, - admin: Option, - rent_receiver: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CloseTokenBadgeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn token_badge(&mut self, token_badge: solana_pubkey::Pubkey) -> &mut Self { - self.token_badge = Some(token_badge); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CloseTokenBadge { - token_badge: self.token_badge.expect("token_badge is not set"), - admin: self.admin.expect("admin is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_token_badge` CPI accounts. -pub struct CloseTokenBadgeCpiAccounts<'a, 'b> { - pub token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_token_badge` CPI instruction. -pub struct CloseTokenBadgeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CloseTokenBadgeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CloseTokenBadgeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - token_badge: accounts.token_badge, - admin: accounts.admin, - rent_receiver: accounts.rent_receiver, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_badge.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = CloseTokenBadgeInstructionData::new().try_to_vec().unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_badge.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.rent_receiver.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CloseTokenBadge` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` token_badge -/// 1. `[writable, signer]` admin -/// 2. `[writable]` rent_receiver -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct CloseTokenBadgeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CloseTokenBadgeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CloseTokenBadgeCpiBuilderInstruction { - __program: program, - token_badge: None, - admin: None, - rent_receiver: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_badge( - &mut self, - token_badge: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge = Some(token_badge); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let instruction = CloseTokenBadgeCpi { - __program: self.instruction.__program, - - token_badge: self - .instruction - .token_badge - .expect("token_badge is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CloseTokenBadgeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_badge: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/create_claim_fee_operator.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/create_claim_fee_operator.rs deleted file mode 100644 index c1cd7363..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/create_claim_fee_operator.rs +++ /dev/null @@ -1,476 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CREATE_CLAIM_FEE_OPERATOR_DISCRIMINATOR: [u8; 8] = [169, 62, 207, 107, 58, 187, 162, 109]; - -/// Accounts. -#[derive(Debug)] -pub struct CreateClaimFeeOperator { - pub claim_fee_operator: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreateClaimFeeOperator { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.claim_fee_operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = CreateClaimFeeOperatorInstructionData::new() - .try_to_vec() - .unwrap(); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateClaimFeeOperatorInstructionData { - discriminator: [u8; 8], -} - -impl CreateClaimFeeOperatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [169, 62, 207, 107, 58, 187, 162, 109], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for CreateClaimFeeOperatorInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateClaimFeeOperator`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[]` operator -/// 2. `[writable, signer]` admin -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreateClaimFeeOperatorBuilder { - claim_fee_operator: Option, - operator: Option, - admin: Option, - system_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CreateClaimFeeOperatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn claim_fee_operator(&mut self, claim_fee_operator: solana_pubkey::Pubkey) -> &mut Self { - self.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateClaimFeeOperator { - claim_fee_operator: self - .claim_fee_operator - .expect("claim_fee_operator is not set"), - operator: self.operator.expect("operator is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_claim_fee_operator` CPI accounts. -pub struct CreateClaimFeeOperatorCpiAccounts<'a, 'b> { - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_claim_fee_operator` CPI instruction. -pub struct CreateClaimFeeOperatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateClaimFeeOperatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateClaimFeeOperatorCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - claim_fee_operator: accounts.claim_fee_operator, - operator: accounts.operator, - admin: accounts.admin, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.claim_fee_operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = CreateClaimFeeOperatorInstructionData::new() - .try_to_vec() - .unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.claim_fee_operator.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateClaimFeeOperator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[]` operator -/// 2. `[writable, signer]` admin -/// 3. `[]` system_program -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug)] -pub struct CreateClaimFeeOperatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateClaimFeeOperatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateClaimFeeOperatorCpiBuilderInstruction { - __program: program, - claim_fee_operator: None, - operator: None, - admin: None, - system_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn claim_fee_operator( - &mut self, - claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let instruction = CreateClaimFeeOperatorCpi { - __program: self.instruction.__program, - - claim_fee_operator: self - .instruction - .claim_fee_operator - .expect("claim_fee_operator is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateClaimFeeOperatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - claim_fee_operator: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/create_config.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/create_config.rs deleted file mode 100644 index 489e7b22..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/create_config.rs +++ /dev/null @@ -1,644 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::PoolFeeParameters; - -pub const CREATE_CONFIG_DISCRIMINATOR: [u8; 8] = [201, 207, 243, 114, 75, 111, 47, 189]; - -/// Accounts. -#[derive(Debug)] -pub struct CreateConfig { - pub config: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreateConfig { - pub fn instruction( - &self, - args: CreateConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = CreateConfigInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigInstructionData { - discriminator: [u8; 8], -} - -impl CreateConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [201, 207, 243, 114, 75, 111, 47, 189], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for CreateConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigInstructionArgs { - pub index: u64, - pub pool_fees: PoolFeeParameters, - pub sqrt_min_price: u128, - pub sqrt_max_price: u128, - pub vault_config_key: Pubkey, - pub pool_creator_authority: Pubkey, - pub activation_type: u8, - pub collect_fee_mode: u8, -} - -impl CreateConfigInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `CreateConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` admin -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreateConfigBuilder { - config: Option, - admin: Option, - system_program: Option, - event_authority: Option, - program: Option, - index: Option, - pool_fees: Option, - sqrt_min_price: Option, - sqrt_max_price: Option, - vault_config_key: Option, - pool_creator_authority: Option, - activation_type: Option, - collect_fee_mode: Option, - __remaining_accounts: Vec, -} - -impl CreateConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u64) -> &mut Self { - self.index = Some(index); - self - } - - #[inline(always)] - pub fn pool_fees(&mut self, pool_fees: PoolFeeParameters) -> &mut Self { - self.pool_fees = Some(pool_fees); - self - } - - #[inline(always)] - pub fn sqrt_min_price(&mut self, sqrt_min_price: u128) -> &mut Self { - self.sqrt_min_price = Some(sqrt_min_price); - self - } - - #[inline(always)] - pub fn sqrt_max_price(&mut self, sqrt_max_price: u128) -> &mut Self { - self.sqrt_max_price = Some(sqrt_max_price); - self - } - - #[inline(always)] - pub fn vault_config_key(&mut self, vault_config_key: Pubkey) -> &mut Self { - self.vault_config_key = Some(vault_config_key); - self - } - - #[inline(always)] - pub fn pool_creator_authority(&mut self, pool_creator_authority: Pubkey) -> &mut Self { - self.pool_creator_authority = Some(pool_creator_authority); - self - } - - #[inline(always)] - pub fn activation_type(&mut self, activation_type: u8) -> &mut Self { - self.activation_type = Some(activation_type); - self - } - - #[inline(always)] - pub fn collect_fee_mode(&mut self, collect_fee_mode: u8) -> &mut Self { - self.collect_fee_mode = Some(collect_fee_mode); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateConfig { - config: self.config.expect("config is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = CreateConfigInstructionArgs { - index: self.index.clone().expect("index is not set"), - pool_fees: self.pool_fees.clone().expect("pool_fees is not set"), - sqrt_min_price: self - .sqrt_min_price - .clone() - .expect("sqrt_min_price is not set"), - sqrt_max_price: self - .sqrt_max_price - .clone() - .expect("sqrt_max_price is not set"), - vault_config_key: self - .vault_config_key - .clone() - .expect("vault_config_key is not set"), - pool_creator_authority: self - .pool_creator_authority - .clone() - .expect("pool_creator_authority is not set"), - activation_type: self - .activation_type - .clone() - .expect("activation_type is not set"), - collect_fee_mode: self - .collect_fee_mode - .clone() - .expect("collect_fee_mode is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_config` CPI accounts. -pub struct CreateConfigCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_config` CPI instruction. -pub struct CreateConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateConfigInstructionArgs, -} - -impl<'a, 'b> CreateConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateConfigCpiAccounts<'a, 'b>, - args: CreateConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - admin: accounts.admin, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = CreateConfigInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` admin -/// 2. `[]` system_program -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct CreateConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateConfigCpiBuilderInstruction { - __program: program, - config: None, - admin: None, - system_program: None, - event_authority: None, - program: None, - index: None, - pool_fees: None, - sqrt_min_price: None, - sqrt_max_price: None, - vault_config_key: None, - pool_creator_authority: None, - activation_type: None, - collect_fee_mode: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u64) -> &mut Self { - self.instruction.index = Some(index); - self - } - - #[inline(always)] - pub fn pool_fees(&mut self, pool_fees: PoolFeeParameters) -> &mut Self { - self.instruction.pool_fees = Some(pool_fees); - self - } - - #[inline(always)] - pub fn sqrt_min_price(&mut self, sqrt_min_price: u128) -> &mut Self { - self.instruction.sqrt_min_price = Some(sqrt_min_price); - self - } - - #[inline(always)] - pub fn sqrt_max_price(&mut self, sqrt_max_price: u128) -> &mut Self { - self.instruction.sqrt_max_price = Some(sqrt_max_price); - self - } - - #[inline(always)] - pub fn vault_config_key(&mut self, vault_config_key: Pubkey) -> &mut Self { - self.instruction.vault_config_key = Some(vault_config_key); - self - } - - #[inline(always)] - pub fn pool_creator_authority(&mut self, pool_creator_authority: Pubkey) -> &mut Self { - self.instruction.pool_creator_authority = Some(pool_creator_authority); - self - } - - #[inline(always)] - pub fn activation_type(&mut self, activation_type: u8) -> &mut Self { - self.instruction.activation_type = Some(activation_type); - self - } - - #[inline(always)] - pub fn collect_fee_mode(&mut self, collect_fee_mode: u8) -> &mut Self { - self.instruction.collect_fee_mode = Some(collect_fee_mode); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = CreateConfigInstructionArgs { - index: self.instruction.index.clone().expect("index is not set"), - pool_fees: self - .instruction - .pool_fees - .clone() - .expect("pool_fees is not set"), - sqrt_min_price: self - .instruction - .sqrt_min_price - .clone() - .expect("sqrt_min_price is not set"), - sqrt_max_price: self - .instruction - .sqrt_max_price - .clone() - .expect("sqrt_max_price is not set"), - vault_config_key: self - .instruction - .vault_config_key - .clone() - .expect("vault_config_key is not set"), - pool_creator_authority: self - .instruction - .pool_creator_authority - .clone() - .expect("pool_creator_authority is not set"), - activation_type: self - .instruction - .activation_type - .clone() - .expect("activation_type is not set"), - collect_fee_mode: self - .instruction - .collect_fee_mode - .clone() - .expect("collect_fee_mode is not set"), - }; - let instruction = CreateConfigCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - index: Option, - pool_fees: Option, - sqrt_min_price: Option, - sqrt_max_price: Option, - vault_config_key: Option, - pool_creator_authority: Option, - activation_type: Option, - collect_fee_mode: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/create_dynamic_config.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/create_dynamic_config.rs deleted file mode 100644 index 515a3cfe..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/create_dynamic_config.rs +++ /dev/null @@ -1,499 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -pub const CREATE_DYNAMIC_CONFIG_DISCRIMINATOR: [u8; 8] = [81, 251, 122, 78, 66, 57, 208, 82]; - -/// Accounts. -#[derive(Debug)] -pub struct CreateDynamicConfig { - pub config: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreateDynamicConfig { - pub fn instruction( - &self, - args: CreateDynamicConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateDynamicConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = CreateDynamicConfigInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateDynamicConfigInstructionData { - discriminator: [u8; 8], -} - -impl CreateDynamicConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [81, 251, 122, 78, 66, 57, 208, 82], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for CreateDynamicConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateDynamicConfigInstructionArgs { - pub index: u64, - pub pool_creator_authority: Pubkey, -} - -impl CreateDynamicConfigInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `CreateDynamicConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` admin -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreateDynamicConfigBuilder { - config: Option, - admin: Option, - system_program: Option, - event_authority: Option, - program: Option, - index: Option, - pool_creator_authority: Option, - __remaining_accounts: Vec, -} - -impl CreateDynamicConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u64) -> &mut Self { - self.index = Some(index); - self - } - - #[inline(always)] - pub fn pool_creator_authority(&mut self, pool_creator_authority: Pubkey) -> &mut Self { - self.pool_creator_authority = Some(pool_creator_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateDynamicConfig { - config: self.config.expect("config is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = CreateDynamicConfigInstructionArgs { - index: self.index.clone().expect("index is not set"), - pool_creator_authority: self - .pool_creator_authority - .clone() - .expect("pool_creator_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_dynamic_config` CPI accounts. -pub struct CreateDynamicConfigCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_dynamic_config` CPI instruction. -pub struct CreateDynamicConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateDynamicConfigInstructionArgs, -} - -impl<'a, 'b> CreateDynamicConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateDynamicConfigCpiAccounts<'a, 'b>, - args: CreateDynamicConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - admin: accounts.admin, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = CreateDynamicConfigInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateDynamicConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` admin -/// 2. `[]` system_program -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct CreateDynamicConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateDynamicConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateDynamicConfigCpiBuilderInstruction { - __program: program, - config: None, - admin: None, - system_program: None, - event_authority: None, - program: None, - index: None, - pool_creator_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u64) -> &mut Self { - self.instruction.index = Some(index); - self - } - - #[inline(always)] - pub fn pool_creator_authority(&mut self, pool_creator_authority: Pubkey) -> &mut Self { - self.instruction.pool_creator_authority = Some(pool_creator_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = CreateDynamicConfigInstructionArgs { - index: self.instruction.index.clone().expect("index is not set"), - pool_creator_authority: self - .instruction - .pool_creator_authority - .clone() - .expect("pool_creator_authority is not set"), - }; - let instruction = CreateDynamicConfigCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateDynamicConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - index: Option, - pool_creator_authority: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/create_position.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/create_position.rs deleted file mode 100644 index db8b78a3..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/create_position.rs +++ /dev/null @@ -1,679 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CREATE_POSITION_DISCRIMINATOR: [u8; 8] = [48, 215, 197, 153, 96, 203, 180, 133]; - -/// Accounts. -#[derive(Debug)] -pub struct CreatePosition { - pub owner: solana_pubkey::Pubkey, - /// position_nft_mint - pub position_nft_mint: solana_pubkey::Pubkey, - /// position nft account - pub position_nft_account: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - /// Address paying to create the position. Can be anyone - pub payer: solana_pubkey::Pubkey, - /// Program to create NFT mint/token account and transfer for token22 account - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreatePosition { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = CreatePositionInstructionData::new().try_to_vec().unwrap(); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePositionInstructionData { - discriminator: [u8; 8], -} - -impl CreatePositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [48, 215, 197, 153, 96, 203, 180, 133], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for CreatePositionInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreatePosition`. -/// -/// ### Accounts: -/// -/// 0. `[]` owner -/// 1. `[writable, signer]` position_nft_mint -/// 2. `[writable]` position_nft_account -/// 3. `[writable]` pool -/// 4. `[writable]` position -/// 5. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 6. `[writable, signer]` payer -/// 7. `[optional]` token_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[]` event_authority -/// 10. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreatePositionBuilder { - owner: Option, - position_nft_mint: Option, - position_nft_account: Option, - pool: Option, - position: Option, - pool_authority: Option, - payer: Option, - token_program: Option, - system_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CreatePositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// position_nft_mint - #[inline(always)] - pub fn position_nft_mint(&mut self, position_nft_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_mint = Some(position_nft_mint); - self - } - - /// position nft account - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - /// Address paying to create the position. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// Program to create NFT mint/token account and transfer for token22 account - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreatePosition { - owner: self.owner.expect("owner is not set"), - position_nft_mint: self - .position_nft_mint - .expect("position_nft_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - payer: self.payer.expect("payer is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_position` CPI accounts. -pub struct CreatePositionCpiAccounts<'a, 'b> { - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// position_nft_mint - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - /// position nft account - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the position. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT mint/token account and transfer for token22 account - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_position` CPI instruction. -pub struct CreatePositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// position_nft_mint - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - /// position nft account - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the position. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT mint/token account and transfer for token22 account - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreatePositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreatePositionCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - position_nft_mint: accounts.position_nft_mint, - position_nft_account: accounts.position_nft_account, - pool: accounts.pool, - position: accounts.position, - pool_authority: accounts.pool_authority, - payer: accounts.payer, - token_program: accounts.token_program, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = CreatePositionInstructionData::new().try_to_vec().unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.position_nft_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreatePosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` owner -/// 1. `[writable, signer]` position_nft_mint -/// 2. `[writable]` position_nft_account -/// 3. `[writable]` pool -/// 4. `[writable]` position -/// 5. `[]` pool_authority -/// 6. `[writable, signer]` payer -/// 7. `[]` token_program -/// 8. `[]` system_program -/// 9. `[]` event_authority -/// 10. `[]` program -#[derive(Clone, Debug)] -pub struct CreatePositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreatePositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreatePositionCpiBuilderInstruction { - __program: program, - owner: None, - position_nft_mint: None, - position_nft_account: None, - pool: None, - position: None, - pool_authority: None, - payer: None, - token_program: None, - system_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// position_nft_mint - #[inline(always)] - pub fn position_nft_mint( - &mut self, - position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_mint = Some(position_nft_mint); - self - } - - /// position nft account - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - /// Address paying to create the position. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Program to create NFT mint/token account and transfer for token22 account - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let instruction = CreatePositionCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - position_nft_mint: self - .instruction - .position_nft_mint - .expect("position_nft_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreatePositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/create_token_badge.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/create_token_badge.rs deleted file mode 100644 index efbe61f2..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/create_token_badge.rs +++ /dev/null @@ -1,473 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CREATE_TOKEN_BADGE_DISCRIMINATOR: [u8; 8] = [88, 206, 0, 91, 60, 175, 151, 118]; - -/// Accounts. -#[derive(Debug)] -pub struct CreateTokenBadge { - pub token_badge: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreateTokenBadge { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.token_badge, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = CreateTokenBadgeInstructionData::new().try_to_vec().unwrap(); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateTokenBadgeInstructionData { - discriminator: [u8; 8], -} - -impl CreateTokenBadgeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [88, 206, 0, 91, 60, 175, 151, 118], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for CreateTokenBadgeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateTokenBadge`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` token_badge -/// 1. `[]` token_mint -/// 2. `[writable, signer]` admin -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreateTokenBadgeBuilder { - token_badge: Option, - token_mint: Option, - admin: Option, - system_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CreateTokenBadgeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn token_badge(&mut self, token_badge: solana_pubkey::Pubkey) -> &mut Self { - self.token_badge = Some(token_badge); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateTokenBadge { - token_badge: self.token_badge.expect("token_badge is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_token_badge` CPI accounts. -pub struct CreateTokenBadgeCpiAccounts<'a, 'b> { - pub token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_token_badge` CPI instruction. -pub struct CreateTokenBadgeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateTokenBadgeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateTokenBadgeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - token_badge: accounts.token_badge, - token_mint: accounts.token_mint, - admin: accounts.admin, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_badge.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = CreateTokenBadgeInstructionData::new().try_to_vec().unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_badge.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateTokenBadge` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` token_badge -/// 1. `[]` token_mint -/// 2. `[writable, signer]` admin -/// 3. `[]` system_program -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug)] -pub struct CreateTokenBadgeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateTokenBadgeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateTokenBadgeCpiBuilderInstruction { - __program: program, - token_badge: None, - token_mint: None, - admin: None, - system_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_badge( - &mut self, - token_badge: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge = Some(token_badge); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let instruction = CreateTokenBadgeCpi { - __program: self.instruction.__program, - - token_badge: self - .instruction - .token_badge - .expect("token_badge is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateTokenBadgeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_badge: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/fund_reward.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/fund_reward.rs deleted file mode 100644 index 112b1264..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/fund_reward.rs +++ /dev/null @@ -1,647 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const FUND_REWARD_DISCRIMINATOR: [u8; 8] = [188, 50, 249, 165, 93, 151, 38, 63]; - -/// Accounts. -#[derive(Debug)] -pub struct FundReward { - pub pool: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub funder_token_account: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl FundReward { - pub fn instruction(&self, args: FundRewardInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: FundRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.funder_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.funder, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = FundRewardInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FundRewardInstructionData { - discriminator: [u8; 8], -} - -impl FundRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [188, 50, 249, 165, 93, 151, 38, 63], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for FundRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FundRewardInstructionArgs { - pub reward_index: u8, - pub amount: u64, - pub carry_forward: bool, -} - -impl FundRewardInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `FundReward`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` reward_vault -/// 2. `[]` reward_mint -/// 3. `[writable]` funder_token_account -/// 4. `[signer]` funder -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 6. `[]` event_authority -/// 7. `[]` program -#[derive(Clone, Debug, Default)] -pub struct FundRewardBuilder { - pool: Option, - reward_vault: Option, - reward_mint: Option, - funder_token_account: Option, - funder: Option, - token_program: Option, - event_authority: Option, - program: Option, - reward_index: Option, - amount: Option, - carry_forward: Option, - __remaining_accounts: Vec, -} - -impl FundRewardBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn carry_forward(&mut self, carry_forward: bool) -> &mut Self { - self.carry_forward = Some(carry_forward); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = FundReward { - pool: self.pool.expect("pool is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - funder_token_account: self - .funder_token_account - .expect("funder_token_account is not set"), - funder: self.funder.expect("funder is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = FundRewardInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - amount: self.amount.clone().expect("amount is not set"), - carry_forward: self - .carry_forward - .clone() - .expect("carry_forward is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `fund_reward` CPI accounts. -pub struct FundRewardCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `fund_reward` CPI instruction. -pub struct FundRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: FundRewardInstructionArgs, -} - -impl<'a, 'b> FundRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: FundRewardCpiAccounts<'a, 'b>, - args: FundRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - reward_vault: accounts.reward_vault, - reward_mint: accounts.reward_mint, - funder_token_account: accounts.funder_token_account, - funder: accounts.funder, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.funder_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.funder.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = FundRewardInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.funder_token_account.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `FundReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` reward_vault -/// 2. `[]` reward_mint -/// 3. `[writable]` funder_token_account -/// 4. `[signer]` funder -/// 5. `[]` token_program -/// 6. `[]` event_authority -/// 7. `[]` program -#[derive(Clone, Debug)] -pub struct FundRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> FundRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(FundRewardCpiBuilderInstruction { - __program: program, - pool: None, - reward_vault: None, - reward_mint: None, - funder_token_account: None, - funder: None, - token_program: None, - event_authority: None, - program: None, - reward_index: None, - amount: None, - carry_forward: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn carry_forward(&mut self, carry_forward: bool) -> &mut Self { - self.instruction.carry_forward = Some(carry_forward); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = FundRewardInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - amount: self.instruction.amount.clone().expect("amount is not set"), - carry_forward: self - .instruction - .carry_forward - .clone() - .expect("carry_forward is not set"), - }; - let instruction = FundRewardCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - funder_token_account: self - .instruction - .funder_token_account - .expect("funder_token_account is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct FundRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - funder_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - amount: Option, - carry_forward: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_customizable_pool.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_customizable_pool.rs deleted file mode 100644 index 80eb3c45..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_customizable_pool.rs +++ /dev/null @@ -1,1085 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::InitializeCustomizablePoolParameters; - -pub const INITIALIZE_CUSTOMIZABLE_POOL_DISCRIMINATOR: [u8; 8] = - [20, 161, 241, 24, 189, 221, 180, 2]; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeCustomizablePool { - pub creator: solana_pubkey::Pubkey, - /// position_nft_mint - pub position_nft_mint: solana_pubkey::Pubkey, - /// position nft account - pub position_nft_account: solana_pubkey::Pubkey, - /// Address paying to create the pool. Can be anyone - pub payer: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - /// Initialize an account to store the pool state - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - /// Token a mint - pub token_a_mint: solana_pubkey::Pubkey, - /// Token b mint - pub token_b_mint: solana_pubkey::Pubkey, - /// Token a vault for the pool - pub token_a_vault: solana_pubkey::Pubkey, - /// Token b vault for the pool - pub token_b_vault: solana_pubkey::Pubkey, - /// payer token a account - pub payer_token_a: solana_pubkey::Pubkey, - /// creator token b account - pub payer_token_b: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_a_program: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_b_program: solana_pubkey::Pubkey, - /// Program to create NFT mint/token account and transfer for token22 account - pub token2022_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeCustomizablePool { - pub fn instruction( - &self, - args: InitializeCustomizablePoolInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeCustomizablePoolInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(19 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = InitializeCustomizablePoolInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeCustomizablePoolInstructionData { - discriminator: [u8; 8], -} - -impl InitializeCustomizablePoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [20, 161, 241, 24, 189, 221, 180, 2], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for InitializeCustomizablePoolInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeCustomizablePoolInstructionArgs { - pub params: InitializeCustomizablePoolParameters, -} - -impl InitializeCustomizablePoolInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `InitializeCustomizablePool`. -/// -/// ### Accounts: -/// -/// 0. `[]` creator -/// 1. `[writable, signer]` position_nft_mint -/// 2. `[writable]` position_nft_account -/// 3. `[writable, signer]` payer -/// 4. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 5. `[writable]` pool -/// 6. `[writable]` position -/// 7. `[]` token_a_mint -/// 8. `[]` token_b_mint -/// 9. `[writable]` token_a_vault -/// 10. `[writable]` token_b_vault -/// 11. `[writable]` payer_token_a -/// 12. `[writable]` payer_token_b -/// 13. `[]` token_a_program -/// 14. `[]` token_b_program -/// 15. `[optional]` token2022_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 16. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 17. `[]` event_authority -/// 18. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeCustomizablePoolBuilder { - creator: Option, - position_nft_mint: Option, - position_nft_account: Option, - payer: Option, - pool_authority: Option, - pool: Option, - position: Option, - token_a_mint: Option, - token_b_mint: Option, - token_a_vault: Option, - token_b_vault: Option, - payer_token_a: Option, - payer_token_b: Option, - token_a_program: Option, - token_b_program: Option, - token2022_program: Option, - system_program: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl InitializeCustomizablePoolBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// position_nft_mint - #[inline(always)] - pub fn position_nft_mint(&mut self, position_nft_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_mint = Some(position_nft_mint); - self - } - - /// position nft account - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - /// Initialize an account to store the pool state - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// Token a mint - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// Token b mint - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// Token a vault for the pool - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// Token b vault for the pool - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// payer token a account - #[inline(always)] - pub fn payer_token_a(&mut self, payer_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_a = Some(payer_token_a); - self - } - - /// creator token b account - #[inline(always)] - pub fn payer_token_b(&mut self, payer_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_b = Some(payer_token_b); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// Program to create NFT mint/token account and transfer for token22 account - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: InitializeCustomizablePoolParameters) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeCustomizablePool { - creator: self.creator.expect("creator is not set"), - position_nft_mint: self - .position_nft_mint - .expect("position_nft_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - payer: self.payer.expect("payer is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - payer_token_a: self.payer_token_a.expect("payer_token_a is not set"), - payer_token_b: self.payer_token_b.expect("payer_token_b is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - token2022_program: self.token2022_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeCustomizablePoolInstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_customizable_pool` CPI accounts. -pub struct InitializeCustomizablePoolCpiAccounts<'a, 'b> { - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// position_nft_mint - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - /// position nft account - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store the pool state - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// Token a mint - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token b mint - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token a vault for the pool - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token b vault for the pool - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// payer token a account - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// creator token b account - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT mint/token account and transfer for token22 account - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_customizable_pool` CPI instruction. -pub struct InitializeCustomizablePoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// position_nft_mint - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - /// position nft account - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store the pool state - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// Token a mint - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token b mint - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token a vault for the pool - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token b vault for the pool - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// payer token a account - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// creator token b account - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT mint/token account and transfer for token22 account - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeCustomizablePoolInstructionArgs, -} - -impl<'a, 'b> InitializeCustomizablePoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCustomizablePoolCpiAccounts<'a, 'b>, - args: InitializeCustomizablePoolInstructionArgs, - ) -> Self { - Self { - __program: program, - creator: accounts.creator, - position_nft_mint: accounts.position_nft_mint, - position_nft_account: accounts.position_nft_account, - payer: accounts.payer, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - position: accounts.position, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - payer_token_a: accounts.payer_token_a, - payer_token_b: accounts.payer_token_b, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - token2022_program: accounts.token2022_program, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(19 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = InitializeCustomizablePoolInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(20 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.position_nft_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.payer_token_a.clone()); - account_infos.push(self.payer_token_b.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - account_infos.push(self.token2022_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeCustomizablePool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` creator -/// 1. `[writable, signer]` position_nft_mint -/// 2. `[writable]` position_nft_account -/// 3. `[writable, signer]` payer -/// 4. `[]` pool_authority -/// 5. `[writable]` pool -/// 6. `[writable]` position -/// 7. `[]` token_a_mint -/// 8. `[]` token_b_mint -/// 9. `[writable]` token_a_vault -/// 10. `[writable]` token_b_vault -/// 11. `[writable]` payer_token_a -/// 12. `[writable]` payer_token_b -/// 13. `[]` token_a_program -/// 14. `[]` token_b_program -/// 15. `[]` token2022_program -/// 16. `[]` system_program -/// 17. `[]` event_authority -/// 18. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeCustomizablePoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeCustomizablePoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCustomizablePoolCpiBuilderInstruction { - __program: program, - creator: None, - position_nft_mint: None, - position_nft_account: None, - payer: None, - pool_authority: None, - pool: None, - position: None, - token_a_mint: None, - token_b_mint: None, - token_a_vault: None, - token_b_vault: None, - payer_token_a: None, - payer_token_b: None, - token_a_program: None, - token_b_program: None, - token2022_program: None, - system_program: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// position_nft_mint - #[inline(always)] - pub fn position_nft_mint( - &mut self, - position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_mint = Some(position_nft_mint); - self - } - - /// position nft account - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - /// Initialize an account to store the pool state - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - /// Token a mint - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// Token b mint - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// Token a vault for the pool - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// Token b vault for the pool - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// payer token a account - #[inline(always)] - pub fn payer_token_a( - &mut self, - payer_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_a = Some(payer_token_a); - self - } - - /// creator token b account - #[inline(always)] - pub fn payer_token_b( - &mut self, - payer_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_b = Some(payer_token_b); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - /// Program to create NFT mint/token account and transfer for token22 account - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: InitializeCustomizablePoolParameters) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = InitializeCustomizablePoolInstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = InitializeCustomizablePoolCpi { - __program: self.instruction.__program, - - creator: self.instruction.creator.expect("creator is not set"), - - position_nft_mint: self - .instruction - .position_nft_mint - .expect("position_nft_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - payer_token_a: self - .instruction - .payer_token_a - .expect("payer_token_a is not set"), - - payer_token_b: self - .instruction - .payer_token_b - .expect("payer_token_b is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCustomizablePoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_pool.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_pool.rs deleted file mode 100644 index d35e2277..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_pool.rs +++ /dev/null @@ -1,1162 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const INITIALIZE_POOL_DISCRIMINATOR: [u8; 8] = [95, 180, 10, 172, 84, 174, 232, 40]; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePool { - pub creator: solana_pubkey::Pubkey, - /// position_nft_mint - pub position_nft_mint: solana_pubkey::Pubkey, - /// position nft account - pub position_nft_account: solana_pubkey::Pubkey, - /// Address paying to create the pool. Can be anyone - pub payer: solana_pubkey::Pubkey, - /// Which config the pool belongs to. - pub config: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - /// Initialize an account to store the pool state - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - /// Token a mint - pub token_a_mint: solana_pubkey::Pubkey, - /// Token b mint - pub token_b_mint: solana_pubkey::Pubkey, - /// Token a vault for the pool - pub token_a_vault: solana_pubkey::Pubkey, - /// Token b vault for the pool - pub token_b_vault: solana_pubkey::Pubkey, - /// payer token a account - pub payer_token_a: solana_pubkey::Pubkey, - /// creator token b account - pub payer_token_b: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_a_program: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_b_program: solana_pubkey::Pubkey, - /// Program to create NFT mint/token account and transfer for token22 account - pub token2022_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializePool { - pub fn instruction( - &self, - args: InitializePoolInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePoolInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(20 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = InitializePoolInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolInstructionData { - discriminator: [u8; 8], -} - -impl InitializePoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [95, 180, 10, 172, 84, 174, 232, 40], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for InitializePoolInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolInstructionArgs { - pub liquidity: u128, - pub sqrt_price: u128, - pub activation_point: Option, -} - -impl InitializePoolInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `InitializePool`. -/// -/// ### Accounts: -/// -/// 0. `[]` creator -/// 1. `[writable, signer]` position_nft_mint -/// 2. `[writable]` position_nft_account -/// 3. `[writable, signer]` payer -/// 4. `[]` config -/// 5. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 6. `[writable]` pool -/// 7. `[writable]` position -/// 8. `[]` token_a_mint -/// 9. `[]` token_b_mint -/// 10. `[writable]` token_a_vault -/// 11. `[writable]` token_b_vault -/// 12. `[writable]` payer_token_a -/// 13. `[writable]` payer_token_b -/// 14. `[]` token_a_program -/// 15. `[]` token_b_program -/// 16. `[optional]` token2022_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 17. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 18. `[]` event_authority -/// 19. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializePoolBuilder { - creator: Option, - position_nft_mint: Option, - position_nft_account: Option, - payer: Option, - config: Option, - pool_authority: Option, - pool: Option, - position: Option, - token_a_mint: Option, - token_b_mint: Option, - token_a_vault: Option, - token_b_vault: Option, - payer_token_a: Option, - payer_token_b: Option, - token_a_program: Option, - token_b_program: Option, - token2022_program: Option, - system_program: Option, - event_authority: Option, - program: Option, - liquidity: Option, - sqrt_price: Option, - activation_point: Option, - __remaining_accounts: Vec, -} - -impl InitializePoolBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// position_nft_mint - #[inline(always)] - pub fn position_nft_mint(&mut self, position_nft_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_mint = Some(position_nft_mint); - self - } - - /// position nft account - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - /// Initialize an account to store the pool state - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// Token a mint - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// Token b mint - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// Token a vault for the pool - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// Token b vault for the pool - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// payer token a account - #[inline(always)] - pub fn payer_token_a(&mut self, payer_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_a = Some(payer_token_a); - self - } - - /// creator token b account - #[inline(always)] - pub fn payer_token_b(&mut self, payer_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_b = Some(payer_token_b); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// Program to create NFT mint/token account and transfer for token22 account - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn sqrt_price(&mut self, sqrt_price: u128) -> &mut Self { - self.sqrt_price = Some(sqrt_price); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn activation_point(&mut self, activation_point: u64) -> &mut Self { - self.activation_point = Some(activation_point); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePool { - creator: self.creator.expect("creator is not set"), - position_nft_mint: self - .position_nft_mint - .expect("position_nft_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - payer: self.payer.expect("payer is not set"), - config: self.config.expect("config is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - payer_token_a: self.payer_token_a.expect("payer_token_a is not set"), - payer_token_b: self.payer_token_b.expect("payer_token_b is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - token2022_program: self.token2022_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializePoolInstructionArgs { - liquidity: self.liquidity.clone().expect("liquidity is not set"), - sqrt_price: self.sqrt_price.clone().expect("sqrt_price is not set"), - activation_point: self.activation_point.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_pool` CPI accounts. -pub struct InitializePoolCpiAccounts<'a, 'b> { - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// position_nft_mint - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - /// position nft account - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store the pool state - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// Token a mint - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token b mint - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token a vault for the pool - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token b vault for the pool - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// payer token a account - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// creator token b account - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT mint/token account and transfer for token22 account - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_pool` CPI instruction. -pub struct InitializePoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// position_nft_mint - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - /// position nft account - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store the pool state - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// Token a mint - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token b mint - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token a vault for the pool - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token b vault for the pool - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// payer token a account - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// creator token b account - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT mint/token account and transfer for token22 account - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePoolInstructionArgs, -} - -impl<'a, 'b> InitializePoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePoolCpiAccounts<'a, 'b>, - args: InitializePoolInstructionArgs, - ) -> Self { - Self { - __program: program, - creator: accounts.creator, - position_nft_mint: accounts.position_nft_mint, - position_nft_account: accounts.position_nft_account, - payer: accounts.payer, - config: accounts.config, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - position: accounts.position, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - payer_token_a: accounts.payer_token_a, - payer_token_b: accounts.payer_token_b, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - token2022_program: accounts.token2022_program, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(20 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = InitializePoolInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(21 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.position_nft_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.payer_token_a.clone()); - account_infos.push(self.payer_token_b.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - account_infos.push(self.token2022_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` creator -/// 1. `[writable, signer]` position_nft_mint -/// 2. `[writable]` position_nft_account -/// 3. `[writable, signer]` payer -/// 4. `[]` config -/// 5. `[]` pool_authority -/// 6. `[writable]` pool -/// 7. `[writable]` position -/// 8. `[]` token_a_mint -/// 9. `[]` token_b_mint -/// 10. `[writable]` token_a_vault -/// 11. `[writable]` token_b_vault -/// 12. `[writable]` payer_token_a -/// 13. `[writable]` payer_token_b -/// 14. `[]` token_a_program -/// 15. `[]` token_b_program -/// 16. `[]` token2022_program -/// 17. `[]` system_program -/// 18. `[]` event_authority -/// 19. `[]` program -#[derive(Clone, Debug)] -pub struct InitializePoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePoolCpiBuilderInstruction { - __program: program, - creator: None, - position_nft_mint: None, - position_nft_account: None, - payer: None, - config: None, - pool_authority: None, - pool: None, - position: None, - token_a_mint: None, - token_b_mint: None, - token_a_vault: None, - token_b_vault: None, - payer_token_a: None, - payer_token_b: None, - token_a_program: None, - token_b_program: None, - token2022_program: None, - system_program: None, - event_authority: None, - program: None, - liquidity: None, - sqrt_price: None, - activation_point: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// position_nft_mint - #[inline(always)] - pub fn position_nft_mint( - &mut self, - position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_mint = Some(position_nft_mint); - self - } - - /// position nft account - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - /// Initialize an account to store the pool state - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - /// Token a mint - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// Token b mint - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// Token a vault for the pool - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// Token b vault for the pool - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// payer token a account - #[inline(always)] - pub fn payer_token_a( - &mut self, - payer_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_a = Some(payer_token_a); - self - } - - /// creator token b account - #[inline(always)] - pub fn payer_token_b( - &mut self, - payer_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_b = Some(payer_token_b); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - /// Program to create NFT mint/token account and transfer for token22 account - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.instruction.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn sqrt_price(&mut self, sqrt_price: u128) -> &mut Self { - self.instruction.sqrt_price = Some(sqrt_price); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn activation_point(&mut self, activation_point: u64) -> &mut Self { - self.instruction.activation_point = Some(activation_point); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = InitializePoolInstructionArgs { - liquidity: self - .instruction - .liquidity - .clone() - .expect("liquidity is not set"), - sqrt_price: self - .instruction - .sqrt_price - .clone() - .expect("sqrt_price is not set"), - activation_point: self.instruction.activation_point.clone(), - }; - let instruction = InitializePoolCpi { - __program: self.instruction.__program, - - creator: self.instruction.creator.expect("creator is not set"), - - position_nft_mint: self - .instruction - .position_nft_mint - .expect("position_nft_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - config: self.instruction.config.expect("config is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - payer_token_a: self - .instruction - .payer_token_a - .expect("payer_token_a is not set"), - - payer_token_b: self - .instruction - .payer_token_b - .expect("payer_token_b is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity: Option, - sqrt_price: Option, - activation_point: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_pool_with_dynamic_config.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_pool_with_dynamic_config.rs deleted file mode 100644 index d3f8d236..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_pool_with_dynamic_config.rs +++ /dev/null @@ -1,1170 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::InitializeCustomizablePoolParameters; - -pub const INITIALIZE_POOL_WITH_DYNAMIC_CONFIG_DISCRIMINATOR: [u8; 8] = - [149, 82, 72, 197, 253, 252, 68, 15]; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePoolWithDynamicConfig { - pub creator: solana_pubkey::Pubkey, - /// position_nft_mint - pub position_nft_mint: solana_pubkey::Pubkey, - /// position nft account - pub position_nft_account: solana_pubkey::Pubkey, - /// Address paying to create the pool. Can be anyone - pub payer: solana_pubkey::Pubkey, - - pub pool_creator_authority: solana_pubkey::Pubkey, - /// Which config the pool belongs to. - pub config: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - /// Initialize an account to store the pool state - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - /// Token a mint - pub token_a_mint: solana_pubkey::Pubkey, - /// Token b mint - pub token_b_mint: solana_pubkey::Pubkey, - /// Token a vault for the pool - pub token_a_vault: solana_pubkey::Pubkey, - /// Token b vault for the pool - pub token_b_vault: solana_pubkey::Pubkey, - /// payer token a account - pub payer_token_a: solana_pubkey::Pubkey, - /// creator token b account - pub payer_token_b: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_a_program: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_b_program: solana_pubkey::Pubkey, - /// Program to create NFT mint/token account and transfer for token22 account - pub token2022_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializePoolWithDynamicConfig { - pub fn instruction( - &self, - args: InitializePoolWithDynamicConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePoolWithDynamicConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(21 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_creator_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = InitializePoolWithDynamicConfigInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolWithDynamicConfigInstructionData { - discriminator: [u8; 8], -} - -impl InitializePoolWithDynamicConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [149, 82, 72, 197, 253, 252, 68, 15], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for InitializePoolWithDynamicConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolWithDynamicConfigInstructionArgs { - pub params: InitializeCustomizablePoolParameters, -} - -impl InitializePoolWithDynamicConfigInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `InitializePoolWithDynamicConfig`. -/// -/// ### Accounts: -/// -/// 0. `[]` creator -/// 1. `[writable, signer]` position_nft_mint -/// 2. `[writable]` position_nft_account -/// 3. `[writable, signer]` payer -/// 4. `[signer]` pool_creator_authority -/// 5. `[]` config -/// 6. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 7. `[writable]` pool -/// 8. `[writable]` position -/// 9. `[]` token_a_mint -/// 10. `[]` token_b_mint -/// 11. `[writable]` token_a_vault -/// 12. `[writable]` token_b_vault -/// 13. `[writable]` payer_token_a -/// 14. `[writable]` payer_token_b -/// 15. `[]` token_a_program -/// 16. `[]` token_b_program -/// 17. `[optional]` token2022_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 18. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 19. `[]` event_authority -/// 20. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializePoolWithDynamicConfigBuilder { - creator: Option, - position_nft_mint: Option, - position_nft_account: Option, - payer: Option, - pool_creator_authority: Option, - config: Option, - pool_authority: Option, - pool: Option, - position: Option, - token_a_mint: Option, - token_b_mint: Option, - token_a_vault: Option, - token_b_vault: Option, - payer_token_a: Option, - payer_token_b: Option, - token_a_program: Option, - token_b_program: Option, - token2022_program: Option, - system_program: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl InitializePoolWithDynamicConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// position_nft_mint - #[inline(always)] - pub fn position_nft_mint(&mut self, position_nft_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_mint = Some(position_nft_mint); - self - } - - /// position nft account - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn pool_creator_authority( - &mut self, - pool_creator_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_creator_authority = Some(pool_creator_authority); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - /// Initialize an account to store the pool state - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// Token a mint - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// Token b mint - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// Token a vault for the pool - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// Token b vault for the pool - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// payer token a account - #[inline(always)] - pub fn payer_token_a(&mut self, payer_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_a = Some(payer_token_a); - self - } - - /// creator token b account - #[inline(always)] - pub fn payer_token_b(&mut self, payer_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_b = Some(payer_token_b); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// Program to create NFT mint/token account and transfer for token22 account - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: InitializeCustomizablePoolParameters) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePoolWithDynamicConfig { - creator: self.creator.expect("creator is not set"), - position_nft_mint: self - .position_nft_mint - .expect("position_nft_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - payer: self.payer.expect("payer is not set"), - pool_creator_authority: self - .pool_creator_authority - .expect("pool_creator_authority is not set"), - config: self.config.expect("config is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - payer_token_a: self.payer_token_a.expect("payer_token_a is not set"), - payer_token_b: self.payer_token_b.expect("payer_token_b is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - token2022_program: self.token2022_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializePoolWithDynamicConfigInstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_pool_with_dynamic_config` CPI accounts. -pub struct InitializePoolWithDynamicConfigCpiAccounts<'a, 'b> { - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// position_nft_mint - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - /// position nft account - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub pool_creator_authority: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store the pool state - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// Token a mint - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token b mint - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token a vault for the pool - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token b vault for the pool - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// payer token a account - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// creator token b account - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT mint/token account and transfer for token22 account - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_pool_with_dynamic_config` CPI instruction. -pub struct InitializePoolWithDynamicConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// position_nft_mint - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - /// position nft account - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub pool_creator_authority: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store the pool state - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// Token a mint - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token b mint - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token a vault for the pool - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token b vault for the pool - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// payer token a account - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// creator token b account - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT mint/token account and transfer for token22 account - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePoolWithDynamicConfigInstructionArgs, -} - -impl<'a, 'b> InitializePoolWithDynamicConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePoolWithDynamicConfigCpiAccounts<'a, 'b>, - args: InitializePoolWithDynamicConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - creator: accounts.creator, - position_nft_mint: accounts.position_nft_mint, - position_nft_account: accounts.position_nft_account, - payer: accounts.payer, - pool_creator_authority: accounts.pool_creator_authority, - config: accounts.config, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - position: accounts.position, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - payer_token_a: accounts.payer_token_a, - payer_token_b: accounts.payer_token_b, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - token2022_program: accounts.token2022_program, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(21 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_creator_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = InitializePoolWithDynamicConfigInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(22 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.position_nft_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.pool_creator_authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.payer_token_a.clone()); - account_infos.push(self.payer_token_b.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - account_infos.push(self.token2022_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePoolWithDynamicConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` creator -/// 1. `[writable, signer]` position_nft_mint -/// 2. `[writable]` position_nft_account -/// 3. `[writable, signer]` payer -/// 4. `[signer]` pool_creator_authority -/// 5. `[]` config -/// 6. `[]` pool_authority -/// 7. `[writable]` pool -/// 8. `[writable]` position -/// 9. `[]` token_a_mint -/// 10. `[]` token_b_mint -/// 11. `[writable]` token_a_vault -/// 12. `[writable]` token_b_vault -/// 13. `[writable]` payer_token_a -/// 14. `[writable]` payer_token_b -/// 15. `[]` token_a_program -/// 16. `[]` token_b_program -/// 17. `[]` token2022_program -/// 18. `[]` system_program -/// 19. `[]` event_authority -/// 20. `[]` program -#[derive(Clone, Debug)] -pub struct InitializePoolWithDynamicConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePoolWithDynamicConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePoolWithDynamicConfigCpiBuilderInstruction { - __program: program, - creator: None, - position_nft_mint: None, - position_nft_account: None, - payer: None, - pool_creator_authority: None, - config: None, - pool_authority: None, - pool: None, - position: None, - token_a_mint: None, - token_b_mint: None, - token_a_vault: None, - token_b_vault: None, - payer_token_a: None, - payer_token_b: None, - token_a_program: None, - token_b_program: None, - token2022_program: None, - system_program: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// position_nft_mint - #[inline(always)] - pub fn position_nft_mint( - &mut self, - position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_mint = Some(position_nft_mint); - self - } - - /// position nft account - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn pool_creator_authority( - &mut self, - pool_creator_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_creator_authority = Some(pool_creator_authority); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - /// Initialize an account to store the pool state - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - /// Token a mint - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// Token b mint - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// Token a vault for the pool - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// Token b vault for the pool - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// payer token a account - #[inline(always)] - pub fn payer_token_a( - &mut self, - payer_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_a = Some(payer_token_a); - self - } - - /// creator token b account - #[inline(always)] - pub fn payer_token_b( - &mut self, - payer_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_b = Some(payer_token_b); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - /// Program to create NFT mint/token account and transfer for token22 account - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: InitializeCustomizablePoolParameters) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = InitializePoolWithDynamicConfigInstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = InitializePoolWithDynamicConfigCpi { - __program: self.instruction.__program, - - creator: self.instruction.creator.expect("creator is not set"), - - position_nft_mint: self - .instruction - .position_nft_mint - .expect("position_nft_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - pool_creator_authority: self - .instruction - .pool_creator_authority - .expect("pool_creator_authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - payer_token_a: self - .instruction - .payer_token_a - .expect("payer_token_a is not set"), - - payer_token_b: self - .instruction - .payer_token_b - .expect("payer_token_b is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePoolWithDynamicConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_creator_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_reward.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_reward.rs deleted file mode 100644 index e7511657..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/initialize_reward.rs +++ /dev/null @@ -1,724 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -pub const INITIALIZE_REWARD_DISCRIMINATOR: [u8; 8] = [95, 135, 192, 196, 242, 129, 230, 68]; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeReward { - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub signer: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeReward { - pub fn instruction( - &self, - args: InitializeRewardInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.signer, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = InitializeRewardInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeRewardInstructionData { - discriminator: [u8; 8], -} - -impl InitializeRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [95, 135, 192, 196, 242, 129, 230, 68], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for InitializeRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeRewardInstructionArgs { - pub reward_index: u8, - pub reward_duration: u64, - pub funder: Pubkey, -} - -impl InitializeRewardInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `InitializeReward`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 1. `[writable]` pool -/// 2. `[writable]` reward_vault -/// 3. `[]` reward_mint -/// 4. `[signer]` signer -/// 5. `[writable, signer]` payer -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeRewardBuilder { - pool_authority: Option, - pool: Option, - reward_vault: Option, - reward_mint: Option, - signer: Option, - payer: Option, - token_program: Option, - system_program: Option, - event_authority: Option, - program: Option, - reward_index: Option, - reward_duration: Option, - funder: Option, - __remaining_accounts: Vec, -} - -impl InitializeRewardBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn signer(&mut self, signer: solana_pubkey::Pubkey) -> &mut Self { - self.signer = Some(signer); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn reward_duration(&mut self, reward_duration: u64) -> &mut Self { - self.reward_duration = Some(reward_duration); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeReward { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - signer: self.signer.expect("signer is not set"), - payer: self.payer.expect("payer is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeRewardInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - reward_duration: self - .reward_duration - .clone() - .expect("reward_duration is not set"), - funder: self.funder.clone().expect("funder is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_reward` CPI accounts. -pub struct InitializeRewardCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub signer: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_reward` CPI instruction. -pub struct InitializeRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub signer: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeRewardInstructionArgs, -} - -impl<'a, 'b> InitializeRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeRewardCpiAccounts<'a, 'b>, - args: InitializeRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - reward_vault: accounts.reward_vault, - reward_mint: accounts.reward_mint, - signer: accounts.signer, - payer: accounts.payer, - token_program: accounts.token_program, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.signer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = InitializeRewardInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.signer.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[writable]` pool -/// 2. `[writable]` reward_vault -/// 3. `[]` reward_mint -/// 4. `[signer]` signer -/// 5. `[writable, signer]` payer -/// 6. `[]` token_program -/// 7. `[]` system_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeRewardCpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - reward_vault: None, - reward_mint: None, - signer: None, - payer: None, - token_program: None, - system_program: None, - event_authority: None, - program: None, - reward_index: None, - reward_duration: None, - funder: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn signer(&mut self, signer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.signer = Some(signer); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn reward_duration(&mut self, reward_duration: u64) -> &mut Self { - self.instruction.reward_duration = Some(reward_duration); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: Pubkey) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = InitializeRewardInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - reward_duration: self - .instruction - .reward_duration - .clone() - .expect("reward_duration is not set"), - funder: self.instruction.funder.clone().expect("funder is not set"), - }; - let instruction = InitializeRewardCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - signer: self.instruction.signer.expect("signer is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - signer: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - reward_duration: Option, - funder: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/lock_position.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/lock_position.rs deleted file mode 100644 index edf2bb85..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/lock_position.rs +++ /dev/null @@ -1,725 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const LOCK_POSITION_DISCRIMINATOR: [u8; 8] = [227, 62, 2, 252, 247, 10, 171, 185]; - -/// Accounts. -#[derive(Debug)] -pub struct LockPosition { - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub vesting: solana_pubkey::Pubkey, - /// The token account for nft - pub position_nft_account: solana_pubkey::Pubkey, - /// owner of position - pub owner: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl LockPosition { - pub fn instruction( - &self, - args: LockPositionInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: LockPositionInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.vesting, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = LockPositionInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockPositionInstructionData { - discriminator: [u8; 8], -} - -impl LockPositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [227, 62, 2, 252, 247, 10, 171, 185], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for LockPositionInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockPositionInstructionArgs { - pub cliff_point: Option, - pub period_frequency: u64, - pub cliff_unlock_liquidity: u128, - pub liquidity_per_period: u128, - pub number_of_period: u16, -} - -impl LockPositionInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `LockPosition`. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[writable]` position -/// 2. `[writable, signer]` vesting -/// 3. `[]` position_nft_account -/// 4. `[signer]` owner -/// 5. `[writable, signer]` payer -/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug, Default)] -pub struct LockPositionBuilder { - pool: Option, - position: Option, - vesting: Option, - position_nft_account: Option, - owner: Option, - payer: Option, - system_program: Option, - event_authority: Option, - program: Option, - cliff_point: Option, - period_frequency: Option, - cliff_unlock_liquidity: Option, - liquidity_per_period: Option, - number_of_period: Option, - __remaining_accounts: Vec, -} - -impl LockPositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn vesting(&mut self, vesting: solana_pubkey::Pubkey) -> &mut Self { - self.vesting = Some(vesting); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn cliff_point(&mut self, cliff_point: u64) -> &mut Self { - self.cliff_point = Some(cliff_point); - self - } - - #[inline(always)] - pub fn period_frequency(&mut self, period_frequency: u64) -> &mut Self { - self.period_frequency = Some(period_frequency); - self - } - - #[inline(always)] - pub fn cliff_unlock_liquidity(&mut self, cliff_unlock_liquidity: u128) -> &mut Self { - self.cliff_unlock_liquidity = Some(cliff_unlock_liquidity); - self - } - - #[inline(always)] - pub fn liquidity_per_period(&mut self, liquidity_per_period: u128) -> &mut Self { - self.liquidity_per_period = Some(liquidity_per_period); - self - } - - #[inline(always)] - pub fn number_of_period(&mut self, number_of_period: u16) -> &mut Self { - self.number_of_period = Some(number_of_period); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = LockPosition { - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - vesting: self.vesting.expect("vesting is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - owner: self.owner.expect("owner is not set"), - payer: self.payer.expect("payer is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = LockPositionInstructionArgs { - cliff_point: self.cliff_point.clone(), - period_frequency: self - .period_frequency - .clone() - .expect("period_frequency is not set"), - cliff_unlock_liquidity: self - .cliff_unlock_liquidity - .clone() - .expect("cliff_unlock_liquidity is not set"), - liquidity_per_period: self - .liquidity_per_period - .clone() - .expect("liquidity_per_period is not set"), - number_of_period: self - .number_of_period - .clone() - .expect("number_of_period is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `lock_position` CPI accounts. -pub struct LockPositionCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub vesting: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `lock_position` CPI instruction. -pub struct LockPositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub vesting: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: LockPositionInstructionArgs, -} - -impl<'a, 'b> LockPositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: LockPositionCpiAccounts<'a, 'b>, - args: LockPositionInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - position: accounts.position, - vesting: accounts.vesting, - position_nft_account: accounts.position_nft_account, - owner: accounts.owner, - payer: accounts.payer, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vesting.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = LockPositionInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.vesting.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `LockPosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[writable]` position -/// 2. `[writable, signer]` vesting -/// 3. `[]` position_nft_account -/// 4. `[signer]` owner -/// 5. `[writable, signer]` payer -/// 6. `[]` system_program -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug)] -pub struct LockPositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> LockPositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(LockPositionCpiBuilderInstruction { - __program: program, - pool: None, - position: None, - vesting: None, - position_nft_account: None, - owner: None, - payer: None, - system_program: None, - event_authority: None, - program: None, - cliff_point: None, - period_frequency: None, - cliff_unlock_liquidity: None, - liquidity_per_period: None, - number_of_period: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn vesting(&mut self, vesting: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vesting = Some(vesting); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn cliff_point(&mut self, cliff_point: u64) -> &mut Self { - self.instruction.cliff_point = Some(cliff_point); - self - } - - #[inline(always)] - pub fn period_frequency(&mut self, period_frequency: u64) -> &mut Self { - self.instruction.period_frequency = Some(period_frequency); - self - } - - #[inline(always)] - pub fn cliff_unlock_liquidity(&mut self, cliff_unlock_liquidity: u128) -> &mut Self { - self.instruction.cliff_unlock_liquidity = Some(cliff_unlock_liquidity); - self - } - - #[inline(always)] - pub fn liquidity_per_period(&mut self, liquidity_per_period: u128) -> &mut Self { - self.instruction.liquidity_per_period = Some(liquidity_per_period); - self - } - - #[inline(always)] - pub fn number_of_period(&mut self, number_of_period: u16) -> &mut Self { - self.instruction.number_of_period = Some(number_of_period); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = LockPositionInstructionArgs { - cliff_point: self.instruction.cliff_point.clone(), - period_frequency: self - .instruction - .period_frequency - .clone() - .expect("period_frequency is not set"), - cliff_unlock_liquidity: self - .instruction - .cliff_unlock_liquidity - .clone() - .expect("cliff_unlock_liquidity is not set"), - liquidity_per_period: self - .instruction - .liquidity_per_period - .clone() - .expect("liquidity_per_period is not set"), - number_of_period: self - .instruction - .number_of_period - .clone() - .expect("number_of_period is not set"), - }; - let instruction = LockPositionCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - vesting: self.instruction.vesting.expect("vesting is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct LockPositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - vesting: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - cliff_point: Option, - period_frequency: Option, - cliff_unlock_liquidity: Option, - liquidity_per_period: Option, - number_of_period: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/mod.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index 4afb264e..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,52 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#add_liquidity; -pub(crate) mod r#claim_partner_fee; -pub(crate) mod r#claim_position_fee; -pub(crate) mod r#claim_protocol_fee; -pub(crate) mod r#claim_reward; -pub(crate) mod r#close_claim_fee_operator; -pub(crate) mod r#close_config; -pub(crate) mod r#close_position; -pub(crate) mod r#close_token_badge; -pub(crate) mod r#create_claim_fee_operator; -pub(crate) mod r#create_config; -pub(crate) mod r#create_dynamic_config; -pub(crate) mod r#create_position; -pub(crate) mod r#create_token_badge; -pub(crate) mod r#fund_reward; -pub(crate) mod r#initialize_customizable_pool; -pub(crate) mod r#initialize_pool; -pub(crate) mod r#initialize_pool_with_dynamic_config; -pub(crate) mod r#initialize_reward; -pub(crate) mod r#lock_position; -pub(crate) mod r#permanent_lock_position; -pub(crate) mod r#refresh_vesting; -pub(crate) mod r#remove_all_liquidity; -pub(crate) mod r#remove_liquidity; -pub(crate) mod r#set_pool_status; -pub(crate) mod r#split_position; -pub(crate) mod r#split_position2; -pub(crate) mod r#swap; -pub(crate) mod r#swap2; -pub(crate) mod r#update_reward_duration; -pub(crate) mod r#update_reward_funder; -pub(crate) mod r#withdraw_ineligible_reward; - -pub use self::{ - r#add_liquidity::*, r#claim_partner_fee::*, r#claim_position_fee::*, r#claim_protocol_fee::*, - r#claim_reward::*, r#close_claim_fee_operator::*, r#close_config::*, r#close_position::*, - r#close_token_badge::*, r#create_claim_fee_operator::*, r#create_config::*, - r#create_dynamic_config::*, r#create_position::*, r#create_token_badge::*, r#fund_reward::*, - r#initialize_customizable_pool::*, r#initialize_pool::*, - r#initialize_pool_with_dynamic_config::*, r#initialize_reward::*, r#lock_position::*, - r#permanent_lock_position::*, r#refresh_vesting::*, r#remove_all_liquidity::*, - r#remove_liquidity::*, r#set_pool_status::*, r#split_position::*, r#split_position2::*, - r#swap::*, r#swap2::*, r#update_reward_duration::*, r#update_reward_funder::*, - r#withdraw_ineligible_reward::*, -}; diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/permanent_lock_position.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/permanent_lock_position.rs deleted file mode 100644 index 2cb7c26b..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/permanent_lock_position.rs +++ /dev/null @@ -1,521 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const PERMANENT_LOCK_POSITION_DISCRIMINATOR: [u8; 8] = [165, 176, 125, 6, 231, 171, 186, 213]; - -/// Accounts. -#[derive(Debug)] -pub struct PermanentLockPosition { - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - /// The token account for nft - pub position_nft_account: solana_pubkey::Pubkey, - /// owner of position - pub owner: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl PermanentLockPosition { - pub fn instruction( - &self, - args: PermanentLockPositionInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: PermanentLockPositionInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = PermanentLockPositionInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PermanentLockPositionInstructionData { - discriminator: [u8; 8], -} - -impl PermanentLockPositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [165, 176, 125, 6, 231, 171, 186, 213], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for PermanentLockPositionInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PermanentLockPositionInstructionArgs { - pub permanent_lock_liquidity: u128, -} - -impl PermanentLockPositionInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `PermanentLockPosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` position -/// 2. `[]` position_nft_account -/// 3. `[signer]` owner -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug, Default)] -pub struct PermanentLockPositionBuilder { - pool: Option, - position: Option, - position_nft_account: Option, - owner: Option, - event_authority: Option, - program: Option, - permanent_lock_liquidity: Option, - __remaining_accounts: Vec, -} - -impl PermanentLockPositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn permanent_lock_liquidity(&mut self, permanent_lock_liquidity: u128) -> &mut Self { - self.permanent_lock_liquidity = Some(permanent_lock_liquidity); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = PermanentLockPosition { - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - owner: self.owner.expect("owner is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = PermanentLockPositionInstructionArgs { - permanent_lock_liquidity: self - .permanent_lock_liquidity - .clone() - .expect("permanent_lock_liquidity is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `permanent_lock_position` CPI accounts. -pub struct PermanentLockPositionCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `permanent_lock_position` CPI instruction. -pub struct PermanentLockPositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: PermanentLockPositionInstructionArgs, -} - -impl<'a, 'b> PermanentLockPositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: PermanentLockPositionCpiAccounts<'a, 'b>, - args: PermanentLockPositionInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - position: accounts.position, - position_nft_account: accounts.position_nft_account, - owner: accounts.owner, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = PermanentLockPositionInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `PermanentLockPosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` position -/// 2. `[]` position_nft_account -/// 3. `[signer]` owner -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug)] -pub struct PermanentLockPositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> PermanentLockPositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(PermanentLockPositionCpiBuilderInstruction { - __program: program, - pool: None, - position: None, - position_nft_account: None, - owner: None, - event_authority: None, - program: None, - permanent_lock_liquidity: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn permanent_lock_liquidity(&mut self, permanent_lock_liquidity: u128) -> &mut Self { - self.instruction.permanent_lock_liquidity = Some(permanent_lock_liquidity); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = PermanentLockPositionInstructionArgs { - permanent_lock_liquidity: self - .instruction - .permanent_lock_liquidity - .clone() - .expect("permanent_lock_liquidity is not set"), - }; - let instruction = PermanentLockPositionCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct PermanentLockPositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - permanent_lock_liquidity: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/refresh_vesting.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/refresh_vesting.rs deleted file mode 100644 index 2b8aafb7..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/refresh_vesting.rs +++ /dev/null @@ -1,391 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const REFRESH_VESTING_DISCRIMINATOR: [u8; 8] = [9, 94, 216, 14, 116, 204, 247, 0]; - -/// Accounts. -#[derive(Debug)] -pub struct RefreshVesting { - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - /// The token account for nft - pub position_nft_account: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, -} - -impl RefreshVesting { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = RefreshVestingInstructionData::new().try_to_vec().unwrap(); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RefreshVestingInstructionData { - discriminator: [u8; 8], -} - -impl RefreshVestingInstructionData { - pub fn new() -> Self { - Self { - discriminator: [9, 94, 216, 14, 116, 204, 247, 0], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for RefreshVestingInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `RefreshVesting`. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[writable]` position -/// 2. `[]` position_nft_account -/// 3. `[]` owner -#[derive(Clone, Debug, Default)] -pub struct RefreshVestingBuilder { - pool: Option, - position: Option, - position_nft_account: Option, - owner: Option, - __remaining_accounts: Vec, -} - -impl RefreshVestingBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RefreshVesting { - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - owner: self.owner.expect("owner is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `refresh_vesting` CPI accounts. -pub struct RefreshVestingCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, -} - -/// `refresh_vesting` CPI instruction. -pub struct RefreshVestingCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> RefreshVestingCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RefreshVestingCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - position: accounts.position, - position_nft_account: accounts.position_nft_account, - owner: accounts.owner, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = RefreshVestingInstructionData::new().try_to_vec().unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.owner.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RefreshVesting` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[writable]` position -/// 2. `[]` position_nft_account -/// 3. `[]` owner -#[derive(Clone, Debug)] -pub struct RefreshVestingCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RefreshVestingCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RefreshVestingCpiBuilderInstruction { - __program: program, - pool: None, - position: None, - position_nft_account: None, - owner: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let instruction = RefreshVestingCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RefreshVestingCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/remove_all_liquidity.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/remove_all_liquidity.rs deleted file mode 100644 index ab993959..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/remove_all_liquidity.rs +++ /dev/null @@ -1,943 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const REMOVE_ALL_LIQUIDITY_DISCRIMINATOR: [u8; 8] = [10, 51, 61, 35, 112, 105, 24, 85]; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveAllLiquidity { - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - /// The user token a account - pub token_a_account: solana_pubkey::Pubkey, - /// The user token b account - pub token_b_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub token_a_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub token_b_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub token_a_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub token_b_mint: solana_pubkey::Pubkey, - /// The token account for nft - pub position_nft_account: solana_pubkey::Pubkey, - /// owner of position - pub owner: solana_pubkey::Pubkey, - /// Token a program - pub token_a_program: solana_pubkey::Pubkey, - /// Token b program - pub token_b_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl RemoveAllLiquidity { - pub fn instruction( - &self, - args: RemoveAllLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemoveAllLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = RemoveAllLiquidityInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveAllLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl RemoveAllLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [10, 51, 61, 35, 112, 105, 24, 85], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for RemoveAllLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveAllLiquidityInstructionArgs { - pub token_a_amount_threshold: u64, - pub token_b_amount_threshold: u64, -} - -impl RemoveAllLiquidityInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `RemoveAllLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 1. `[writable]` pool -/// 2. `[writable]` position -/// 3. `[writable]` token_a_account -/// 4. `[writable]` token_b_account -/// 5. `[writable]` token_a_vault -/// 6. `[writable]` token_b_vault -/// 7. `[]` token_a_mint -/// 8. `[]` token_b_mint -/// 9. `[]` position_nft_account -/// 10. `[signer]` owner -/// 11. `[]` token_a_program -/// 12. `[]` token_b_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct RemoveAllLiquidityBuilder { - pool_authority: Option, - pool: Option, - position: Option, - token_a_account: Option, - token_b_account: Option, - token_a_vault: Option, - token_b_vault: Option, - token_a_mint: Option, - token_b_mint: Option, - position_nft_account: Option, - owner: Option, - token_a_program: Option, - token_b_program: Option, - event_authority: Option, - program: Option, - token_a_amount_threshold: Option, - token_b_amount_threshold: Option, - __remaining_accounts: Vec, -} - -impl RemoveAllLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// The user token a account - #[inline(always)] - pub fn token_a_account(&mut self, token_a_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_account = Some(token_a_account); - self - } - - /// The user token b account - #[inline(always)] - pub fn token_b_account(&mut self, token_b_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn token_a_amount_threshold(&mut self, token_a_amount_threshold: u64) -> &mut Self { - self.token_a_amount_threshold = Some(token_a_amount_threshold); - self - } - - #[inline(always)] - pub fn token_b_amount_threshold(&mut self, token_b_amount_threshold: u64) -> &mut Self { - self.token_b_amount_threshold = Some(token_b_amount_threshold); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveAllLiquidity { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - token_a_account: self.token_a_account.expect("token_a_account is not set"), - token_b_account: self.token_b_account.expect("token_b_account is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - owner: self.owner.expect("owner is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = RemoveAllLiquidityInstructionArgs { - token_a_amount_threshold: self - .token_a_amount_threshold - .clone() - .expect("token_a_amount_threshold is not set"), - token_b_amount_threshold: self - .token_b_amount_threshold - .clone() - .expect("token_b_amount_threshold is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_all_liquidity` CPI accounts. -pub struct RemoveAllLiquidityCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The user token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_all_liquidity` CPI instruction. -pub struct RemoveAllLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The user token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemoveAllLiquidityInstructionArgs, -} - -impl<'a, 'b> RemoveAllLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveAllLiquidityCpiAccounts<'a, 'b>, - args: RemoveAllLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - position: accounts.position, - token_a_account: accounts.token_a_account, - token_b_account: accounts.token_b_account, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - position_nft_account: accounts.position_nft_account, - owner: accounts.owner, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = RemoveAllLiquidityInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.token_a_account.clone()); - account_infos.push(self.token_b_account.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveAllLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[writable]` pool -/// 2. `[writable]` position -/// 3. `[writable]` token_a_account -/// 4. `[writable]` token_b_account -/// 5. `[writable]` token_a_vault -/// 6. `[writable]` token_b_vault -/// 7. `[]` token_a_mint -/// 8. `[]` token_b_mint -/// 9. `[]` position_nft_account -/// 10. `[signer]` owner -/// 11. `[]` token_a_program -/// 12. `[]` token_b_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct RemoveAllLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveAllLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveAllLiquidityCpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - position: None, - token_a_account: None, - token_b_account: None, - token_a_vault: None, - token_b_vault: None, - token_a_mint: None, - token_b_mint: None, - position_nft_account: None, - owner: None, - token_a_program: None, - token_b_program: None, - event_authority: None, - program: None, - token_a_amount_threshold: None, - token_b_amount_threshold: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - /// The user token a account - #[inline(always)] - pub fn token_a_account( - &mut self, - token_a_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_account = Some(token_a_account); - self - } - - /// The user token b account - #[inline(always)] - pub fn token_b_account( - &mut self, - token_b_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn token_a_amount_threshold(&mut self, token_a_amount_threshold: u64) -> &mut Self { - self.instruction.token_a_amount_threshold = Some(token_a_amount_threshold); - self - } - - #[inline(always)] - pub fn token_b_amount_threshold(&mut self, token_b_amount_threshold: u64) -> &mut Self { - self.instruction.token_b_amount_threshold = Some(token_b_amount_threshold); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = RemoveAllLiquidityInstructionArgs { - token_a_amount_threshold: self - .instruction - .token_a_amount_threshold - .clone() - .expect("token_a_amount_threshold is not set"), - token_b_amount_threshold: self - .instruction - .token_b_amount_threshold - .clone() - .expect("token_b_amount_threshold is not set"), - }; - let instruction = RemoveAllLiquidityCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - token_a_account: self - .instruction - .token_a_account - .expect("token_a_account is not set"), - - token_b_account: self - .instruction - .token_b_account - .expect("token_b_account is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveAllLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_amount_threshold: Option, - token_b_amount_threshold: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/remove_liquidity.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/remove_liquidity.rs deleted file mode 100644 index 91233902..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/remove_liquidity.rs +++ /dev/null @@ -1,909 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemoveLiquidityParameters; - -pub const REMOVE_LIQUIDITY_DISCRIMINATOR: [u8; 8] = [80, 85, 209, 72, 24, 206, 177, 108]; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveLiquidity { - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - /// The user token a account - pub token_a_account: solana_pubkey::Pubkey, - /// The user token b account - pub token_b_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub token_a_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub token_b_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub token_a_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub token_b_mint: solana_pubkey::Pubkey, - /// The token account for nft - pub position_nft_account: solana_pubkey::Pubkey, - /// owner of position - pub owner: solana_pubkey::Pubkey, - /// Token a program - pub token_a_program: solana_pubkey::Pubkey, - /// Token b program - pub token_b_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl RemoveLiquidity { - pub fn instruction( - &self, - args: RemoveLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemoveLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = RemoveLiquidityInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl RemoveLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [80, 85, 209, 72, 24, 206, 177, 108], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for RemoveLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidityInstructionArgs { - pub params: RemoveLiquidityParameters, -} - -impl RemoveLiquidityInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `RemoveLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 1. `[writable]` pool -/// 2. `[writable]` position -/// 3. `[writable]` token_a_account -/// 4. `[writable]` token_b_account -/// 5. `[writable]` token_a_vault -/// 6. `[writable]` token_b_vault -/// 7. `[]` token_a_mint -/// 8. `[]` token_b_mint -/// 9. `[]` position_nft_account -/// 10. `[signer]` owner -/// 11. `[]` token_a_program -/// 12. `[]` token_b_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct RemoveLiquidityBuilder { - pool_authority: Option, - pool: Option, - position: Option, - token_a_account: Option, - token_b_account: Option, - token_a_vault: Option, - token_b_vault: Option, - token_a_mint: Option, - token_b_mint: Option, - position_nft_account: Option, - owner: Option, - token_a_program: Option, - token_b_program: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl RemoveLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - /// The user token a account - #[inline(always)] - pub fn token_a_account(&mut self, token_a_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_account = Some(token_a_account); - self - } - - /// The user token b account - #[inline(always)] - pub fn token_b_account(&mut self, token_b_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: RemoveLiquidityParameters) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveLiquidity { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - position: self.position.expect("position is not set"), - token_a_account: self.token_a_account.expect("token_a_account is not set"), - token_b_account: self.token_b_account.expect("token_b_account is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - owner: self.owner.expect("owner is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = RemoveLiquidityInstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_liquidity` CPI accounts. -pub struct RemoveLiquidityCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The user token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_liquidity` CPI instruction. -pub struct RemoveLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - /// The user token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The token account for nft - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// owner of position - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemoveLiquidityInstructionArgs, -} - -impl<'a, 'b> RemoveLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveLiquidityCpiAccounts<'a, 'b>, - args: RemoveLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - position: accounts.position, - token_a_account: accounts.token_a_account, - token_b_account: accounts.token_b_account, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - position_nft_account: accounts.position_nft_account, - owner: accounts.owner, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = RemoveLiquidityInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.token_a_account.clone()); - account_infos.push(self.token_b_account.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[writable]` pool -/// 2. `[writable]` position -/// 3. `[writable]` token_a_account -/// 4. `[writable]` token_b_account -/// 5. `[writable]` token_a_vault -/// 6. `[writable]` token_b_vault -/// 7. `[]` token_a_mint -/// 8. `[]` token_b_mint -/// 9. `[]` position_nft_account -/// 10. `[signer]` owner -/// 11. `[]` token_a_program -/// 12. `[]` token_b_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct RemoveLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveLiquidityCpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - position: None, - token_a_account: None, - token_b_account: None, - token_a_vault: None, - token_b_vault: None, - token_a_mint: None, - token_b_mint: None, - position_nft_account: None, - owner: None, - token_a_program: None, - token_b_program: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - /// The user token a account - #[inline(always)] - pub fn token_a_account( - &mut self, - token_a_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_account = Some(token_a_account); - self - } - - /// The user token b account - #[inline(always)] - pub fn token_b_account( - &mut self, - token_b_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// The token account for nft - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - /// owner of position - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: RemoveLiquidityParameters) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = RemoveLiquidityInstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = RemoveLiquidityCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - position: self.instruction.position.expect("position is not set"), - - token_a_account: self - .instruction - .token_a_account - .expect("token_a_account is not set"), - - token_b_account: self - .instruction - .token_b_account - .expect("token_b_account is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/set_pool_status.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/set_pool_status.rs deleted file mode 100644 index 690c8fda..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/set_pool_status.rs +++ /dev/null @@ -1,426 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const SET_POOL_STATUS_DISCRIMINATOR: [u8; 8] = [112, 87, 135, 223, 83, 204, 132, 53]; - -/// Accounts. -#[derive(Debug)] -pub struct SetPoolStatus { - pub pool: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SetPoolStatus { - pub fn instruction( - &self, - args: SetPoolStatusInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetPoolStatusInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = SetPoolStatusInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPoolStatusInstructionData { - discriminator: [u8; 8], -} - -impl SetPoolStatusInstructionData { - pub fn new() -> Self { - Self { - discriminator: [112, 87, 135, 223, 83, 204, 132, 53], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for SetPoolStatusInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPoolStatusInstructionArgs { - pub status: u8, -} - -impl SetPoolStatusInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `SetPoolStatus`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` admin -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SetPoolStatusBuilder { - pool: Option, - admin: Option, - event_authority: Option, - program: Option, - status: Option, - __remaining_accounts: Vec, -} - -impl SetPoolStatusBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn status(&mut self, status: u8) -> &mut Self { - self.status = Some(status); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetPoolStatus { - pool: self.pool.expect("pool is not set"), - admin: self.admin.expect("admin is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SetPoolStatusInstructionArgs { - status: self.status.clone().expect("status is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_pool_status` CPI accounts. -pub struct SetPoolStatusCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_pool_status` CPI instruction. -pub struct SetPoolStatusCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetPoolStatusInstructionArgs, -} - -impl<'a, 'b> SetPoolStatusCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetPoolStatusCpiAccounts<'a, 'b>, - args: SetPoolStatusInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - admin: accounts.admin, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = SetPoolStatusInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetPoolStatus` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` admin -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug)] -pub struct SetPoolStatusCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetPoolStatusCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetPoolStatusCpiBuilderInstruction { - __program: program, - pool: None, - admin: None, - event_authority: None, - program: None, - status: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn status(&mut self, status: u8) -> &mut Self { - self.instruction.status = Some(status); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = SetPoolStatusInstructionArgs { - status: self.instruction.status.clone().expect("status is not set"), - }; - let instruction = SetPoolStatusCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetPoolStatusCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - status: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/split_position.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/split_position.rs deleted file mode 100644 index 16dc926b..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/split_position.rs +++ /dev/null @@ -1,832 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const SPLIT_POSITION_DISCRIMINATOR: [u8; 8] = [172, 241, 221, 138, 161, 29, 253, 42]; - -/// Accounts. -#[derive(Debug)] -pub struct SplitPosition { - pub pool: solana_pubkey::Pubkey, - /// The first position - pub first_position: solana_pubkey::Pubkey, - /// The token account for position nft - pub first_position_nft_account: solana_pubkey::Pubkey, - /// The second position - pub second_position: solana_pubkey::Pubkey, - /// The token account for position nft - pub second_position_nft_account: solana_pubkey::Pubkey, - /// Owner of first position - pub first_owner: solana_pubkey::Pubkey, - /// Owner of second position - pub second_owner: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SplitPosition { - pub fn instruction( - &self, - args: SplitPositionInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SplitPositionInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.first_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.first_position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.second_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.second_position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.first_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.second_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = SplitPositionInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SplitPositionInstructionData { - discriminator: [u8; 8], -} - -impl SplitPositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [172, 241, 221, 138, 161, 29, 253, 42], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for SplitPositionInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SplitPositionInstructionArgs { - pub unlocked_liquidity_percentage: u8, - pub permanent_locked_liquidity_percentage: u8, - pub fee_a_percentage: u8, - pub fee_b_percentage: u8, - pub reward0_percentage: u8, - pub reward1_percentage: u8, - pub padding: [u8; 16], -} - -impl SplitPositionInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `SplitPosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` first_position -/// 2. `[]` first_position_nft_account -/// 3. `[writable]` second_position -/// 4. `[]` second_position_nft_account -/// 5. `[signer]` first_owner -/// 6. `[signer]` second_owner -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SplitPositionBuilder { - pool: Option, - first_position: Option, - first_position_nft_account: Option, - second_position: Option, - second_position_nft_account: Option, - first_owner: Option, - second_owner: Option, - event_authority: Option, - program: Option, - unlocked_liquidity_percentage: Option, - permanent_locked_liquidity_percentage: Option, - fee_a_percentage: Option, - fee_b_percentage: Option, - reward0_percentage: Option, - reward1_percentage: Option, - padding: Option<[u8; 16]>, - __remaining_accounts: Vec, -} - -impl SplitPositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// The first position - #[inline(always)] - pub fn first_position(&mut self, first_position: solana_pubkey::Pubkey) -> &mut Self { - self.first_position = Some(first_position); - self - } - - /// The token account for position nft - #[inline(always)] - pub fn first_position_nft_account( - &mut self, - first_position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.first_position_nft_account = Some(first_position_nft_account); - self - } - - /// The second position - #[inline(always)] - pub fn second_position(&mut self, second_position: solana_pubkey::Pubkey) -> &mut Self { - self.second_position = Some(second_position); - self - } - - /// The token account for position nft - #[inline(always)] - pub fn second_position_nft_account( - &mut self, - second_position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.second_position_nft_account = Some(second_position_nft_account); - self - } - - /// Owner of first position - #[inline(always)] - pub fn first_owner(&mut self, first_owner: solana_pubkey::Pubkey) -> &mut Self { - self.first_owner = Some(first_owner); - self - } - - /// Owner of second position - #[inline(always)] - pub fn second_owner(&mut self, second_owner: solana_pubkey::Pubkey) -> &mut Self { - self.second_owner = Some(second_owner); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn unlocked_liquidity_percentage( - &mut self, - unlocked_liquidity_percentage: u8, - ) -> &mut Self { - self.unlocked_liquidity_percentage = Some(unlocked_liquidity_percentage); - self - } - - #[inline(always)] - pub fn permanent_locked_liquidity_percentage( - &mut self, - permanent_locked_liquidity_percentage: u8, - ) -> &mut Self { - self.permanent_locked_liquidity_percentage = Some(permanent_locked_liquidity_percentage); - self - } - - #[inline(always)] - pub fn fee_a_percentage(&mut self, fee_a_percentage: u8) -> &mut Self { - self.fee_a_percentage = Some(fee_a_percentage); - self - } - - #[inline(always)] - pub fn fee_b_percentage(&mut self, fee_b_percentage: u8) -> &mut Self { - self.fee_b_percentage = Some(fee_b_percentage); - self - } - - #[inline(always)] - pub fn reward0_percentage(&mut self, reward0_percentage: u8) -> &mut Self { - self.reward0_percentage = Some(reward0_percentage); - self - } - - #[inline(always)] - pub fn reward1_percentage(&mut self, reward1_percentage: u8) -> &mut Self { - self.reward1_percentage = Some(reward1_percentage); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 16]) -> &mut Self { - self.padding = Some(padding); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SplitPosition { - pool: self.pool.expect("pool is not set"), - first_position: self.first_position.expect("first_position is not set"), - first_position_nft_account: self - .first_position_nft_account - .expect("first_position_nft_account is not set"), - second_position: self.second_position.expect("second_position is not set"), - second_position_nft_account: self - .second_position_nft_account - .expect("second_position_nft_account is not set"), - first_owner: self.first_owner.expect("first_owner is not set"), - second_owner: self.second_owner.expect("second_owner is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SplitPositionInstructionArgs { - unlocked_liquidity_percentage: self - .unlocked_liquidity_percentage - .clone() - .expect("unlocked_liquidity_percentage is not set"), - permanent_locked_liquidity_percentage: self - .permanent_locked_liquidity_percentage - .clone() - .expect("permanent_locked_liquidity_percentage is not set"), - fee_a_percentage: self - .fee_a_percentage - .clone() - .expect("fee_a_percentage is not set"), - fee_b_percentage: self - .fee_b_percentage - .clone() - .expect("fee_b_percentage is not set"), - reward0_percentage: self - .reward0_percentage - .clone() - .expect("reward0_percentage is not set"), - reward1_percentage: self - .reward1_percentage - .clone() - .expect("reward1_percentage is not set"), - padding: self.padding.clone().expect("padding is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `split_position` CPI accounts. -pub struct SplitPositionCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The first position - pub first_position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for position nft - pub first_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// The second position - pub second_position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for position nft - pub second_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Owner of first position - pub first_owner: &'b solana_account_info::AccountInfo<'a>, - /// Owner of second position - pub second_owner: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `split_position` CPI instruction. -pub struct SplitPositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The first position - pub first_position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for position nft - pub first_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// The second position - pub second_position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for position nft - pub second_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Owner of first position - pub first_owner: &'b solana_account_info::AccountInfo<'a>, - /// Owner of second position - pub second_owner: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SplitPositionInstructionArgs, -} - -impl<'a, 'b> SplitPositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SplitPositionCpiAccounts<'a, 'b>, - args: SplitPositionInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - first_position: accounts.first_position, - first_position_nft_account: accounts.first_position_nft_account, - second_position: accounts.second_position, - second_position_nft_account: accounts.second_position_nft_account, - first_owner: accounts.first_owner, - second_owner: accounts.second_owner, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.first_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.first_position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.second_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.second_position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.first_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.second_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = SplitPositionInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.first_position.clone()); - account_infos.push(self.first_position_nft_account.clone()); - account_infos.push(self.second_position.clone()); - account_infos.push(self.second_position_nft_account.clone()); - account_infos.push(self.first_owner.clone()); - account_infos.push(self.second_owner.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SplitPosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` first_position -/// 2. `[]` first_position_nft_account -/// 3. `[writable]` second_position -/// 4. `[]` second_position_nft_account -/// 5. `[signer]` first_owner -/// 6. `[signer]` second_owner -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug)] -pub struct SplitPositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SplitPositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SplitPositionCpiBuilderInstruction { - __program: program, - pool: None, - first_position: None, - first_position_nft_account: None, - second_position: None, - second_position_nft_account: None, - first_owner: None, - second_owner: None, - event_authority: None, - program: None, - unlocked_liquidity_percentage: None, - permanent_locked_liquidity_percentage: None, - fee_a_percentage: None, - fee_b_percentage: None, - reward0_percentage: None, - reward1_percentage: None, - padding: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// The first position - #[inline(always)] - pub fn first_position( - &mut self, - first_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.first_position = Some(first_position); - self - } - - /// The token account for position nft - #[inline(always)] - pub fn first_position_nft_account( - &mut self, - first_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.first_position_nft_account = Some(first_position_nft_account); - self - } - - /// The second position - #[inline(always)] - pub fn second_position( - &mut self, - second_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.second_position = Some(second_position); - self - } - - /// The token account for position nft - #[inline(always)] - pub fn second_position_nft_account( - &mut self, - second_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.second_position_nft_account = Some(second_position_nft_account); - self - } - - /// Owner of first position - #[inline(always)] - pub fn first_owner( - &mut self, - first_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.first_owner = Some(first_owner); - self - } - - /// Owner of second position - #[inline(always)] - pub fn second_owner( - &mut self, - second_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.second_owner = Some(second_owner); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn unlocked_liquidity_percentage( - &mut self, - unlocked_liquidity_percentage: u8, - ) -> &mut Self { - self.instruction.unlocked_liquidity_percentage = Some(unlocked_liquidity_percentage); - self - } - - #[inline(always)] - pub fn permanent_locked_liquidity_percentage( - &mut self, - permanent_locked_liquidity_percentage: u8, - ) -> &mut Self { - self.instruction.permanent_locked_liquidity_percentage = - Some(permanent_locked_liquidity_percentage); - self - } - - #[inline(always)] - pub fn fee_a_percentage(&mut self, fee_a_percentage: u8) -> &mut Self { - self.instruction.fee_a_percentage = Some(fee_a_percentage); - self - } - - #[inline(always)] - pub fn fee_b_percentage(&mut self, fee_b_percentage: u8) -> &mut Self { - self.instruction.fee_b_percentage = Some(fee_b_percentage); - self - } - - #[inline(always)] - pub fn reward0_percentage(&mut self, reward0_percentage: u8) -> &mut Self { - self.instruction.reward0_percentage = Some(reward0_percentage); - self - } - - #[inline(always)] - pub fn reward1_percentage(&mut self, reward1_percentage: u8) -> &mut Self { - self.instruction.reward1_percentage = Some(reward1_percentage); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 16]) -> &mut Self { - self.instruction.padding = Some(padding); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = SplitPositionInstructionArgs { - unlocked_liquidity_percentage: self - .instruction - .unlocked_liquidity_percentage - .clone() - .expect("unlocked_liquidity_percentage is not set"), - permanent_locked_liquidity_percentage: self - .instruction - .permanent_locked_liquidity_percentage - .clone() - .expect("permanent_locked_liquidity_percentage is not set"), - fee_a_percentage: self - .instruction - .fee_a_percentage - .clone() - .expect("fee_a_percentage is not set"), - fee_b_percentage: self - .instruction - .fee_b_percentage - .clone() - .expect("fee_b_percentage is not set"), - reward0_percentage: self - .instruction - .reward0_percentage - .clone() - .expect("reward0_percentage is not set"), - reward1_percentage: self - .instruction - .reward1_percentage - .clone() - .expect("reward1_percentage is not set"), - padding: self - .instruction - .padding - .clone() - .expect("padding is not set"), - }; - let instruction = SplitPositionCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - first_position: self - .instruction - .first_position - .expect("first_position is not set"), - - first_position_nft_account: self - .instruction - .first_position_nft_account - .expect("first_position_nft_account is not set"), - - second_position: self - .instruction - .second_position - .expect("second_position is not set"), - - second_position_nft_account: self - .instruction - .second_position_nft_account - .expect("second_position_nft_account is not set"), - - first_owner: self - .instruction - .first_owner - .expect("first_owner is not set"), - - second_owner: self - .instruction - .second_owner - .expect("second_owner is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SplitPositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - first_position: Option<&'b solana_account_info::AccountInfo<'a>>, - first_position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - second_position: Option<&'b solana_account_info::AccountInfo<'a>>, - second_position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - first_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - second_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - unlocked_liquidity_percentage: Option, - permanent_locked_liquidity_percentage: Option, - fee_a_percentage: Option, - fee_b_percentage: Option, - reward0_percentage: Option, - reward1_percentage: Option, - padding: Option<[u8; 16]>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/split_position2.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/split_position2.rs deleted file mode 100644 index 8eef1f56..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/split_position2.rs +++ /dev/null @@ -1,669 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const SPLIT_POSITION2_DISCRIMINATOR: [u8; 8] = [221, 147, 228, 207, 140, 212, 17, 119]; - -/// Accounts. -#[derive(Debug)] -pub struct SplitPosition2 { - pub pool: solana_pubkey::Pubkey, - /// The first position - pub first_position: solana_pubkey::Pubkey, - /// The token account for position nft - pub first_position_nft_account: solana_pubkey::Pubkey, - /// The second position - pub second_position: solana_pubkey::Pubkey, - /// The token account for position nft - pub second_position_nft_account: solana_pubkey::Pubkey, - /// Owner of first position - pub first_owner: solana_pubkey::Pubkey, - /// Owner of second position - pub second_owner: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SplitPosition2 { - pub fn instruction( - &self, - args: SplitPosition2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SplitPosition2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.first_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.first_position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.second_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.second_position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.first_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.second_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = SplitPosition2InstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SplitPosition2InstructionData { - discriminator: [u8; 8], -} - -impl SplitPosition2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [221, 147, 228, 207, 140, 212, 17, 119], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for SplitPosition2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SplitPosition2InstructionArgs { - pub numerator: u32, -} - -impl SplitPosition2InstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `SplitPosition2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` first_position -/// 2. `[]` first_position_nft_account -/// 3. `[writable]` second_position -/// 4. `[]` second_position_nft_account -/// 5. `[signer]` first_owner -/// 6. `[signer]` second_owner -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SplitPosition2Builder { - pool: Option, - first_position: Option, - first_position_nft_account: Option, - second_position: Option, - second_position_nft_account: Option, - first_owner: Option, - second_owner: Option, - event_authority: Option, - program: Option, - numerator: Option, - __remaining_accounts: Vec, -} - -impl SplitPosition2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// The first position - #[inline(always)] - pub fn first_position(&mut self, first_position: solana_pubkey::Pubkey) -> &mut Self { - self.first_position = Some(first_position); - self - } - - /// The token account for position nft - #[inline(always)] - pub fn first_position_nft_account( - &mut self, - first_position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.first_position_nft_account = Some(first_position_nft_account); - self - } - - /// The second position - #[inline(always)] - pub fn second_position(&mut self, second_position: solana_pubkey::Pubkey) -> &mut Self { - self.second_position = Some(second_position); - self - } - - /// The token account for position nft - #[inline(always)] - pub fn second_position_nft_account( - &mut self, - second_position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.second_position_nft_account = Some(second_position_nft_account); - self - } - - /// Owner of first position - #[inline(always)] - pub fn first_owner(&mut self, first_owner: solana_pubkey::Pubkey) -> &mut Self { - self.first_owner = Some(first_owner); - self - } - - /// Owner of second position - #[inline(always)] - pub fn second_owner(&mut self, second_owner: solana_pubkey::Pubkey) -> &mut Self { - self.second_owner = Some(second_owner); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn numerator(&mut self, numerator: u32) -> &mut Self { - self.numerator = Some(numerator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SplitPosition2 { - pool: self.pool.expect("pool is not set"), - first_position: self.first_position.expect("first_position is not set"), - first_position_nft_account: self - .first_position_nft_account - .expect("first_position_nft_account is not set"), - second_position: self.second_position.expect("second_position is not set"), - second_position_nft_account: self - .second_position_nft_account - .expect("second_position_nft_account is not set"), - first_owner: self.first_owner.expect("first_owner is not set"), - second_owner: self.second_owner.expect("second_owner is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SplitPosition2InstructionArgs { - numerator: self.numerator.clone().expect("numerator is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `split_position2` CPI accounts. -pub struct SplitPosition2CpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The first position - pub first_position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for position nft - pub first_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// The second position - pub second_position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for position nft - pub second_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Owner of first position - pub first_owner: &'b solana_account_info::AccountInfo<'a>, - /// Owner of second position - pub second_owner: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `split_position2` CPI instruction. -pub struct SplitPosition2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The first position - pub first_position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for position nft - pub first_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// The second position - pub second_position: &'b solana_account_info::AccountInfo<'a>, - /// The token account for position nft - pub second_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - /// Owner of first position - pub first_owner: &'b solana_account_info::AccountInfo<'a>, - /// Owner of second position - pub second_owner: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SplitPosition2InstructionArgs, -} - -impl<'a, 'b> SplitPosition2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SplitPosition2CpiAccounts<'a, 'b>, - args: SplitPosition2InstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - first_position: accounts.first_position, - first_position_nft_account: accounts.first_position_nft_account, - second_position: accounts.second_position, - second_position_nft_account: accounts.second_position_nft_account, - first_owner: accounts.first_owner, - second_owner: accounts.second_owner, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.first_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.first_position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.second_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.second_position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.first_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.second_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = SplitPosition2InstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.first_position.clone()); - account_infos.push(self.first_position_nft_account.clone()); - account_infos.push(self.second_position.clone()); - account_infos.push(self.second_position_nft_account.clone()); - account_infos.push(self.first_owner.clone()); - account_infos.push(self.second_owner.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SplitPosition2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` first_position -/// 2. `[]` first_position_nft_account -/// 3. `[writable]` second_position -/// 4. `[]` second_position_nft_account -/// 5. `[signer]` first_owner -/// 6. `[signer]` second_owner -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug)] -pub struct SplitPosition2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SplitPosition2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SplitPosition2CpiBuilderInstruction { - __program: program, - pool: None, - first_position: None, - first_position_nft_account: None, - second_position: None, - second_position_nft_account: None, - first_owner: None, - second_owner: None, - event_authority: None, - program: None, - numerator: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// The first position - #[inline(always)] - pub fn first_position( - &mut self, - first_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.first_position = Some(first_position); - self - } - - /// The token account for position nft - #[inline(always)] - pub fn first_position_nft_account( - &mut self, - first_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.first_position_nft_account = Some(first_position_nft_account); - self - } - - /// The second position - #[inline(always)] - pub fn second_position( - &mut self, - second_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.second_position = Some(second_position); - self - } - - /// The token account for position nft - #[inline(always)] - pub fn second_position_nft_account( - &mut self, - second_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.second_position_nft_account = Some(second_position_nft_account); - self - } - - /// Owner of first position - #[inline(always)] - pub fn first_owner( - &mut self, - first_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.first_owner = Some(first_owner); - self - } - - /// Owner of second position - #[inline(always)] - pub fn second_owner( - &mut self, - second_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.second_owner = Some(second_owner); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn numerator(&mut self, numerator: u32) -> &mut Self { - self.instruction.numerator = Some(numerator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = SplitPosition2InstructionArgs { - numerator: self - .instruction - .numerator - .clone() - .expect("numerator is not set"), - }; - let instruction = SplitPosition2Cpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - first_position: self - .instruction - .first_position - .expect("first_position is not set"), - - first_position_nft_account: self - .instruction - .first_position_nft_account - .expect("first_position_nft_account is not set"), - - second_position: self - .instruction - .second_position - .expect("second_position is not set"), - - second_position_nft_account: self - .instruction - .second_position_nft_account - .expect("second_position_nft_account is not set"), - - first_owner: self - .instruction - .first_owner - .expect("first_owner is not set"), - - second_owner: self - .instruction - .second_owner - .expect("second_owner is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SplitPosition2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - first_position: Option<&'b solana_account_info::AccountInfo<'a>>, - first_position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - second_position: Option<&'b solana_account_info::AccountInfo<'a>>, - second_position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - first_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - second_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - numerator: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/swap.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/swap.rs deleted file mode 100644 index ead95d4d..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/swap.rs +++ /dev/null @@ -1,895 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::SwapParameters; - -pub const SWAP_DISCRIMINATOR: [u8; 8] = [248, 198, 158, 145, 225, 117, 135, 200]; - -/// Accounts. -#[derive(Debug)] -pub struct Swap { - pub pool_authority: solana_pubkey::Pubkey, - /// Pool account - pub pool: solana_pubkey::Pubkey, - /// The user token account for input token - pub input_token_account: solana_pubkey::Pubkey, - /// The user token account for output token - pub output_token_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub token_a_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub token_b_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub token_a_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub token_b_mint: solana_pubkey::Pubkey, - /// The user performing the swap - pub payer: solana_pubkey::Pubkey, - /// Token a program - pub token_a_program: solana_pubkey::Pubkey, - /// Token b program - pub token_b_program: solana_pubkey::Pubkey, - /// referral token account - pub referral_token_account: Option, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Swap { - pub fn instruction(&self, args: SwapInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.input_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - if let Some(referral_token_account) = self.referral_token_account { - accounts.push(solana_instruction::AccountMeta::new( - referral_token_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::CP_AMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = SwapInstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionData { - discriminator: [u8; 8], -} - -impl SwapInstructionData { - pub fn new() -> Self { - Self { - discriminator: [248, 198, 158, 145, 225, 117, 135, 200], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for SwapInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionArgs { - pub params: SwapParameters, -} - -impl SwapInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `Swap`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 1. `[writable]` pool -/// 2. `[writable]` input_token_account -/// 3. `[writable]` output_token_account -/// 4. `[writable]` token_a_vault -/// 5. `[writable]` token_b_vault -/// 6. `[]` token_a_mint -/// 7. `[]` token_b_mint -/// 8. `[signer]` payer -/// 9. `[]` token_a_program -/// 10. `[]` token_b_program -/// 11. `[writable, optional]` referral_token_account -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SwapBuilder { - pool_authority: Option, - pool: Option, - input_token_account: Option, - output_token_account: Option, - token_a_vault: Option, - token_b_vault: Option, - token_a_mint: Option, - token_b_mint: Option, - payer: Option, - token_a_program: Option, - token_b_program: Option, - referral_token_account: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl SwapBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// The user token account for input token - #[inline(always)] - pub fn input_token_account(&mut self, input_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_account = Some(input_token_account); - self - } - - /// The user token account for output token - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_account = Some(output_token_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// The user performing the swap - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - /// `[optional account]` - /// referral token account - #[inline(always)] - pub fn referral_token_account( - &mut self, - referral_token_account: Option, - ) -> &mut Self { - self.referral_token_account = referral_token_account; - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: SwapParameters) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Swap { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - input_token_account: self - .input_token_account - .expect("input_token_account is not set"), - output_token_account: self - .output_token_account - .expect("output_token_account is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - payer: self.payer.expect("payer is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - referral_token_account: self.referral_token_account, - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SwapInstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap` CPI accounts. -pub struct SwapCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for input token - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for output token - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - /// referral token account - pub referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap` CPI instruction. -pub struct SwapCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for input token - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for output token - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - /// referral token account - pub referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapInstructionArgs, -} - -impl<'a, 'b> SwapCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapCpiAccounts<'a, 'b>, - args: SwapInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - input_token_account: accounts.input_token_account, - output_token_account: accounts.output_token_account, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - payer: accounts.payer, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - referral_token_account: accounts.referral_token_account, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - if let Some(referral_token_account) = self.referral_token_account { - accounts.push(solana_instruction::AccountMeta::new( - *referral_token_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::CP_AMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = SwapInstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.input_token_account.clone()); - account_infos.push(self.output_token_account.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - if let Some(referral_token_account) = self.referral_token_account { - account_infos.push(referral_token_account.clone()); - } - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Swap` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[writable]` pool -/// 2. `[writable]` input_token_account -/// 3. `[writable]` output_token_account -/// 4. `[writable]` token_a_vault -/// 5. `[writable]` token_b_vault -/// 6. `[]` token_a_mint -/// 7. `[]` token_b_mint -/// 8. `[signer]` payer -/// 9. `[]` token_a_program -/// 10. `[]` token_b_program -/// 11. `[writable, optional]` referral_token_account -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct SwapCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapCpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - input_token_account: None, - output_token_account: None, - token_a_vault: None, - token_b_vault: None, - token_a_mint: None, - token_b_mint: None, - payer: None, - token_a_program: None, - token_b_program: None, - referral_token_account: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// The user token account for input token - #[inline(always)] - pub fn input_token_account( - &mut self, - input_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_account = Some(input_token_account); - self - } - - /// The user token account for output token - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_account = Some(output_token_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// The user performing the swap - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - /// `[optional account]` - /// referral token account - #[inline(always)] - pub fn referral_token_account( - &mut self, - referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.referral_token_account = referral_token_account; - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: SwapParameters) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = SwapInstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = SwapCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - input_token_account: self - .instruction - .input_token_account - .expect("input_token_account is not set"), - - output_token_account: self - .instruction - .output_token_account - .expect("output_token_account is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - referral_token_account: self.instruction.referral_token_account, - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/swap2.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/swap2.rs deleted file mode 100644 index 46ec0a47..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/swap2.rs +++ /dev/null @@ -1,895 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::SwapParameters2; - -pub const SWAP2_DISCRIMINATOR: [u8; 8] = [65, 75, 63, 76, 235, 91, 91, 136]; - -/// Accounts. -#[derive(Debug)] -pub struct Swap2 { - pub pool_authority: solana_pubkey::Pubkey, - /// Pool account - pub pool: solana_pubkey::Pubkey, - /// The user token account for input token - pub input_token_account: solana_pubkey::Pubkey, - /// The user token account for output token - pub output_token_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub token_a_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub token_b_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub token_a_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub token_b_mint: solana_pubkey::Pubkey, - /// The user performing the swap - pub payer: solana_pubkey::Pubkey, - /// Token a program - pub token_a_program: solana_pubkey::Pubkey, - /// Token b program - pub token_b_program: solana_pubkey::Pubkey, - /// referral token account - pub referral_token_account: Option, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Swap2 { - pub fn instruction(&self, args: Swap2InstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: Swap2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.input_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_program, - false, - )); - if let Some(referral_token_account) = self.referral_token_account { - accounts.push(solana_instruction::AccountMeta::new( - referral_token_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::CP_AMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = Swap2InstructionData::new().try_to_vec().unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Swap2InstructionData { - discriminator: [u8; 8], -} - -impl Swap2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [65, 75, 63, 76, 235, 91, 91, 136], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for Swap2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Swap2InstructionArgs { - pub params: SwapParameters2, -} - -impl Swap2InstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `Swap2`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 1. `[writable]` pool -/// 2. `[writable]` input_token_account -/// 3. `[writable]` output_token_account -/// 4. `[writable]` token_a_vault -/// 5. `[writable]` token_b_vault -/// 6. `[]` token_a_mint -/// 7. `[]` token_b_mint -/// 8. `[signer]` payer -/// 9. `[]` token_a_program -/// 10. `[]` token_b_program -/// 11. `[writable, optional]` referral_token_account -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct Swap2Builder { - pool_authority: Option, - pool: Option, - input_token_account: Option, - output_token_account: Option, - token_a_vault: Option, - token_b_vault: Option, - token_a_mint: Option, - token_b_mint: Option, - payer: Option, - token_a_program: Option, - token_b_program: Option, - referral_token_account: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl Swap2Builder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// The user token account for input token - #[inline(always)] - pub fn input_token_account(&mut self, input_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_account = Some(input_token_account); - self - } - - /// The user token account for output token - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_account = Some(output_token_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// The user performing the swap - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program(&mut self, token_a_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program(&mut self, token_b_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_program = Some(token_b_program); - self - } - - /// `[optional account]` - /// referral token account - #[inline(always)] - pub fn referral_token_account( - &mut self, - referral_token_account: Option, - ) -> &mut Self { - self.referral_token_account = referral_token_account; - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: SwapParameters2) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Swap2 { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - input_token_account: self - .input_token_account - .expect("input_token_account is not set"), - output_token_account: self - .output_token_account - .expect("output_token_account is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - payer: self.payer.expect("payer is not set"), - token_a_program: self.token_a_program.expect("token_a_program is not set"), - token_b_program: self.token_b_program.expect("token_b_program is not set"), - referral_token_account: self.referral_token_account, - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = Swap2InstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap2` CPI accounts. -pub struct Swap2CpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for input token - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for output token - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - /// referral token account - pub referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap2` CPI instruction. -pub struct Swap2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for input token - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for output token - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_a_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_b_program: &'b solana_account_info::AccountInfo<'a>, - /// referral token account - pub referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: Swap2InstructionArgs, -} - -impl<'a, 'b> Swap2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: Swap2CpiAccounts<'a, 'b>, - args: Swap2InstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - input_token_account: accounts.input_token_account, - output_token_account: accounts.output_token_account, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - payer: accounts.payer, - token_a_program: accounts.token_a_program, - token_b_program: accounts.token_b_program, - referral_token_account: accounts.referral_token_account, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_program.key, - false, - )); - if let Some(referral_token_account) = self.referral_token_account { - accounts.push(solana_instruction::AccountMeta::new( - *referral_token_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::CP_AMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = Swap2InstructionData::new().try_to_vec().unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.input_token_account.clone()); - account_infos.push(self.output_token_account.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_a_program.clone()); - account_infos.push(self.token_b_program.clone()); - if let Some(referral_token_account) = self.referral_token_account { - account_infos.push(referral_token_account.clone()); - } - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Swap2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[writable]` pool -/// 2. `[writable]` input_token_account -/// 3. `[writable]` output_token_account -/// 4. `[writable]` token_a_vault -/// 5. `[writable]` token_b_vault -/// 6. `[]` token_a_mint -/// 7. `[]` token_b_mint -/// 8. `[signer]` payer -/// 9. `[]` token_a_program -/// 10. `[]` token_b_program -/// 11. `[writable, optional]` referral_token_account -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct Swap2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> Swap2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(Swap2CpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - input_token_account: None, - output_token_account: None, - token_a_vault: None, - token_b_vault: None, - token_a_mint: None, - token_b_mint: None, - payer: None, - token_a_program: None, - token_b_program: None, - referral_token_account: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// The user token account for input token - #[inline(always)] - pub fn input_token_account( - &mut self, - input_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_account = Some(input_token_account); - self - } - - /// The user token account for output token - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_account = Some(output_token_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// The user performing the swap - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Token a program - #[inline(always)] - pub fn token_a_program( - &mut self, - token_a_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_program = Some(token_a_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_b_program( - &mut self, - token_b_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_program = Some(token_b_program); - self - } - - /// `[optional account]` - /// referral token account - #[inline(always)] - pub fn referral_token_account( - &mut self, - referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.referral_token_account = referral_token_account; - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: SwapParameters2) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = Swap2InstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = Swap2Cpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - input_token_account: self - .instruction - .input_token_account - .expect("input_token_account is not set"), - - output_token_account: self - .instruction - .output_token_account - .expect("output_token_account is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_a_program: self - .instruction - .token_a_program - .expect("token_a_program is not set"), - - token_b_program: self - .instruction - .token_b_program - .expect("token_b_program is not set"), - - referral_token_account: self.instruction.referral_token_account, - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct Swap2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_program: Option<&'b solana_account_info::AccountInfo<'a>>, - referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/update_reward_duration.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/update_reward_duration.rs deleted file mode 100644 index a56d3bfa..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/update_reward_duration.rs +++ /dev/null @@ -1,457 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const UPDATE_REWARD_DURATION_DISCRIMINATOR: [u8; 8] = [138, 174, 196, 169, 213, 235, 254, 107]; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateRewardDuration { - pub pool: solana_pubkey::Pubkey, - - pub signer: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl UpdateRewardDuration { - pub fn instruction( - &self, - args: UpdateRewardDurationInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateRewardDurationInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.signer, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = UpdateRewardDurationInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateRewardDurationInstructionData { - discriminator: [u8; 8], -} - -impl UpdateRewardDurationInstructionData { - pub fn new() -> Self { - Self { - discriminator: [138, 174, 196, 169, 213, 235, 254, 107], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for UpdateRewardDurationInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateRewardDurationInstructionArgs { - pub reward_index: u8, - pub new_duration: u64, -} - -impl UpdateRewardDurationInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `UpdateRewardDuration`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` signer -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug, Default)] -pub struct UpdateRewardDurationBuilder { - pool: Option, - signer: Option, - event_authority: Option, - program: Option, - reward_index: Option, - new_duration: Option, - __remaining_accounts: Vec, -} - -impl UpdateRewardDurationBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn signer(&mut self, signer: solana_pubkey::Pubkey) -> &mut Self { - self.signer = Some(signer); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn new_duration(&mut self, new_duration: u64) -> &mut Self { - self.new_duration = Some(new_duration); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateRewardDuration { - pool: self.pool.expect("pool is not set"), - signer: self.signer.expect("signer is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = UpdateRewardDurationInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - new_duration: self.new_duration.clone().expect("new_duration is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_reward_duration` CPI accounts. -pub struct UpdateRewardDurationCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub signer: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_reward_duration` CPI instruction. -pub struct UpdateRewardDurationCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub signer: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateRewardDurationInstructionArgs, -} - -impl<'a, 'b> UpdateRewardDurationCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateRewardDurationCpiAccounts<'a, 'b>, - args: UpdateRewardDurationInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - signer: accounts.signer, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.signer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = UpdateRewardDurationInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.signer.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateRewardDuration` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` signer -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug)] -pub struct UpdateRewardDurationCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateRewardDurationCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateRewardDurationCpiBuilderInstruction { - __program: program, - pool: None, - signer: None, - event_authority: None, - program: None, - reward_index: None, - new_duration: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn signer(&mut self, signer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.signer = Some(signer); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn new_duration(&mut self, new_duration: u64) -> &mut Self { - self.instruction.new_duration = Some(new_duration); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = UpdateRewardDurationInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - new_duration: self - .instruction - .new_duration - .clone() - .expect("new_duration is not set"), - }; - let instruction = UpdateRewardDurationCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - signer: self.instruction.signer.expect("signer is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateRewardDurationCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - signer: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - new_duration: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/update_reward_funder.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/update_reward_funder.rs deleted file mode 100644 index aad0c711..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/update_reward_funder.rs +++ /dev/null @@ -1,458 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -pub const UPDATE_REWARD_FUNDER_DISCRIMINATOR: [u8; 8] = [211, 28, 48, 32, 215, 160, 35, 23]; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateRewardFunder { - pub pool: solana_pubkey::Pubkey, - - pub signer: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl UpdateRewardFunder { - pub fn instruction( - &self, - args: UpdateRewardFunderInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateRewardFunderInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.signer, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = UpdateRewardFunderInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateRewardFunderInstructionData { - discriminator: [u8; 8], -} - -impl UpdateRewardFunderInstructionData { - pub fn new() -> Self { - Self { - discriminator: [211, 28, 48, 32, 215, 160, 35, 23], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for UpdateRewardFunderInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateRewardFunderInstructionArgs { - pub reward_index: u8, - pub new_funder: Pubkey, -} - -impl UpdateRewardFunderInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `UpdateRewardFunder`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` signer -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug, Default)] -pub struct UpdateRewardFunderBuilder { - pool: Option, - signer: Option, - event_authority: Option, - program: Option, - reward_index: Option, - new_funder: Option, - __remaining_accounts: Vec, -} - -impl UpdateRewardFunderBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn signer(&mut self, signer: solana_pubkey::Pubkey) -> &mut Self { - self.signer = Some(signer); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn new_funder(&mut self, new_funder: Pubkey) -> &mut Self { - self.new_funder = Some(new_funder); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateRewardFunder { - pool: self.pool.expect("pool is not set"), - signer: self.signer.expect("signer is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = UpdateRewardFunderInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - new_funder: self.new_funder.clone().expect("new_funder is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_reward_funder` CPI accounts. -pub struct UpdateRewardFunderCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub signer: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_reward_funder` CPI instruction. -pub struct UpdateRewardFunderCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub signer: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateRewardFunderInstructionArgs, -} - -impl<'a, 'b> UpdateRewardFunderCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateRewardFunderCpiAccounts<'a, 'b>, - args: UpdateRewardFunderInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - signer: accounts.signer, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.signer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = UpdateRewardFunderInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.signer.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateRewardFunder` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` signer -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug)] -pub struct UpdateRewardFunderCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateRewardFunderCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateRewardFunderCpiBuilderInstruction { - __program: program, - pool: None, - signer: None, - event_authority: None, - program: None, - reward_index: None, - new_funder: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn signer(&mut self, signer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.signer = Some(signer); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn new_funder(&mut self, new_funder: Pubkey) -> &mut Self { - self.instruction.new_funder = Some(new_funder); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = UpdateRewardFunderInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - new_funder: self - .instruction - .new_funder - .clone() - .expect("new_funder is not set"), - }; - let instruction = UpdateRewardFunderCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - signer: self.instruction.signer.expect("signer is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateRewardFunderCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - signer: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - new_funder: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/instructions/withdraw_ineligible_reward.rs b/crates/meteora-amm-parser/src/generated_sdk/instructions/withdraw_ineligible_reward.rs deleted file mode 100644 index 1baea8cd..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/instructions/withdraw_ineligible_reward.rs +++ /dev/null @@ -1,656 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const WITHDRAW_INELIGIBLE_REWARD_DISCRIMINATOR: [u8; 8] = [148, 206, 42, 195, 247, 49, 103, 8]; - -/// Accounts. -#[derive(Debug)] -pub struct WithdrawIneligibleReward { - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub funder_token_account: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl WithdrawIneligibleReward { - pub fn instruction( - &self, - args: WithdrawIneligibleRewardInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: WithdrawIneligibleRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.funder_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.funder, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = WithdrawIneligibleRewardInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = args.try_to_vec().unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawIneligibleRewardInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawIneligibleRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [148, 206, 42, 195, 247, 49, 103, 8], - } - } - - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -impl Default for WithdrawIneligibleRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawIneligibleRewardInstructionArgs { - pub reward_index: u8, -} - -impl WithdrawIneligibleRewardInstructionArgs { - pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } -} - -/// Instruction builder for `WithdrawIneligibleReward`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC`) -/// 1. `[writable]` pool -/// 2. `[writable]` reward_vault -/// 3. `[]` reward_mint -/// 4. `[writable]` funder_token_account -/// 5. `[signer]` funder -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug, Default)] -pub struct WithdrawIneligibleRewardBuilder { - pool_authority: Option, - pool: Option, - reward_vault: Option, - reward_mint: Option, - funder_token_account: Option, - funder: Option, - token_program: Option, - event_authority: Option, - program: Option, - reward_index: Option, - __remaining_accounts: Vec, -} - -impl WithdrawIneligibleRewardBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = WithdrawIneligibleReward { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - )), - pool: self.pool.expect("pool is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - funder_token_account: self - .funder_token_account - .expect("funder_token_account is not set"), - funder: self.funder.expect("funder is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = WithdrawIneligibleRewardInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw_ineligible_reward` CPI accounts. -pub struct WithdrawIneligibleRewardCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw_ineligible_reward` CPI instruction. -pub struct WithdrawIneligibleRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: WithdrawIneligibleRewardInstructionArgs, -} - -impl<'a, 'b> WithdrawIneligibleRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawIneligibleRewardCpiAccounts<'a, 'b>, - args: WithdrawIneligibleRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - reward_vault: accounts.reward_vault, - reward_mint: accounts.reward_mint, - funder_token_account: accounts.funder_token_account, - funder: accounts.funder, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_error::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.funder_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.funder.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = WithdrawIneligibleRewardInstructionData::new() - .try_to_vec() - .unwrap(); - let mut args = self.__args.try_to_vec().unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::CP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.funder_token_account.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `WithdrawIneligibleReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[writable]` pool -/// 2. `[writable]` reward_vault -/// 3. `[]` reward_mint -/// 4. `[writable]` funder_token_account -/// 5. `[signer]` funder -/// 6. `[]` token_program -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug)] -pub struct WithdrawIneligibleRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawIneligibleRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawIneligibleRewardCpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - reward_vault: None, - reward_mint: None, - funder_token_account: None, - funder: None, - token_program: None, - event_authority: None, - program: None, - reward_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = WithdrawIneligibleRewardInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - }; - let instruction = WithdrawIneligibleRewardCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - funder_token_account: self - .instruction - .funder_token_account - .expect("funder_token_account is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawIneligibleRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - funder_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/mod.rs b/crates/meteora-amm-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/meteora-amm-parser/src/generated_sdk/programs.rs b/crates/meteora-amm-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 042c6a55..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `cp_amm` program ID. -pub const CP_AMM_ID: Pubkey = pubkey!("cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"); diff --git a/crates/meteora-amm-parser/src/generated_sdk/shared.rs b/crates/meteora-amm-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/add_liquidity_parameters.rs b/crates/meteora-amm-parser/src/generated_sdk/types/add_liquidity_parameters.rs deleted file mode 100644 index 37311010..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/add_liquidity_parameters.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityParameters { - /// delta liquidity - pub liquidity_delta: u128, - /// maximum token a amount - pub token_a_amount_threshold: u64, - /// maximum token b amount - pub token_b_amount_threshold: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/base_fee_config.rs b/crates/meteora-amm-parser/src/generated_sdk/types/base_fee_config.rs deleted file mode 100644 index b48db5af..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/base_fee_config.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BaseFeeConfig { - pub cliff_fee_numerator: u64, - pub base_fee_mode: u8, - pub padding: [u8; 5], - pub first_factor: u16, - pub second_factor: [u8; 8], - pub third_factor: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/base_fee_parameters.rs b/crates/meteora-amm-parser/src/generated_sdk/types/base_fee_parameters.rs deleted file mode 100644 index 9567e9a2..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/base_fee_parameters.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BaseFeeParameters { - pub cliff_fee_numerator: u64, - pub first_factor: u16, - pub second_factor: [u8; 8], - pub third_factor: u64, - pub base_fee_mode: u8, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/base_fee_struct.rs b/crates/meteora-amm-parser/src/generated_sdk/types/base_fee_struct.rs deleted file mode 100644 index 5f353a04..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/base_fee_struct.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BaseFeeStruct { - pub cliff_fee_numerator: u64, - pub base_fee_mode: u8, - pub padding0: [u8; 5], - pub first_factor: u16, - pub second_factor: [u8; 8], - pub third_factor: u64, - pub padding1: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/dynamic_fee_config.rs b/crates/meteora-amm-parser/src/generated_sdk/types/dynamic_fee_config.rs deleted file mode 100644 index 26f0bde6..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/dynamic_fee_config.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DynamicFeeConfig { - pub initialized: u8, - pub padding: [u8; 7], - pub max_volatility_accumulator: u32, - pub variable_fee_control: u32, - pub bin_step: u16, - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub padding1: [u8; 8], - pub bin_step_u128: u128, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/dynamic_fee_parameters.rs b/crates/meteora-amm-parser/src/generated_sdk/types/dynamic_fee_parameters.rs deleted file mode 100644 index 35fc67cd..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/dynamic_fee_parameters.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DynamicFeeParameters { - pub bin_step: u16, - pub bin_step_u128: u128, - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub max_volatility_accumulator: u32, - pub variable_fee_control: u32, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/dynamic_fee_struct.rs b/crates/meteora-amm-parser/src/generated_sdk/types/dynamic_fee_struct.rs deleted file mode 100644 index e4b3c886..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/dynamic_fee_struct.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DynamicFeeStruct { - pub initialized: u8, - pub padding: [u8; 7], - pub max_volatility_accumulator: u32, - pub variable_fee_control: u32, - pub bin_step: u16, - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub last_update_timestamp: u64, - pub bin_step_u128: u128, - pub sqrt_price_reference: u128, - pub volatility_accumulator: u128, - pub volatility_reference: u128, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_add_liquidity.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_add_liquidity.rs deleted file mode 100644 index d94dffa1..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_add_liquidity.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::AddLiquidityParameters; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtAddLiquidity { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - pub params: AddLiquidityParameters, - pub token_a_amount: u64, - pub token_b_amount: u64, - pub total_amount_a: u64, - pub total_amount_b: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_partner_fee.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_partner_fee.rs deleted file mode 100644 index 39674644..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_partner_fee.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtClaimPartnerFee { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub token_a_amount: u64, - pub token_b_amount: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_position_fee.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_position_fee.rs deleted file mode 100644 index ceefb3eb..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_position_fee.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtClaimPositionFee { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - pub fee_a_claimed: u64, - pub fee_b_claimed: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_protocol_fee.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_protocol_fee.rs deleted file mode 100644 index ba539424..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_protocol_fee.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtClaimProtocolFee { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub token_a_amount: u64, - pub token_b_amount: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_reward.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_reward.rs deleted file mode 100644 index d51f5f30..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_claim_reward.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtClaimReward { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint_reward: Pubkey, - pub reward_index: u8, - pub total_reward: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_close_claim_fee_operator.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_close_claim_fee_operator.rs deleted file mode 100644 index 68f06abb..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_close_claim_fee_operator.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Close claim fee operator -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCloseClaimFeeOperator { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub claim_fee_operator: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub operator: Pubkey, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_close_config.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_close_config.rs deleted file mode 100644 index 5ed22a91..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_close_config.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Close config -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCloseConfig { - /// Config pubkey - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config: Pubkey, - /// admin pk - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub admin: Pubkey, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_close_position.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_close_position.rs deleted file mode 100644 index ad9842dd..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_close_position.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtClosePosition { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position_nft_mint: Pubkey, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_claim_fee_operator.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_claim_fee_operator.rs deleted file mode 100644 index 89636344..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_claim_fee_operator.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Create claim fee operator -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCreateClaimFeeOperator { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub operator: Pubkey, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_config.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_config.rs deleted file mode 100644 index c2c19d70..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_config.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::PoolFeeParameters; - -/// Create static config -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCreateConfig { - pub pool_fees: PoolFeeParameters, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vault_config_key: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_creator_authority: Pubkey, - pub activation_type: u8, - pub sqrt_min_price: u128, - pub sqrt_max_price: u128, - pub collect_fee_mode: u8, - pub index: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config: Pubkey, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_dynamic_config.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_dynamic_config.rs deleted file mode 100644 index 89adea66..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_dynamic_config.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Create dynamic config -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCreateDynamicConfig { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_creator_authority: Pubkey, - pub index: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_position.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_position.rs deleted file mode 100644 index bcdbd515..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_position.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCreatePosition { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position_nft_mint: Pubkey, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_token_badge.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_token_badge.rs deleted file mode 100644 index 162ab7b1..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_create_token_badge.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Create token badge -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCreateTokenBadge { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_mint: Pubkey, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_fund_reward.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_fund_reward.rs deleted file mode 100644 index 073e13cc..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_fund_reward.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtFundReward { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub funder: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint_reward: Pubkey, - pub reward_index: u8, - pub amount: u64, - pub transfer_fee_excluded_amount_in: u64, - pub reward_duration_end: u64, - pub pre_reward_rate: u128, - pub post_reward_rate: u128, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_initialize_pool.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_initialize_pool.rs deleted file mode 100644 index d1a5ff26..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_initialize_pool.rs +++ /dev/null @@ -1,61 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::PoolFeeParameters; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtInitializePool { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_a_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_b_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub payer: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub alpha_vault: Pubkey, - pub pool_fees: PoolFeeParameters, - pub sqrt_min_price: u128, - pub sqrt_max_price: u128, - pub activation_type: u8, - pub collect_fee_mode: u8, - pub liquidity: u128, - pub sqrt_price: u128, - pub activation_point: u64, - pub token_a_flag: u8, - pub token_b_flag: u8, - pub token_a_amount: u64, - pub token_b_amount: u64, - pub total_amount_a: u64, - pub total_amount_b: u64, - pub pool_type: u8, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_initialize_reward.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_initialize_reward.rs deleted file mode 100644 index 515ba984..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_initialize_reward.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtInitializeReward { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub reward_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub funder: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - pub reward_index: u8, - pub reward_duration: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_liquidity_change.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_liquidity_change.rs deleted file mode 100644 index d264583c..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_liquidity_change.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtLiquidityChange { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - pub token_a_amount: u64, - pub token_b_amount: u64, - pub transfer_fee_included_token_a_amount: u64, - pub transfer_fee_included_token_b_amount: u64, - pub reserve_a_amount: u64, - pub reserve_b_amount: u64, - pub liquidity_delta: u128, - pub token_a_amount_threshold: u64, - pub token_b_amount_threshold: u64, - pub change_type: u8, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_lock_position.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_lock_position.rs deleted file mode 100644 index 5fa65703..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_lock_position.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtLockPosition { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vesting: Pubkey, - pub cliff_point: u64, - pub period_frequency: u64, - pub cliff_unlock_liquidity: u128, - pub liquidity_per_period: u128, - pub number_of_period: u16, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_permanent_lock_position.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_permanent_lock_position.rs deleted file mode 100644 index 5014a2cf..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_permanent_lock_position.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtPermanentLockPosition { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - pub lock_liquidity_amount: u128, - pub total_permanent_locked_liquidity: u128, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_remove_liquidity.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_remove_liquidity.rs deleted file mode 100644 index f9203544..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_remove_liquidity.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::RemoveLiquidityParameters; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtRemoveLiquidity { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - pub params: RemoveLiquidityParameters, - pub token_a_amount: u64, - pub token_b_amount: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_set_pool_status.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_set_pool_status.rs deleted file mode 100644 index 819e3e2d..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_set_pool_status.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtSetPoolStatus { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub status: u8, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_split_position2.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_split_position2.rs deleted file mode 100644 index 175e402a..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_split_position2.rs +++ /dev/null @@ -1,46 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{SplitAmountInfo, SplitPositionInfo, SplitPositionParameters2}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtSplitPosition2 { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub first_owner: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub second_owner: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub first_position: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub second_position: Pubkey, - pub current_sqrt_price: u128, - pub amount_splits: SplitAmountInfo, - pub first_position_info: SplitPositionInfo, - pub second_position_info: SplitPositionInfo, - pub split_position_parameters: SplitPositionParameters2, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_swap.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_swap.rs deleted file mode 100644 index 429c84ed..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_swap.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{SwapParameters, SwapResult}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtSwap { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub trade_direction: u8, - pub has_referral: bool, - pub params: SwapParameters, - pub swap_result: SwapResult, - pub actual_amount_in: u64, - pub current_timestamp: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_swap2.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_swap2.rs deleted file mode 100644 index 49942fba..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_swap2.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{SwapParameters2, SwapResult2}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtSwap2 { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub trade_direction: u8, - pub collect_fee_mode: u8, - pub has_referral: bool, - pub params: SwapParameters2, - pub swap_result: SwapResult2, - pub included_transfer_fee_amount_in: u64, - pub included_transfer_fee_amount_out: u64, - pub excluded_transfer_fee_amount_out: u64, - pub current_timestamp: u64, - pub reserve_a_amount: u64, - pub reserve_b_amount: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_update_reward_duration.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_update_reward_duration.rs deleted file mode 100644 index 437fc30a..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_update_reward_duration.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtUpdateRewardDuration { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub reward_index: u8, - pub old_reward_duration: u64, - pub new_reward_duration: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_update_reward_funder.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_update_reward_funder.rs deleted file mode 100644 index 9e3e501d..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_update_reward_funder.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtUpdateRewardFunder { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub reward_index: u8, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub old_funder: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub new_funder: Pubkey, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/evt_withdraw_ineligible_reward.rs b/crates/meteora-amm-parser/src/generated_sdk/types/evt_withdraw_ineligible_reward.rs deleted file mode 100644 index b146fbe3..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/evt_withdraw_ineligible_reward.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtWithdrawIneligibleReward { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub reward_mint: Pubkey, - pub amount: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/initialize_customizable_pool_parameters.rs b/crates/meteora-amm-parser/src/generated_sdk/types/initialize_customizable_pool_parameters.rs deleted file mode 100644 index 679f3d5f..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/initialize_customizable_pool_parameters.rs +++ /dev/null @@ -1,33 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::PoolFeeParameters; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeCustomizablePoolParameters { - /// pool fees - pub pool_fees: PoolFeeParameters, - /// sqrt min price - pub sqrt_min_price: u128, - /// sqrt max price - pub sqrt_max_price: u128, - /// has alpha vault - pub has_alpha_vault: bool, - /// initialize liquidity - pub liquidity: u128, - /// The init price of the pool as a sqrt(token_b/token_a) Q64.64 value - pub sqrt_price: u128, - /// activation type - pub activation_type: u8, - /// collect fee mode - pub collect_fee_mode: u8, - /// activation point - pub activation_point: Option, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/mod.rs b/crates/meteora-amm-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index a5991eaa..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,77 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#add_liquidity_parameters; -pub(crate) mod r#base_fee_config; -pub(crate) mod r#base_fee_parameters; -pub(crate) mod r#base_fee_struct; -pub(crate) mod r#dynamic_fee_config; -pub(crate) mod r#dynamic_fee_parameters; -pub(crate) mod r#dynamic_fee_struct; -pub(crate) mod r#evt_add_liquidity; -pub(crate) mod r#evt_claim_partner_fee; -pub(crate) mod r#evt_claim_position_fee; -pub(crate) mod r#evt_claim_protocol_fee; -pub(crate) mod r#evt_claim_reward; -pub(crate) mod r#evt_close_claim_fee_operator; -pub(crate) mod r#evt_close_config; -pub(crate) mod r#evt_close_position; -pub(crate) mod r#evt_create_claim_fee_operator; -pub(crate) mod r#evt_create_config; -pub(crate) mod r#evt_create_dynamic_config; -pub(crate) mod r#evt_create_position; -pub(crate) mod r#evt_create_token_badge; -pub(crate) mod r#evt_fund_reward; -pub(crate) mod r#evt_initialize_pool; -pub(crate) mod r#evt_initialize_reward; -pub(crate) mod r#evt_liquidity_change; -pub(crate) mod r#evt_lock_position; -pub(crate) mod r#evt_permanent_lock_position; -pub(crate) mod r#evt_remove_liquidity; -pub(crate) mod r#evt_set_pool_status; -pub(crate) mod r#evt_split_position2; -pub(crate) mod r#evt_swap; -pub(crate) mod r#evt_swap2; -pub(crate) mod r#evt_update_reward_duration; -pub(crate) mod r#evt_update_reward_funder; -pub(crate) mod r#evt_withdraw_ineligible_reward; -pub(crate) mod r#initialize_customizable_pool_parameters; -pub(crate) mod r#pool_fee_parameters; -pub(crate) mod r#pool_fees_config; -pub(crate) mod r#pool_fees_struct; -pub(crate) mod r#pool_metrics; -pub(crate) mod r#position_metrics; -pub(crate) mod r#remove_liquidity_parameters; -pub(crate) mod r#reward_info; -pub(crate) mod r#split_amount_info; -pub(crate) mod r#split_position_info; -pub(crate) mod r#split_position_parameters2; -pub(crate) mod r#swap_parameters; -pub(crate) mod r#swap_parameters2; -pub(crate) mod r#swap_result; -pub(crate) mod r#swap_result2; -pub(crate) mod r#user_reward_info; - -pub use self::{ - r#add_liquidity_parameters::*, r#base_fee_config::*, r#base_fee_parameters::*, - r#base_fee_struct::*, r#dynamic_fee_config::*, r#dynamic_fee_parameters::*, - r#dynamic_fee_struct::*, r#evt_add_liquidity::*, r#evt_claim_partner_fee::*, - r#evt_claim_position_fee::*, r#evt_claim_protocol_fee::*, r#evt_claim_reward::*, - r#evt_close_claim_fee_operator::*, r#evt_close_config::*, r#evt_close_position::*, - r#evt_create_claim_fee_operator::*, r#evt_create_config::*, r#evt_create_dynamic_config::*, - r#evt_create_position::*, r#evt_create_token_badge::*, r#evt_fund_reward::*, - r#evt_initialize_pool::*, r#evt_initialize_reward::*, r#evt_liquidity_change::*, - r#evt_lock_position::*, r#evt_permanent_lock_position::*, r#evt_remove_liquidity::*, - r#evt_set_pool_status::*, r#evt_split_position2::*, r#evt_swap::*, r#evt_swap2::*, - r#evt_update_reward_duration::*, r#evt_update_reward_funder::*, - r#evt_withdraw_ineligible_reward::*, r#initialize_customizable_pool_parameters::*, - r#pool_fee_parameters::*, r#pool_fees_config::*, r#pool_fees_struct::*, r#pool_metrics::*, - r#position_metrics::*, r#remove_liquidity_parameters::*, r#reward_info::*, - r#split_amount_info::*, r#split_position_info::*, r#split_position_parameters2::*, - r#swap_parameters::*, r#swap_parameters2::*, r#swap_result::*, r#swap_result2::*, - r#user_reward_info::*, -}; diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/pool_fee_parameters.rs b/crates/meteora-amm-parser/src/generated_sdk/types/pool_fee_parameters.rs deleted file mode 100644 index a9f33e7c..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/pool_fee_parameters.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{BaseFeeParameters, DynamicFeeParameters}; - -/// Information regarding fee charges -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolFeeParameters { - /// Base fee - pub base_fee: BaseFeeParameters, - /// padding - pub padding: [u8; 3], - /// dynamic fee - pub dynamic_fee: Option, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/pool_fees_config.rs b/crates/meteora-amm-parser/src/generated_sdk/types/pool_fees_config.rs deleted file mode 100644 index bd939921..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/pool_fees_config.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{BaseFeeConfig, DynamicFeeConfig}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolFeesConfig { - pub base_fee: BaseFeeConfig, - pub dynamic_fee: DynamicFeeConfig, - pub protocol_fee_percent: u8, - pub partner_fee_percent: u8, - pub referral_fee_percent: u8, - pub padding0: [u8; 5], - pub padding1: [u64; 5], -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/pool_fees_struct.rs b/crates/meteora-amm-parser/src/generated_sdk/types/pool_fees_struct.rs deleted file mode 100644 index 7d85c2ca..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/pool_fees_struct.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{BaseFeeStruct, DynamicFeeStruct}; - -/// 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 -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolFeesStruct { - /// 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 - pub base_fee: BaseFeeStruct, - /// 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 - pub protocol_fee_percent: u8, - /// partner fee - pub partner_fee_percent: u8, - /// referral fee - pub referral_fee_percent: u8, - /// padding - pub padding0: [u8; 5], - /// dynamic fee - pub dynamic_fee: DynamicFeeStruct, - /// padding - pub padding1: [u64; 2], -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/pool_metrics.rs b/crates/meteora-amm-parser/src/generated_sdk/types/pool_metrics.rs deleted file mode 100644 index baec484d..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/pool_metrics.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolMetrics { - pub total_lp_a_fee: u128, - pub total_lp_b_fee: u128, - pub total_protocol_a_fee: u64, - pub total_protocol_b_fee: u64, - pub total_partner_a_fee: u64, - pub total_partner_b_fee: u64, - pub total_position: u64, - pub padding: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/position_metrics.rs b/crates/meteora-amm-parser/src/generated_sdk/types/position_metrics.rs deleted file mode 100644 index 2d7c6ffd..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/position_metrics.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PositionMetrics { - pub total_claimed_a_fee: u64, - pub total_claimed_b_fee: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/remove_liquidity_parameters.rs b/crates/meteora-amm-parser/src/generated_sdk/types/remove_liquidity_parameters.rs deleted file mode 100644 index e0afad57..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/remove_liquidity_parameters.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidityParameters { - /// delta liquidity - pub liquidity_delta: u128, - /// minimum token a amount - pub token_a_amount_threshold: u64, - /// minimum token b amount - pub token_b_amount_threshold: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/reward_info.rs b/crates/meteora-amm-parser/src/generated_sdk/types/reward_info.rs deleted file mode 100644 index a851253f..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/reward_info.rs +++ /dev/null @@ -1,54 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Stores the state relevant for tracking liquidity mining rewards -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RewardInfo { - /// Indicates if the reward has been initialized - pub initialized: u8, - /// reward token flag - pub reward_token_flag: u8, - /// padding - pub padding0: [u8; 6], - /// Padding to ensure `reward_rate: u128` is 16-byte aligned - pub padding1: [u8; 8], - /// Reward token mint. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - /// Reward vault token account. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vault: Pubkey, - /// Authority account that allows to fund rewards - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub funder: Pubkey, - /// reward duration - pub reward_duration: u64, - /// reward duration end - pub reward_duration_end: u64, - /// reward rate - pub reward_rate: u128, - /// Reward per token stored - pub reward_per_token_stored: [u8; 32], - /// The last time reward states were updated. - pub last_update_time: u64, - /// Accumulated seconds when the farm distributed rewards but the bin was empty. - /// These rewards will be carried over to the next reward time window. - pub cumulative_seconds_with_empty_liquidity_reward: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/split_amount_info.rs b/crates/meteora-amm-parser/src/generated_sdk/types/split_amount_info.rs deleted file mode 100644 index c81d8116..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/split_amount_info.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SplitAmountInfo { - pub permanent_locked_liquidity: u128, - pub unlocked_liquidity: u128, - pub fee_a: u64, - pub fee_b: u64, - pub reward0: u64, - pub reward1: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/split_position_info.rs b/crates/meteora-amm-parser/src/generated_sdk/types/split_position_info.rs deleted file mode 100644 index 777952af..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/split_position_info.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SplitPositionInfo { - pub liquidity: u128, - pub fee_a: u64, - pub fee_b: u64, - pub reward0: u64, - pub reward1: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/split_position_parameters2.rs b/crates/meteora-amm-parser/src/generated_sdk/types/split_position_parameters2.rs deleted file mode 100644 index 7c43b86c..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/split_position_parameters2.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SplitPositionParameters2 { - pub unlocked_liquidity_numerator: u32, - pub permanent_locked_liquidity_numerator: u32, - pub fee_a_numerator: u32, - pub fee_b_numerator: u32, - pub reward0_numerator: u32, - pub reward1_numerator: u32, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/swap_parameters.rs b/crates/meteora-amm-parser/src/generated_sdk/types/swap_parameters.rs deleted file mode 100644 index cbd11f27..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/swap_parameters.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapParameters { - pub amount_in: u64, - pub minimum_amount_out: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/swap_parameters2.rs b/crates/meteora-amm-parser/src/generated_sdk/types/swap_parameters2.rs deleted file mode 100644 index 52e57c93..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/swap_parameters2.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapParameters2 { - /// When it's exact in, partial fill, this will be amount_in. When it's exact out, this will be amount_out - pub amount0: u64, - /// When it's exact in, partial fill, this will be minimum_amount_out. When it's exact out, this will be maximum_amount_in - pub amount1: u64, - /// Swap mode, refer [SwapMode] - pub swap_mode: u8, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/swap_result.rs b/crates/meteora-amm-parser/src/generated_sdk/types/swap_result.rs deleted file mode 100644 index 70eedddf..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/swap_result.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Encodes all results of swapping -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapResult { - pub output_amount: u64, - pub next_sqrt_price: u128, - pub lp_fee: u64, - pub protocol_fee: u64, - pub partner_fee: u64, - pub referral_fee: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/swap_result2.rs b/crates/meteora-amm-parser/src/generated_sdk/types/swap_result2.rs deleted file mode 100644 index 4b20b96e..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/swap_result2.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapResult2 { - pub included_fee_input_amount: u64, - pub excluded_fee_input_amount: u64, - pub amount_left: u64, - pub output_amount: u64, - pub next_sqrt_price: u128, - pub trading_fee: u64, - pub protocol_fee: u64, - pub partner_fee: u64, - pub referral_fee: u64, -} diff --git a/crates/meteora-amm-parser/src/generated_sdk/types/user_reward_info.rs b/crates/meteora-amm-parser/src/generated_sdk/types/user_reward_info.rs deleted file mode 100644 index a7010920..00000000 --- a/crates/meteora-amm-parser/src/generated_sdk/types/user_reward_info.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UserRewardInfo { - /// The latest update reward checkpoint - pub reward_per_token_checkpoint: [u8; 32], - /// Current pending rewards - pub reward_pendings: u64, - /// Total claimed rewards - pub total_claimed_rewards: u64, -} diff --git a/crates/meteora-amm-parser/src/lib.rs b/crates/meteora-amm-parser/src/lib.rs deleted file mode 100644 index 2c8e3da3..00000000 --- a/crates/meteora-amm-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = CP_AMM_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.meteora_amm"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/meteora-dbc-parser/Cargo.toml b/crates/meteora-dbc-parser/Cargo.toml deleted file mode 100644 index 471ce7f7..00000000 --- a/crates/meteora-dbc-parser/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "yellowstone-vixen-meteora-dbc-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Meteora DBC program" -license.workspace = true -repository.workspace = true -authors.workspace = true - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info = { workspace = true } -solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction = { workspace = true } -solana-msg = { workspace = true } -solana-program-entrypoint = { workspace = true } -solana-program-error = { workspace = true } -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true \ No newline at end of file diff --git a/crates/meteora-dbc-parser/build.rs b/crates/meteora-dbc-parser/build.rs deleted file mode 100644 index e08762a2..00000000 --- a/crates/meteora-dbc-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/meteora_dbc.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/meteora-dbc-parser/idl.json b/crates/meteora-dbc-parser/idl.json deleted file mode 100644 index c5f87bca..00000000 --- a/crates/meteora-dbc-parser/idl.json +++ /dev/null @@ -1,5705 +0,0 @@ -{ - "address": "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN", - "metadata": { - "name": "dynamic_bonding_curve", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "claim_creator_trading_fee", - "discriminator": [ - 82, - 220, - 250, - 189, - 3, - 85, - 107, - 45 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "pool", - "writable": true - }, - { - "name": "token_a_account", - "docs": [ - "The treasury token a account" - ], - "writable": true - }, - { - "name": "token_b_account", - "docs": [ - "The treasury token b account" - ], - "writable": true - }, - { - "name": "base_vault", - "docs": [ - "The vault token account for input token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "quote_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "base_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] - }, - { - "name": "quote_mint", - "docs": [ - "The mint of token b" - ] - }, - { - "name": "creator", - "signer": true, - "relations": [ - "pool" - ] - }, - { - "name": "token_base_program", - "docs": [ - "Token a program" - ] - }, - { - "name": "token_quote_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "max_base_amount", - "type": "u64" - }, - { - "name": "max_quote_amount", - "type": "u64" - } - ] - }, - { - "name": "claim_protocol_fee", - "discriminator": [ - 165, - 228, - 133, - 48, - 99, - 249, - 255, - 33 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "config", - "relations": [ - "pool" - ] - }, - { - "name": "pool", - "writable": true - }, - { - "name": "base_vault", - "docs": [ - "The vault token account for input token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "quote_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "base_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] - }, - { - "name": "quote_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "config" - ] - }, - { - "name": "token_base_account", - "docs": [ - "The treasury token a account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 48, - 9, - 89, - 123, - 106, - 114, - 131, - 251, - 50, - 173, - 254, - 250, - 10, - 80, - 160, - 84, - 143, - 100, - 81, - 249, - 134, - 112, - 30, - 213, - 50, - 166, - 239, - 78, - 53, - 175, - 188, - 85 - ] - }, - { - "kind": "account", - "path": "token_base_program" - }, - { - "kind": "account", - "path": "base_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "token_quote_account", - "docs": [ - "The treasury token b account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 48, - 9, - 89, - 123, - 106, - 114, - 131, - 251, - 50, - 173, - 254, - 250, - 10, - 80, - 160, - 84, - 143, - 100, - 81, - 249, - 134, - 112, - 30, - 213, - 50, - 166, - 239, - 78, - 53, - 175, - 188, - 85 - ] - }, - { - "kind": "account", - "path": "token_quote_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "claim_fee_operator", - "docs": [ - "Claim fee operator" - ] - }, - { - "name": "operator", - "docs": [ - "Operator" - ], - "signer": true, - "relations": [ - "claim_fee_operator" - ] - }, - { - "name": "token_base_program", - "docs": [ - "Token a program" - ] - }, - { - "name": "token_quote_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "claim_trading_fee", - "discriminator": [ - 8, - 236, - 89, - 49, - 152, - 125, - 177, - 81 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "config", - "relations": [ - "pool" - ] - }, - { - "name": "pool", - "writable": true - }, - { - "name": "token_a_account", - "docs": [ - "The treasury token a account" - ], - "writable": true - }, - { - "name": "token_b_account", - "docs": [ - "The treasury token b account" - ], - "writable": true - }, - { - "name": "base_vault", - "docs": [ - "The vault token account for input token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "quote_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "base_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] - }, - { - "name": "quote_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "config" - ] - }, - { - "name": "fee_claimer", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "token_base_program", - "docs": [ - "Token a program" - ] - }, - { - "name": "token_quote_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "max_amount_a", - "type": "u64" - }, - { - "name": "max_amount_b", - "type": "u64" - } - ] - }, - { - "name": "close_claim_fee_operator", - "discriminator": [ - 38, - 134, - 82, - 216, - 95, - 124, - 17, - 99 - ], - "accounts": [ - { - "name": "claim_fee_operator", - "writable": true - }, - { - "name": "rent_receiver", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "create_claim_fee_operator", - "docs": [ - "ADMIN FUNCTIONS ///" - ], - "discriminator": [ - 169, - 62, - 207, - 107, - 58, - 187, - 162, - 109 - ], - "accounts": [ - { - "name": "claim_fee_operator", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 102, - 95, - 111, - 112, - 101, - 114, - 97, - 116, - 111, - 114 - ] - }, - { - "kind": "account", - "path": "operator" - } - ] - } - }, - { - "name": "operator" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "create_config", - "discriminator": [ - 201, - 207, - 243, - 114, - 75, - 111, - 47, - 189 - ], - "accounts": [ - { - "name": "config", - "writable": true, - "signer": true - }, - { - "name": "fee_claimer" - }, - { - "name": "leftover_receiver" - }, - { - "name": "quote_mint", - "docs": [ - "quote mint" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "config_parameters", - "type": { - "defined": { - "name": "ConfigParameters" - } - } - } - ] - }, - { - "name": "create_locker", - "docs": [ - "PERMISSIONLESS FUNCTIONS ///", - "create locker" - ], - "discriminator": [ - 167, - 90, - 137, - 154, - 75, - 47, - 17, - 84 - ], - "accounts": [ - { - "name": "virtual_pool", - "docs": [ - "Virtual pool" - ], - "writable": true - }, - { - "name": "config", - "docs": [ - "Config" - ], - "relations": [ - "virtual_pool" - ] - }, - { - "name": "pool_authority", - "writable": true, - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "base_vault", - "writable": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "base_mint", - "writable": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "base", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 97, - 115, - 101, - 95, - 108, - 111, - 99, - 107, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "virtual_pool" - } - ] - } - }, - { - "name": "creator", - "relations": [ - "virtual_pool" - ] - }, - { - "name": "escrow", - "writable": true - }, - { - "name": "escrow_token", - "writable": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "locker_program", - "address": "LocpQgucEQHbqNABEYvBvwoxCPsSbG91A1QaQhQQqjn" - }, - { - "name": "locker_event_authority" - }, - { - "name": "system_program", - "docs": [ - "System program." - ], - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "create_partner_metadata", - "docs": [ - "PARTNER FUNCTIONS ////" - ], - "discriminator": [ - 192, - 168, - 234, - 191, - 188, - 226, - 227, - 255 - ], - "accounts": [ - { - "name": "partner_metadata", - "docs": [ - "Partner metadata" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 97, - 114, - 116, - 110, - 101, - 114, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "fee_claimer" - } - ] - } - }, - { - "name": "payer", - "docs": [ - "Payer of the partner metadata." - ], - "writable": true, - "signer": true - }, - { - "name": "fee_claimer", - "docs": [ - "Fee claimer for partner" - ], - "signer": true - }, - { - "name": "system_program", - "docs": [ - "System program." - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "metadata", - "type": { - "defined": { - "name": "CreatePartnerMetadataParameters" - } - } - } - ] - }, - { - "name": "create_virtual_pool_metadata", - "discriminator": [ - 45, - 97, - 187, - 103, - 254, - 109, - 124, - 134 - ], - "accounts": [ - { - "name": "virtual_pool", - "writable": true - }, - { - "name": "virtual_pool_metadata", - "docs": [ - "Virtual pool metadata" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 105, - 114, - 116, - 117, - 97, - 108, - 95, - 112, - 111, - 111, - 108, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "virtual_pool" - } - ] - } - }, - { - "name": "creator", - "signer": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "payer", - "docs": [ - "Payer of the virtual pool metadata." - ], - "writable": true, - "signer": true - }, - { - "name": "system_program", - "docs": [ - "System program." - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "metadata", - "type": { - "defined": { - "name": "CreateVirtualPoolMetadataParameters" - } - } - } - ] - }, - { - "name": "creator_withdraw_surplus", - "discriminator": [ - 165, - 3, - 137, - 7, - 28, - 134, - 76, - 80 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "config", - "relations": [ - "virtual_pool" - ] - }, - { - "name": "virtual_pool", - "writable": true - }, - { - "name": "token_quote_account", - "docs": [ - "The receiver token account" - ], - "writable": true - }, - { - "name": "quote_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "quote_mint", - "docs": [ - "The mint of quote token" - ], - "relations": [ - "config" - ] - }, - { - "name": "creator", - "signer": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "token_quote_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "initialize_virtual_pool_with_spl_token", - "docs": [ - "POOL CREATOR FUNCTIONS ////" - ], - "discriminator": [ - 140, - 85, - 215, - 176, - 102, - 54, - 104, - 79 - ], - "accounts": [ - { - "name": "config", - "docs": [ - "Which config the pool belongs to." - ] - }, - { - "name": "pool_authority", - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "creator", - "signer": true - }, - { - "name": "base_mint", - "writable": true, - "signer": true - }, - { - "name": "quote_mint", - "relations": [ - "config" - ] - }, - { - "name": "pool", - "docs": [ - "Initialize an account to store the pool state" - ], - "writable": true - }, - { - "name": "base_vault", - "docs": [ - "Token a vault for the pool" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "base_mint" - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "quote_vault", - "docs": [ - "Token b vault for the pool" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "quote_mint" - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "mint_metadata", - "writable": true - }, - { - "name": "metadata_program", - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - }, - { - "name": "payer", - "docs": [ - "Address paying to create the pool. Can be anyone" - ], - "writable": true, - "signer": true - }, - { - "name": "token_quote_program", - "docs": [ - "Program to create mint account and mint tokens" - ] - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "InitializePoolParameters" - } - } - } - ] - }, - { - "name": "initialize_virtual_pool_with_token2022", - "discriminator": [ - 169, - 118, - 51, - 78, - 145, - 110, - 220, - 155 - ], - "accounts": [ - { - "name": "config", - "docs": [ - "Which config the pool belongs to." - ] - }, - { - "name": "pool_authority", - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "creator", - "signer": true - }, - { - "name": "base_mint", - "docs": [ - "Unique token mint address, initialize in contract" - ], - "writable": true, - "signer": true - }, - { - "name": "quote_mint", - "relations": [ - "config" - ] - }, - { - "name": "pool", - "docs": [ - "Initialize an account to store the pool state" - ], - "writable": true - }, - { - "name": "base_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "base_mint" - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "quote_vault", - "docs": [ - "Token quote vault for the pool" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "quote_mint" - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "payer", - "docs": [ - "Address paying to create the pool. Can be anyone" - ], - "writable": true, - "signer": true - }, - { - "name": "token_quote_program", - "docs": [ - "Program to create mint account and mint tokens" - ] - }, - { - "name": "token_program", - "docs": [ - "token program for base mint" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "InitializePoolParameters" - } - } - } - ] - }, - { - "name": "migrate_meteora_damm", - "discriminator": [ - 27, - 1, - 48, - 22, - 180, - 63, - 118, - 217 - ], - "accounts": [ - { - "name": "virtual_pool", - "docs": [ - "virtual pool" - ], - "writable": true, - "relations": [ - "migration_metadata" - ] - }, - { - "name": "migration_metadata", - "writable": true - }, - { - "name": "config", - "relations": [ - "virtual_pool" - ] - }, - { - "name": "pool_authority", - "writable": true, - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "pool", - "writable": true - }, - { - "name": "damm_config", - "docs": [ - "pool config" - ] - }, - { - "name": "lp_mint", - "writable": true - }, - { - "name": "token_a_mint", - "writable": true - }, - { - "name": "token_b_mint" - }, - { - "name": "a_vault", - "writable": true - }, - { - "name": "b_vault", - "writable": true - }, - { - "name": "a_token_vault", - "writable": true - }, - { - "name": "b_token_vault", - "writable": true - }, - { - "name": "a_vault_lp_mint", - "writable": true - }, - { - "name": "b_vault_lp_mint", - "writable": true - }, - { - "name": "a_vault_lp", - "writable": true - }, - { - "name": "b_vault_lp", - "writable": true - }, - { - "name": "base_vault", - "writable": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "quote_vault", - "writable": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "virtual_pool_lp", - "writable": true - }, - { - "name": "protocol_token_a_fee", - "writable": true - }, - { - "name": "protocol_token_b_fee", - "writable": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent" - }, - { - "name": "mint_metadata", - "writable": true - }, - { - "name": "metadata_program" - }, - { - "name": "amm_program", - "address": "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" - }, - { - "name": "vault_program" - }, - { - "name": "token_program", - "docs": [ - "token_program" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program" - }, - { - "name": "system_program", - "docs": [ - "System program." - ], - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "migrate_meteora_damm_claim_lp_token", - "discriminator": [ - 139, - 133, - 2, - 30, - 91, - 145, - 127, - 154 - ], - "accounts": [ - { - "name": "virtual_pool", - "relations": [ - "migration_metadata" - ] - }, - { - "name": "migration_metadata", - "docs": [ - "migration metadata" - ], - "writable": true - }, - { - "name": "pool_authority", - "writable": true, - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "lp_mint", - "relations": [ - "migration_metadata" - ] - }, - { - "name": "source_token", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "pool_authority" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "migration_metadata" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "destination_token", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "owner" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "migration_metadata" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "owner" - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_program", - "docs": [ - "token_program" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - } - ], - "args": [] - }, - { - "name": "migrate_meteora_damm_lock_lp_token", - "discriminator": [ - 177, - 55, - 238, - 157, - 251, - 88, - 165, - 42 - ], - "accounts": [ - { - "name": "virtual_pool", - "relations": [ - "migration_metadata" - ] - }, - { - "name": "migration_metadata", - "docs": [ - "migration_metadata" - ], - "writable": true - }, - { - "name": "pool_authority", - "writable": true, - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "pool", - "writable": true, - "relations": [ - "lock_escrow" - ] - }, - { - "name": "lp_mint", - "relations": [ - "migration_metadata" - ] - }, - { - "name": "lock_escrow", - "writable": true - }, - { - "name": "owner", - "relations": [ - "lock_escrow" - ] - }, - { - "name": "source_tokens", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "pool_authority" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "migration_metadata" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "escrow_vault", - "writable": true - }, - { - "name": "amm_program", - "address": "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" - }, - { - "name": "a_vault" - }, - { - "name": "b_vault" - }, - { - "name": "a_vault_lp" - }, - { - "name": "b_vault_lp" - }, - { - "name": "a_vault_lp_mint" - }, - { - "name": "b_vault_lp_mint" - }, - { - "name": "token_program", - "docs": [ - "token_program" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - } - ], - "args": [] - }, - { - "name": "migration_damm_v2", - "discriminator": [ - 156, - 169, - 230, - 103, - 53, - 228, - 80, - 64 - ], - "accounts": [ - { - "name": "virtual_pool", - "docs": [ - "virtual pool" - ], - "writable": true, - "relations": [ - "migration_metadata" - ] - }, - { - "name": "migration_metadata", - "docs": [ - "migration metadata" - ] - }, - { - "name": "config", - "docs": [ - "virtual pool config key" - ], - "relations": [ - "virtual_pool" - ] - }, - { - "name": "pool_authority", - "writable": true, - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "pool", - "writable": true - }, - { - "name": "first_position_nft_mint", - "writable": true - }, - { - "name": "first_position_nft_account", - "writable": true - }, - { - "name": "first_position", - "writable": true - }, - { - "name": "second_position_nft_mint", - "writable": true, - "optional": true - }, - { - "name": "second_position_nft_account", - "writable": true, - "optional": true - }, - { - "name": "second_position", - "writable": true, - "optional": true - }, - { - "name": "damm_pool_authority" - }, - { - "name": "amm_program", - "address": "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG" - }, - { - "name": "base_mint", - "writable": true - }, - { - "name": "quote_mint", - "writable": true - }, - { - "name": "token_a_vault", - "writable": true - }, - { - "name": "token_b_vault", - "writable": true - }, - { - "name": "base_vault", - "writable": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "quote_vault", - "writable": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "token_base_program" - }, - { - "name": "token_quote_program" - }, - { - "name": "token_2022_program" - }, - { - "name": "damm_event_authority" - }, - { - "name": "system_program", - "docs": [ - "System program." - ], - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "migration_damm_v2_create_metadata", - "discriminator": [ - 109, - 189, - 19, - 36, - 195, - 183, - 222, - 82 - ], - "accounts": [ - { - "name": "virtual_pool" - }, - { - "name": "config", - "relations": [ - "virtual_pool" - ] - }, - { - "name": "migration_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 97, - 109, - 109, - 95, - 118, - 50 - ] - }, - { - "kind": "account", - "path": "virtual_pool" - } - ] - } - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "migration_meteora_damm_create_metadata", - "docs": [ - "migrate damm v1" - ], - "discriminator": [ - 47, - 94, - 126, - 115, - 221, - 226, - 194, - 133 - ], - "accounts": [ - { - "name": "virtual_pool" - }, - { - "name": "config", - "relations": [ - "virtual_pool" - ] - }, - { - "name": "migration_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 116, - 101, - 111, - 114, - 97 - ] - }, - { - "kind": "account", - "path": "virtual_pool" - } - ] - } - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "partner_withdraw_surplus", - "discriminator": [ - 168, - 173, - 72, - 100, - 201, - 98, - 38, - 92 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "config", - "relations": [ - "virtual_pool" - ] - }, - { - "name": "virtual_pool", - "writable": true - }, - { - "name": "token_quote_account", - "docs": [ - "The receiver token account" - ], - "writable": true - }, - { - "name": "quote_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "quote_mint", - "docs": [ - "The mint of quote token" - ], - "relations": [ - "config" - ] - }, - { - "name": "fee_claimer", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "token_quote_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "protocol_withdraw_surplus", - "discriminator": [ - 54, - 136, - 225, - 138, - 172, - 182, - 214, - 167 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "config", - "relations": [ - "virtual_pool" - ] - }, - { - "name": "virtual_pool", - "writable": true - }, - { - "name": "token_quote_account", - "docs": [ - "The treasury quote token account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 48, - 9, - 89, - 123, - 106, - 114, - 131, - 251, - 50, - 173, - 254, - 250, - 10, - 80, - 160, - 84, - 143, - 100, - 81, - 249, - 134, - 112, - 30, - 213, - 50, - 166, - 239, - 78, - 53, - 175, - 188, - 85 - ] - }, - { - "kind": "account", - "path": "token_quote_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "quote_vault", - "docs": [ - "The vault token account for quote token" - ], - "writable": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "quote_mint", - "docs": [ - "The mint of of token" - ], - "relations": [ - "config" - ] - }, - { - "name": "token_quote_program", - "docs": [ - "Token b program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "swap", - "docs": [ - "TRADING BOTS FUNCTIONS ////" - ], - "discriminator": [ - 248, - 198, - 158, - 145, - 225, - 117, - 135, - 200 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "config", - "docs": [ - "config key" - ], - "relations": [ - "pool" - ] - }, - { - "name": "pool", - "docs": [ - "Pool account" - ], - "writable": true - }, - { - "name": "input_token_account", - "docs": [ - "The user token account for input token" - ], - "writable": true - }, - { - "name": "output_token_account", - "docs": [ - "The user token account for output token" - ], - "writable": true - }, - { - "name": "base_vault", - "docs": [ - "The vault token account for base token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "quote_vault", - "docs": [ - "The vault token account for quote token" - ], - "writable": true, - "relations": [ - "pool" - ] - }, - { - "name": "base_mint", - "docs": [ - "The mint of base token" - ] - }, - { - "name": "quote_mint", - "docs": [ - "The mint of quote token" - ] - }, - { - "name": "payer", - "docs": [ - "The user performing the swap" - ], - "signer": true - }, - { - "name": "token_base_program", - "docs": [ - "Token base program" - ] - }, - { - "name": "token_quote_program", - "docs": [ - "Token quote program" - ] - }, - { - "name": "referral_token_account", - "docs": [ - "referral token account" - ], - "writable": true, - "optional": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SwapParameters" - } - } - } - ] - }, - { - "name": "withdraw_leftover", - "discriminator": [ - 20, - 198, - 202, - 237, - 235, - 243, - 183, - 66 - ], - "accounts": [ - { - "name": "pool_authority", - "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - }, - { - "name": "config", - "relations": [ - "virtual_pool" - ] - }, - { - "name": "virtual_pool", - "writable": true - }, - { - "name": "token_base_account", - "docs": [ - "The receiver token account, withdraw to ATA" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "leftover_receiver" - }, - { - "kind": "account", - "path": "token_base_program" - }, - { - "kind": "account", - "path": "base_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "base_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "virtual_pool" - ] - }, - { - "name": "base_mint", - "docs": [ - "The mint of quote token" - ], - "relations": [ - "virtual_pool" - ] - }, - { - "name": "leftover_receiver", - "relations": [ - "config" - ] - }, - { - "name": "token_base_program", - "docs": [ - "Token base program" - ] - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - } - ], - "accounts": [ - { - "name": "ClaimFeeOperator", - "discriminator": [ - 166, - 48, - 134, - 86, - 34, - 200, - 188, - 150 - ] - }, - { - "name": "Config", - "discriminator": [ - 155, - 12, - 170, - 224, - 30, - 250, - 204, - 130 - ] - }, - { - "name": "LockEscrow", - "discriminator": [ - 190, - 106, - 121, - 6, - 200, - 182, - 21, - 75 - ] - }, - { - "name": "MeteoraDammMigrationMetadata", - "discriminator": [ - 17, - 155, - 141, - 215, - 207, - 4, - 133, - 156 - ] - }, - { - "name": "MeteoraDammV2Metadata", - "discriminator": [ - 104, - 221, - 219, - 203, - 10, - 142, - 250, - 163 - ] - }, - { - "name": "PartnerMetadata", - "discriminator": [ - 68, - 68, - 130, - 19, - 16, - 209, - 98, - 156 - ] - }, - { - "name": "PoolConfig", - "discriminator": [ - 26, - 108, - 14, - 123, - 116, - 230, - 129, - 43 - ] - }, - { - "name": "VirtualPool", - "discriminator": [ - 213, - 224, - 5, - 209, - 98, - 69, - 119, - 92 - ] - }, - { - "name": "VirtualPoolMetadata", - "discriminator": [ - 217, - 37, - 82, - 250, - 43, - 47, - 228, - 254 - ] - } - ], - "events": [ - { - "name": "EvtClaimCreatorTradingFee", - "discriminator": [ - 154, - 228, - 215, - 202, - 133, - 155, - 214, - 138 - ] - }, - { - "name": "EvtClaimProtocolFee", - "discriminator": [ - 186, - 244, - 75, - 251, - 188, - 13, - 25, - 33 - ] - }, - { - "name": "EvtClaimTradingFee", - "discriminator": [ - 26, - 83, - 117, - 240, - 92, - 202, - 112, - 254 - ] - }, - { - "name": "EvtCloseClaimFeeOperator", - "discriminator": [ - 111, - 39, - 37, - 55, - 110, - 216, - 194, - 23 - ] - }, - { - "name": "EvtCreateClaimFeeOperator", - "discriminator": [ - 21, - 6, - 153, - 120, - 68, - 116, - 28, - 177 - ] - }, - { - "name": "EvtCreateConfig", - "discriminator": [ - 131, - 207, - 180, - 174, - 180, - 73, - 165, - 54 - ] - }, - { - "name": "EvtCreateDammV2MigrationMetadata", - "discriminator": [ - 103, - 111, - 132, - 168, - 140, - 253, - 150, - 114 - ] - }, - { - "name": "EvtCreateMeteoraMigrationMetadata", - "discriminator": [ - 99, - 167, - 133, - 63, - 214, - 143, - 175, - 139 - ] - }, - { - "name": "EvtCreatorWithdrawSurplus", - "discriminator": [ - 152, - 73, - 21, - 15, - 66, - 87, - 53, - 157 - ] - }, - { - "name": "EvtCurveComplete", - "discriminator": [ - 229, - 231, - 86, - 84, - 156, - 134, - 75, - 24 - ] - }, - { - "name": "EvtInitializePool", - "discriminator": [ - 228, - 50, - 246, - 85, - 203, - 66, - 134, - 37 - ] - }, - { - "name": "EvtPartnerMetadata", - "discriminator": [ - 200, - 127, - 6, - 55, - 13, - 32, - 8, - 150 - ] - }, - { - "name": "EvtPartnerWithdrawSurplus", - "discriminator": [ - 195, - 56, - 152, - 9, - 232, - 72, - 35, - 22 - ] - }, - { - "name": "EvtProtocolWithdrawSurplus", - "discriminator": [ - 109, - 111, - 28, - 221, - 134, - 195, - 230, - 203 - ] - }, - { - "name": "EvtSwap", - "discriminator": [ - 27, - 60, - 21, - 213, - 138, - 170, - 187, - 147 - ] - }, - { - "name": "EvtVirtualPoolMetadata", - "discriminator": [ - 188, - 18, - 72, - 76, - 195, - 91, - 38, - 74 - ] - }, - { - "name": "EvtWithdrawLeftover", - "discriminator": [ - 191, - 189, - 104, - 143, - 111, - 156, - 94, - 229 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "MathOverflow", - "msg": "Math operation overflow" - }, - { - "code": 6001, - "name": "InvalidFee", - "msg": "Invalid fee setup" - }, - { - "code": 6002, - "name": "ExceededSlippage", - "msg": "Exceeded slippage tolerance" - }, - { - "code": 6003, - "name": "ExceedMaxFeeBps", - "msg": "Exceeded max fee bps" - }, - { - "code": 6004, - "name": "InvalidAdmin", - "msg": "Invalid admin" - }, - { - "code": 6005, - "name": "AmountIsZero", - "msg": "Amount is zero" - }, - { - "code": 6006, - "name": "TypeCastFailed", - "msg": "Type cast error" - }, - { - "code": 6007, - "name": "InvalidActivationType", - "msg": "Invalid activation type" - }, - { - "code": 6008, - "name": "InvalidQuoteMint", - "msg": "Invalid quote mint" - }, - { - "code": 6009, - "name": "InvalidCollectFeeMode", - "msg": "Invalid collect fee mode" - }, - { - "code": 6010, - "name": "InvalidMigrationFeeOption", - "msg": "Invalid migration fee option" - }, - { - "code": 6011, - "name": "InvalidInput", - "msg": "Invalid input" - }, - { - "code": 6012, - "name": "NotEnoughLiquidity", - "msg": "Not enough liquidity" - }, - { - "code": 6013, - "name": "PoolIsCompleted", - "msg": "Pool is completed" - }, - { - "code": 6014, - "name": "PoolIsIncompleted", - "msg": "Pool is incompleted" - }, - { - "code": 6015, - "name": "InvalidMigrationOption", - "msg": "Invalid migration option" - }, - { - "code": 6016, - "name": "InvalidTokenDecimals", - "msg": "Invalid activation type" - }, - { - "code": 6017, - "name": "InvalidTokenType", - "msg": "Invalid token type" - }, - { - "code": 6018, - "name": "InvalidFeePercentage", - "msg": "Invalid fee percentage" - }, - { - "code": 6019, - "name": "InvalidQuoteThreshold", - "msg": "Invalid quote threshold" - }, - { - "code": 6020, - "name": "InvalidTokenSupply", - "msg": "Invalid token supply" - }, - { - "code": 6021, - "name": "InvalidCurve", - "msg": "Invalid curve" - }, - { - "code": 6022, - "name": "NotPermitToDoThisAction", - "msg": "Not permit to do this action" - }, - { - "code": 6023, - "name": "InvalidOwnerAccount", - "msg": "Invalid owner account" - }, - { - "code": 6024, - "name": "InvalidConfigAccount", - "msg": "Invalid config account" - }, - { - "code": 6025, - "name": "SurplusHasBeenWithdraw", - "msg": "Surplus has been withdraw" - }, - { - "code": 6026, - "name": "LeftoverHasBeenWithdraw", - "msg": "Leftover has been withdraw" - }, - { - "code": 6027, - "name": "TotalBaseTokenExceedMaxSupply", - "msg": "Total base token is exceeded max supply" - }, - { - "code": 6028, - "name": "UnsupportNativeMintToken2022", - "msg": "Unsupport native mint token 2022" - }, - { - "code": 6029, - "name": "InsufficientLiquidityForMigration", - "msg": "Insufficient liquidity for migration" - }, - { - "code": 6030, - "name": "MissingPoolConfigInRemainingAccount", - "msg": "Missing pool config in remaining account" - }, - { - "code": 6031, - "name": "InvalidVestingParameters", - "msg": "Invalid vesting parameters" - }, - { - "code": 6032, - "name": "InvalidLeftoverAddress", - "msg": "Invalid leftover address" - }, - { - "code": 6033, - "name": "SwapAmountIsOverAThreshold", - "msg": "Swap amount is over a threshold" - }, - { - "code": 6034, - "name": "InvalidFeeScheduler", - "msg": "Invalid fee scheduler" - }, - { - "code": 6035, - "name": "InvalidCreatorTradingFeePercentage", - "msg": "Invalid creator trading fee percentage" - } - ], - "types": [ - { - "name": "BaseFeeConfig", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "cliff_fee_numerator", - "type": "u64" - }, - { - "name": "period_frequency", - "type": "u64" - }, - { - "name": "reduction_factor", - "type": "u64" - }, - { - "name": "number_of_period", - "type": "u16" - }, - { - "name": "fee_scheduler_mode", - "type": "u8" - }, - { - "name": "padding_0", - "type": { - "array": [ - "u8", - 5 - ] - } - } - ] - } - }, - { - "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": "ClaimFeeOperator", - "docs": [ - "Parameter that set by the protocol" - ], - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "operator", - "docs": [ - "operator" - ], - "type": "pubkey" - }, - { - "name": "_padding", - "docs": [ - "Reserve" - ], - "type": { - "array": [ - "u8", - 128 - ] - } - } - ] - } - }, - { - "name": "Config", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_fees", - "type": { - "defined": { - "name": "PoolFees" - } - } - }, - { - "name": "activation_duration", - "type": "u64" - }, - { - "name": "vault_config_key", - "type": "pubkey" - }, - { - "name": "pool_creator_authority", - "type": "pubkey" - }, - { - "name": "activation_type", - "type": "u8" - }, - { - "name": "partner_fee_numerator", - "type": "u64" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 219 - ] - } - } - ] - } - }, - { - "name": "ConfigParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_fees", - "type": { - "defined": { - "name": "PoolFeeParameters" - } - } - }, - { - "name": "collect_fee_mode", - "type": "u8" - }, - { - "name": "migration_option", - "type": "u8" - }, - { - "name": "activation_type", - "type": "u8" - }, - { - "name": "token_type", - "type": "u8" - }, - { - "name": "token_decimal", - "type": "u8" - }, - { - "name": "partner_lp_percentage", - "type": "u8" - }, - { - "name": "partner_locked_lp_percentage", - "type": "u8" - }, - { - "name": "creator_lp_percentage", - "type": "u8" - }, - { - "name": "creator_locked_lp_percentage", - "type": "u8" - }, - { - "name": "migration_quote_threshold", - "type": "u64" - }, - { - "name": "sqrt_start_price", - "type": "u128" - }, - { - "name": "locked_vesting", - "type": { - "defined": { - "name": "LockedVestingParams" - } - } - }, - { - "name": "migration_fee_option", - "type": "u8" - }, - { - "name": "token_supply", - "type": { - "option": { - "defined": { - "name": "TokenSupplyParams" - } - } - } - }, - { - "name": "creator_trading_fee_percentage", - "type": "u8" - }, - { - "name": "padding_0", - "type": { - "array": [ - "u8", - 7 - ] - } - }, - { - "name": "padding_1", - "docs": [ - "padding for future use" - ], - "type": { - "array": [ - "u64", - 7 - ] - } - }, - { - "name": "curve", - "type": { - "vec": { - "defined": { - "name": "LiquidityDistributionParameters" - } - } - } - } - ] - } - }, - { - "name": "CreatePartnerMetadataParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "padding", - "type": { - "array": [ - "u8", - 96 - ] - } - }, - { - "name": "name", - "type": "string" - }, - { - "name": "website", - "type": "string" - }, - { - "name": "logo", - "type": "string" - } - ] - } - }, - { - "name": "CreateVirtualPoolMetadataParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "padding", - "type": { - "array": [ - "u8", - 96 - ] - } - }, - { - "name": "name", - "type": "string" - }, - { - "name": "website", - "type": "string" - }, - { - "name": "logo", - "type": "string" - } - ] - } - }, - { - "name": "DynamicFeeConfig", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "initialized", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 7 - ] - } - }, - { - "name": "max_volatility_accumulator", - "type": "u32" - }, - { - "name": "variable_fee_control", - "type": "u32" - }, - { - "name": "bin_step", - "type": "u16" - }, - { - "name": "filter_period", - "type": "u16" - }, - { - "name": "decay_period", - "type": "u16" - }, - { - "name": "reduction_factor", - "type": "u16" - }, - { - "name": "padding2", - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "bin_step_u128", - "type": "u128" - } - ] - } - }, - { - "name": "DynamicFeeParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bin_step", - "type": "u16" - }, - { - "name": "bin_step_u128", - "type": "u128" - }, - { - "name": "filter_period", - "type": "u16" - }, - { - "name": "decay_period", - "type": "u16" - }, - { - "name": "reduction_factor", - "type": "u16" - }, - { - "name": "max_volatility_accumulator", - "type": "u32" - }, - { - "name": "variable_fee_control", - "type": "u32" - } - ] - } - }, - { - "name": "EvtClaimCreatorTradingFee", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "token_base_amount", - "type": "u64" - }, - { - "name": "token_quote_amount", - "type": "u64" - } - ] - } - }, - { - "name": "EvtClaimProtocolFee", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "token_base_amount", - "type": "u64" - }, - { - "name": "token_quote_amount", - "type": "u64" - } - ] - } - }, - { - "name": "EvtClaimTradingFee", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "token_base_amount", - "type": "u64" - }, - { - "name": "token_quote_amount", - "type": "u64" - } - ] - } - }, - { - "name": "EvtCloseClaimFeeOperator", - "docs": [ - "Close claim fee operator" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "claim_fee_operator", - "type": "pubkey" - }, - { - "name": "operator", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtCreateClaimFeeOperator", - "docs": [ - "Create claim fee operator" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "operator", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtCreateConfig", - "docs": [ - "Create config" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "config", - "type": "pubkey" - }, - { - "name": "quote_mint", - "type": "pubkey" - }, - { - "name": "fee_claimer", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pool_fees", - "type": { - "defined": { - "name": "PoolFeeParameters" - } - } - }, - { - "name": "collect_fee_mode", - "type": "u8" - }, - { - "name": "migration_option", - "type": "u8" - }, - { - "name": "activation_type", - "type": "u8" - }, - { - "name": "token_decimal", - "type": "u8" - }, - { - "name": "token_type", - "type": "u8" - }, - { - "name": "partner_locked_lp_percentage", - "type": "u8" - }, - { - "name": "partner_lp_percentage", - "type": "u8" - }, - { - "name": "creator_locked_lp_percentage", - "type": "u8" - }, - { - "name": "creator_lp_percentage", - "type": "u8" - }, - { - "name": "swap_base_amount", - "type": "u64" - }, - { - "name": "migration_quote_threshold", - "type": "u64" - }, - { - "name": "migration_base_amount", - "type": "u64" - }, - { - "name": "sqrt_start_price", - "type": "u128" - }, - { - "name": "locked_vesting", - "type": { - "defined": { - "name": "LockedVestingParams" - } - } - }, - { - "name": "migration_fee_option", - "type": "u8" - }, - { - "name": "fixed_token_supply_flag", - "type": "u8" - }, - { - "name": "pre_migration_token_supply", - "type": "u64" - }, - { - "name": "post_migration_token_supply", - "type": "u64" - }, - { - "name": "curve", - "type": { - "vec": { - "defined": { - "name": "LiquidityDistributionParameters" - } - } - } - } - ] - } - }, - { - "name": "EvtCreateDammV2MigrationMetadata", - "type": { - "kind": "struct", - "fields": [ - { - "name": "virtual_pool", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtCreateMeteoraMigrationMetadata", - "type": { - "kind": "struct", - "fields": [ - { - "name": "virtual_pool", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtCreatorWithdrawSurplus", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "surplus_amount", - "type": "u64" - } - ] - } - }, - { - "name": "EvtCurveComplete", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "config", - "type": "pubkey" - }, - { - "name": "base_reserve", - "type": "u64" - }, - { - "name": "quote_reserve", - "type": "u64" - } - ] - } - }, - { - "name": "EvtInitializePool", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "config", - "type": "pubkey" - }, - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "base_mint", - "type": "pubkey" - }, - { - "name": "pool_type", - "type": "u8" - }, - { - "name": "activation_point", - "type": "u64" - } - ] - } - }, - { - "name": "EvtPartnerMetadata", - "docs": [ - "Create partner metadata" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "partner_metadata", - "type": "pubkey" - }, - { - "name": "fee_claimer", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtPartnerWithdrawSurplus", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "surplus_amount", - "type": "u64" - } - ] - } - }, - { - "name": "EvtProtocolWithdrawSurplus", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "surplus_amount", - "type": "u64" - } - ] - } - }, - { - "name": "EvtSwap", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "config", - "type": "pubkey" - }, - { - "name": "trade_direction", - "type": "u8" - }, - { - "name": "has_referral", - "type": "bool" - }, - { - "name": "params", - "type": { - "defined": { - "name": "SwapParameters" - } - } - }, - { - "name": "swap_result", - "type": { - "defined": { - "name": "SwapResult" - } - } - }, - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "current_timestamp", - "type": "u64" - } - ] - } - }, - { - "name": "EvtVirtualPoolMetadata", - "docs": [ - "Create virtual pool metadata" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "virtual_pool_metadata", - "type": "pubkey" - }, - { - "name": "virtual_pool", - "type": "pubkey" - } - ] - } - }, - { - "name": "EvtWithdrawLeftover", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "leftover_receiver", - "type": "pubkey" - }, - { - "name": "leftover_amount", - "type": "u64" - } - ] - } - }, - { - "name": "InitializePoolParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "name", - "type": "string" - }, - { - "name": "symbol", - "type": "string" - }, - { - "name": "uri", - "type": "string" - } - ] - } - }, - { - "name": "LiquidityDistributionConfig", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "sqrt_price", - "type": "u128" - }, - { - "name": "liquidity", - "type": "u128" - } - ] - } - }, - { - "name": "LiquidityDistributionParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "sqrt_price", - "type": "u128" - }, - { - "name": "liquidity", - "type": "u128" - } - ] - } - }, - { - "name": "LockEscrow", - "docs": [ - "State of lock escrow account" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "escrow_vault", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "total_locked_amount", - "type": "u64" - }, - { - "name": "lp_per_token", - "type": "u128" - }, - { - "name": "unclaimed_fee_pending", - "type": "u64" - }, - { - "name": "a_fee", - "type": "u64" - }, - { - "name": "b_fee", - "type": "u64" - } - ] - } - }, - { - "name": "LockedVestingConfig", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_per_period", - "type": "u64" - }, - { - "name": "cliff_duration_from_migration_time", - "type": "u64" - }, - { - "name": "frequency", - "type": "u64" - }, - { - "name": "number_of_period", - "type": "u64" - }, - { - "name": "cliff_unlock_amount", - "type": "u64" - }, - { - "name": "_padding", - "type": "u64" - } - ] - } - }, - { - "name": "LockedVestingParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_per_period", - "type": "u64" - }, - { - "name": "cliff_duration_from_migration_time", - "type": "u64" - }, - { - "name": "frequency", - "type": "u64" - }, - { - "name": "number_of_period", - "type": "u64" - }, - { - "name": "cliff_unlock_amount", - "type": "u64" - } - ] - } - }, - { - "name": "MeteoraDammMigrationMetadata", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "virtual_pool", - "docs": [ - "pool" - ], - "type": "pubkey" - }, - { - "name": "pool_creator", - "docs": [ - "pool creator" - ], - "type": "pubkey" - }, - { - "name": "partner", - "docs": [ - "partner" - ], - "type": "pubkey" - }, - { - "name": "lp_mint", - "docs": [ - "lp mint" - ], - "type": "pubkey" - }, - { - "name": "partner_locked_lp", - "docs": [ - "partner locked lp" - ], - "type": "u64" - }, - { - "name": "partner_lp", - "docs": [ - "partner lp" - ], - "type": "u64" - }, - { - "name": "creator_locked_lp", - "docs": [ - "creator locked lp" - ], - "type": "u64" - }, - { - "name": "creator_lp", - "docs": [ - "creator lp" - ], - "type": "u64" - }, - { - "name": "_padding_0", - "docs": [ - "padding" - ], - "type": "u8" - }, - { - "name": "creator_locked_status", - "docs": [ - "flag to check whether lp is locked for creator" - ], - "type": "u8" - }, - { - "name": "partner_locked_status", - "docs": [ - "flag to check whether lp is locked for partner" - ], - "type": "u8" - }, - { - "name": "creator_claim_status", - "docs": [ - "flag to check whether creator has claimed lp token" - ], - "type": "u8" - }, - { - "name": "partner_claim_status", - "docs": [ - "flag to check whether partner has claimed lp token" - ], - "type": "u8" - }, - { - "name": "_padding", - "docs": [ - "Reserve" - ], - "type": { - "array": [ - "u8", - 107 - ] - } - } - ] - } - }, - { - "name": "MeteoraDammV2Metadata", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "virtual_pool", - "docs": [ - "pool" - ], - "type": "pubkey" - }, - { - "name": "pool_creator", - "docs": [ - "pool creator" - ], - "type": "pubkey" - }, - { - "name": "partner", - "docs": [ - "partner" - ], - "type": "pubkey" - }, - { - "name": "_padding", - "docs": [ - "Reserve" - ], - "type": { - "array": [ - "u8", - 126 - ] - } - } - ] - } - }, - { - "name": "PartnerMetadata", - "docs": [ - "Metadata for a partner." - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "fee_claimer", - "docs": [ - "fee claimer" - ], - "type": "pubkey" - }, - { - "name": "padding", - "docs": [ - "padding for future use" - ], - "type": { - "array": [ - "u128", - 6 - ] - } - }, - { - "name": "name", - "docs": [ - "Name of partner." - ], - "type": "string" - }, - { - "name": "website", - "docs": [ - "Website of partner." - ], - "type": "string" - }, - { - "name": "logo", - "docs": [ - "Logo of partner" - ], - "type": "string" - } - ] - } - }, - { - "name": "PoolConfig", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "quote_mint", - "docs": [ - "quote mint" - ], - "type": "pubkey" - }, - { - "name": "fee_claimer", - "docs": [ - "Address to get the fee" - ], - "type": "pubkey" - }, - { - "name": "leftover_receiver", - "docs": [ - "Address to receive extra base token after migration, in case token is fixed supply" - ], - "type": "pubkey" - }, - { - "name": "pool_fees", - "docs": [ - "Pool fee" - ], - "type": { - "defined": { - "name": "PoolFeesConfig" - } - } - }, - { - "name": "collect_fee_mode", - "docs": [ - "Collect fee mode" - ], - "type": "u8" - }, - { - "name": "migration_option", - "docs": [ - "migration option" - ], - "type": "u8" - }, - { - "name": "activation_type", - "docs": [ - "whether mode slot or timestamp" - ], - "type": "u8" - }, - { - "name": "token_decimal", - "docs": [ - "token decimals" - ], - "type": "u8" - }, - { - "name": "version", - "docs": [ - "version" - ], - "type": "u8" - }, - { - "name": "token_type", - "docs": [ - "token type of base token" - ], - "type": "u8" - }, - { - "name": "quote_token_flag", - "docs": [ - "quote token flag" - ], - "type": "u8" - }, - { - "name": "partner_locked_lp_percentage", - "docs": [ - "partner locked lp percentage" - ], - "type": "u8" - }, - { - "name": "partner_lp_percentage", - "docs": [ - "partner lp percentage" - ], - "type": "u8" - }, - { - "name": "creator_locked_lp_percentage", - "docs": [ - "creator post migration fee percentage" - ], - "type": "u8" - }, - { - "name": "creator_lp_percentage", - "docs": [ - "creator lp percentage" - ], - "type": "u8" - }, - { - "name": "migration_fee_option", - "docs": [ - "migration fee option" - ], - "type": "u8" - }, - { - "name": "fixed_token_supply_flag", - "docs": [ - "flag to indicate whether token is dynamic supply (0) or fixed supply (1)" - ], - "type": "u8" - }, - { - "name": "creator_trading_fee_percentage", - "docs": [ - "creator trading fee percentage" - ], - "type": "u8" - }, - { - "name": "_padding_0", - "docs": [ - "padding 0" - ], - "type": { - "array": [ - "u8", - 2 - ] - } - }, - { - "name": "_padding_1", - "docs": [ - "padding 1" - ], - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "swap_base_amount", - "docs": [ - "swap base amount" - ], - "type": "u64" - }, - { - "name": "migration_quote_threshold", - "docs": [ - "migration quote threshold (in quote token)" - ], - "type": "u64" - }, - { - "name": "migration_base_threshold", - "docs": [ - "migration base threshold (in base token)" - ], - "type": "u64" - }, - { - "name": "migration_sqrt_price", - "docs": [ - "migration sqrt price" - ], - "type": "u128" - }, - { - "name": "locked_vesting_config", - "docs": [ - "locked vesting config" - ], - "type": { - "defined": { - "name": "LockedVestingConfig" - } - } - }, - { - "name": "pre_migration_token_supply", - "docs": [ - "pre migration token supply" - ], - "type": "u64" - }, - { - "name": "post_migration_token_supply", - "docs": [ - "post migration token supply" - ], - "type": "u64" - }, - { - "name": "_padding_2", - "docs": [ - "padding 2" - ], - "type": { - "array": [ - "u128", - 2 - ] - } - }, - { - "name": "sqrt_start_price", - "docs": [ - "minimum price" - ], - "type": "u128" - }, - { - "name": "curve", - "docs": [ - "curve, only use 20 point firstly, we can extend that latter" - ], - "type": { - "array": [ - { - "defined": { - "name": "LiquidityDistributionConfig" - } - }, - 20 - ] - } - } - ] - } - }, - { - "name": "PoolFeeParameters", - "docs": [ - "Information regarding fee charges" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "base_fee", - "docs": [ - "Base fee" - ], - "type": { - "defined": { - "name": "BaseFeeParameters" - } - } - }, - { - "name": "dynamic_fee", - "docs": [ - "dynamic fee" - ], - "type": { - "option": { - "defined": { - "name": "DynamicFeeParameters" - } - } - } - } - ] - } - }, - { - "name": "PoolFees", - "docs": [ - "Information regarding fee charges" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "trade_fee_numerator", - "type": "u64" - }, - { - "name": "trade_fee_denominator", - "type": "u64" - }, - { - "name": "protocol_trade_fee_numerator", - "type": "u64" - }, - { - "name": "protocol_trade_fee_denominator", - "type": "u64" - } - ] - } - }, - { - "name": "PoolFeesConfig", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "base_fee", - "type": { - "defined": { - "name": "BaseFeeConfig" - } - } - }, - { - "name": "dynamic_fee", - "type": { - "defined": { - "name": "DynamicFeeConfig" - } - } - }, - { - "name": "padding_0", - "type": { - "array": [ - "u64", - 5 - ] - } - }, - { - "name": "padding_1", - "type": { - "array": [ - "u8", - 6 - ] - } - }, - { - "name": "protocol_fee_percent", - "type": "u8" - }, - { - "name": "referral_fee_percent", - "type": "u8" - } - ] - } - }, - { - "name": "PoolMetrics", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "total_protocol_base_fee", - "type": "u64" - }, - { - "name": "total_protocol_quote_fee", - "type": "u64" - }, - { - "name": "total_trading_base_fee", - "type": "u64" - }, - { - "name": "total_trading_quote_fee", - "type": "u64" - } - ] - } - }, - { - "name": "SwapParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "minimum_amount_out", - "type": "u64" - } - ] - } - }, - { - "name": "SwapResult", - "docs": [ - "Encodes all results of swapping" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "actual_input_amount", - "type": "u64" - }, - { - "name": "output_amount", - "type": "u64" - }, - { - "name": "next_sqrt_price", - "type": "u128" - }, - { - "name": "trading_fee", - "type": "u64" - }, - { - "name": "protocol_fee", - "type": "u64" - }, - { - "name": "referral_fee", - "type": "u64" - } - ] - } - }, - { - "name": "TokenSupplyParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pre_migration_token_supply", - "docs": [ - "pre migration token supply" - ], - "type": "u64" - }, - { - "name": "post_migration_token_supply", - "docs": [ - "post migration token supply" - ], - "type": "u64" - } - ] - } - }, - { - "name": "VirtualPool", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "volatility_tracker", - "docs": [ - "volatility tracker" - ], - "type": { - "defined": { - "name": "VolatilityTracker" - } - } - }, - { - "name": "config", - "docs": [ - "config key" - ], - "type": "pubkey" - }, - { - "name": "creator", - "docs": [ - "creator" - ], - "type": "pubkey" - }, - { - "name": "base_mint", - "docs": [ - "base mint" - ], - "type": "pubkey" - }, - { - "name": "base_vault", - "docs": [ - "base vault" - ], - "type": "pubkey" - }, - { - "name": "quote_vault", - "docs": [ - "quote vault" - ], - "type": "pubkey" - }, - { - "name": "base_reserve", - "docs": [ - "base reserve" - ], - "type": "u64" - }, - { - "name": "quote_reserve", - "docs": [ - "quote reserve" - ], - "type": "u64" - }, - { - "name": "protocol_base_fee", - "docs": [ - "protocol base fee" - ], - "type": "u64" - }, - { - "name": "protocol_quote_fee", - "docs": [ - "protocol quote fee" - ], - "type": "u64" - }, - { - "name": "partner_base_fee", - "docs": [ - "partner base fee" - ], - "type": "u64" - }, - { - "name": "partner_quote_fee", - "docs": [ - "trading quote fee" - ], - "type": "u64" - }, - { - "name": "sqrt_price", - "docs": [ - "current price" - ], - "type": "u128" - }, - { - "name": "activation_point", - "docs": [ - "Activation point" - ], - "type": "u64" - }, - { - "name": "pool_type", - "docs": [ - "pool type, spl token or token2022" - ], - "type": "u8" - }, - { - "name": "is_migrated", - "docs": [ - "is migrated" - ], - "type": "u8" - }, - { - "name": "is_partner_withdraw_surplus", - "docs": [ - "is partner withdraw surplus" - ], - "type": "u8" - }, - { - "name": "is_protocol_withdraw_surplus", - "docs": [ - "is protocol withdraw surplus" - ], - "type": "u8" - }, - { - "name": "migration_progress", - "docs": [ - "migration progress" - ], - "type": "u8" - }, - { - "name": "is_withdraw_leftover", - "docs": [ - "is withdraw leftover" - ], - "type": "u8" - }, - { - "name": "is_creator_withdraw_surplus", - "docs": [ - "is creator withdraw surplus" - ], - "type": "u8" - }, - { - "name": "_padding_0", - "docs": [ - "padding" - ], - "type": { - "array": [ - "u8", - 1 - ] - } - }, - { - "name": "metrics", - "docs": [ - "pool metrics" - ], - "type": { - "defined": { - "name": "PoolMetrics" - } - } - }, - { - "name": "finish_curve_timestamp", - "docs": [ - "The time curve is finished" - ], - "type": "u64" - }, - { - "name": "creator_base_fee", - "docs": [ - "creator base fee" - ], - "type": "u64" - }, - { - "name": "creator_quote_fee", - "docs": [ - "creator quote fee" - ], - "type": "u64" - }, - { - "name": "_padding_1", - "docs": [ - "Padding for further use" - ], - "type": { - "array": [ - "u64", - 7 - ] - } - } - ] - } - }, - { - "name": "VirtualPoolMetadata", - "docs": [ - "Metadata for a virtual pool." - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "virtual_pool", - "docs": [ - "virtual pool" - ], - "type": "pubkey" - }, - { - "name": "padding", - "docs": [ - "padding for future use" - ], - "type": { - "array": [ - "u128", - 6 - ] - } - }, - { - "name": "name", - "docs": [ - "Name of project." - ], - "type": "string" - }, - { - "name": "website", - "docs": [ - "Website of project." - ], - "type": "string" - }, - { - "name": "logo", - "docs": [ - "Logo of project" - ], - "type": "string" - } - ] - } - }, - { - "name": "VolatilityTracker", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "last_update_timestamp", - "type": "u64" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "sqrt_price_reference", - "type": "u128" - }, - { - "name": "volatility_accumulator", - "type": "u128" - }, - { - "name": "volatility_reference", - "type": "u128" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/crates/meteora-dbc-parser/proto/meteora_dbc.proto b/crates/meteora-dbc-parser/proto/meteora_dbc.proto deleted file mode 100644 index e4361fe3..00000000 --- a/crates/meteora-dbc-parser/proto/meteora_dbc.proto +++ /dev/null @@ -1,935 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.meteora_dbc; - -message ClaimCreatorTradingFeeIx { - ClaimCreatorTradingFeeIxAccounts accounts = 1; - ClaimCreatorTradingFeeIxData data = 2; -} - -message ClaimProtocolFeeIx { - ClaimProtocolFeeIxAccounts accounts = 1; -} - -message ClaimTradingFeeIx { - ClaimTradingFeeIxAccounts accounts = 1; - ClaimTradingFeeIxData data = 2; -} - -message CloseClaimFeeOperatorIx { - CloseClaimFeeOperatorIxAccounts accounts = 1; -} - -message CreateClaimFeeOperatorIx { - CreateClaimFeeOperatorIxAccounts accounts = 1; -} - -message CreateConfigIx { - CreateConfigIxAccounts accounts = 1; - CreateConfigIxData data = 2; -} - -message CreateLockerIx { - CreateLockerIxAccounts accounts = 1; -} - -message CreatePartnerMetadataIx { - CreatePartnerMetadataIxAccounts accounts = 1; - CreatePartnerMetadataIxData data = 2; -} - -message CreateVirtualPoolMetadataIx { - CreateVirtualPoolMetadataIxAccounts accounts = 1; - CreateVirtualPoolMetadataIxData data = 2; -} - -message CreatorWithdrawSurplusIx { - CreatorWithdrawSurplusIxAccounts accounts = 1; -} - -message InitializeVirtualPoolWithSplTokenIx { - InitializeVirtualPoolWithSplTokenIxAccounts accounts = 1; - InitializeVirtualPoolWithSplTokenIxData data = 2; -} - -message InitializeVirtualPoolWithToken2022Ix { - InitializeVirtualPoolWithToken2022IxAccounts accounts = 1; - InitializeVirtualPoolWithToken2022IxData data = 2; -} - -message MigrateMeteoraDammIx { - MigrateMeteoraDammIxAccounts accounts = 1; -} - -message MigrateMeteoraDammClaimLpTokenIx { - MigrateMeteoraDammClaimLpTokenIxAccounts accounts = 1; -} - -message MigrateMeteoraDammLockLpTokenIx { - MigrateMeteoraDammLockLpTokenIxAccounts accounts = 1; -} - -message MigrationDammV2Ix { - MigrationDammV2IxAccounts accounts = 1; -} - -message MigrationDammV2CreateMetadataIx { - MigrationDammV2CreateMetadataIxAccounts accounts = 1; -} - -message MigrationMeteoraDammCreateMetadataIx { - MigrationMeteoraDammCreateMetadataIxAccounts accounts = 1; -} - -message PartnerWithdrawSurplusIx { - PartnerWithdrawSurplusIxAccounts accounts = 1; -} - -message ProtocolWithdrawSurplusIx { - ProtocolWithdrawSurplusIxAccounts accounts = 1; -} - -message SwapIx { - SwapIxAccounts accounts = 1; - SwapIxData data = 2; -} - -message WithdrawLeftoverIx { - WithdrawLeftoverIxAccounts accounts = 1; -} - - -message BaseFeeConfig { - uint64 cliff_fee_numerator = 1; - uint64 period_frequency = 2; - uint64 reduction_factor = 3; - uint32 number_of_period = 4; - uint32 fee_scheduler_mode = 5; - repeated uint32 padding0 = 6; -} - -message BaseFeeParameters { - uint64 cliff_fee_numerator = 1; - uint32 number_of_period = 2; - uint64 period_frequency = 3; - uint64 reduction_factor = 4; - uint32 fee_scheduler_mode = 5; -} - -message DynamicFeeConfig { - uint32 initialized = 1; - repeated uint32 padding = 2; - uint32 max_volatility_accumulator = 3; - uint32 variable_fee_control = 4; - uint32 bin_step = 5; - uint32 filter_period = 6; - uint32 decay_period = 7; - uint32 reduction_factor = 8; - repeated uint32 padding2 = 9; - string bin_step_u128 = 10; -} - -message DynamicFeeParameters { - uint32 bin_step = 1; - string bin_step_u128 = 2; - uint32 filter_period = 3; - uint32 decay_period = 4; - uint32 reduction_factor = 5; - uint32 max_volatility_accumulator = 6; - uint32 variable_fee_control = 7; -} - -message EvtClaimCreatorTradingFee { - string pool = 1; - uint64 token_base_amount = 2; - uint64 token_quote_amount = 3; -} - -message EvtClaimProtocolFee { - string pool = 1; - uint64 token_base_amount = 2; - uint64 token_quote_amount = 3; -} - -message EvtClaimTradingFee { - string pool = 1; - uint64 token_base_amount = 2; - uint64 token_quote_amount = 3; -} - -message EvtCloseClaimFeeOperator { - string claim_fee_operator = 1; - string operator = 2; -} - -message EvtCreateClaimFeeOperator { - string operator = 1; -} - -message EvtCreateConfig { - string config = 1; - string quote_mint = 2; - string fee_claimer = 3; - string owner = 4; - PoolFeeParameters pool_fees = 5; - uint32 collect_fee_mode = 6; - uint32 migration_option = 7; - uint32 activation_type = 8; - uint32 token_decimal = 9; - uint32 token_type = 10; - uint32 partner_locked_lp_percentage = 11; - uint32 partner_lp_percentage = 12; - uint32 creator_locked_lp_percentage = 13; - uint32 creator_lp_percentage = 14; - uint64 swap_base_amount = 15; - uint64 migration_quote_threshold = 16; - uint64 migration_base_amount = 17; - string sqrt_start_price = 18; - LockedVestingParams locked_vesting = 19; - uint32 migration_fee_option = 20; - uint32 fixed_token_supply_flag = 21; - uint64 pre_migration_token_supply = 22; - uint64 post_migration_token_supply = 23; - repeated LiquidityDistributionParameters curve = 24; -} - -message EvtCreateDammV2MigrationMetadata { - string virtual_pool = 1; -} - -message EvtCreateMeteoraMigrationMetadata { - string virtual_pool = 1; -} - -message EvtCreatorWithdrawSurplus { - string pool = 1; - uint64 surplus_amount = 2; -} - -message EvtCurveComplete { - string pool = 1; - string config = 2; - uint64 base_reserve = 3; - uint64 quote_reserve = 4; -} - -message EvtInitializePool { - string pool = 1; - string config = 2; - string creator = 3; - string base_mint = 4; - uint32 pool_type = 5; - uint64 activation_point = 6; -} - -message EvtPartnerMetadata { - string partner_metadata = 1; - string fee_claimer = 2; -} - -message EvtPartnerWithdrawSurplus { - string pool = 1; - uint64 surplus_amount = 2; -} - -message EvtProtocolWithdrawSurplus { - string pool = 1; - uint64 surplus_amount = 2; -} - -message EvtSwap { - string pool = 1; - string config = 2; - uint32 trade_direction = 3; - bool has_referral = 4; - SwapParameters params = 5; - SwapResult swap_result = 6; - uint64 amount_in = 7; - uint64 current_timestamp = 8; -} - -message EvtVirtualPoolMetadata { - string virtual_pool_metadata = 1; - string virtual_pool = 2; -} - -message EvtWithdrawLeftover { - string pool = 1; - string leftover_receiver = 2; - uint64 leftover_amount = 3; -} - -message InitializePoolParameters { - string name = 1; - string symbol = 2; - string uri = 3; -} - -message LiquidityDistributionConfig { - string sqrt_price = 1; - string liquidity = 2; -} - -message LiquidityDistributionParameters { - string sqrt_price = 1; - string liquidity = 2; -} - -message LockedVestingConfig { - uint64 amount_per_period = 1; - uint64 cliff_duration_from_migration_time = 2; - uint64 frequency = 3; - uint64 number_of_period = 4; - uint64 cliff_unlock_amount = 5; - uint64 padding = 6; -} - -message LockedVestingParams { - uint64 amount_per_period = 1; - uint64 cliff_duration_from_migration_time = 2; - uint64 frequency = 3; - uint64 number_of_period = 4; - uint64 cliff_unlock_amount = 5; -} - -message PoolFeeParameters { - BaseFeeParameters base_fee = 1; - optional DynamicFeeParameters dynamic_fee = 2; -} - -message PoolFees { - uint64 trade_fee_numerator = 1; - uint64 trade_fee_denominator = 2; - uint64 protocol_trade_fee_numerator = 3; - uint64 protocol_trade_fee_denominator = 4; -} - -message PoolFeesConfig { - BaseFeeConfig base_fee = 1; - DynamicFeeConfig dynamic_fee = 2; - repeated uint64 padding0 = 3; - repeated uint32 padding1 = 4; - uint32 protocol_fee_percent = 5; - uint32 referral_fee_percent = 6; -} - -message PoolMetrics { - uint64 total_protocol_base_fee = 1; - uint64 total_protocol_quote_fee = 2; - uint64 total_trading_base_fee = 3; - uint64 total_trading_quote_fee = 4; -} - -message SwapParameters { - uint64 amount_in = 1; - uint64 minimum_amount_out = 2; -} - -message SwapResult { - uint64 actual_input_amount = 1; - uint64 output_amount = 2; - string next_sqrt_price = 3; - uint64 trading_fee = 4; - uint64 protocol_fee = 5; - uint64 referral_fee = 6; -} - -message TokenSupplyParams { - uint64 pre_migration_token_supply = 1; - uint64 post_migration_token_supply = 2; -} - -message VolatilityTracker { - uint64 last_update_timestamp = 1; - repeated uint32 padding = 2; - string sqrt_price_reference = 3; - string volatility_accumulator = 4; - string volatility_reference = 5; -} - - -message ClaimFeeOperator { - string operator = 1; - repeated uint32 padding = 2; -} - -message Config { - PoolFees pool_fees = 1; - uint64 activation_duration = 2; - string vault_config_key = 3; - string pool_creator_authority = 4; - uint32 activation_type = 5; - uint64 partner_fee_numerator = 6; - repeated uint32 padding = 7; -} - -message LockEscrow { - string pool = 1; - string owner = 2; - string escrow_vault = 3; - uint32 bump = 4; - uint64 total_locked_amount = 5; - string lp_per_token = 6; - uint64 unclaimed_fee_pending = 7; - uint64 a_fee = 8; - uint64 b_fee = 9; -} - -message MeteoraDammMigrationMetadata { - string virtual_pool = 1; - string pool_creator = 2; - string partner = 3; - string lp_mint = 4; - uint64 partner_locked_lp = 5; - uint64 partner_lp = 6; - uint64 creator_locked_lp = 7; - uint64 creator_lp = 8; - uint32 padding0 = 9; - uint32 creator_locked_status = 10; - uint32 partner_locked_status = 11; - uint32 creator_claim_status = 12; - uint32 partner_claim_status = 13; - repeated uint32 padding = 14; -} - -message MeteoraDammV2Metadata { - string virtual_pool = 1; - string pool_creator = 2; - string partner = 3; - repeated uint32 padding = 4; -} - -message PartnerMetadata { - string fee_claimer = 1; - repeated string padding = 2; - string name = 3; - string website = 4; - string logo = 5; -} - -message PoolConfig { - string quote_mint = 1; - string fee_claimer = 2; - string leftover_receiver = 3; - PoolFeesConfig pool_fees = 4; - uint32 collect_fee_mode = 5; - uint32 migration_option = 6; - uint32 activation_type = 7; - uint32 token_decimal = 8; - uint32 version = 9; - uint32 token_type = 10; - uint32 quote_token_flag = 11; - uint32 partner_locked_lp_percentage = 12; - uint32 partner_lp_percentage = 13; - uint32 creator_locked_lp_percentage = 14; - uint32 creator_lp_percentage = 15; - uint32 migration_fee_option = 16; - uint32 fixed_token_supply_flag = 17; - uint32 creator_trading_fee_percentage = 18; - repeated uint32 padding0 = 19; - repeated uint32 padding1 = 20; - uint64 swap_base_amount = 21; - uint64 migration_quote_threshold = 22; - uint64 migration_base_threshold = 23; - string migration_sqrt_price = 24; - LockedVestingConfig locked_vesting_config = 25; - uint64 pre_migration_token_supply = 26; - uint64 post_migration_token_supply = 27; - repeated string padding2 = 28; - string sqrt_start_price = 29; - repeated LiquidityDistributionConfig curve = 30; -} - -message VirtualPool { - VolatilityTracker volatility_tracker = 1; - string config = 2; - string creator = 3; - string base_mint = 4; - string base_vault = 5; - string quote_vault = 6; - uint64 base_reserve = 7; - uint64 quote_reserve = 8; - uint64 protocol_base_fee = 9; - uint64 protocol_quote_fee = 10; - uint64 partner_base_fee = 11; - uint64 partner_quote_fee = 12; - string sqrt_price = 13; - uint64 activation_point = 14; - uint32 pool_type = 15; - uint32 is_migrated = 16; - uint32 is_partner_withdraw_surplus = 17; - uint32 is_protocol_withdraw_surplus = 18; - uint32 migration_progress = 19; - uint32 is_withdraw_leftover = 20; - uint32 is_creator_withdraw_surplus = 21; - repeated uint32 padding0 = 22; - PoolMetrics metrics = 23; - uint64 finish_curve_timestamp = 24; - uint64 creator_base_fee = 25; - uint64 creator_quote_fee = 26; - repeated uint64 padding1 = 27; -} - -message VirtualPoolMetadata { - string virtual_pool = 1; - repeated string padding = 2; - string name = 3; - string website = 4; - string logo = 5; -} - - -message ClaimCreatorTradingFeeIxAccounts { - string pool_authority = 1; - string pool = 2; - string token_a_account = 3; - string token_b_account = 4; - string base_vault = 5; - string quote_vault = 6; - string base_mint = 7; - string quote_mint = 8; - string creator = 9; - string token_base_program = 10; - string token_quote_program = 11; - string event_authority = 12; - string program = 13; -} - -message ClaimCreatorTradingFeeIxData { - uint64 max_base_amount = 1; - uint64 max_quote_amount = 2; -} - -message ClaimProtocolFeeIxAccounts { - string pool_authority = 1; - string config = 2; - string pool = 3; - string base_vault = 4; - string quote_vault = 5; - string base_mint = 6; - string quote_mint = 7; - string token_base_account = 8; - string token_quote_account = 9; - string claim_fee_operator = 10; - string operator = 11; - string token_base_program = 12; - string token_quote_program = 13; - string event_authority = 14; - string program = 15; -} - - -message ClaimTradingFeeIxAccounts { - string pool_authority = 1; - string config = 2; - string pool = 3; - string token_a_account = 4; - string token_b_account = 5; - string base_vault = 6; - string quote_vault = 7; - string base_mint = 8; - string quote_mint = 9; - string fee_claimer = 10; - string token_base_program = 11; - string token_quote_program = 12; - string event_authority = 13; - string program = 14; -} - -message ClaimTradingFeeIxData { - uint64 max_amount_a = 1; - uint64 max_amount_b = 2; -} - -message CloseClaimFeeOperatorIxAccounts { - string claim_fee_operator = 1; - string rent_receiver = 2; - string admin = 3; - string event_authority = 4; - string program = 5; -} - - -message CreateClaimFeeOperatorIxAccounts { - string claim_fee_operator = 1; - string operator = 2; - string admin = 3; - string system_program = 4; - string event_authority = 5; - string program = 6; -} - - -message CreateConfigIxAccounts { - string config = 1; - string fee_claimer = 2; - string leftover_receiver = 3; - string quote_mint = 4; - string payer = 5; - string system_program = 6; - string event_authority = 7; - string program = 8; -} - -message CreateConfigIxData { - PoolFeeParameters pool_fees = 1; - uint32 collect_fee_mode = 2; - uint32 migration_option = 3; - uint32 activation_type = 4; - uint32 token_type = 5; - uint32 token_decimal = 6; - uint32 partner_lp_percentage = 7; - uint32 partner_locked_lp_percentage = 8; - uint32 creator_lp_percentage = 9; - uint32 creator_locked_lp_percentage = 10; - uint64 migration_quote_threshold = 11; - string sqrt_start_price = 12; - LockedVestingParams locked_vesting = 13; - uint32 migration_fee_option = 14; - optional TokenSupplyParams token_supply = 15; - uint32 creator_trading_fee_percentage = 16; - repeated uint32 padding0 = 17; - repeated uint64 padding1 = 18; - repeated LiquidityDistributionParameters curve = 19; -} - -message CreateLockerIxAccounts { - string virtual_pool = 1; - string config = 2; - string pool_authority = 3; - string base_vault = 4; - string base_mint = 5; - string base = 6; - string creator = 7; - string escrow = 8; - string escrow_token = 9; - string payer = 10; - string token_program = 11; - string locker_program = 12; - string locker_event_authority = 13; - string system_program = 14; -} - - -message CreatePartnerMetadataIxAccounts { - string partner_metadata = 1; - string payer = 2; - string fee_claimer = 3; - string system_program = 4; - string event_authority = 5; - string program = 6; -} - -message CreatePartnerMetadataIxData { - repeated uint32 padding = 1; - string name = 2; - string website = 3; - string logo = 4; -} - -message CreateVirtualPoolMetadataIxAccounts { - string virtual_pool = 1; - string virtual_pool_metadata = 2; - string creator = 3; - string payer = 4; - string system_program = 5; - string event_authority = 6; - string program = 7; -} - -message CreateVirtualPoolMetadataIxData { - repeated uint32 padding = 1; - string name = 2; - string website = 3; - string logo = 4; -} - -message CreatorWithdrawSurplusIxAccounts { - string pool_authority = 1; - string config = 2; - string virtual_pool = 3; - string token_quote_account = 4; - string quote_vault = 5; - string quote_mint = 6; - string creator = 7; - string token_quote_program = 8; - string event_authority = 9; - string program = 10; -} - - -message InitializeVirtualPoolWithSplTokenIxAccounts { - string config = 1; - string pool_authority = 2; - string creator = 3; - string base_mint = 4; - string quote_mint = 5; - string pool = 6; - string base_vault = 7; - string quote_vault = 8; - string mint_metadata = 9; - string metadata_program = 10; - string payer = 11; - string token_quote_program = 12; - string token_program = 13; - string system_program = 14; - string event_authority = 15; - string program = 16; -} - -message InitializeVirtualPoolWithSplTokenIxData { - InitializePoolParameters params = 1; -} - -message InitializeVirtualPoolWithToken2022IxAccounts { - string config = 1; - string pool_authority = 2; - string creator = 3; - string base_mint = 4; - string quote_mint = 5; - string pool = 6; - string base_vault = 7; - string quote_vault = 8; - string payer = 9; - string token_quote_program = 10; - string token_program = 11; - string system_program = 12; - string event_authority = 13; - string program = 14; -} - -message InitializeVirtualPoolWithToken2022IxData { - InitializePoolParameters params = 1; -} - -message MigrateMeteoraDammIxAccounts { - string virtual_pool = 1; - string migration_metadata = 2; - string config = 3; - string pool_authority = 4; - string pool = 5; - string damm_config = 6; - string lp_mint = 7; - string token_a_mint = 8; - string token_b_mint = 9; - string a_vault = 10; - string b_vault = 11; - string a_token_vault = 12; - string b_token_vault = 13; - string a_vault_lp_mint = 14; - string b_vault_lp_mint = 15; - string a_vault_lp = 16; - string b_vault_lp = 17; - string base_vault = 18; - string quote_vault = 19; - string virtual_pool_lp = 20; - string protocol_token_a_fee = 21; - string protocol_token_b_fee = 22; - string payer = 23; - string rent = 24; - string mint_metadata = 25; - string metadata_program = 26; - string amm_program = 27; - string vault_program = 28; - string token_program = 29; - string associated_token_program = 30; - string system_program = 31; -} - - -message MigrateMeteoraDammClaimLpTokenIxAccounts { - string virtual_pool = 1; - string migration_metadata = 2; - string pool_authority = 3; - string lp_mint = 4; - string source_token = 5; - string destination_token = 6; - string owner = 7; - string sender = 8; - string token_program = 9; -} - - -message MigrateMeteoraDammLockLpTokenIxAccounts { - string virtual_pool = 1; - string migration_metadata = 2; - string pool_authority = 3; - string pool = 4; - string lp_mint = 5; - string lock_escrow = 6; - string owner = 7; - string source_tokens = 8; - string escrow_vault = 9; - string amm_program = 10; - string a_vault = 11; - string b_vault = 12; - string a_vault_lp = 13; - string b_vault_lp = 14; - string a_vault_lp_mint = 15; - string b_vault_lp_mint = 16; - string token_program = 17; -} - - -message MigrationDammV2IxAccounts { - string virtual_pool = 1; - string migration_metadata = 2; - string config = 3; - string pool_authority = 4; - string pool = 5; - string first_position_nft_mint = 6; - string first_position_nft_account = 7; - string first_position = 8; - optional string second_position_nft_mint = 9; - optional string second_position_nft_account = 10; - optional string second_position = 11; - string damm_pool_authority = 12; - string amm_program = 13; - string base_mint = 14; - string quote_mint = 15; - string token_a_vault = 16; - string token_b_vault = 17; - string base_vault = 18; - string quote_vault = 19; - string payer = 20; - string token_base_program = 21; - string token_quote_program = 22; - string token2022_program = 23; - string damm_event_authority = 24; - string system_program = 25; -} - - -message MigrationDammV2CreateMetadataIxAccounts { - string virtual_pool = 1; - string config = 2; - string migration_metadata = 3; - string payer = 4; - string system_program = 5; - string event_authority = 6; - string program = 7; -} - - -message MigrationMeteoraDammCreateMetadataIxAccounts { - string virtual_pool = 1; - string config = 2; - string migration_metadata = 3; - string payer = 4; - string system_program = 5; - string event_authority = 6; - string program = 7; -} - - -message PartnerWithdrawSurplusIxAccounts { - string pool_authority = 1; - string config = 2; - string virtual_pool = 3; - string token_quote_account = 4; - string quote_vault = 5; - string quote_mint = 6; - string fee_claimer = 7; - string token_quote_program = 8; - string event_authority = 9; - string program = 10; -} - - -message ProtocolWithdrawSurplusIxAccounts { - string pool_authority = 1; - string config = 2; - string virtual_pool = 3; - string token_quote_account = 4; - string quote_vault = 5; - string quote_mint = 6; - string token_quote_program = 7; - string event_authority = 8; - string program = 9; -} - - -message SwapIxAccounts { - string pool_authority = 1; - string config = 2; - string pool = 3; - string input_token_account = 4; - string output_token_account = 5; - string base_vault = 6; - string quote_vault = 7; - string base_mint = 8; - string quote_mint = 9; - string payer = 10; - string token_base_program = 11; - string token_quote_program = 12; - optional string referral_token_account = 13; - string event_authority = 14; - string program = 15; -} - -message SwapIxData { - SwapParameters params = 1; -} - -message WithdrawLeftoverIxAccounts { - string pool_authority = 1; - string config = 2; - string virtual_pool = 3; - string token_base_account = 4; - string base_vault = 5; - string base_mint = 6; - string leftover_receiver = 7; - string token_base_program = 8; - string event_authority = 9; - string program = 10; -} - - - -message ProgramState { - oneof state_oneof { - ClaimFeeOperator claim_fee_operator = 1; - Config config = 2; - LockEscrow lock_escrow = 3; - MeteoraDammMigrationMetadata meteora_damm_migration_metadata = 4; - MeteoraDammV2Metadata meteora_damm_v2_metadata = 5; - PartnerMetadata partner_metadata = 6; - PoolConfig pool_config = 7; - VirtualPool virtual_pool = 8; - VirtualPoolMetadata virtual_pool_metadata = 9; - } -} - -message ProgramIxs { - oneof ix_oneof { - ClaimCreatorTradingFeeIx claim_creator_trading_fee = 1; - ClaimProtocolFeeIx claim_protocol_fee = 2; - ClaimTradingFeeIx claim_trading_fee = 3; - CloseClaimFeeOperatorIx close_claim_fee_operator = 4; - CreateClaimFeeOperatorIx create_claim_fee_operator = 5; - CreateConfigIx create_config = 6; - CreateLockerIx create_locker = 7; - CreatePartnerMetadataIx create_partner_metadata = 8; - CreateVirtualPoolMetadataIx create_virtual_pool_metadata = 9; - CreatorWithdrawSurplusIx creator_withdraw_surplus = 10; - InitializeVirtualPoolWithSplTokenIx initialize_virtual_pool_with_spl_token = 11; - InitializeVirtualPoolWithToken2022Ix initialize_virtual_pool_with_token2022 = 12; - MigrateMeteoraDammIx migrate_meteora_damm = 13; - MigrateMeteoraDammClaimLpTokenIx migrate_meteora_damm_claim_lp_token = 14; - MigrateMeteoraDammLockLpTokenIx migrate_meteora_damm_lock_lp_token = 15; - MigrationDammV2Ix migration_damm_v2 = 16; - MigrationDammV2CreateMetadataIx migration_damm_v2_create_metadata = 17; - MigrationMeteoraDammCreateMetadataIx migration_meteora_damm_create_metadata = 18; - PartnerWithdrawSurplusIx partner_withdraw_surplus = 19; - ProtocolWithdrawSurplusIx protocol_withdraw_surplus = 20; - SwapIx swap = 21; - WithdrawLeftoverIx withdraw_leftover = 22; - } -} - diff --git a/crates/meteora-dbc-parser/src/generated_parser/accounts_parser.rs b/crates/meteora-dbc-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index fe33832a..00000000 --- a/crates/meteora-dbc-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,376 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{ - ClaimFeeOperator, Config, LockEscrow, MeteoraDammMigrationMetadata, MeteoraDammV2Metadata, - PartnerMetadata, PoolConfig, VirtualPool, VirtualPoolMetadata, - }, - deserialize_checked, ID, -}; - -/// DynamicBondingCurve Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum DynamicBondingCurveProgramState { - ClaimFeeOperator(ClaimFeeOperator), - Config(Config), - LockEscrow(LockEscrow), - MeteoraDammMigrationMetadata(MeteoraDammMigrationMetadata), - MeteoraDammV2Metadata(MeteoraDammV2Metadata), - PartnerMetadata(PartnerMetadata), - PoolConfig(PoolConfig), - VirtualPool(VirtualPool), - VirtualPoolMetadata(VirtualPoolMetadata), -} - -impl DynamicBondingCurveProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [166, 48, 134, 86, 34, 200, 188, 150] => { - Ok(DynamicBondingCurveProgramState::ClaimFeeOperator( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [155, 12, 170, 224, 30, 250, 204, 130] => Ok(DynamicBondingCurveProgramState::Config( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [190, 106, 121, 6, 200, 182, 21, 75] => { - Ok(DynamicBondingCurveProgramState::LockEscrow( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [17, 155, 141, 215, 207, 4, 133, 156] => Ok( - DynamicBondingCurveProgramState::MeteoraDammMigrationMetadata(deserialize_checked( - data_bytes, - &acc_discriminator, - )?), - ), - [104, 221, 219, 203, 10, 142, 250, 163] => { - Ok(DynamicBondingCurveProgramState::MeteoraDammV2Metadata( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [68, 68, 130, 19, 16, 209, 98, 156] => { - Ok(DynamicBondingCurveProgramState::PartnerMetadata( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [26, 108, 14, 123, 116, 230, 129, 43] => { - Ok(DynamicBondingCurveProgramState::PoolConfig( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [213, 224, 5, 209, 98, 69, 119, 92] => { - Ok(DynamicBondingCurveProgramState::VirtualPool( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [217, 37, 82, 250, 43, 47, 228, 254] => { - Ok(DynamicBondingCurveProgramState::VirtualPoolMetadata( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = DynamicBondingCurveProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "dynamic_bonding_curve::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = DynamicBondingCurveProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, ClaimFeeOperator, DynamicBondingCurveProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for ClaimFeeOperator { - fn into_proto(self) -> proto_def::ClaimFeeOperator { - proto_def::ClaimFeeOperator { - operator: self.operator.to_string(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::Config; - impl IntoProto for Config { - fn into_proto(self) -> proto_def::Config { - proto_def::Config { - pool_fees: Some(self.pool_fees.into_proto()), - activation_duration: self.activation_duration, - vault_config_key: self.vault_config_key.to_string(), - pool_creator_authority: self.pool_creator_authority.to_string(), - activation_type: self.activation_type.into(), - partner_fee_numerator: self.partner_fee_numerator, - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::LockEscrow; - impl IntoProto for LockEscrow { - fn into_proto(self) -> proto_def::LockEscrow { - proto_def::LockEscrow { - pool: self.pool.to_string(), - owner: self.owner.to_string(), - escrow_vault: self.escrow_vault.to_string(), - bump: self.bump.into(), - total_locked_amount: self.total_locked_amount, - lp_per_token: self.lp_per_token.to_string(), - unclaimed_fee_pending: self.unclaimed_fee_pending, - a_fee: self.a_fee, - b_fee: self.b_fee, - } - } - } - use super::MeteoraDammMigrationMetadata; - impl IntoProto for MeteoraDammMigrationMetadata { - fn into_proto(self) -> proto_def::MeteoraDammMigrationMetadata { - proto_def::MeteoraDammMigrationMetadata { - virtual_pool: self.virtual_pool.to_string(), - pool_creator: self.pool_creator.to_string(), - partner: self.partner.to_string(), - lp_mint: self.lp_mint.to_string(), - partner_locked_lp: self.partner_locked_lp, - partner_lp: self.partner_lp, - creator_locked_lp: self.creator_locked_lp, - creator_lp: self.creator_lp, - padding0: self.padding0.into(), - creator_locked_status: self.creator_locked_status.into(), - partner_locked_status: self.partner_locked_status.into(), - creator_claim_status: self.creator_claim_status.into(), - partner_claim_status: self.partner_claim_status.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::MeteoraDammV2Metadata; - impl IntoProto for MeteoraDammV2Metadata { - fn into_proto(self) -> proto_def::MeteoraDammV2Metadata { - proto_def::MeteoraDammV2Metadata { - virtual_pool: self.virtual_pool.to_string(), - pool_creator: self.pool_creator.to_string(), - partner: self.partner.to_string(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::PartnerMetadata; - impl IntoProto for PartnerMetadata { - fn into_proto(self) -> proto_def::PartnerMetadata { - proto_def::PartnerMetadata { - fee_claimer: self.fee_claimer.to_string(), - padding: self.padding.into_iter().map(|x| x.to_string()).collect(), - name: self.name, - website: self.website, - logo: self.logo, - } - } - } - use super::PoolConfig; - impl IntoProto for PoolConfig { - fn into_proto(self) -> proto_def::PoolConfig { - proto_def::PoolConfig { - quote_mint: self.quote_mint.to_string(), - fee_claimer: self.fee_claimer.to_string(), - leftover_receiver: self.leftover_receiver.to_string(), - pool_fees: Some(self.pool_fees.into_proto()), - collect_fee_mode: self.collect_fee_mode.into(), - migration_option: self.migration_option.into(), - activation_type: self.activation_type.into(), - token_decimal: self.token_decimal.into(), - version: self.version.into(), - token_type: self.token_type.into(), - quote_token_flag: self.quote_token_flag.into(), - partner_locked_lp_percentage: self.partner_locked_lp_percentage.into(), - partner_lp_percentage: self.partner_lp_percentage.into(), - creator_locked_lp_percentage: self.creator_locked_lp_percentage.into(), - creator_lp_percentage: self.creator_lp_percentage.into(), - migration_fee_option: self.migration_fee_option.into(), - fixed_token_supply_flag: self.fixed_token_supply_flag.into(), - creator_trading_fee_percentage: self.creator_trading_fee_percentage.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - padding1: self.padding1.into_iter().map(|x| x.into()).collect(), - swap_base_amount: self.swap_base_amount, - migration_quote_threshold: self.migration_quote_threshold, - migration_base_threshold: self.migration_base_threshold, - migration_sqrt_price: self.migration_sqrt_price.to_string(), - locked_vesting_config: Some(self.locked_vesting_config.into_proto()), - pre_migration_token_supply: self.pre_migration_token_supply, - post_migration_token_supply: self.post_migration_token_supply, - padding2: self.padding2.into_iter().map(|x| x.to_string()).collect(), - sqrt_start_price: self.sqrt_start_price.to_string(), - curve: self.curve.into_iter().map(|x| x.into_proto()).collect(), - } - } - } - use super::VirtualPool; - impl IntoProto for VirtualPool { - fn into_proto(self) -> proto_def::VirtualPool { - proto_def::VirtualPool { - volatility_tracker: Some(self.volatility_tracker.into_proto()), - config: self.config.to_string(), - creator: self.creator.to_string(), - base_mint: self.base_mint.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - base_reserve: self.base_reserve, - quote_reserve: self.quote_reserve, - protocol_base_fee: self.protocol_base_fee, - protocol_quote_fee: self.protocol_quote_fee, - partner_base_fee: self.partner_base_fee, - partner_quote_fee: self.partner_quote_fee, - sqrt_price: self.sqrt_price.to_string(), - activation_point: self.activation_point, - pool_type: self.pool_type.into(), - is_migrated: self.is_migrated.into(), - is_partner_withdraw_surplus: self.is_partner_withdraw_surplus.into(), - is_protocol_withdraw_surplus: self.is_protocol_withdraw_surplus.into(), - migration_progress: self.migration_progress.into(), - is_withdraw_leftover: self.is_withdraw_leftover.into(), - is_creator_withdraw_surplus: self.is_creator_withdraw_surplus.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - metrics: Some(self.metrics.into_proto()), - finish_curve_timestamp: self.finish_curve_timestamp, - creator_base_fee: self.creator_base_fee, - creator_quote_fee: self.creator_quote_fee, - padding1: self.padding1.to_vec(), - } - } - } - use super::VirtualPoolMetadata; - impl IntoProto for VirtualPoolMetadata { - fn into_proto(self) -> proto_def::VirtualPoolMetadata { - proto_def::VirtualPoolMetadata { - virtual_pool: self.virtual_pool.to_string(), - padding: self.padding.into_iter().map(|x| x.to_string()).collect(), - name: self.name, - website: self.website, - logo: self.logo, - } - } - } - - impl IntoProto for DynamicBondingCurveProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - DynamicBondingCurveProgramState::ClaimFeeOperator(data) => { - proto_def::program_state::StateOneof::ClaimFeeOperator(data.into_proto()) - }, - DynamicBondingCurveProgramState::Config(data) => { - proto_def::program_state::StateOneof::Config(data.into_proto()) - }, - DynamicBondingCurveProgramState::LockEscrow(data) => { - proto_def::program_state::StateOneof::LockEscrow(data.into_proto()) - }, - DynamicBondingCurveProgramState::MeteoraDammMigrationMetadata(data) => { - proto_def::program_state::StateOneof::MeteoraDammMigrationMetadata( - data.into_proto(), - ) - }, - DynamicBondingCurveProgramState::MeteoraDammV2Metadata(data) => { - proto_def::program_state::StateOneof::MeteoraDammV2Metadata(data.into_proto()) - }, - DynamicBondingCurveProgramState::PartnerMetadata(data) => { - proto_def::program_state::StateOneof::PartnerMetadata(data.into_proto()) - }, - DynamicBondingCurveProgramState::PoolConfig(data) => { - proto_def::program_state::StateOneof::PoolConfig(data.into_proto()) - }, - DynamicBondingCurveProgramState::VirtualPool(data) => { - proto_def::program_state::StateOneof::VirtualPool(data.into_proto()) - }, - DynamicBondingCurveProgramState::VirtualPoolMetadata(data) => { - proto_def::program_state::StateOneof::VirtualPoolMetadata(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/meteora-dbc-parser/src/generated_parser/instructions_parser.rs b/crates/meteora-dbc-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index 4fb55de7..00000000 --- a/crates/meteora-dbc-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,1483 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - ClaimCreatorTradingFee as ClaimCreatorTradingFeeIxAccounts, - ClaimCreatorTradingFeeInstructionArgs as ClaimCreatorTradingFeeIxData, - ClaimProtocolFee as ClaimProtocolFeeIxAccounts, - ClaimTradingFee as ClaimTradingFeeIxAccounts, - ClaimTradingFeeInstructionArgs as ClaimTradingFeeIxData, - CloseClaimFeeOperator as CloseClaimFeeOperatorIxAccounts, - CreateClaimFeeOperator as CreateClaimFeeOperatorIxAccounts, - CreateConfig as CreateConfigIxAccounts, CreateConfigInstructionArgs as CreateConfigIxData, - CreateLocker as CreateLockerIxAccounts, - CreatePartnerMetadata as CreatePartnerMetadataIxAccounts, - CreatePartnerMetadataInstructionArgs as CreatePartnerMetadataIxData, - CreateVirtualPoolMetadata as CreateVirtualPoolMetadataIxAccounts, - CreateVirtualPoolMetadataInstructionArgs as CreateVirtualPoolMetadataIxData, - CreatorWithdrawSurplus as CreatorWithdrawSurplusIxAccounts, - InitializeVirtualPoolWithSplToken as InitializeVirtualPoolWithSplTokenIxAccounts, - InitializeVirtualPoolWithSplTokenInstructionArgs as InitializeVirtualPoolWithSplTokenIxData, - InitializeVirtualPoolWithToken2022 as InitializeVirtualPoolWithToken2022IxAccounts, - InitializeVirtualPoolWithToken2022InstructionArgs as InitializeVirtualPoolWithToken2022IxData, - MigrateMeteoraDamm as MigrateMeteoraDammIxAccounts, - MigrateMeteoraDammClaimLpToken as MigrateMeteoraDammClaimLpTokenIxAccounts, - MigrateMeteoraDammLockLpToken as MigrateMeteoraDammLockLpTokenIxAccounts, - MigrationDammV2 as MigrationDammV2IxAccounts, - MigrationDammV2CreateMetadata as MigrationDammV2CreateMetadataIxAccounts, - MigrationMeteoraDammCreateMetadata as MigrationMeteoraDammCreateMetadataIxAccounts, - PartnerWithdrawSurplus as PartnerWithdrawSurplusIxAccounts, - ProtocolWithdrawSurplus as ProtocolWithdrawSurplusIxAccounts, Swap as SwapIxAccounts, - SwapInstructionArgs as SwapIxData, WithdrawLeftover as WithdrawLeftoverIxAccounts, - }, - ID, -}; - -/// DynamicBondingCurve Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum DynamicBondingCurveProgramIx { - ClaimCreatorTradingFee( - ClaimCreatorTradingFeeIxAccounts, - ClaimCreatorTradingFeeIxData, - ), - ClaimProtocolFee(ClaimProtocolFeeIxAccounts), - ClaimTradingFee(ClaimTradingFeeIxAccounts, ClaimTradingFeeIxData), - CloseClaimFeeOperator(CloseClaimFeeOperatorIxAccounts), - CreateClaimFeeOperator(CreateClaimFeeOperatorIxAccounts), - CreateConfig(CreateConfigIxAccounts, CreateConfigIxData), - CreateLocker(CreateLockerIxAccounts), - CreatePartnerMetadata(CreatePartnerMetadataIxAccounts, CreatePartnerMetadataIxData), - CreateVirtualPoolMetadata( - CreateVirtualPoolMetadataIxAccounts, - CreateVirtualPoolMetadataIxData, - ), - CreatorWithdrawSurplus(CreatorWithdrawSurplusIxAccounts), - InitializeVirtualPoolWithSplToken( - InitializeVirtualPoolWithSplTokenIxAccounts, - InitializeVirtualPoolWithSplTokenIxData, - ), - InitializeVirtualPoolWithToken2022( - InitializeVirtualPoolWithToken2022IxAccounts, - InitializeVirtualPoolWithToken2022IxData, - ), - MigrateMeteoraDamm(MigrateMeteoraDammIxAccounts), - MigrateMeteoraDammClaimLpToken(MigrateMeteoraDammClaimLpTokenIxAccounts), - MigrateMeteoraDammLockLpToken(MigrateMeteoraDammLockLpTokenIxAccounts), - MigrationDammV2(MigrationDammV2IxAccounts), - MigrationDammV2CreateMetadata(MigrationDammV2CreateMetadataIxAccounts), - MigrationMeteoraDammCreateMetadata(MigrationMeteoraDammCreateMetadataIxAccounts), - PartnerWithdrawSurplus(PartnerWithdrawSurplusIxAccounts), - ProtocolWithdrawSurplus(ProtocolWithdrawSurplusIxAccounts), - Swap(SwapIxAccounts, SwapIxData), - WithdrawLeftover(WithdrawLeftoverIxAccounts), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = DynamicBondingCurveProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { - "DynamicBondingCurve::InstructionParser".into() - } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [82, 220, 250, 189, 3, 85, 107, 45] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimCreatorTradingFeeIxAccounts { - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - token_a_account: next_account(accounts)?, - token_b_account: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - creator: next_account(accounts)?, - token_base_program: next_account(accounts)?, - token_quote_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: ClaimCreatorTradingFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(DynamicBondingCurveProgramIx::ClaimCreatorTradingFee( - ix_accounts, - de_ix_data, - )) - }, - [165, 228, 133, 48, 99, 249, 255, 33] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimProtocolFeeIxAccounts { - pool_authority: next_account(accounts)?, - config: next_account(accounts)?, - pool: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - token_base_account: next_account(accounts)?, - token_quote_account: next_account(accounts)?, - claim_fee_operator: next_account(accounts)?, - operator: next_account(accounts)?, - token_base_program: next_account(accounts)?, - token_quote_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::ClaimProtocolFee(ix_accounts)) - }, - [8, 236, 89, 49, 152, 125, 177, 81] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimTradingFeeIxAccounts { - pool_authority: next_account(accounts)?, - config: next_account(accounts)?, - pool: next_account(accounts)?, - token_a_account: next_account(accounts)?, - token_b_account: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - fee_claimer: next_account(accounts)?, - token_base_program: next_account(accounts)?, - token_quote_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: ClaimTradingFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(DynamicBondingCurveProgramIx::ClaimTradingFee( - ix_accounts, - de_ix_data, - )) - }, - [38, 134, 82, 216, 95, 124, 17, 99] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CloseClaimFeeOperatorIxAccounts { - claim_fee_operator: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - admin: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::CloseClaimFeeOperator( - ix_accounts, - )) - }, - [169, 62, 207, 107, 58, 187, 162, 109] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateClaimFeeOperatorIxAccounts { - claim_fee_operator: next_account(accounts)?, - operator: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::CreateClaimFeeOperator( - ix_accounts, - )) - }, - [201, 207, 243, 114, 75, 111, 47, 189] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateConfigIxAccounts { - config: next_account(accounts)?, - fee_claimer: next_account(accounts)?, - leftover_receiver: next_account(accounts)?, - quote_mint: next_account(accounts)?, - payer: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: CreateConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(DynamicBondingCurveProgramIx::CreateConfig( - ix_accounts, - de_ix_data, - )) - }, - [167, 90, 137, 154, 75, 47, 17, 84] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateLockerIxAccounts { - virtual_pool: next_account(accounts)?, - config: next_account(accounts)?, - pool_authority: next_account(accounts)?, - base_vault: next_account(accounts)?, - base_mint: next_account(accounts)?, - base: next_account(accounts)?, - creator: next_account(accounts)?, - escrow: next_account(accounts)?, - escrow_token: next_account(accounts)?, - payer: next_account(accounts)?, - token_program: next_account(accounts)?, - locker_program: next_account(accounts)?, - locker_event_authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::CreateLocker(ix_accounts)) - }, - [192, 168, 234, 191, 188, 226, 227, 255] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreatePartnerMetadataIxAccounts { - partner_metadata: next_account(accounts)?, - payer: next_account(accounts)?, - fee_claimer: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: CreatePartnerMetadataIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(DynamicBondingCurveProgramIx::CreatePartnerMetadata( - ix_accounts, - de_ix_data, - )) - }, - [45, 97, 187, 103, 254, 109, 124, 134] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateVirtualPoolMetadataIxAccounts { - virtual_pool: next_account(accounts)?, - virtual_pool_metadata: next_account(accounts)?, - creator: next_account(accounts)?, - payer: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: CreateVirtualPoolMetadataIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(DynamicBondingCurveProgramIx::CreateVirtualPoolMetadata( - ix_accounts, - de_ix_data, - )) - }, - [165, 3, 137, 7, 28, 134, 76, 80] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreatorWithdrawSurplusIxAccounts { - pool_authority: next_account(accounts)?, - config: next_account(accounts)?, - virtual_pool: next_account(accounts)?, - token_quote_account: next_account(accounts)?, - quote_vault: next_account(accounts)?, - quote_mint: next_account(accounts)?, - creator: next_account(accounts)?, - token_quote_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::CreatorWithdrawSurplus( - ix_accounts, - )) - }, - [140, 85, 215, 176, 102, 54, 104, 79] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeVirtualPoolWithSplTokenIxAccounts { - config: next_account(accounts)?, - pool_authority: next_account(accounts)?, - creator: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - pool: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - payer: next_account(accounts)?, - token_quote_program: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeVirtualPoolWithSplTokenIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok( - DynamicBondingCurveProgramIx::InitializeVirtualPoolWithSplToken( - ix_accounts, - de_ix_data, - ), - ) - }, - [169, 118, 51, 78, 145, 110, 220, 155] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeVirtualPoolWithToken2022IxAccounts { - config: next_account(accounts)?, - pool_authority: next_account(accounts)?, - creator: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - pool: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - payer: next_account(accounts)?, - token_quote_program: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeVirtualPoolWithToken2022IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok( - DynamicBondingCurveProgramIx::InitializeVirtualPoolWithToken2022( - ix_accounts, - de_ix_data, - ), - ) - }, - [27, 1, 48, 22, 180, 63, 118, 217] => { - let expected_accounts_len = 31; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrateMeteoraDammIxAccounts { - virtual_pool: next_account(accounts)?, - migration_metadata: next_account(accounts)?, - config: next_account(accounts)?, - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - damm_config: next_account(accounts)?, - lp_mint: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - virtual_pool_lp: next_account(accounts)?, - protocol_token_a_fee: next_account(accounts)?, - protocol_token_b_fee: next_account(accounts)?, - payer: next_account(accounts)?, - rent: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - amm_program: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::MigrateMeteoraDamm( - ix_accounts, - )) - }, - [139, 133, 2, 30, 91, 145, 127, 154] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrateMeteoraDammClaimLpTokenIxAccounts { - virtual_pool: next_account(accounts)?, - migration_metadata: next_account(accounts)?, - pool_authority: next_account(accounts)?, - lp_mint: next_account(accounts)?, - source_token: next_account(accounts)?, - destination_token: next_account(accounts)?, - owner: next_account(accounts)?, - sender: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::MigrateMeteoraDammClaimLpToken(ix_accounts)) - }, - [177, 55, 238, 157, 251, 88, 165, 42] => { - let expected_accounts_len = 17; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrateMeteoraDammLockLpTokenIxAccounts { - virtual_pool: next_account(accounts)?, - migration_metadata: next_account(accounts)?, - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - lock_escrow: next_account(accounts)?, - owner: next_account(accounts)?, - source_tokens: next_account(accounts)?, - escrow_vault: next_account(accounts)?, - amm_program: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::MigrateMeteoraDammLockLpToken( - ix_accounts, - )) - }, - [156, 169, 230, 103, 53, 228, 80, 64] => { - let expected_accounts_len = 25; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrationDammV2IxAccounts { - virtual_pool: next_account(accounts)?, - migration_metadata: next_account(accounts)?, - config: next_account(accounts)?, - pool_authority: next_account(accounts)?, - pool: next_account(accounts)?, - first_position_nft_mint: next_account(accounts)?, - first_position_nft_account: next_account(accounts)?, - first_position: next_account(accounts)?, - second_position_nft_mint: next_program_id_optional_account(accounts)?, - second_position_nft_account: next_program_id_optional_account(accounts)?, - second_position: next_program_id_optional_account(accounts)?, - damm_pool_authority: next_account(accounts)?, - amm_program: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - token_a_vault: next_account(accounts)?, - token_b_vault: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - payer: next_account(accounts)?, - token_base_program: next_account(accounts)?, - token_quote_program: next_account(accounts)?, - token2022_program: next_account(accounts)?, - damm_event_authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::MigrationDammV2(ix_accounts)) - }, - [109, 189, 19, 36, 195, 183, 222, 82] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrationDammV2CreateMetadataIxAccounts { - virtual_pool: next_account(accounts)?, - config: next_account(accounts)?, - migration_metadata: next_account(accounts)?, - payer: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::MigrationDammV2CreateMetadata( - ix_accounts, - )) - }, - [47, 94, 126, 115, 221, 226, 194, 133] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrationMeteoraDammCreateMetadataIxAccounts { - virtual_pool: next_account(accounts)?, - config: next_account(accounts)?, - migration_metadata: next_account(accounts)?, - payer: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::MigrationMeteoraDammCreateMetadata(ix_accounts)) - }, - [168, 173, 72, 100, 201, 98, 38, 92] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = PartnerWithdrawSurplusIxAccounts { - pool_authority: next_account(accounts)?, - config: next_account(accounts)?, - virtual_pool: next_account(accounts)?, - token_quote_account: next_account(accounts)?, - quote_vault: next_account(accounts)?, - quote_mint: next_account(accounts)?, - fee_claimer: next_account(accounts)?, - token_quote_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::PartnerWithdrawSurplus( - ix_accounts, - )) - }, - [54, 136, 225, 138, 172, 182, 214, 167] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ProtocolWithdrawSurplusIxAccounts { - pool_authority: next_account(accounts)?, - config: next_account(accounts)?, - virtual_pool: next_account(accounts)?, - token_quote_account: next_account(accounts)?, - quote_vault: next_account(accounts)?, - quote_mint: next_account(accounts)?, - token_quote_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::ProtocolWithdrawSurplus( - ix_accounts, - )) - }, - [248, 198, 158, 145, 225, 117, 135, 200] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapIxAccounts { - pool_authority: next_account(accounts)?, - config: next_account(accounts)?, - pool: next_account(accounts)?, - input_token_account: next_account(accounts)?, - output_token_account: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - payer: next_account(accounts)?, - token_base_program: next_account(accounts)?, - token_quote_program: next_account(accounts)?, - referral_token_account: next_program_id_optional_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SwapIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(DynamicBondingCurveProgramIx::Swap(ix_accounts, de_ix_data)) - }, - [20, 198, 202, 237, 235, 243, 183, 66] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawLeftoverIxAccounts { - pool_authority: next_account(accounts)?, - config: next_account(accounts)?, - virtual_pool: next_account(accounts)?, - token_base_account: next_account(accounts)?, - base_vault: next_account(accounts)?, - base_mint: next_account(accounts)?, - leftover_receiver: next_account(accounts)?, - token_base_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(DynamicBondingCurveProgramIx::WithdrawLeftover(ix_accounts)) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{ - ClaimCreatorTradingFeeIxAccounts, DynamicBondingCurveProgramIx, InstructionParser, - }; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for ClaimCreatorTradingFeeIxAccounts { - fn into_proto(self) -> proto_def::ClaimCreatorTradingFeeIxAccounts { - proto_def::ClaimCreatorTradingFeeIxAccounts { - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - token_a_account: self.token_a_account.to_string(), - token_b_account: self.token_b_account.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - creator: self.creator.to_string(), - token_base_program: self.token_base_program.to_string(), - token_quote_program: self.token_quote_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClaimCreatorTradingFeeIxData; - impl IntoProto for ClaimCreatorTradingFeeIxData { - fn into_proto(self) -> proto_def::ClaimCreatorTradingFeeIxData { - proto_def::ClaimCreatorTradingFeeIxData { - max_base_amount: self.max_base_amount, - max_quote_amount: self.max_quote_amount, - } - } - } - use super::ClaimProtocolFeeIxAccounts; - impl IntoProto for ClaimProtocolFeeIxAccounts { - fn into_proto(self) -> proto_def::ClaimProtocolFeeIxAccounts { - proto_def::ClaimProtocolFeeIxAccounts { - pool_authority: self.pool_authority.to_string(), - config: self.config.to_string(), - pool: self.pool.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - token_base_account: self.token_base_account.to_string(), - token_quote_account: self.token_quote_account.to_string(), - claim_fee_operator: self.claim_fee_operator.to_string(), - operator: self.operator.to_string(), - token_base_program: self.token_base_program.to_string(), - token_quote_program: self.token_quote_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClaimTradingFeeIxAccounts; - impl IntoProto for ClaimTradingFeeIxAccounts { - fn into_proto(self) -> proto_def::ClaimTradingFeeIxAccounts { - proto_def::ClaimTradingFeeIxAccounts { - pool_authority: self.pool_authority.to_string(), - config: self.config.to_string(), - pool: self.pool.to_string(), - token_a_account: self.token_a_account.to_string(), - token_b_account: self.token_b_account.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - fee_claimer: self.fee_claimer.to_string(), - token_base_program: self.token_base_program.to_string(), - token_quote_program: self.token_quote_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClaimTradingFeeIxData; - impl IntoProto for ClaimTradingFeeIxData { - fn into_proto(self) -> proto_def::ClaimTradingFeeIxData { - proto_def::ClaimTradingFeeIxData { - max_amount_a: self.max_amount_a, - max_amount_b: self.max_amount_b, - } - } - } - use super::CloseClaimFeeOperatorIxAccounts; - impl IntoProto for CloseClaimFeeOperatorIxAccounts { - fn into_proto(self) -> proto_def::CloseClaimFeeOperatorIxAccounts { - proto_def::CloseClaimFeeOperatorIxAccounts { - claim_fee_operator: self.claim_fee_operator.to_string(), - rent_receiver: self.rent_receiver.to_string(), - admin: self.admin.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateClaimFeeOperatorIxAccounts; - impl IntoProto for CreateClaimFeeOperatorIxAccounts { - fn into_proto(self) -> proto_def::CreateClaimFeeOperatorIxAccounts { - proto_def::CreateClaimFeeOperatorIxAccounts { - claim_fee_operator: self.claim_fee_operator.to_string(), - operator: self.operator.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateConfigIxAccounts; - impl IntoProto for CreateConfigIxAccounts { - fn into_proto(self) -> proto_def::CreateConfigIxAccounts { - proto_def::CreateConfigIxAccounts { - config: self.config.to_string(), - fee_claimer: self.fee_claimer.to_string(), - leftover_receiver: self.leftover_receiver.to_string(), - quote_mint: self.quote_mint.to_string(), - payer: self.payer.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateConfigIxData; - impl IntoProto for CreateConfigIxData { - fn into_proto(self) -> proto_def::CreateConfigIxData { - proto_def::CreateConfigIxData { - pool_fees: Some(self.pool_fees.into_proto()), - collect_fee_mode: self.collect_fee_mode.into(), - migration_option: self.migration_option.into(), - activation_type: self.activation_type.into(), - token_type: self.token_type.into(), - token_decimal: self.token_decimal.into(), - partner_lp_percentage: self.partner_lp_percentage.into(), - partner_locked_lp_percentage: self.partner_locked_lp_percentage.into(), - creator_lp_percentage: self.creator_lp_percentage.into(), - creator_locked_lp_percentage: self.creator_locked_lp_percentage.into(), - migration_quote_threshold: self.migration_quote_threshold, - sqrt_start_price: self.sqrt_start_price.to_string(), - locked_vesting: Some(self.locked_vesting.into_proto()), - migration_fee_option: self.migration_fee_option.into(), - token_supply: self.token_supply.map(|x| x.into_proto()), - creator_trading_fee_percentage: self.creator_trading_fee_percentage.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - padding1: self.padding1.to_vec(), - curve: self.curve.into_iter().map(|x| x.into_proto()).collect(), - } - } - } - use super::CreateLockerIxAccounts; - impl IntoProto for CreateLockerIxAccounts { - fn into_proto(self) -> proto_def::CreateLockerIxAccounts { - proto_def::CreateLockerIxAccounts { - virtual_pool: self.virtual_pool.to_string(), - config: self.config.to_string(), - pool_authority: self.pool_authority.to_string(), - base_vault: self.base_vault.to_string(), - base_mint: self.base_mint.to_string(), - base: self.base.to_string(), - creator: self.creator.to_string(), - escrow: self.escrow.to_string(), - escrow_token: self.escrow_token.to_string(), - payer: self.payer.to_string(), - token_program: self.token_program.to_string(), - locker_program: self.locker_program.to_string(), - locker_event_authority: self.locker_event_authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreatePartnerMetadataIxAccounts; - impl IntoProto for CreatePartnerMetadataIxAccounts { - fn into_proto(self) -> proto_def::CreatePartnerMetadataIxAccounts { - proto_def::CreatePartnerMetadataIxAccounts { - partner_metadata: self.partner_metadata.to_string(), - payer: self.payer.to_string(), - fee_claimer: self.fee_claimer.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreatePartnerMetadataIxData; - impl IntoProto for CreatePartnerMetadataIxData { - fn into_proto(self) -> proto_def::CreatePartnerMetadataIxData { - proto_def::CreatePartnerMetadataIxData { - padding: self.padding.into_iter().map(|x| x.into()).collect(), - name: self.name, - website: self.website, - logo: self.logo, - } - } - } - use super::CreateVirtualPoolMetadataIxAccounts; - impl IntoProto - for CreateVirtualPoolMetadataIxAccounts - { - fn into_proto(self) -> proto_def::CreateVirtualPoolMetadataIxAccounts { - proto_def::CreateVirtualPoolMetadataIxAccounts { - virtual_pool: self.virtual_pool.to_string(), - virtual_pool_metadata: self.virtual_pool_metadata.to_string(), - creator: self.creator.to_string(), - payer: self.payer.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateVirtualPoolMetadataIxData; - impl IntoProto for CreateVirtualPoolMetadataIxData { - fn into_proto(self) -> proto_def::CreateVirtualPoolMetadataIxData { - proto_def::CreateVirtualPoolMetadataIxData { - padding: self.padding.into_iter().map(|x| x.into()).collect(), - name: self.name, - website: self.website, - logo: self.logo, - } - } - } - use super::CreatorWithdrawSurplusIxAccounts; - impl IntoProto for CreatorWithdrawSurplusIxAccounts { - fn into_proto(self) -> proto_def::CreatorWithdrawSurplusIxAccounts { - proto_def::CreatorWithdrawSurplusIxAccounts { - pool_authority: self.pool_authority.to_string(), - config: self.config.to_string(), - virtual_pool: self.virtual_pool.to_string(), - token_quote_account: self.token_quote_account.to_string(), - quote_vault: self.quote_vault.to_string(), - quote_mint: self.quote_mint.to_string(), - creator: self.creator.to_string(), - token_quote_program: self.token_quote_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeVirtualPoolWithSplTokenIxAccounts; - impl IntoProto - for InitializeVirtualPoolWithSplTokenIxAccounts - { - fn into_proto(self) -> proto_def::InitializeVirtualPoolWithSplTokenIxAccounts { - proto_def::InitializeVirtualPoolWithSplTokenIxAccounts { - config: self.config.to_string(), - pool_authority: self.pool_authority.to_string(), - creator: self.creator.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - pool: self.pool.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - payer: self.payer.to_string(), - token_quote_program: self.token_quote_program.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeVirtualPoolWithSplTokenIxData; - impl IntoProto - for InitializeVirtualPoolWithSplTokenIxData - { - fn into_proto(self) -> proto_def::InitializeVirtualPoolWithSplTokenIxData { - proto_def::InitializeVirtualPoolWithSplTokenIxData { - params: Some(self.params.into_proto()), - } - } - } - use super::InitializeVirtualPoolWithToken2022IxAccounts; - impl IntoProto - for InitializeVirtualPoolWithToken2022IxAccounts - { - fn into_proto(self) -> proto_def::InitializeVirtualPoolWithToken2022IxAccounts { - proto_def::InitializeVirtualPoolWithToken2022IxAccounts { - config: self.config.to_string(), - pool_authority: self.pool_authority.to_string(), - creator: self.creator.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - pool: self.pool.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - payer: self.payer.to_string(), - token_quote_program: self.token_quote_program.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeVirtualPoolWithToken2022IxData; - impl IntoProto - for InitializeVirtualPoolWithToken2022IxData - { - fn into_proto(self) -> proto_def::InitializeVirtualPoolWithToken2022IxData { - proto_def::InitializeVirtualPoolWithToken2022IxData { - params: Some(self.params.into_proto()), - } - } - } - use super::MigrateMeteoraDammIxAccounts; - impl IntoProto for MigrateMeteoraDammIxAccounts { - fn into_proto(self) -> proto_def::MigrateMeteoraDammIxAccounts { - proto_def::MigrateMeteoraDammIxAccounts { - virtual_pool: self.virtual_pool.to_string(), - migration_metadata: self.migration_metadata.to_string(), - config: self.config.to_string(), - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - damm_config: self.damm_config.to_string(), - lp_mint: self.lp_mint.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - virtual_pool_lp: self.virtual_pool_lp.to_string(), - protocol_token_a_fee: self.protocol_token_a_fee.to_string(), - protocol_token_b_fee: self.protocol_token_b_fee.to_string(), - payer: self.payer.to_string(), - rent: self.rent.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - amm_program: self.amm_program.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::MigrateMeteoraDammClaimLpTokenIxAccounts; - impl IntoProto - for MigrateMeteoraDammClaimLpTokenIxAccounts - { - fn into_proto(self) -> proto_def::MigrateMeteoraDammClaimLpTokenIxAccounts { - proto_def::MigrateMeteoraDammClaimLpTokenIxAccounts { - virtual_pool: self.virtual_pool.to_string(), - migration_metadata: self.migration_metadata.to_string(), - pool_authority: self.pool_authority.to_string(), - lp_mint: self.lp_mint.to_string(), - source_token: self.source_token.to_string(), - destination_token: self.destination_token.to_string(), - owner: self.owner.to_string(), - sender: self.sender.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::MigrateMeteoraDammLockLpTokenIxAccounts; - impl IntoProto - for MigrateMeteoraDammLockLpTokenIxAccounts - { - fn into_proto(self) -> proto_def::MigrateMeteoraDammLockLpTokenIxAccounts { - proto_def::MigrateMeteoraDammLockLpTokenIxAccounts { - virtual_pool: self.virtual_pool.to_string(), - migration_metadata: self.migration_metadata.to_string(), - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - lock_escrow: self.lock_escrow.to_string(), - owner: self.owner.to_string(), - source_tokens: self.source_tokens.to_string(), - escrow_vault: self.escrow_vault.to_string(), - amm_program: self.amm_program.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::MigrationDammV2IxAccounts; - impl IntoProto for MigrationDammV2IxAccounts { - fn into_proto(self) -> proto_def::MigrationDammV2IxAccounts { - proto_def::MigrationDammV2IxAccounts { - virtual_pool: self.virtual_pool.to_string(), - migration_metadata: self.migration_metadata.to_string(), - config: self.config.to_string(), - pool_authority: self.pool_authority.to_string(), - pool: self.pool.to_string(), - first_position_nft_mint: self.first_position_nft_mint.to_string(), - first_position_nft_account: self.first_position_nft_account.to_string(), - first_position: self.first_position.to_string(), - second_position_nft_mint: self.second_position_nft_mint.map(|p| p.to_string()), - second_position_nft_account: self - .second_position_nft_account - .map(|p| p.to_string()), - second_position: self.second_position.map(|p| p.to_string()), - damm_pool_authority: self.damm_pool_authority.to_string(), - amm_program: self.amm_program.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - token_a_vault: self.token_a_vault.to_string(), - token_b_vault: self.token_b_vault.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - payer: self.payer.to_string(), - token_base_program: self.token_base_program.to_string(), - token_quote_program: self.token_quote_program.to_string(), - token2022_program: self.token2022_program.to_string(), - damm_event_authority: self.damm_event_authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::MigrationDammV2CreateMetadataIxAccounts; - impl IntoProto - for MigrationDammV2CreateMetadataIxAccounts - { - fn into_proto(self) -> proto_def::MigrationDammV2CreateMetadataIxAccounts { - proto_def::MigrationDammV2CreateMetadataIxAccounts { - virtual_pool: self.virtual_pool.to_string(), - config: self.config.to_string(), - migration_metadata: self.migration_metadata.to_string(), - payer: self.payer.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::MigrationMeteoraDammCreateMetadataIxAccounts; - impl IntoProto - for MigrationMeteoraDammCreateMetadataIxAccounts - { - fn into_proto(self) -> proto_def::MigrationMeteoraDammCreateMetadataIxAccounts { - proto_def::MigrationMeteoraDammCreateMetadataIxAccounts { - virtual_pool: self.virtual_pool.to_string(), - config: self.config.to_string(), - migration_metadata: self.migration_metadata.to_string(), - payer: self.payer.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::PartnerWithdrawSurplusIxAccounts; - impl IntoProto for PartnerWithdrawSurplusIxAccounts { - fn into_proto(self) -> proto_def::PartnerWithdrawSurplusIxAccounts { - proto_def::PartnerWithdrawSurplusIxAccounts { - pool_authority: self.pool_authority.to_string(), - config: self.config.to_string(), - virtual_pool: self.virtual_pool.to_string(), - token_quote_account: self.token_quote_account.to_string(), - quote_vault: self.quote_vault.to_string(), - quote_mint: self.quote_mint.to_string(), - fee_claimer: self.fee_claimer.to_string(), - token_quote_program: self.token_quote_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ProtocolWithdrawSurplusIxAccounts; - impl IntoProto for ProtocolWithdrawSurplusIxAccounts { - fn into_proto(self) -> proto_def::ProtocolWithdrawSurplusIxAccounts { - proto_def::ProtocolWithdrawSurplusIxAccounts { - pool_authority: self.pool_authority.to_string(), - config: self.config.to_string(), - virtual_pool: self.virtual_pool.to_string(), - token_quote_account: self.token_quote_account.to_string(), - quote_vault: self.quote_vault.to_string(), - quote_mint: self.quote_mint.to_string(), - token_quote_program: self.token_quote_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SwapIxAccounts; - impl IntoProto for SwapIxAccounts { - fn into_proto(self) -> proto_def::SwapIxAccounts { - proto_def::SwapIxAccounts { - pool_authority: self.pool_authority.to_string(), - config: self.config.to_string(), - pool: self.pool.to_string(), - input_token_account: self.input_token_account.to_string(), - output_token_account: self.output_token_account.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - payer: self.payer.to_string(), - token_base_program: self.token_base_program.to_string(), - token_quote_program: self.token_quote_program.to_string(), - referral_token_account: self.referral_token_account.map(|p| p.to_string()), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SwapIxData; - impl IntoProto for SwapIxData { - fn into_proto(self) -> proto_def::SwapIxData { - proto_def::SwapIxData { - params: Some(self.params.into_proto()), - } - } - } - use super::WithdrawLeftoverIxAccounts; - impl IntoProto for WithdrawLeftoverIxAccounts { - fn into_proto(self) -> proto_def::WithdrawLeftoverIxAccounts { - proto_def::WithdrawLeftoverIxAccounts { - pool_authority: self.pool_authority.to_string(), - config: self.config.to_string(), - virtual_pool: self.virtual_pool.to_string(), - token_base_account: self.token_base_account.to_string(), - base_vault: self.base_vault.to_string(), - base_mint: self.base_mint.to_string(), - leftover_receiver: self.leftover_receiver.to_string(), - token_base_program: self.token_base_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - - impl IntoProto for DynamicBondingCurveProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - DynamicBondingCurveProgramIx::ClaimCreatorTradingFee(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimCreatorTradingFee( - proto_def::ClaimCreatorTradingFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - DynamicBondingCurveProgramIx::ClaimProtocolFee(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimProtocolFee( - proto_def::ClaimProtocolFeeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - DynamicBondingCurveProgramIx::ClaimTradingFee(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimTradingFee( - proto_def::ClaimTradingFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - DynamicBondingCurveProgramIx::CloseClaimFeeOperator(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CloseClaimFeeOperator( - proto_def::CloseClaimFeeOperatorIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - DynamicBondingCurveProgramIx::CreateClaimFeeOperator(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateClaimFeeOperator( - proto_def::CreateClaimFeeOperatorIx { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - DynamicBondingCurveProgramIx::CreateConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateConfig( - proto_def::CreateConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - DynamicBondingCurveProgramIx::CreateLocker(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateLocker( - proto_def::CreateLockerIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - DynamicBondingCurveProgramIx::CreatePartnerMetadata(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreatePartnerMetadata( - proto_def::CreatePartnerMetadataIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - DynamicBondingCurveProgramIx::CreateVirtualPoolMetadata(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateVirtualPoolMetadata( - proto_def::CreateVirtualPoolMetadataIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - DynamicBondingCurveProgramIx::CreatorWithdrawSurplus(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreatorWithdrawSurplus( - proto_def::CreatorWithdrawSurplusIx { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - DynamicBondingCurveProgramIx::InitializeVirtualPoolWithSplToken(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::InitializeVirtualPoolWithSplToken( - proto_def::InitializeVirtualPoolWithSplTokenIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - DynamicBondingCurveProgramIx::InitializeVirtualPoolWithToken2022(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::InitializeVirtualPoolWithToken2022( - proto_def::InitializeVirtualPoolWithToken2022Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - DynamicBondingCurveProgramIx::MigrateMeteoraDamm(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::MigrateMeteoraDamm( - proto_def::MigrateMeteoraDammIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - DynamicBondingCurveProgramIx::MigrateMeteoraDammClaimLpToken(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::MigrateMeteoraDammClaimLpToken( - proto_def::MigrateMeteoraDammClaimLpTokenIx { - accounts: Some(acc.into_proto()), - }, - ), - ), - } - }, - DynamicBondingCurveProgramIx::MigrateMeteoraDammLockLpToken(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::MigrateMeteoraDammLockLpToken( - proto_def::MigrateMeteoraDammLockLpTokenIx { - accounts: Some(acc.into_proto()), - }, - ), - ), - } - }, - DynamicBondingCurveProgramIx::MigrationDammV2(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::MigrationDammV2( - proto_def::MigrationDammV2Ix { - accounts: Some(acc.into_proto()), - }, - )), - }, - DynamicBondingCurveProgramIx::MigrationDammV2CreateMetadata(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::MigrationDammV2CreateMetadata( - proto_def::MigrationDammV2CreateMetadataIx { - accounts: Some(acc.into_proto()), - }, - ), - ), - } - }, - DynamicBondingCurveProgramIx::MigrationMeteoraDammCreateMetadata(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::MigrationMeteoraDammCreateMetadata( - proto_def::MigrationMeteoraDammCreateMetadataIx { - accounts: Some(acc.into_proto()), - }, - ), - ), - } - }, - DynamicBondingCurveProgramIx::PartnerWithdrawSurplus(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::PartnerWithdrawSurplus( - proto_def::PartnerWithdrawSurplusIx { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - DynamicBondingCurveProgramIx::ProtocolWithdrawSurplus(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ProtocolWithdrawSurplus( - proto_def::ProtocolWithdrawSurplusIx { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - DynamicBondingCurveProgramIx::Swap(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Swap(proto_def::SwapIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - DynamicBondingCurveProgramIx::WithdrawLeftover(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::WithdrawLeftover( - proto_def::WithdrawLeftoverIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/meteora-dbc-parser/src/generated_parser/mod.rs b/crates/meteora-dbc-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/meteora-dbc-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/meteora-dbc-parser/src/generated_parser/proto_helpers.rs b/crates/meteora-dbc-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index 36c39d68..00000000 --- a/crates/meteora-dbc-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,396 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::BaseFeeConfig}; - impl IntoProto for BaseFeeConfig { - fn into_proto(self) -> proto_def::BaseFeeConfig { - proto_def::BaseFeeConfig { - cliff_fee_numerator: self.cliff_fee_numerator, - period_frequency: self.period_frequency, - reduction_factor: self.reduction_factor, - number_of_period: self.number_of_period.into(), - fee_scheduler_mode: self.fee_scheduler_mode.into(), - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - } - } - } - use crate::types::BaseFeeParameters; - impl IntoProto for BaseFeeParameters { - fn into_proto(self) -> proto_def::BaseFeeParameters { - proto_def::BaseFeeParameters { - cliff_fee_numerator: self.cliff_fee_numerator, - number_of_period: self.number_of_period.into(), - period_frequency: self.period_frequency, - reduction_factor: self.reduction_factor, - fee_scheduler_mode: self.fee_scheduler_mode.into(), - } - } - } - use crate::types::DynamicFeeConfig; - impl IntoProto for DynamicFeeConfig { - fn into_proto(self) -> proto_def::DynamicFeeConfig { - proto_def::DynamicFeeConfig { - initialized: self.initialized.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - max_volatility_accumulator: self.max_volatility_accumulator, - variable_fee_control: self.variable_fee_control, - bin_step: self.bin_step.into(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - padding2: self.padding2.into_iter().map(|x| x.into()).collect(), - bin_step_u128: self.bin_step_u128.to_string(), - } - } - } - use crate::types::DynamicFeeParameters; - impl IntoProto for DynamicFeeParameters { - fn into_proto(self) -> proto_def::DynamicFeeParameters { - proto_def::DynamicFeeParameters { - bin_step: self.bin_step.into(), - bin_step_u128: self.bin_step_u128.to_string(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - max_volatility_accumulator: self.max_volatility_accumulator, - variable_fee_control: self.variable_fee_control, - } - } - } - use crate::types::EvtClaimCreatorTradingFee; - impl IntoProto for EvtClaimCreatorTradingFee { - fn into_proto(self) -> proto_def::EvtClaimCreatorTradingFee { - proto_def::EvtClaimCreatorTradingFee { - pool: self.pool.to_string(), - token_base_amount: self.token_base_amount, - token_quote_amount: self.token_quote_amount, - } - } - } - use crate::types::EvtClaimProtocolFee; - impl IntoProto for EvtClaimProtocolFee { - fn into_proto(self) -> proto_def::EvtClaimProtocolFee { - proto_def::EvtClaimProtocolFee { - pool: self.pool.to_string(), - token_base_amount: self.token_base_amount, - token_quote_amount: self.token_quote_amount, - } - } - } - use crate::types::EvtClaimTradingFee; - impl IntoProto for EvtClaimTradingFee { - fn into_proto(self) -> proto_def::EvtClaimTradingFee { - proto_def::EvtClaimTradingFee { - pool: self.pool.to_string(), - token_base_amount: self.token_base_amount, - token_quote_amount: self.token_quote_amount, - } - } - } - use crate::types::EvtCloseClaimFeeOperator; - impl IntoProto for EvtCloseClaimFeeOperator { - fn into_proto(self) -> proto_def::EvtCloseClaimFeeOperator { - proto_def::EvtCloseClaimFeeOperator { - claim_fee_operator: self.claim_fee_operator.to_string(), - operator: self.operator.to_string(), - } - } - } - use crate::types::EvtCreateClaimFeeOperator; - impl IntoProto for EvtCreateClaimFeeOperator { - fn into_proto(self) -> proto_def::EvtCreateClaimFeeOperator { - proto_def::EvtCreateClaimFeeOperator { - operator: self.operator.to_string(), - } - } - } - use crate::types::EvtCreateConfig; - impl IntoProto for EvtCreateConfig { - fn into_proto(self) -> proto_def::EvtCreateConfig { - proto_def::EvtCreateConfig { - config: self.config.to_string(), - quote_mint: self.quote_mint.to_string(), - fee_claimer: self.fee_claimer.to_string(), - owner: self.owner.to_string(), - pool_fees: Some(self.pool_fees.into_proto()), - collect_fee_mode: self.collect_fee_mode.into(), - migration_option: self.migration_option.into(), - activation_type: self.activation_type.into(), - token_decimal: self.token_decimal.into(), - token_type: self.token_type.into(), - partner_locked_lp_percentage: self.partner_locked_lp_percentage.into(), - partner_lp_percentage: self.partner_lp_percentage.into(), - creator_locked_lp_percentage: self.creator_locked_lp_percentage.into(), - creator_lp_percentage: self.creator_lp_percentage.into(), - swap_base_amount: self.swap_base_amount, - migration_quote_threshold: self.migration_quote_threshold, - migration_base_amount: self.migration_base_amount, - sqrt_start_price: self.sqrt_start_price.to_string(), - locked_vesting: Some(self.locked_vesting.into_proto()), - migration_fee_option: self.migration_fee_option.into(), - fixed_token_supply_flag: self.fixed_token_supply_flag.into(), - pre_migration_token_supply: self.pre_migration_token_supply, - post_migration_token_supply: self.post_migration_token_supply, - curve: self.curve.into_iter().map(|x| x.into_proto()).collect(), - } - } - } - use crate::types::EvtCreateDammV2MigrationMetadata; - impl IntoProto for EvtCreateDammV2MigrationMetadata { - fn into_proto(self) -> proto_def::EvtCreateDammV2MigrationMetadata { - proto_def::EvtCreateDammV2MigrationMetadata { - virtual_pool: self.virtual_pool.to_string(), - } - } - } - use crate::types::EvtCreateMeteoraMigrationMetadata; - impl IntoProto for EvtCreateMeteoraMigrationMetadata { - fn into_proto(self) -> proto_def::EvtCreateMeteoraMigrationMetadata { - proto_def::EvtCreateMeteoraMigrationMetadata { - virtual_pool: self.virtual_pool.to_string(), - } - } - } - use crate::types::EvtCreatorWithdrawSurplus; - impl IntoProto for EvtCreatorWithdrawSurplus { - fn into_proto(self) -> proto_def::EvtCreatorWithdrawSurplus { - proto_def::EvtCreatorWithdrawSurplus { - pool: self.pool.to_string(), - surplus_amount: self.surplus_amount, - } - } - } - use crate::types::EvtCurveComplete; - impl IntoProto for EvtCurveComplete { - fn into_proto(self) -> proto_def::EvtCurveComplete { - proto_def::EvtCurveComplete { - pool: self.pool.to_string(), - config: self.config.to_string(), - base_reserve: self.base_reserve, - quote_reserve: self.quote_reserve, - } - } - } - use crate::types::EvtInitializePool; - impl IntoProto for EvtInitializePool { - fn into_proto(self) -> proto_def::EvtInitializePool { - proto_def::EvtInitializePool { - pool: self.pool.to_string(), - config: self.config.to_string(), - creator: self.creator.to_string(), - base_mint: self.base_mint.to_string(), - pool_type: self.pool_type.into(), - activation_point: self.activation_point, - } - } - } - use crate::types::EvtPartnerMetadata; - impl IntoProto for EvtPartnerMetadata { - fn into_proto(self) -> proto_def::EvtPartnerMetadata { - proto_def::EvtPartnerMetadata { - partner_metadata: self.partner_metadata.to_string(), - fee_claimer: self.fee_claimer.to_string(), - } - } - } - use crate::types::EvtPartnerWithdrawSurplus; - impl IntoProto for EvtPartnerWithdrawSurplus { - fn into_proto(self) -> proto_def::EvtPartnerWithdrawSurplus { - proto_def::EvtPartnerWithdrawSurplus { - pool: self.pool.to_string(), - surplus_amount: self.surplus_amount, - } - } - } - use crate::types::EvtProtocolWithdrawSurplus; - impl IntoProto for EvtProtocolWithdrawSurplus { - fn into_proto(self) -> proto_def::EvtProtocolWithdrawSurplus { - proto_def::EvtProtocolWithdrawSurplus { - pool: self.pool.to_string(), - surplus_amount: self.surplus_amount, - } - } - } - use crate::types::EvtSwap; - impl IntoProto for EvtSwap { - fn into_proto(self) -> proto_def::EvtSwap { - proto_def::EvtSwap { - pool: self.pool.to_string(), - config: self.config.to_string(), - trade_direction: self.trade_direction.into(), - has_referral: self.has_referral, - params: Some(self.params.into_proto()), - swap_result: Some(self.swap_result.into_proto()), - amount_in: self.amount_in, - current_timestamp: self.current_timestamp, - } - } - } - use crate::types::EvtVirtualPoolMetadata; - impl IntoProto for EvtVirtualPoolMetadata { - fn into_proto(self) -> proto_def::EvtVirtualPoolMetadata { - proto_def::EvtVirtualPoolMetadata { - virtual_pool_metadata: self.virtual_pool_metadata.to_string(), - virtual_pool: self.virtual_pool.to_string(), - } - } - } - use crate::types::EvtWithdrawLeftover; - impl IntoProto for EvtWithdrawLeftover { - fn into_proto(self) -> proto_def::EvtWithdrawLeftover { - proto_def::EvtWithdrawLeftover { - pool: self.pool.to_string(), - leftover_receiver: self.leftover_receiver.to_string(), - leftover_amount: self.leftover_amount, - } - } - } - use crate::types::InitializePoolParameters; - impl IntoProto for InitializePoolParameters { - fn into_proto(self) -> proto_def::InitializePoolParameters { - proto_def::InitializePoolParameters { - name: self.name, - symbol: self.symbol, - uri: self.uri, - } - } - } - use crate::types::LiquidityDistributionConfig; - impl IntoProto for LiquidityDistributionConfig { - fn into_proto(self) -> proto_def::LiquidityDistributionConfig { - proto_def::LiquidityDistributionConfig { - sqrt_price: self.sqrt_price.to_string(), - liquidity: self.liquidity.to_string(), - } - } - } - use crate::types::LiquidityDistributionParameters; - impl IntoProto for LiquidityDistributionParameters { - fn into_proto(self) -> proto_def::LiquidityDistributionParameters { - proto_def::LiquidityDistributionParameters { - sqrt_price: self.sqrt_price.to_string(), - liquidity: self.liquidity.to_string(), - } - } - } - use crate::types::LockedVestingConfig; - impl IntoProto for LockedVestingConfig { - fn into_proto(self) -> proto_def::LockedVestingConfig { - proto_def::LockedVestingConfig { - amount_per_period: self.amount_per_period, - cliff_duration_from_migration_time: self.cliff_duration_from_migration_time, - frequency: self.frequency, - number_of_period: self.number_of_period, - cliff_unlock_amount: self.cliff_unlock_amount, - padding: self.padding, - } - } - } - use crate::types::LockedVestingParams; - impl IntoProto for LockedVestingParams { - fn into_proto(self) -> proto_def::LockedVestingParams { - proto_def::LockedVestingParams { - amount_per_period: self.amount_per_period, - cliff_duration_from_migration_time: self.cliff_duration_from_migration_time, - frequency: self.frequency, - number_of_period: self.number_of_period, - cliff_unlock_amount: self.cliff_unlock_amount, - } - } - } - use crate::types::PoolFeeParameters; - impl IntoProto for PoolFeeParameters { - fn into_proto(self) -> proto_def::PoolFeeParameters { - proto_def::PoolFeeParameters { - base_fee: Some(self.base_fee.into_proto()), - dynamic_fee: self.dynamic_fee.map(|x| x.into_proto()), - } - } - } - use crate::types::PoolFees; - impl IntoProto for PoolFees { - fn into_proto(self) -> proto_def::PoolFees { - proto_def::PoolFees { - trade_fee_numerator: self.trade_fee_numerator, - trade_fee_denominator: self.trade_fee_denominator, - protocol_trade_fee_numerator: self.protocol_trade_fee_numerator, - protocol_trade_fee_denominator: self.protocol_trade_fee_denominator, - } - } - } - use crate::types::PoolFeesConfig; - impl IntoProto for PoolFeesConfig { - fn into_proto(self) -> proto_def::PoolFeesConfig { - proto_def::PoolFeesConfig { - base_fee: Some(self.base_fee.into_proto()), - dynamic_fee: Some(self.dynamic_fee.into_proto()), - padding0: self.padding0.to_vec(), - padding1: self.padding1.into_iter().map(|x| x.into()).collect(), - protocol_fee_percent: self.protocol_fee_percent.into(), - referral_fee_percent: self.referral_fee_percent.into(), - } - } - } - use crate::types::PoolMetrics; - impl IntoProto for PoolMetrics { - fn into_proto(self) -> proto_def::PoolMetrics { - proto_def::PoolMetrics { - total_protocol_base_fee: self.total_protocol_base_fee, - total_protocol_quote_fee: self.total_protocol_quote_fee, - total_trading_base_fee: self.total_trading_base_fee, - total_trading_quote_fee: self.total_trading_quote_fee, - } - } - } - use crate::types::SwapParameters; - impl IntoProto for SwapParameters { - fn into_proto(self) -> proto_def::SwapParameters { - proto_def::SwapParameters { - amount_in: self.amount_in, - minimum_amount_out: self.minimum_amount_out, - } - } - } - use crate::types::SwapResult; - impl IntoProto for SwapResult { - fn into_proto(self) -> proto_def::SwapResult { - proto_def::SwapResult { - actual_input_amount: self.actual_input_amount, - output_amount: self.output_amount, - next_sqrt_price: self.next_sqrt_price.to_string(), - trading_fee: self.trading_fee, - protocol_fee: self.protocol_fee, - referral_fee: self.referral_fee, - } - } - } - use crate::types::TokenSupplyParams; - impl IntoProto for TokenSupplyParams { - fn into_proto(self) -> proto_def::TokenSupplyParams { - proto_def::TokenSupplyParams { - pre_migration_token_supply: self.pre_migration_token_supply, - post_migration_token_supply: self.post_migration_token_supply, - } - } - } - use crate::types::VolatilityTracker; - impl IntoProto for VolatilityTracker { - fn into_proto(self) -> proto_def::VolatilityTracker { - proto_def::VolatilityTracker { - last_update_timestamp: self.last_update_timestamp, - padding: self.padding.into_iter().map(|x| x.into()).collect(), - sqrt_price_reference: self.sqrt_price_reference.to_string(), - volatility_accumulator: self.volatility_accumulator.to_string(), - volatility_reference: self.volatility_reference.to_string(), - } - } - } -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/accounts/claim_fee_operator.rs b/crates/meteora-dbc-parser/src/generated_sdk/accounts/claim_fee_operator.rs deleted file mode 100644 index 84982e01..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/accounts/claim_fee_operator.rs +++ /dev/null @@ -1,136 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimFeeOperator { - pub discriminator: [u8; 8], - /// operator - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub operator: Pubkey, - /// Reserve - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 128], -} - -impl ClaimFeeOperator { - pub const LEN: usize = 168; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for ClaimFeeOperator { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_claim_fee_operator(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = ClaimFeeOperator::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_claim_fee_operator(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = ClaimFeeOperator::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for ClaimFeeOperator { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for ClaimFeeOperator {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for ClaimFeeOperator { - fn owner() -> Pubkey { crate::DYNAMIC_BONDING_CURVE_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for ClaimFeeOperator {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for ClaimFeeOperator { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/accounts/config.rs b/crates/meteora-dbc-parser/src/generated_sdk/accounts/config.rs deleted file mode 100644 index 9eabbeb9..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/accounts/config.rs +++ /dev/null @@ -1,145 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::PoolFees; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Config { - pub discriminator: [u8; 8], - pub pool_fees: PoolFees, - pub activation_duration: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vault_config_key: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_creator_authority: Pubkey, - pub activation_type: u8, - pub partner_fee_numerator: u64, - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 219], -} - -impl Config { - pub const LEN: usize = 340; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Config { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Config::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Config::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Config { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Config {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Config { - fn owner() -> Pubkey { crate::DYNAMIC_BONDING_CURVE_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Config {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Config { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/accounts/lock_escrow.rs b/crates/meteora-dbc-parser/src/generated_sdk/accounts/lock_escrow.rs deleted file mode 100644 index 30fff02d..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/accounts/lock_escrow.rs +++ /dev/null @@ -1,148 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockEscrow { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub escrow_vault: Pubkey, - pub bump: u8, - pub total_locked_amount: u64, - pub lp_per_token: u128, - pub unclaimed_fee_pending: u64, - pub a_fee: u64, - pub b_fee: u64, -} - -impl LockEscrow { - pub const LEN: usize = 153; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for LockEscrow { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_lock_escrow( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_lock_escrow(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_lock_escrow( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = LockEscrow::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_lock_escrow( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_lock_escrow(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_lock_escrow( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = LockEscrow::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for LockEscrow { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for LockEscrow {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for LockEscrow { - fn owner() -> Pubkey { crate::DYNAMIC_BONDING_CURVE_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for LockEscrow {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for LockEscrow { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/accounts/meteora_damm_migration_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/accounts/meteora_damm_migration_metadata.rs deleted file mode 100644 index c58b741b..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/accounts/meteora_damm_migration_metadata.rs +++ /dev/null @@ -1,174 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MeteoraDammMigrationMetadata { - pub discriminator: [u8; 8], - /// pool - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub virtual_pool: Pubkey, - /// pool creator - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_creator: Pubkey, - /// partner - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub partner: Pubkey, - /// lp mint - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lp_mint: Pubkey, - /// partner locked lp - pub partner_locked_lp: u64, - /// partner lp - pub partner_lp: u64, - /// creator locked lp - pub creator_locked_lp: u64, - /// creator lp - pub creator_lp: u64, - /// padding - pub padding0: u8, - /// flag to check whether lp is locked for creator - pub creator_locked_status: u8, - /// flag to check whether lp is locked for partner - pub partner_locked_status: u8, - /// flag to check whether creator has claimed lp token - pub creator_claim_status: u8, - /// flag to check whether partner has claimed lp token - pub partner_claim_status: u8, - /// Reserve - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 107], -} - -impl MeteoraDammMigrationMetadata { - pub const LEN: usize = 280; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for MeteoraDammMigrationMetadata { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_meteora_damm_migration_metadata( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_meteora_damm_migration_metadata(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_meteora_damm_migration_metadata( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = MeteoraDammMigrationMetadata::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_meteora_damm_migration_metadata( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_meteora_damm_migration_metadata(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_meteora_damm_migration_metadata( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = MeteoraDammMigrationMetadata::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for MeteoraDammMigrationMetadata { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for MeteoraDammMigrationMetadata {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for MeteoraDammMigrationMetadata { - fn owner() -> Pubkey { crate::DYNAMIC_BONDING_CURVE_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for MeteoraDammMigrationMetadata {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for MeteoraDammMigrationMetadata { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/accounts/meteora_damm_v2_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/accounts/meteora_damm_v2_metadata.rs deleted file mode 100644 index 8b6c8625..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/accounts/meteora_damm_v2_metadata.rs +++ /dev/null @@ -1,149 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MeteoraDammV2Metadata { - pub discriminator: [u8; 8], - /// pool - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub virtual_pool: Pubkey, - /// pool creator - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_creator: Pubkey, - /// partner - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub partner: Pubkey, - /// Reserve - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 126], -} - -impl MeteoraDammV2Metadata { - pub const LEN: usize = 230; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for MeteoraDammV2Metadata { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_meteora_damm_v2_metadata( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_meteora_damm_v2_metadata(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_meteora_damm_v2_metadata( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = MeteoraDammV2Metadata::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_meteora_damm_v2_metadata( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_meteora_damm_v2_metadata(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_meteora_damm_v2_metadata( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = MeteoraDammV2Metadata::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for MeteoraDammV2Metadata { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for MeteoraDammV2Metadata {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for MeteoraDammV2Metadata { - fn owner() -> Pubkey { crate::DYNAMIC_BONDING_CURVE_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for MeteoraDammV2Metadata {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for MeteoraDammV2Metadata { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/accounts/mod.rs b/crates/meteora-dbc-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index b7e35bf8..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#claim_fee_operator; -pub(crate) mod r#config; -pub(crate) mod r#lock_escrow; -pub(crate) mod r#meteora_damm_migration_metadata; -pub(crate) mod r#meteora_damm_v2_metadata; -pub(crate) mod r#partner_metadata; -pub(crate) mod r#pool_config; -pub(crate) mod r#virtual_pool; -pub(crate) mod r#virtual_pool_metadata; - -pub use self::{ - r#claim_fee_operator::*, r#config::*, r#lock_escrow::*, r#meteora_damm_migration_metadata::*, - r#meteora_damm_v2_metadata::*, r#partner_metadata::*, r#pool_config::*, r#virtual_pool::*, - r#virtual_pool_metadata::*, -}; diff --git a/crates/meteora-dbc-parser/src/generated_sdk/accounts/partner_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/accounts/partner_metadata.rs deleted file mode 100644 index 1558f316..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/accounts/partner_metadata.rs +++ /dev/null @@ -1,139 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PartnerMetadata { - pub discriminator: [u8; 8], - /// fee claimer - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_claimer: Pubkey, - /// padding for future use - pub padding: [u128; 6], - /// Name of partner. - pub name: String, - /// Website of partner. - pub website: String, - /// Logo of partner - pub logo: String, -} - -impl PartnerMetadata { - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PartnerMetadata { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_partner_metadata( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_partner_metadata(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_partner_metadata( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PartnerMetadata::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_partner_metadata( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_partner_metadata(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_partner_metadata( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PartnerMetadata::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PartnerMetadata { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PartnerMetadata {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PartnerMetadata { - fn owner() -> Pubkey { crate::DYNAMIC_BONDING_CURVE_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PartnerMetadata {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PartnerMetadata { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/accounts/pool_config.rs b/crates/meteora-dbc-parser/src/generated_sdk/accounts/pool_config.rs deleted file mode 100644 index 298208f4..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/accounts/pool_config.rs +++ /dev/null @@ -1,201 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{LiquidityDistributionConfig, LockedVestingConfig, PoolFeesConfig}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolConfig { - pub discriminator: [u8; 8], - /// quote mint - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub quote_mint: Pubkey, - /// Address to get the fee - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_claimer: Pubkey, - /// Address to receive extra base token after migration, in case token is fixed supply - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub leftover_receiver: Pubkey, - /// Pool fee - pub pool_fees: PoolFeesConfig, - /// Collect fee mode - pub collect_fee_mode: u8, - /// migration option - pub migration_option: u8, - /// whether mode slot or timestamp - pub activation_type: u8, - /// token decimals - pub token_decimal: u8, - /// version - pub version: u8, - /// token type of base token - pub token_type: u8, - /// quote token flag - pub quote_token_flag: u8, - /// partner locked lp percentage - pub partner_locked_lp_percentage: u8, - /// partner lp percentage - pub partner_lp_percentage: u8, - /// creator post migration fee percentage - pub creator_locked_lp_percentage: u8, - /// creator lp percentage - pub creator_lp_percentage: u8, - /// migration fee option - pub migration_fee_option: u8, - /// flag to indicate whether token is dynamic supply (0) or fixed supply (1) - pub fixed_token_supply_flag: u8, - /// creator trading fee percentage - pub creator_trading_fee_percentage: u8, - /// padding 0 - pub padding0: [u8; 2], - /// padding 1 - pub padding1: [u8; 8], - /// swap base amount - pub swap_base_amount: u64, - /// migration quote threshold (in quote token) - pub migration_quote_threshold: u64, - /// migration base threshold (in base token) - pub migration_base_threshold: u64, - /// migration sqrt price - pub migration_sqrt_price: u128, - /// locked vesting config - pub locked_vesting_config: LockedVestingConfig, - /// pre migration token supply - pub pre_migration_token_supply: u64, - /// post migration token supply - pub post_migration_token_supply: u64, - /// padding 2 - pub padding2: [u128; 2], - /// minimum price - pub sqrt_start_price: u128, - /// curve, only use 20 point firstly, we can extend that latter - pub curve: [LiquidityDistributionConfig; 20], -} - -impl PoolConfig { - pub const LEN: usize = 1048; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PoolConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_pool_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_pool_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_pool_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PoolConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_pool_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_pool_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_pool_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PoolConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PoolConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PoolConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PoolConfig { - fn owner() -> Pubkey { crate::DYNAMIC_BONDING_CURVE_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PoolConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PoolConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/accounts/virtual_pool.rs b/crates/meteora-dbc-parser/src/generated_sdk/accounts/virtual_pool.rs deleted file mode 100644 index 13b38a7a..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/accounts/virtual_pool.rs +++ /dev/null @@ -1,203 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{PoolMetrics, VolatilityTracker}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct VirtualPool { - pub discriminator: [u8; 8], - /// volatility tracker - pub volatility_tracker: VolatilityTracker, - /// config key - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config: Pubkey, - /// creator - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - /// base mint - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base_mint: Pubkey, - /// base vault - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base_vault: Pubkey, - /// quote vault - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub quote_vault: Pubkey, - /// base reserve - pub base_reserve: u64, - /// quote reserve - pub quote_reserve: u64, - /// protocol base fee - pub protocol_base_fee: u64, - /// protocol quote fee - pub protocol_quote_fee: u64, - /// partner base fee - pub partner_base_fee: u64, - /// trading quote fee - pub partner_quote_fee: u64, - /// current price - pub sqrt_price: u128, - /// Activation point - pub activation_point: u64, - /// pool type, spl token or token2022 - pub pool_type: u8, - /// is migrated - pub is_migrated: u8, - /// is partner withdraw surplus - pub is_partner_withdraw_surplus: u8, - /// is protocol withdraw surplus - pub is_protocol_withdraw_surplus: u8, - /// migration progress - pub migration_progress: u8, - /// is withdraw leftover - pub is_withdraw_leftover: u8, - /// is creator withdraw surplus - pub is_creator_withdraw_surplus: u8, - /// padding - pub padding0: [u8; 1], - /// pool metrics - pub metrics: PoolMetrics, - /// The time curve is finished - pub finish_curve_timestamp: u64, - /// creator base fee - pub creator_base_fee: u64, - /// creator quote fee - pub creator_quote_fee: u64, - /// Padding for further use - pub padding1: [u64; 7], -} - -impl VirtualPool { - pub const LEN: usize = 424; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for VirtualPool { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_virtual_pool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_virtual_pool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_virtual_pool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = VirtualPool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_virtual_pool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_virtual_pool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_virtual_pool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = VirtualPool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for VirtualPool { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for VirtualPool {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for VirtualPool { - fn owner() -> Pubkey { crate::DYNAMIC_BONDING_CURVE_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for VirtualPool {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for VirtualPool { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/accounts/virtual_pool_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/accounts/virtual_pool_metadata.rs deleted file mode 100644 index 4b5621eb..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/accounts/virtual_pool_metadata.rs +++ /dev/null @@ -1,139 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct VirtualPoolMetadata { - pub discriminator: [u8; 8], - /// virtual pool - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub virtual_pool: Pubkey, - /// padding for future use - pub padding: [u128; 6], - /// Name of project. - pub name: String, - /// Website of project. - pub website: String, - /// Logo of project - pub logo: String, -} - -impl VirtualPoolMetadata { - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for VirtualPoolMetadata { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_virtual_pool_metadata( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_virtual_pool_metadata(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_virtual_pool_metadata( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = VirtualPoolMetadata::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_virtual_pool_metadata( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_virtual_pool_metadata(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_virtual_pool_metadata( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = VirtualPoolMetadata::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for VirtualPoolMetadata { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for VirtualPoolMetadata {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for VirtualPoolMetadata { - fn owner() -> Pubkey { crate::DYNAMIC_BONDING_CURVE_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for VirtualPoolMetadata {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for VirtualPoolMetadata { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/errors/dynamic_bonding_curve.rs b/crates/meteora-dbc-parser/src/generated_sdk/errors/dynamic_bonding_curve.rs deleted file mode 100644 index 0341ba6c..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/errors/dynamic_bonding_curve.rs +++ /dev/null @@ -1,133 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum DynamicBondingCurveError { - /// 6000 - Math operation overflow - #[error("Math operation overflow")] - MathOverflow = 0x1770, - /// 6001 - Invalid fee setup - #[error("Invalid fee setup")] - InvalidFee = 0x1771, - /// 6002 - Exceeded slippage tolerance - #[error("Exceeded slippage tolerance")] - ExceededSlippage = 0x1772, - /// 6003 - Exceeded max fee bps - #[error("Exceeded max fee bps")] - ExceedMaxFeeBps = 0x1773, - /// 6004 - Invalid admin - #[error("Invalid admin")] - InvalidAdmin = 0x1774, - /// 6005 - Amount is zero - #[error("Amount is zero")] - AmountIsZero = 0x1775, - /// 6006 - Type cast error - #[error("Type cast error")] - TypeCastFailed = 0x1776, - /// 6007 - Invalid activation type - #[error("Invalid activation type")] - InvalidActivationType = 0x1777, - /// 6008 - Invalid quote mint - #[error("Invalid quote mint")] - InvalidQuoteMint = 0x1778, - /// 6009 - Invalid collect fee mode - #[error("Invalid collect fee mode")] - InvalidCollectFeeMode = 0x1779, - /// 6010 - Invalid migration fee option - #[error("Invalid migration fee option")] - InvalidMigrationFeeOption = 0x177a, - /// 6011 - Invalid input - #[error("Invalid input")] - InvalidInput = 0x177b, - /// 6012 - Not enough liquidity - #[error("Not enough liquidity")] - NotEnoughLiquidity = 0x177c, - /// 6013 - Pool is completed - #[error("Pool is completed")] - PoolIsCompleted = 0x177d, - /// 6014 - Pool is incompleted - #[error("Pool is incompleted")] - PoolIsIncompleted = 0x177e, - /// 6015 - Invalid migration option - #[error("Invalid migration option")] - InvalidMigrationOption = 0x177f, - /// 6016 - Invalid activation type - #[error("Invalid activation type")] - InvalidTokenDecimals = 0x1780, - /// 6017 - Invalid token type - #[error("Invalid token type")] - InvalidTokenType = 0x1781, - /// 6018 - Invalid fee percentage - #[error("Invalid fee percentage")] - InvalidFeePercentage = 0x1782, - /// 6019 - Invalid quote threshold - #[error("Invalid quote threshold")] - InvalidQuoteThreshold = 0x1783, - /// 6020 - Invalid token supply - #[error("Invalid token supply")] - InvalidTokenSupply = 0x1784, - /// 6021 - Invalid curve - #[error("Invalid curve")] - InvalidCurve = 0x1785, - /// 6022 - Not permit to do this action - #[error("Not permit to do this action")] - NotPermitToDoThisAction = 0x1786, - /// 6023 - Invalid owner account - #[error("Invalid owner account")] - InvalidOwnerAccount = 0x1787, - /// 6024 - Invalid config account - #[error("Invalid config account")] - InvalidConfigAccount = 0x1788, - /// 6025 - Surplus has been withdraw - #[error("Surplus has been withdraw")] - SurplusHasBeenWithdraw = 0x1789, - /// 6026 - Leftover has been withdraw - #[error("Leftover has been withdraw")] - LeftoverHasBeenWithdraw = 0x178a, - /// 6027 - Total base token is exceeded max supply - #[error("Total base token is exceeded max supply")] - TotalBaseTokenExceedMaxSupply = 0x178b, - /// 6028 - Unsupport native mint token 2022 - #[error("Unsupport native mint token 2022")] - UnsupportNativeMintToken2022 = 0x178c, - /// 6029 - Insufficient liquidity for migration - #[error("Insufficient liquidity for migration")] - InsufficientLiquidityForMigration = 0x178d, - /// 6030 - Missing pool config in remaining account - #[error("Missing pool config in remaining account")] - MissingPoolConfigInRemainingAccount = 0x178e, - /// 6031 - Invalid vesting parameters - #[error("Invalid vesting parameters")] - InvalidVestingParameters = 0x178f, - /// 6032 - Invalid leftover address - #[error("Invalid leftover address")] - InvalidLeftoverAddress = 0x1790, - /// 6033 - Swap amount is over a threshold - #[error("Swap amount is over a threshold")] - SwapAmountIsOverAThreshold = 0x1791, - /// 6034 - Invalid fee scheduler - #[error("Invalid fee scheduler")] - InvalidFeeScheduler = 0x1792, - /// 6035 - Invalid creator trading fee percentage - #[error("Invalid creator trading fee percentage")] - InvalidCreatorTradingFeePercentage = 0x1793, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for DynamicBondingCurveError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for DynamicBondingCurveError { - fn type_of() -> &'static str { "DynamicBondingCurveError" } -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/errors/mod.rs b/crates/meteora-dbc-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 2f101e79..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod dynamic_bonding_curve; - -pub use self::dynamic_bonding_curve::DynamicBondingCurveError; diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/claim_creator_trading_fee.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/claim_creator_trading_fee.rs deleted file mode 100644 index 33df5bfa..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/claim_creator_trading_fee.rs +++ /dev/null @@ -1,843 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimCreatorTradingFee { - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - /// The treasury token a account - pub token_a_account: solana_pubkey::Pubkey, - /// The treasury token b account - pub token_b_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub base_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub base_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub quote_mint: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - /// Token a program - pub token_base_program: solana_pubkey::Pubkey, - /// Token b program - pub token_quote_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimCreatorTradingFee { - pub fn instruction( - &self, - args: ClaimCreatorTradingFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimCreatorTradingFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_base_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_quote_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ClaimCreatorTradingFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimCreatorTradingFeeInstructionData { - discriminator: [u8; 8], -} - -impl ClaimCreatorTradingFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [82, 220, 250, 189, 3, 85, 107, 45], - } - } -} - -impl Default for ClaimCreatorTradingFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimCreatorTradingFeeInstructionArgs { - pub max_base_amount: u64, - pub max_quote_amount: u64, -} - -/// Instruction builder for `ClaimCreatorTradingFee`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 1. `[writable]` pool -/// 2. `[writable]` token_a_account -/// 3. `[writable]` token_b_account -/// 4. `[writable]` base_vault -/// 5. `[writable]` quote_vault -/// 6. `[]` base_mint -/// 7. `[]` quote_mint -/// 8. `[signer]` creator -/// 9. `[]` token_base_program -/// 10. `[]` token_quote_program -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimCreatorTradingFeeBuilder { - pool_authority: Option, - pool: Option, - token_a_account: Option, - token_b_account: Option, - base_vault: Option, - quote_vault: Option, - base_mint: Option, - quote_mint: Option, - creator: Option, - token_base_program: Option, - token_quote_program: Option, - event_authority: Option, - program: Option, - max_base_amount: Option, - max_quote_amount: Option, - __remaining_accounts: Vec, -} - -impl ClaimCreatorTradingFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// The treasury token a account - #[inline(always)] - pub fn token_a_account(&mut self, token_a_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_account = Some(token_a_account); - self - } - - /// The treasury token b account - #[inline(always)] - pub fn token_b_account(&mut self, token_b_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Token a program - #[inline(always)] - pub fn token_base_program(&mut self, token_base_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_base_program = Some(token_base_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program(&mut self, token_quote_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn max_base_amount(&mut self, max_base_amount: u64) -> &mut Self { - self.max_base_amount = Some(max_base_amount); - self - } - - #[inline(always)] - pub fn max_quote_amount(&mut self, max_quote_amount: u64) -> &mut Self { - self.max_quote_amount = Some(max_quote_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimCreatorTradingFee { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - pool: self.pool.expect("pool is not set"), - token_a_account: self.token_a_account.expect("token_a_account is not set"), - token_b_account: self.token_b_account.expect("token_b_account is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - creator: self.creator.expect("creator is not set"), - token_base_program: self - .token_base_program - .expect("token_base_program is not set"), - token_quote_program: self - .token_quote_program - .expect("token_quote_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = ClaimCreatorTradingFeeInstructionArgs { - max_base_amount: self - .max_base_amount - .clone() - .expect("max_base_amount is not set"), - max_quote_amount: self - .max_quote_amount - .clone() - .expect("max_quote_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim_creator_trading_fee` CPI accounts. -pub struct ClaimCreatorTradingFeeCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_creator_trading_fee` CPI instruction. -pub struct ClaimCreatorTradingFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimCreatorTradingFeeInstructionArgs, -} - -impl<'a, 'b> ClaimCreatorTradingFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimCreatorTradingFeeCpiAccounts<'a, 'b>, - args: ClaimCreatorTradingFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - token_a_account: accounts.token_a_account, - token_b_account: accounts.token_b_account, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - creator: accounts.creator, - token_base_program: accounts.token_base_program, - token_quote_program: accounts.token_quote_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_base_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_quote_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ClaimCreatorTradingFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.token_a_account.clone()); - account_infos.push(self.token_b_account.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.token_base_program.clone()); - account_infos.push(self.token_quote_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimCreatorTradingFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[writable]` pool -/// 2. `[writable]` token_a_account -/// 3. `[writable]` token_b_account -/// 4. `[writable]` base_vault -/// 5. `[writable]` quote_vault -/// 6. `[]` base_mint -/// 7. `[]` quote_mint -/// 8. `[signer]` creator -/// 9. `[]` token_base_program -/// 10. `[]` token_quote_program -/// 11. `[]` event_authority -/// 12. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimCreatorTradingFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimCreatorTradingFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimCreatorTradingFeeCpiBuilderInstruction { - __program: program, - pool_authority: None, - pool: None, - token_a_account: None, - token_b_account: None, - base_vault: None, - quote_vault: None, - base_mint: None, - quote_mint: None, - creator: None, - token_base_program: None, - token_quote_program: None, - event_authority: None, - program: None, - max_base_amount: None, - max_quote_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// The treasury token a account - #[inline(always)] - pub fn token_a_account( - &mut self, - token_a_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_account = Some(token_a_account); - self - } - - /// The treasury token b account - #[inline(always)] - pub fn token_b_account( - &mut self, - token_b_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Token a program - #[inline(always)] - pub fn token_base_program( - &mut self, - token_base_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_base_program = Some(token_base_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program( - &mut self, - token_quote_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn max_base_amount(&mut self, max_base_amount: u64) -> &mut Self { - self.instruction.max_base_amount = Some(max_base_amount); - self - } - - #[inline(always)] - pub fn max_quote_amount(&mut self, max_quote_amount: u64) -> &mut Self { - self.instruction.max_quote_amount = Some(max_quote_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ClaimCreatorTradingFeeInstructionArgs { - max_base_amount: self - .instruction - .max_base_amount - .clone() - .expect("max_base_amount is not set"), - max_quote_amount: self - .instruction - .max_quote_amount - .clone() - .expect("max_quote_amount is not set"), - }; - let instruction = ClaimCreatorTradingFeeCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - token_a_account: self - .instruction - .token_a_account - .expect("token_a_account is not set"), - - token_b_account: self - .instruction - .token_b_account - .expect("token_b_account is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - token_base_program: self - .instruction - .token_base_program - .expect("token_base_program is not set"), - - token_quote_program: self - .instruction - .token_quote_program - .expect("token_quote_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimCreatorTradingFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_account: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - token_base_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - max_base_amount: Option, - max_quote_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/claim_protocol_fee.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/claim_protocol_fee.rs deleted file mode 100644 index a6ece7b2..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/claim_protocol_fee.rs +++ /dev/null @@ -1,859 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimProtocolFee { - pub pool_authority: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - /// The vault token account for input token - pub base_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub base_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub quote_mint: solana_pubkey::Pubkey, - /// The treasury token a account - pub token_base_account: solana_pubkey::Pubkey, - /// The treasury token b account - pub token_quote_account: solana_pubkey::Pubkey, - /// Claim fee operator - pub claim_fee_operator: solana_pubkey::Pubkey, - /// Operator - pub operator: solana_pubkey::Pubkey, - /// Token a program - pub token_base_program: solana_pubkey::Pubkey, - /// Token b program - pub token_quote_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimProtocolFee { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_base_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_quote_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.claim_fee_operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_base_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_quote_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClaimProtocolFeeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimProtocolFeeInstructionData { - discriminator: [u8; 8], -} - -impl ClaimProtocolFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [165, 228, 133, 48, 99, 249, 255, 33], - } - } -} - -impl Default for ClaimProtocolFeeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClaimProtocolFee`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 1. `[]` config -/// 2. `[writable]` pool -/// 3. `[writable]` base_vault -/// 4. `[writable]` quote_vault -/// 5. `[]` base_mint -/// 6. `[]` quote_mint -/// 7. `[writable]` token_base_account -/// 8. `[writable]` token_quote_account -/// 9. `[]` claim_fee_operator -/// 10. `[signer]` operator -/// 11. `[]` token_base_program -/// 12. `[]` token_quote_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimProtocolFeeBuilder { - pool_authority: Option, - config: Option, - pool: Option, - base_vault: Option, - quote_vault: Option, - base_mint: Option, - quote_mint: Option, - token_base_account: Option, - token_quote_account: Option, - claim_fee_operator: Option, - operator: Option, - token_base_program: Option, - token_quote_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl ClaimProtocolFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// The treasury token a account - #[inline(always)] - pub fn token_base_account(&mut self, token_base_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_base_account = Some(token_base_account); - self - } - - /// The treasury token b account - #[inline(always)] - pub fn token_quote_account(&mut self, token_quote_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_account = Some(token_quote_account); - self - } - - /// Claim fee operator - #[inline(always)] - pub fn claim_fee_operator(&mut self, claim_fee_operator: solana_pubkey::Pubkey) -> &mut Self { - self.claim_fee_operator = Some(claim_fee_operator); - self - } - - /// Operator - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - /// Token a program - #[inline(always)] - pub fn token_base_program(&mut self, token_base_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_base_program = Some(token_base_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program(&mut self, token_quote_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimProtocolFee { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - config: self.config.expect("config is not set"), - pool: self.pool.expect("pool is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - token_base_account: self - .token_base_account - .expect("token_base_account is not set"), - token_quote_account: self - .token_quote_account - .expect("token_quote_account is not set"), - claim_fee_operator: self - .claim_fee_operator - .expect("claim_fee_operator is not set"), - operator: self.operator.expect("operator is not set"), - token_base_program: self - .token_base_program - .expect("token_base_program is not set"), - token_quote_program: self - .token_quote_program - .expect("token_quote_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `claim_protocol_fee` CPI accounts. -pub struct ClaimProtocolFeeCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token a account - pub token_base_account: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token b account - pub token_quote_account: &'b solana_account_info::AccountInfo<'a>, - /// Claim fee operator - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - /// Operator - pub operator: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_protocol_fee` CPI instruction. -pub struct ClaimProtocolFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token a account - pub token_base_account: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token b account - pub token_quote_account: &'b solana_account_info::AccountInfo<'a>, - /// Claim fee operator - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - /// Operator - pub operator: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClaimProtocolFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimProtocolFeeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - config: accounts.config, - pool: accounts.pool, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - token_base_account: accounts.token_base_account, - token_quote_account: accounts.token_quote_account, - claim_fee_operator: accounts.claim_fee_operator, - operator: accounts.operator, - token_base_program: accounts.token_base_program, - token_quote_program: accounts.token_quote_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_base_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_quote_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.claim_fee_operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_base_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_quote_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClaimProtocolFeeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.token_base_account.clone()); - account_infos.push(self.token_quote_account.clone()); - account_infos.push(self.claim_fee_operator.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.token_base_program.clone()); - account_infos.push(self.token_quote_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimProtocolFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[]` config -/// 2. `[writable]` pool -/// 3. `[writable]` base_vault -/// 4. `[writable]` quote_vault -/// 5. `[]` base_mint -/// 6. `[]` quote_mint -/// 7. `[writable]` token_base_account -/// 8. `[writable]` token_quote_account -/// 9. `[]` claim_fee_operator -/// 10. `[signer]` operator -/// 11. `[]` token_base_program -/// 12. `[]` token_quote_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimProtocolFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimProtocolFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimProtocolFeeCpiBuilderInstruction { - __program: program, - pool_authority: None, - config: None, - pool: None, - base_vault: None, - quote_vault: None, - base_mint: None, - quote_mint: None, - token_base_account: None, - token_quote_account: None, - claim_fee_operator: None, - operator: None, - token_base_program: None, - token_quote_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// The treasury token a account - #[inline(always)] - pub fn token_base_account( - &mut self, - token_base_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_base_account = Some(token_base_account); - self - } - - /// The treasury token b account - #[inline(always)] - pub fn token_quote_account( - &mut self, - token_quote_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_account = Some(token_quote_account); - self - } - - /// Claim fee operator - #[inline(always)] - pub fn claim_fee_operator( - &mut self, - claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.claim_fee_operator = Some(claim_fee_operator); - self - } - - /// Operator - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - /// Token a program - #[inline(always)] - pub fn token_base_program( - &mut self, - token_base_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_base_program = Some(token_base_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program( - &mut self, - token_quote_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClaimProtocolFeeCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - token_base_account: self - .instruction - .token_base_account - .expect("token_base_account is not set"), - - token_quote_account: self - .instruction - .token_quote_account - .expect("token_quote_account is not set"), - - claim_fee_operator: self - .instruction - .claim_fee_operator - .expect("claim_fee_operator is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - token_base_program: self - .instruction - .token_base_program - .expect("token_base_program is not set"), - - token_quote_program: self - .instruction - .token_quote_program - .expect("token_quote_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimProtocolFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_base_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_account: Option<&'b solana_account_info::AccountInfo<'a>>, - claim_fee_operator: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - token_base_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/claim_trading_fee.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/claim_trading_fee.rs deleted file mode 100644 index 1c47afe2..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/claim_trading_fee.rs +++ /dev/null @@ -1,879 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimTradingFee { - pub pool_authority: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - /// The treasury token a account - pub token_a_account: solana_pubkey::Pubkey, - /// The treasury token b account - pub token_b_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub base_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of token a - pub base_mint: solana_pubkey::Pubkey, - /// The mint of token b - pub quote_mint: solana_pubkey::Pubkey, - - pub fee_claimer: solana_pubkey::Pubkey, - /// Token a program - pub token_base_program: solana_pubkey::Pubkey, - /// Token b program - pub token_quote_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimTradingFee { - pub fn instruction( - &self, - args: ClaimTradingFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimTradingFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_claimer, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_base_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_quote_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ClaimTradingFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimTradingFeeInstructionData { - discriminator: [u8; 8], -} - -impl ClaimTradingFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [8, 236, 89, 49, 152, 125, 177, 81], - } - } -} - -impl Default for ClaimTradingFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimTradingFeeInstructionArgs { - pub max_amount_a: u64, - pub max_amount_b: u64, -} - -/// Instruction builder for `ClaimTradingFee`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 1. `[]` config -/// 2. `[writable]` pool -/// 3. `[writable]` token_a_account -/// 4. `[writable]` token_b_account -/// 5. `[writable]` base_vault -/// 6. `[writable]` quote_vault -/// 7. `[]` base_mint -/// 8. `[]` quote_mint -/// 9. `[signer]` fee_claimer -/// 10. `[]` token_base_program -/// 11. `[]` token_quote_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimTradingFeeBuilder { - pool_authority: Option, - config: Option, - pool: Option, - token_a_account: Option, - token_b_account: Option, - base_vault: Option, - quote_vault: Option, - base_mint: Option, - quote_mint: Option, - fee_claimer: Option, - token_base_program: Option, - token_quote_program: Option, - event_authority: Option, - program: Option, - max_amount_a: Option, - max_amount_b: Option, - __remaining_accounts: Vec, -} - -impl ClaimTradingFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// The treasury token a account - #[inline(always)] - pub fn token_a_account(&mut self, token_a_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_account = Some(token_a_account); - self - } - - /// The treasury token b account - #[inline(always)] - pub fn token_b_account(&mut self, token_b_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn fee_claimer(&mut self, fee_claimer: solana_pubkey::Pubkey) -> &mut Self { - self.fee_claimer = Some(fee_claimer); - self - } - - /// Token a program - #[inline(always)] - pub fn token_base_program(&mut self, token_base_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_base_program = Some(token_base_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program(&mut self, token_quote_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn max_amount_a(&mut self, max_amount_a: u64) -> &mut Self { - self.max_amount_a = Some(max_amount_a); - self - } - - #[inline(always)] - pub fn max_amount_b(&mut self, max_amount_b: u64) -> &mut Self { - self.max_amount_b = Some(max_amount_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimTradingFee { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - config: self.config.expect("config is not set"), - pool: self.pool.expect("pool is not set"), - token_a_account: self.token_a_account.expect("token_a_account is not set"), - token_b_account: self.token_b_account.expect("token_b_account is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - fee_claimer: self.fee_claimer.expect("fee_claimer is not set"), - token_base_program: self - .token_base_program - .expect("token_base_program is not set"), - token_quote_program: self - .token_quote_program - .expect("token_quote_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = ClaimTradingFeeInstructionArgs { - max_amount_a: self.max_amount_a.clone().expect("max_amount_a is not set"), - max_amount_b: self.max_amount_b.clone().expect("max_amount_b is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim_trading_fee` CPI accounts. -pub struct ClaimTradingFeeCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub fee_claimer: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_trading_fee` CPI instruction. -pub struct ClaimTradingFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token a account - pub token_a_account: &'b solana_account_info::AccountInfo<'a>, - /// The treasury token b account - pub token_b_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token a - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token b - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub fee_claimer: &'b solana_account_info::AccountInfo<'a>, - /// Token a program - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimTradingFeeInstructionArgs, -} - -impl<'a, 'b> ClaimTradingFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimTradingFeeCpiAccounts<'a, 'b>, - args: ClaimTradingFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - config: accounts.config, - pool: accounts.pool, - token_a_account: accounts.token_a_account, - token_b_account: accounts.token_b_account, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - fee_claimer: accounts.fee_claimer, - token_base_program: accounts.token_base_program, - token_quote_program: accounts.token_quote_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_claimer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_base_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_quote_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ClaimTradingFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.token_a_account.clone()); - account_infos.push(self.token_b_account.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.fee_claimer.clone()); - account_infos.push(self.token_base_program.clone()); - account_infos.push(self.token_quote_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimTradingFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[]` config -/// 2. `[writable]` pool -/// 3. `[writable]` token_a_account -/// 4. `[writable]` token_b_account -/// 5. `[writable]` base_vault -/// 6. `[writable]` quote_vault -/// 7. `[]` base_mint -/// 8. `[]` quote_mint -/// 9. `[signer]` fee_claimer -/// 10. `[]` token_base_program -/// 11. `[]` token_quote_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimTradingFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimTradingFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimTradingFeeCpiBuilderInstruction { - __program: program, - pool_authority: None, - config: None, - pool: None, - token_a_account: None, - token_b_account: None, - base_vault: None, - quote_vault: None, - base_mint: None, - quote_mint: None, - fee_claimer: None, - token_base_program: None, - token_quote_program: None, - event_authority: None, - program: None, - max_amount_a: None, - max_amount_b: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// The treasury token a account - #[inline(always)] - pub fn token_a_account( - &mut self, - token_a_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_account = Some(token_a_account); - self - } - - /// The treasury token b account - #[inline(always)] - pub fn token_b_account( - &mut self, - token_b_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_account = Some(token_b_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of token a - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - /// The mint of token b - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn fee_claimer( - &mut self, - fee_claimer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_claimer = Some(fee_claimer); - self - } - - /// Token a program - #[inline(always)] - pub fn token_base_program( - &mut self, - token_base_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_base_program = Some(token_base_program); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program( - &mut self, - token_quote_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn max_amount_a(&mut self, max_amount_a: u64) -> &mut Self { - self.instruction.max_amount_a = Some(max_amount_a); - self - } - - #[inline(always)] - pub fn max_amount_b(&mut self, max_amount_b: u64) -> &mut Self { - self.instruction.max_amount_b = Some(max_amount_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ClaimTradingFeeInstructionArgs { - max_amount_a: self - .instruction - .max_amount_a - .clone() - .expect("max_amount_a is not set"), - max_amount_b: self - .instruction - .max_amount_b - .clone() - .expect("max_amount_b is not set"), - }; - let instruction = ClaimTradingFeeCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - token_a_account: self - .instruction - .token_a_account - .expect("token_a_account is not set"), - - token_b_account: self - .instruction - .token_b_account - .expect("token_b_account is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - fee_claimer: self - .instruction - .fee_claimer - .expect("fee_claimer is not set"), - - token_base_program: self - .instruction - .token_base_program - .expect("token_base_program is not set"), - - token_quote_program: self - .instruction - .token_quote_program - .expect("token_quote_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimTradingFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_account: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_claimer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_base_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - max_amount_a: Option, - max_amount_b: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/close_claim_fee_operator.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/close_claim_fee_operator.rs deleted file mode 100644 index 4926b62f..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/close_claim_fee_operator.rs +++ /dev/null @@ -1,440 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CloseClaimFeeOperator { - pub claim_fee_operator: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CloseClaimFeeOperator { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.claim_fee_operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CloseClaimFeeOperatorInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseClaimFeeOperatorInstructionData { - discriminator: [u8; 8], -} - -impl CloseClaimFeeOperatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [38, 134, 82, 216, 95, 124, 17, 99], - } - } -} - -impl Default for CloseClaimFeeOperatorInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CloseClaimFeeOperator`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[writable]` rent_receiver -/// 2. `[signer]` admin -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CloseClaimFeeOperatorBuilder { - claim_fee_operator: Option, - rent_receiver: Option, - admin: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CloseClaimFeeOperatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn claim_fee_operator(&mut self, claim_fee_operator: solana_pubkey::Pubkey) -> &mut Self { - self.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CloseClaimFeeOperator { - claim_fee_operator: self - .claim_fee_operator - .expect("claim_fee_operator is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - admin: self.admin.expect("admin is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_claim_fee_operator` CPI accounts. -pub struct CloseClaimFeeOperatorCpiAccounts<'a, 'b> { - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_claim_fee_operator` CPI instruction. -pub struct CloseClaimFeeOperatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CloseClaimFeeOperatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CloseClaimFeeOperatorCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - claim_fee_operator: accounts.claim_fee_operator, - rent_receiver: accounts.rent_receiver, - admin: accounts.admin, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.claim_fee_operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CloseClaimFeeOperatorInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.claim_fee_operator.clone()); - account_infos.push(self.rent_receiver.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CloseClaimFeeOperator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[writable]` rent_receiver -/// 2. `[signer]` admin -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct CloseClaimFeeOperatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CloseClaimFeeOperatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CloseClaimFeeOperatorCpiBuilderInstruction { - __program: program, - claim_fee_operator: None, - rent_receiver: None, - admin: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn claim_fee_operator( - &mut self, - claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CloseClaimFeeOperatorCpi { - __program: self.instruction.__program, - - claim_fee_operator: self - .instruction - .claim_fee_operator - .expect("claim_fee_operator is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CloseClaimFeeOperatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - claim_fee_operator: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_claim_fee_operator.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_claim_fee_operator.rs deleted file mode 100644 index d2ab269d..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_claim_fee_operator.rs +++ /dev/null @@ -1,474 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateClaimFeeOperator { - pub claim_fee_operator: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreateClaimFeeOperator { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.claim_fee_operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateClaimFeeOperatorInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateClaimFeeOperatorInstructionData { - discriminator: [u8; 8], -} - -impl CreateClaimFeeOperatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [169, 62, 207, 107, 58, 187, 162, 109], - } - } -} - -impl Default for CreateClaimFeeOperatorInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateClaimFeeOperator`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[]` operator -/// 2. `[writable, signer]` admin -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreateClaimFeeOperatorBuilder { - claim_fee_operator: Option, - operator: Option, - admin: Option, - system_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CreateClaimFeeOperatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn claim_fee_operator(&mut self, claim_fee_operator: solana_pubkey::Pubkey) -> &mut Self { - self.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateClaimFeeOperator { - claim_fee_operator: self - .claim_fee_operator - .expect("claim_fee_operator is not set"), - operator: self.operator.expect("operator is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_claim_fee_operator` CPI accounts. -pub struct CreateClaimFeeOperatorCpiAccounts<'a, 'b> { - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_claim_fee_operator` CPI instruction. -pub struct CreateClaimFeeOperatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateClaimFeeOperatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateClaimFeeOperatorCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - claim_fee_operator: accounts.claim_fee_operator, - operator: accounts.operator, - admin: accounts.admin, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.claim_fee_operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateClaimFeeOperatorInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.claim_fee_operator.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateClaimFeeOperator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[]` operator -/// 2. `[writable, signer]` admin -/// 3. `[]` system_program -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug)] -pub struct CreateClaimFeeOperatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateClaimFeeOperatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateClaimFeeOperatorCpiBuilderInstruction { - __program: program, - claim_fee_operator: None, - operator: None, - admin: None, - system_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn claim_fee_operator( - &mut self, - claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateClaimFeeOperatorCpi { - __program: self.instruction.__program, - - claim_fee_operator: self - .instruction - .claim_fee_operator - .expect("claim_fee_operator is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateClaimFeeOperatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - claim_fee_operator: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_config.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_config.rs deleted file mode 100644 index e07f0c81..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_config.rs +++ /dev/null @@ -1,1034 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{ - LiquidityDistributionParameters, LockedVestingParams, PoolFeeParameters, TokenSupplyParams, -}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateConfig { - pub config: solana_pubkey::Pubkey, - - pub fee_claimer: solana_pubkey::Pubkey, - - pub leftover_receiver: solana_pubkey::Pubkey, - /// quote mint - pub quote_mint: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreateConfig { - pub fn instruction( - &self, - args: CreateConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_claimer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.leftover_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigInstructionData { - discriminator: [u8; 8], -} - -impl CreateConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [201, 207, 243, 114, 75, 111, 47, 189], - } - } -} - -impl Default for CreateConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigInstructionArgs { - pub pool_fees: PoolFeeParameters, - pub collect_fee_mode: u8, - pub migration_option: u8, - pub activation_type: u8, - pub token_type: u8, - pub token_decimal: u8, - pub partner_lp_percentage: u8, - pub partner_locked_lp_percentage: u8, - pub creator_lp_percentage: u8, - pub creator_locked_lp_percentage: u8, - pub migration_quote_threshold: u64, - pub sqrt_start_price: u128, - pub locked_vesting: LockedVestingParams, - pub migration_fee_option: u8, - pub token_supply: Option, - pub creator_trading_fee_percentage: u8, - pub padding0: [u8; 7], - pub padding1: [u64; 7], - pub curve: Vec, -} - -/// Instruction builder for `CreateConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` config -/// 1. `[]` fee_claimer -/// 2. `[]` leftover_receiver -/// 3. `[]` quote_mint -/// 4. `[writable, signer]` payer -/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 6. `[]` event_authority -/// 7. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreateConfigBuilder { - config: Option, - fee_claimer: Option, - leftover_receiver: Option, - quote_mint: Option, - payer: Option, - system_program: Option, - event_authority: Option, - program: Option, - pool_fees: Option, - collect_fee_mode: Option, - migration_option: Option, - activation_type: Option, - token_type: Option, - token_decimal: Option, - partner_lp_percentage: Option, - partner_locked_lp_percentage: Option, - creator_lp_percentage: Option, - creator_locked_lp_percentage: Option, - migration_quote_threshold: Option, - sqrt_start_price: Option, - locked_vesting: Option, - migration_fee_option: Option, - token_supply: Option, - creator_trading_fee_percentage: Option, - padding0: Option<[u8; 7]>, - padding1: Option<[u64; 7]>, - curve: Option>, - __remaining_accounts: Vec, -} - -impl CreateConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn fee_claimer(&mut self, fee_claimer: solana_pubkey::Pubkey) -> &mut Self { - self.fee_claimer = Some(fee_claimer); - self - } - - #[inline(always)] - pub fn leftover_receiver(&mut self, leftover_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.leftover_receiver = Some(leftover_receiver); - self - } - - /// quote mint - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn pool_fees(&mut self, pool_fees: PoolFeeParameters) -> &mut Self { - self.pool_fees = Some(pool_fees); - self - } - - #[inline(always)] - pub fn collect_fee_mode(&mut self, collect_fee_mode: u8) -> &mut Self { - self.collect_fee_mode = Some(collect_fee_mode); - self - } - - #[inline(always)] - pub fn migration_option(&mut self, migration_option: u8) -> &mut Self { - self.migration_option = Some(migration_option); - self - } - - #[inline(always)] - pub fn activation_type(&mut self, activation_type: u8) -> &mut Self { - self.activation_type = Some(activation_type); - self - } - - #[inline(always)] - pub fn token_type(&mut self, token_type: u8) -> &mut Self { - self.token_type = Some(token_type); - self - } - - #[inline(always)] - pub fn token_decimal(&mut self, token_decimal: u8) -> &mut Self { - self.token_decimal = Some(token_decimal); - self - } - - #[inline(always)] - pub fn partner_lp_percentage(&mut self, partner_lp_percentage: u8) -> &mut Self { - self.partner_lp_percentage = Some(partner_lp_percentage); - self - } - - #[inline(always)] - pub fn partner_locked_lp_percentage(&mut self, partner_locked_lp_percentage: u8) -> &mut Self { - self.partner_locked_lp_percentage = Some(partner_locked_lp_percentage); - self - } - - #[inline(always)] - pub fn creator_lp_percentage(&mut self, creator_lp_percentage: u8) -> &mut Self { - self.creator_lp_percentage = Some(creator_lp_percentage); - self - } - - #[inline(always)] - pub fn creator_locked_lp_percentage(&mut self, creator_locked_lp_percentage: u8) -> &mut Self { - self.creator_locked_lp_percentage = Some(creator_locked_lp_percentage); - self - } - - #[inline(always)] - pub fn migration_quote_threshold(&mut self, migration_quote_threshold: u64) -> &mut Self { - self.migration_quote_threshold = Some(migration_quote_threshold); - self - } - - #[inline(always)] - pub fn sqrt_start_price(&mut self, sqrt_start_price: u128) -> &mut Self { - self.sqrt_start_price = Some(sqrt_start_price); - self - } - - #[inline(always)] - pub fn locked_vesting(&mut self, locked_vesting: LockedVestingParams) -> &mut Self { - self.locked_vesting = Some(locked_vesting); - self - } - - #[inline(always)] - pub fn migration_fee_option(&mut self, migration_fee_option: u8) -> &mut Self { - self.migration_fee_option = Some(migration_fee_option); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn token_supply(&mut self, token_supply: TokenSupplyParams) -> &mut Self { - self.token_supply = Some(token_supply); - self - } - - #[inline(always)] - pub fn creator_trading_fee_percentage( - &mut self, - creator_trading_fee_percentage: u8, - ) -> &mut Self { - self.creator_trading_fee_percentage = Some(creator_trading_fee_percentage); - self - } - - #[inline(always)] - pub fn padding0(&mut self, padding0: [u8; 7]) -> &mut Self { - self.padding0 = Some(padding0); - self - } - - #[inline(always)] - pub fn padding1(&mut self, padding1: [u64; 7]) -> &mut Self { - self.padding1 = Some(padding1); - self - } - - #[inline(always)] - pub fn curve(&mut self, curve: Vec) -> &mut Self { - self.curve = Some(curve); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateConfig { - config: self.config.expect("config is not set"), - fee_claimer: self.fee_claimer.expect("fee_claimer is not set"), - leftover_receiver: self - .leftover_receiver - .expect("leftover_receiver is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - payer: self.payer.expect("payer is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = CreateConfigInstructionArgs { - pool_fees: self.pool_fees.clone().expect("pool_fees is not set"), - collect_fee_mode: self - .collect_fee_mode - .clone() - .expect("collect_fee_mode is not set"), - migration_option: self - .migration_option - .clone() - .expect("migration_option is not set"), - activation_type: self - .activation_type - .clone() - .expect("activation_type is not set"), - token_type: self.token_type.clone().expect("token_type is not set"), - token_decimal: self - .token_decimal - .clone() - .expect("token_decimal is not set"), - partner_lp_percentage: self - .partner_lp_percentage - .clone() - .expect("partner_lp_percentage is not set"), - partner_locked_lp_percentage: self - .partner_locked_lp_percentage - .clone() - .expect("partner_locked_lp_percentage is not set"), - creator_lp_percentage: self - .creator_lp_percentage - .clone() - .expect("creator_lp_percentage is not set"), - creator_locked_lp_percentage: self - .creator_locked_lp_percentage - .clone() - .expect("creator_locked_lp_percentage is not set"), - migration_quote_threshold: self - .migration_quote_threshold - .clone() - .expect("migration_quote_threshold is not set"), - sqrt_start_price: self - .sqrt_start_price - .clone() - .expect("sqrt_start_price is not set"), - locked_vesting: self - .locked_vesting - .clone() - .expect("locked_vesting is not set"), - migration_fee_option: self - .migration_fee_option - .clone() - .expect("migration_fee_option is not set"), - token_supply: self.token_supply.clone(), - creator_trading_fee_percentage: self - .creator_trading_fee_percentage - .clone() - .expect("creator_trading_fee_percentage is not set"), - padding0: self.padding0.clone().expect("padding0 is not set"), - padding1: self.padding1.clone().expect("padding1 is not set"), - curve: self.curve.clone().expect("curve is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_config` CPI accounts. -pub struct CreateConfigCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_claimer: &'b solana_account_info::AccountInfo<'a>, - - pub leftover_receiver: &'b solana_account_info::AccountInfo<'a>, - /// quote mint - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_config` CPI instruction. -pub struct CreateConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_claimer: &'b solana_account_info::AccountInfo<'a>, - - pub leftover_receiver: &'b solana_account_info::AccountInfo<'a>, - /// quote mint - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateConfigInstructionArgs, -} - -impl<'a, 'b> CreateConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateConfigCpiAccounts<'a, 'b>, - args: CreateConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - fee_claimer: accounts.fee_claimer, - leftover_receiver: accounts.leftover_receiver, - quote_mint: accounts.quote_mint, - payer: accounts.payer, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.config.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_claimer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.leftover_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.fee_claimer.clone()); - account_infos.push(self.leftover_receiver.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` config -/// 1. `[]` fee_claimer -/// 2. `[]` leftover_receiver -/// 3. `[]` quote_mint -/// 4. `[writable, signer]` payer -/// 5. `[]` system_program -/// 6. `[]` event_authority -/// 7. `[]` program -#[derive(Clone, Debug)] -pub struct CreateConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateConfigCpiBuilderInstruction { - __program: program, - config: None, - fee_claimer: None, - leftover_receiver: None, - quote_mint: None, - payer: None, - system_program: None, - event_authority: None, - program: None, - pool_fees: None, - collect_fee_mode: None, - migration_option: None, - activation_type: None, - token_type: None, - token_decimal: None, - partner_lp_percentage: None, - partner_locked_lp_percentage: None, - creator_lp_percentage: None, - creator_locked_lp_percentage: None, - migration_quote_threshold: None, - sqrt_start_price: None, - locked_vesting: None, - migration_fee_option: None, - token_supply: None, - creator_trading_fee_percentage: None, - padding0: None, - padding1: None, - curve: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn fee_claimer( - &mut self, - fee_claimer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_claimer = Some(fee_claimer); - self - } - - #[inline(always)] - pub fn leftover_receiver( - &mut self, - leftover_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.leftover_receiver = Some(leftover_receiver); - self - } - - /// quote mint - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn pool_fees(&mut self, pool_fees: PoolFeeParameters) -> &mut Self { - self.instruction.pool_fees = Some(pool_fees); - self - } - - #[inline(always)] - pub fn collect_fee_mode(&mut self, collect_fee_mode: u8) -> &mut Self { - self.instruction.collect_fee_mode = Some(collect_fee_mode); - self - } - - #[inline(always)] - pub fn migration_option(&mut self, migration_option: u8) -> &mut Self { - self.instruction.migration_option = Some(migration_option); - self - } - - #[inline(always)] - pub fn activation_type(&mut self, activation_type: u8) -> &mut Self { - self.instruction.activation_type = Some(activation_type); - self - } - - #[inline(always)] - pub fn token_type(&mut self, token_type: u8) -> &mut Self { - self.instruction.token_type = Some(token_type); - self - } - - #[inline(always)] - pub fn token_decimal(&mut self, token_decimal: u8) -> &mut Self { - self.instruction.token_decimal = Some(token_decimal); - self - } - - #[inline(always)] - pub fn partner_lp_percentage(&mut self, partner_lp_percentage: u8) -> &mut Self { - self.instruction.partner_lp_percentage = Some(partner_lp_percentage); - self - } - - #[inline(always)] - pub fn partner_locked_lp_percentage(&mut self, partner_locked_lp_percentage: u8) -> &mut Self { - self.instruction.partner_locked_lp_percentage = Some(partner_locked_lp_percentage); - self - } - - #[inline(always)] - pub fn creator_lp_percentage(&mut self, creator_lp_percentage: u8) -> &mut Self { - self.instruction.creator_lp_percentage = Some(creator_lp_percentage); - self - } - - #[inline(always)] - pub fn creator_locked_lp_percentage(&mut self, creator_locked_lp_percentage: u8) -> &mut Self { - self.instruction.creator_locked_lp_percentage = Some(creator_locked_lp_percentage); - self - } - - #[inline(always)] - pub fn migration_quote_threshold(&mut self, migration_quote_threshold: u64) -> &mut Self { - self.instruction.migration_quote_threshold = Some(migration_quote_threshold); - self - } - - #[inline(always)] - pub fn sqrt_start_price(&mut self, sqrt_start_price: u128) -> &mut Self { - self.instruction.sqrt_start_price = Some(sqrt_start_price); - self - } - - #[inline(always)] - pub fn locked_vesting(&mut self, locked_vesting: LockedVestingParams) -> &mut Self { - self.instruction.locked_vesting = Some(locked_vesting); - self - } - - #[inline(always)] - pub fn migration_fee_option(&mut self, migration_fee_option: u8) -> &mut Self { - self.instruction.migration_fee_option = Some(migration_fee_option); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn token_supply(&mut self, token_supply: TokenSupplyParams) -> &mut Self { - self.instruction.token_supply = Some(token_supply); - self - } - - #[inline(always)] - pub fn creator_trading_fee_percentage( - &mut self, - creator_trading_fee_percentage: u8, - ) -> &mut Self { - self.instruction.creator_trading_fee_percentage = Some(creator_trading_fee_percentage); - self - } - - #[inline(always)] - pub fn padding0(&mut self, padding0: [u8; 7]) -> &mut Self { - self.instruction.padding0 = Some(padding0); - self - } - - #[inline(always)] - pub fn padding1(&mut self, padding1: [u64; 7]) -> &mut Self { - self.instruction.padding1 = Some(padding1); - self - } - - #[inline(always)] - pub fn curve(&mut self, curve: Vec) -> &mut Self { - self.instruction.curve = Some(curve); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateConfigInstructionArgs { - pool_fees: self - .instruction - .pool_fees - .clone() - .expect("pool_fees is not set"), - collect_fee_mode: self - .instruction - .collect_fee_mode - .clone() - .expect("collect_fee_mode is not set"), - migration_option: self - .instruction - .migration_option - .clone() - .expect("migration_option is not set"), - activation_type: self - .instruction - .activation_type - .clone() - .expect("activation_type is not set"), - token_type: self - .instruction - .token_type - .clone() - .expect("token_type is not set"), - token_decimal: self - .instruction - .token_decimal - .clone() - .expect("token_decimal is not set"), - partner_lp_percentage: self - .instruction - .partner_lp_percentage - .clone() - .expect("partner_lp_percentage is not set"), - partner_locked_lp_percentage: self - .instruction - .partner_locked_lp_percentage - .clone() - .expect("partner_locked_lp_percentage is not set"), - creator_lp_percentage: self - .instruction - .creator_lp_percentage - .clone() - .expect("creator_lp_percentage is not set"), - creator_locked_lp_percentage: self - .instruction - .creator_locked_lp_percentage - .clone() - .expect("creator_locked_lp_percentage is not set"), - migration_quote_threshold: self - .instruction - .migration_quote_threshold - .clone() - .expect("migration_quote_threshold is not set"), - sqrt_start_price: self - .instruction - .sqrt_start_price - .clone() - .expect("sqrt_start_price is not set"), - locked_vesting: self - .instruction - .locked_vesting - .clone() - .expect("locked_vesting is not set"), - migration_fee_option: self - .instruction - .migration_fee_option - .clone() - .expect("migration_fee_option is not set"), - token_supply: self.instruction.token_supply.clone(), - creator_trading_fee_percentage: self - .instruction - .creator_trading_fee_percentage - .clone() - .expect("creator_trading_fee_percentage is not set"), - padding0: self - .instruction - .padding0 - .clone() - .expect("padding0 is not set"), - padding1: self - .instruction - .padding1 - .clone() - .expect("padding1 is not set"), - curve: self.instruction.curve.clone().expect("curve is not set"), - }; - let instruction = CreateConfigCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - fee_claimer: self - .instruction - .fee_claimer - .expect("fee_claimer is not set"), - - leftover_receiver: self - .instruction - .leftover_receiver - .expect("leftover_receiver is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_claimer: Option<&'b solana_account_info::AccountInfo<'a>>, - leftover_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_fees: Option, - collect_fee_mode: Option, - migration_option: Option, - activation_type: Option, - token_type: Option, - token_decimal: Option, - partner_lp_percentage: Option, - partner_locked_lp_percentage: Option, - creator_lp_percentage: Option, - creator_locked_lp_percentage: Option, - migration_quote_threshold: Option, - sqrt_start_price: Option, - locked_vesting: Option, - migration_fee_option: Option, - token_supply: Option, - creator_trading_fee_percentage: Option, - padding0: Option<[u8; 7]>, - padding1: Option<[u64; 7]>, - curve: Option>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_locker.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_locker.rs deleted file mode 100644 index 480f5313..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_locker.rs +++ /dev/null @@ -1,794 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateLocker { - /// Virtual pool - pub virtual_pool: solana_pubkey::Pubkey, - /// Config - pub config: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - - pub base_vault: solana_pubkey::Pubkey, - - pub base_mint: solana_pubkey::Pubkey, - - pub base: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - - pub escrow: solana_pubkey::Pubkey, - - pub escrow_token: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub locker_program: solana_pubkey::Pubkey, - - pub locker_event_authority: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateLocker { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.base_mint, false)); - accounts.push(solana_instruction::AccountMeta::new(self.base, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.escrow, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.escrow_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.locker_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.locker_event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateLockerInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateLockerInstructionData { - discriminator: [u8; 8], -} - -impl CreateLockerInstructionData { - pub fn new() -> Self { - Self { - discriminator: [167, 90, 137, 154, 75, 47, 17, 84], - } - } -} - -impl Default for CreateLockerInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateLocker`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` virtual_pool -/// 1. `[]` config -/// 2. `[writable, optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 3. `[writable]` base_vault -/// 4. `[writable]` base_mint -/// 5. `[writable]` base -/// 6. `[]` creator -/// 7. `[writable]` escrow -/// 8. `[writable]` escrow_token -/// 9. `[writable, signer]` payer -/// 10. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 11. `[optional]` locker_program (default to `LocpQgucEQHbqNABEYvBvwoxCPsSbG91A1QaQhQQqjn`) -/// 12. `[]` locker_event_authority -/// 13. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateLockerBuilder { - virtual_pool: Option, - config: Option, - pool_authority: Option, - base_vault: Option, - base_mint: Option, - base: Option, - creator: Option, - escrow: Option, - escrow_token: Option, - payer: Option, - token_program: Option, - locker_program: Option, - locker_event_authority: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl CreateLockerBuilder { - pub fn new() -> Self { Self::default() } - - /// Virtual pool - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - /// Config - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn base(&mut self, base: solana_pubkey::Pubkey) -> &mut Self { - self.base = Some(base); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn escrow(&mut self, escrow: solana_pubkey::Pubkey) -> &mut Self { - self.escrow = Some(escrow); - self - } - - #[inline(always)] - pub fn escrow_token(&mut self, escrow_token: solana_pubkey::Pubkey) -> &mut Self { - self.escrow_token = Some(escrow_token); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'LocpQgucEQHbqNABEYvBvwoxCPsSbG91A1QaQhQQqjn']` - #[inline(always)] - pub fn locker_program(&mut self, locker_program: solana_pubkey::Pubkey) -> &mut Self { - self.locker_program = Some(locker_program); - self - } - - #[inline(always)] - pub fn locker_event_authority( - &mut self, - locker_event_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.locker_event_authority = Some(locker_event_authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateLocker { - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - config: self.config.expect("config is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - base_vault: self.base_vault.expect("base_vault is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - base: self.base.expect("base is not set"), - creator: self.creator.expect("creator is not set"), - escrow: self.escrow.expect("escrow is not set"), - escrow_token: self.escrow_token.expect("escrow_token is not set"), - payer: self.payer.expect("payer is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - locker_program: self.locker_program.unwrap_or(solana_pubkey::pubkey!( - "LocpQgucEQHbqNABEYvBvwoxCPsSbG91A1QaQhQQqjn" - )), - locker_event_authority: self - .locker_event_authority - .expect("locker_event_authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_locker` CPI accounts. -pub struct CreateLockerCpiAccounts<'a, 'b> { - /// Virtual pool - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// Config - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub base: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub escrow: &'b solana_account_info::AccountInfo<'a>, - - pub escrow_token: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub locker_program: &'b solana_account_info::AccountInfo<'a>, - - pub locker_event_authority: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_locker` CPI instruction. -pub struct CreateLockerCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Virtual pool - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// Config - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub base: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub escrow: &'b solana_account_info::AccountInfo<'a>, - - pub escrow_token: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub locker_program: &'b solana_account_info::AccountInfo<'a>, - - pub locker_event_authority: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateLockerCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateLockerCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - virtual_pool: accounts.virtual_pool, - config: accounts.config, - pool_authority: accounts.pool_authority, - base_vault: accounts.base_vault, - base_mint: accounts.base_mint, - base: accounts.base, - creator: accounts.creator, - escrow: accounts.escrow, - escrow_token: accounts.escrow_token, - payer: accounts.payer, - token_program: accounts.token_program, - locker_program: accounts.locker_program, - locker_event_authority: accounts.locker_event_authority, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.base.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.escrow.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.escrow_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.locker_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.locker_event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateLockerInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.base.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.escrow.clone()); - account_infos.push(self.escrow_token.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.locker_program.clone()); - account_infos.push(self.locker_event_authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateLocker` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` virtual_pool -/// 1. `[]` config -/// 2. `[writable]` pool_authority -/// 3. `[writable]` base_vault -/// 4. `[writable]` base_mint -/// 5. `[writable]` base -/// 6. `[]` creator -/// 7. `[writable]` escrow -/// 8. `[writable]` escrow_token -/// 9. `[writable, signer]` payer -/// 10. `[]` token_program -/// 11. `[]` locker_program -/// 12. `[]` locker_event_authority -/// 13. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateLockerCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateLockerCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateLockerCpiBuilderInstruction { - __program: program, - virtual_pool: None, - config: None, - pool_authority: None, - base_vault: None, - base_mint: None, - base: None, - creator: None, - escrow: None, - escrow_token: None, - payer: None, - token_program: None, - locker_program: None, - locker_event_authority: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Virtual pool - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - /// Config - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn base(&mut self, base: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base = Some(base); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn escrow(&mut self, escrow: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.escrow = Some(escrow); - self - } - - #[inline(always)] - pub fn escrow_token( - &mut self, - escrow_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.escrow_token = Some(escrow_token); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn locker_program( - &mut self, - locker_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.locker_program = Some(locker_program); - self - } - - #[inline(always)] - pub fn locker_event_authority( - &mut self, - locker_event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.locker_event_authority = Some(locker_event_authority); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateLockerCpi { - __program: self.instruction.__program, - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - config: self.instruction.config.expect("config is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - base: self.instruction.base.expect("base is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - escrow: self.instruction.escrow.expect("escrow is not set"), - - escrow_token: self - .instruction - .escrow_token - .expect("escrow_token is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - locker_program: self - .instruction - .locker_program - .expect("locker_program is not set"), - - locker_event_authority: self - .instruction - .locker_event_authority - .expect("locker_event_authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateLockerCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - base: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - escrow: Option<&'b solana_account_info::AccountInfo<'a>>, - escrow_token: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - locker_program: Option<&'b solana_account_info::AccountInfo<'a>>, - locker_event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_partner_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_partner_metadata.rs deleted file mode 100644 index 0ad9a46a..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_partner_metadata.rs +++ /dev/null @@ -1,590 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreatePartnerMetadata { - /// Partner metadata - pub partner_metadata: solana_pubkey::Pubkey, - /// Payer of the partner metadata. - pub payer: solana_pubkey::Pubkey, - /// Fee claimer for partner - pub fee_claimer: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreatePartnerMetadata { - pub fn instruction( - &self, - args: CreatePartnerMetadataInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreatePartnerMetadataInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.partner_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_claimer, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreatePartnerMetadataInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePartnerMetadataInstructionData { - discriminator: [u8; 8], -} - -impl CreatePartnerMetadataInstructionData { - pub fn new() -> Self { - Self { - discriminator: [192, 168, 234, 191, 188, 226, 227, 255], - } - } -} - -impl Default for CreatePartnerMetadataInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePartnerMetadataInstructionArgs { - pub padding: [u8; 96], - pub name: String, - pub website: String, - pub logo: String, -} - -/// Instruction builder for `CreatePartnerMetadata`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` partner_metadata -/// 1. `[writable, signer]` payer -/// 2. `[signer]` fee_claimer -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreatePartnerMetadataBuilder { - partner_metadata: Option, - payer: Option, - fee_claimer: Option, - system_program: Option, - event_authority: Option, - program: Option, - padding: Option<[u8; 96]>, - name: Option, - website: Option, - logo: Option, - __remaining_accounts: Vec, -} - -impl CreatePartnerMetadataBuilder { - pub fn new() -> Self { Self::default() } - - /// Partner metadata - #[inline(always)] - pub fn partner_metadata(&mut self, partner_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.partner_metadata = Some(partner_metadata); - self - } - - /// Payer of the partner metadata. - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// Fee claimer for partner - #[inline(always)] - pub fn fee_claimer(&mut self, fee_claimer: solana_pubkey::Pubkey) -> &mut Self { - self.fee_claimer = Some(fee_claimer); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 96]) -> &mut Self { - self.padding = Some(padding); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.name = Some(name); - self - } - - #[inline(always)] - pub fn website(&mut self, website: String) -> &mut Self { - self.website = Some(website); - self - } - - #[inline(always)] - pub fn logo(&mut self, logo: String) -> &mut Self { - self.logo = Some(logo); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreatePartnerMetadata { - partner_metadata: self.partner_metadata.expect("partner_metadata is not set"), - payer: self.payer.expect("payer is not set"), - fee_claimer: self.fee_claimer.expect("fee_claimer is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = CreatePartnerMetadataInstructionArgs { - padding: self.padding.clone().expect("padding is not set"), - name: self.name.clone().expect("name is not set"), - website: self.website.clone().expect("website is not set"), - logo: self.logo.clone().expect("logo is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_partner_metadata` CPI accounts. -pub struct CreatePartnerMetadataCpiAccounts<'a, 'b> { - /// Partner metadata - pub partner_metadata: &'b solana_account_info::AccountInfo<'a>, - /// Payer of the partner metadata. - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Fee claimer for partner - pub fee_claimer: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_partner_metadata` CPI instruction. -pub struct CreatePartnerMetadataCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Partner metadata - pub partner_metadata: &'b solana_account_info::AccountInfo<'a>, - /// Payer of the partner metadata. - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Fee claimer for partner - pub fee_claimer: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreatePartnerMetadataInstructionArgs, -} - -impl<'a, 'b> CreatePartnerMetadataCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreatePartnerMetadataCpiAccounts<'a, 'b>, - args: CreatePartnerMetadataInstructionArgs, - ) -> Self { - Self { - __program: program, - partner_metadata: accounts.partner_metadata, - payer: accounts.payer, - fee_claimer: accounts.fee_claimer, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.partner_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_claimer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreatePartnerMetadataInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.partner_metadata.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.fee_claimer.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreatePartnerMetadata` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` partner_metadata -/// 1. `[writable, signer]` payer -/// 2. `[signer]` fee_claimer -/// 3. `[]` system_program -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug)] -pub struct CreatePartnerMetadataCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreatePartnerMetadataCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreatePartnerMetadataCpiBuilderInstruction { - __program: program, - partner_metadata: None, - payer: None, - fee_claimer: None, - system_program: None, - event_authority: None, - program: None, - padding: None, - name: None, - website: None, - logo: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Partner metadata - #[inline(always)] - pub fn partner_metadata( - &mut self, - partner_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.partner_metadata = Some(partner_metadata); - self - } - - /// Payer of the partner metadata. - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Fee claimer for partner - #[inline(always)] - pub fn fee_claimer( - &mut self, - fee_claimer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_claimer = Some(fee_claimer); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 96]) -> &mut Self { - self.instruction.padding = Some(padding); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.instruction.name = Some(name); - self - } - - #[inline(always)] - pub fn website(&mut self, website: String) -> &mut Self { - self.instruction.website = Some(website); - self - } - - #[inline(always)] - pub fn logo(&mut self, logo: String) -> &mut Self { - self.instruction.logo = Some(logo); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreatePartnerMetadataInstructionArgs { - padding: self - .instruction - .padding - .clone() - .expect("padding is not set"), - name: self.instruction.name.clone().expect("name is not set"), - website: self - .instruction - .website - .clone() - .expect("website is not set"), - logo: self.instruction.logo.clone().expect("logo is not set"), - }; - let instruction = CreatePartnerMetadataCpi { - __program: self.instruction.__program, - - partner_metadata: self - .instruction - .partner_metadata - .expect("partner_metadata is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - fee_claimer: self - .instruction - .fee_claimer - .expect("fee_claimer is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreatePartnerMetadataCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - partner_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_claimer: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - padding: Option<[u8; 96]>, - name: Option, - website: Option, - logo: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_virtual_pool_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_virtual_pool_metadata.rs deleted file mode 100644 index 0977fe1e..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/create_virtual_pool_metadata.rs +++ /dev/null @@ -1,627 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateVirtualPoolMetadata { - pub virtual_pool: solana_pubkey::Pubkey, - /// Virtual pool metadata - pub virtual_pool_metadata: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - /// Payer of the virtual pool metadata. - pub payer: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreateVirtualPoolMetadata { - pub fn instruction( - &self, - args: CreateVirtualPoolMetadataInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateVirtualPoolMetadataInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtual_pool_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateVirtualPoolMetadataInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateVirtualPoolMetadataInstructionData { - discriminator: [u8; 8], -} - -impl CreateVirtualPoolMetadataInstructionData { - pub fn new() -> Self { - Self { - discriminator: [45, 97, 187, 103, 254, 109, 124, 134], - } - } -} - -impl Default for CreateVirtualPoolMetadataInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateVirtualPoolMetadataInstructionArgs { - pub padding: [u8; 96], - pub name: String, - pub website: String, - pub logo: String, -} - -/// Instruction builder for `CreateVirtualPoolMetadata`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` virtual_pool -/// 1. `[writable]` virtual_pool_metadata -/// 2. `[signer]` creator -/// 3. `[writable, signer]` payer -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 5. `[]` event_authority -/// 6. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreateVirtualPoolMetadataBuilder { - virtual_pool: Option, - virtual_pool_metadata: Option, - creator: Option, - payer: Option, - system_program: Option, - event_authority: Option, - program: Option, - padding: Option<[u8; 96]>, - name: Option, - website: Option, - logo: Option, - __remaining_accounts: Vec, -} - -impl CreateVirtualPoolMetadataBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - /// Virtual pool metadata - #[inline(always)] - pub fn virtual_pool_metadata( - &mut self, - virtual_pool_metadata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.virtual_pool_metadata = Some(virtual_pool_metadata); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Payer of the virtual pool metadata. - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 96]) -> &mut Self { - self.padding = Some(padding); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.name = Some(name); - self - } - - #[inline(always)] - pub fn website(&mut self, website: String) -> &mut Self { - self.website = Some(website); - self - } - - #[inline(always)] - pub fn logo(&mut self, logo: String) -> &mut Self { - self.logo = Some(logo); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateVirtualPoolMetadata { - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - virtual_pool_metadata: self - .virtual_pool_metadata - .expect("virtual_pool_metadata is not set"), - creator: self.creator.expect("creator is not set"), - payer: self.payer.expect("payer is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = CreateVirtualPoolMetadataInstructionArgs { - padding: self.padding.clone().expect("padding is not set"), - name: self.name.clone().expect("name is not set"), - website: self.website.clone().expect("website is not set"), - logo: self.logo.clone().expect("logo is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_virtual_pool_metadata` CPI accounts. -pub struct CreateVirtualPoolMetadataCpiAccounts<'a, 'b> { - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// Virtual pool metadata - pub virtual_pool_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Payer of the virtual pool metadata. - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_virtual_pool_metadata` CPI instruction. -pub struct CreateVirtualPoolMetadataCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// Virtual pool metadata - pub virtual_pool_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Payer of the virtual pool metadata. - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateVirtualPoolMetadataInstructionArgs, -} - -impl<'a, 'b> CreateVirtualPoolMetadataCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateVirtualPoolMetadataCpiAccounts<'a, 'b>, - args: CreateVirtualPoolMetadataInstructionArgs, - ) -> Self { - Self { - __program: program, - virtual_pool: accounts.virtual_pool, - virtual_pool_metadata: accounts.virtual_pool_metadata, - creator: accounts.creator, - payer: accounts.payer, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtual_pool_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateVirtualPoolMetadataInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.virtual_pool_metadata.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateVirtualPoolMetadata` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` virtual_pool -/// 1. `[writable]` virtual_pool_metadata -/// 2. `[signer]` creator -/// 3. `[writable, signer]` payer -/// 4. `[]` system_program -/// 5. `[]` event_authority -/// 6. `[]` program -#[derive(Clone, Debug)] -pub struct CreateVirtualPoolMetadataCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateVirtualPoolMetadataCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateVirtualPoolMetadataCpiBuilderInstruction { - __program: program, - virtual_pool: None, - virtual_pool_metadata: None, - creator: None, - payer: None, - system_program: None, - event_authority: None, - program: None, - padding: None, - name: None, - website: None, - logo: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - /// Virtual pool metadata - #[inline(always)] - pub fn virtual_pool_metadata( - &mut self, - virtual_pool_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool_metadata = Some(virtual_pool_metadata); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Payer of the virtual pool metadata. - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 96]) -> &mut Self { - self.instruction.padding = Some(padding); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.instruction.name = Some(name); - self - } - - #[inline(always)] - pub fn website(&mut self, website: String) -> &mut Self { - self.instruction.website = Some(website); - self - } - - #[inline(always)] - pub fn logo(&mut self, logo: String) -> &mut Self { - self.instruction.logo = Some(logo); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateVirtualPoolMetadataInstructionArgs { - padding: self - .instruction - .padding - .clone() - .expect("padding is not set"), - name: self.instruction.name.clone().expect("name is not set"), - website: self - .instruction - .website - .clone() - .expect("website is not set"), - logo: self.instruction.logo.clone().expect("logo is not set"), - }; - let instruction = CreateVirtualPoolMetadataCpi { - __program: self.instruction.__program, - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - virtual_pool_metadata: self - .instruction - .virtual_pool_metadata - .expect("virtual_pool_metadata is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateVirtualPoolMetadataCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - virtual_pool_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - padding: Option<[u8; 96]>, - name: Option, - website: Option, - logo: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/creator_withdraw_surplus.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/creator_withdraw_surplus.rs deleted file mode 100644 index 1d056a75..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/creator_withdraw_surplus.rs +++ /dev/null @@ -1,655 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreatorWithdrawSurplus { - pub pool_authority: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub virtual_pool: solana_pubkey::Pubkey, - /// The receiver token account - pub token_quote_account: solana_pubkey::Pubkey, - /// The vault token account for output token - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of quote token - pub quote_mint: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - /// Token b program - pub token_quote_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreatorWithdrawSurplus { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_quote_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_quote_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreatorWithdrawSurplusInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatorWithdrawSurplusInstructionData { - discriminator: [u8; 8], -} - -impl CreatorWithdrawSurplusInstructionData { - pub fn new() -> Self { - Self { - discriminator: [165, 3, 137, 7, 28, 134, 76, 80], - } - } -} - -impl Default for CreatorWithdrawSurplusInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreatorWithdrawSurplus`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 1. `[]` config -/// 2. `[writable]` virtual_pool -/// 3. `[writable]` token_quote_account -/// 4. `[writable]` quote_vault -/// 5. `[]` quote_mint -/// 6. `[signer]` creator -/// 7. `[]` token_quote_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreatorWithdrawSurplusBuilder { - pool_authority: Option, - config: Option, - virtual_pool: Option, - token_quote_account: Option, - quote_vault: Option, - quote_mint: Option, - creator: Option, - token_quote_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CreatorWithdrawSurplusBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - /// The receiver token account - #[inline(always)] - pub fn token_quote_account(&mut self, token_quote_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_account = Some(token_quote_account); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of quote token - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program(&mut self, token_quote_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreatorWithdrawSurplus { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - config: self.config.expect("config is not set"), - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - token_quote_account: self - .token_quote_account - .expect("token_quote_account is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - creator: self.creator.expect("creator is not set"), - token_quote_program: self - .token_quote_program - .expect("token_quote_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `creator_withdraw_surplus` CPI accounts. -pub struct CreatorWithdrawSurplusCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// The receiver token account - pub token_quote_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `creator_withdraw_surplus` CPI instruction. -pub struct CreatorWithdrawSurplusCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// The receiver token account - pub token_quote_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreatorWithdrawSurplusCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreatorWithdrawSurplusCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - config: accounts.config, - virtual_pool: accounts.virtual_pool, - token_quote_account: accounts.token_quote_account, - quote_vault: accounts.quote_vault, - quote_mint: accounts.quote_mint, - creator: accounts.creator, - token_quote_program: accounts.token_quote_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_quote_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_quote_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreatorWithdrawSurplusInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.token_quote_account.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.token_quote_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreatorWithdrawSurplus` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[]` config -/// 2. `[writable]` virtual_pool -/// 3. `[writable]` token_quote_account -/// 4. `[writable]` quote_vault -/// 5. `[]` quote_mint -/// 6. `[signer]` creator -/// 7. `[]` token_quote_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct CreatorWithdrawSurplusCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreatorWithdrawSurplusCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreatorWithdrawSurplusCpiBuilderInstruction { - __program: program, - pool_authority: None, - config: None, - virtual_pool: None, - token_quote_account: None, - quote_vault: None, - quote_mint: None, - creator: None, - token_quote_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - /// The receiver token account - #[inline(always)] - pub fn token_quote_account( - &mut self, - token_quote_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_account = Some(token_quote_account); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of quote token - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program( - &mut self, - token_quote_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreatorWithdrawSurplusCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - token_quote_account: self - .instruction - .token_quote_account - .expect("token_quote_account is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - token_quote_program: self - .instruction - .token_quote_program - .expect("token_quote_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreatorWithdrawSurplusCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_account: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/initialize_virtual_pool_with_spl_token.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/initialize_virtual_pool_with_spl_token.rs deleted file mode 100644 index 279348f2..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/initialize_virtual_pool_with_spl_token.rs +++ /dev/null @@ -1,925 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::InitializePoolParameters; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeVirtualPoolWithSplToken { - /// Which config the pool belongs to. - pub config: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - - pub base_mint: solana_pubkey::Pubkey, - - pub quote_mint: solana_pubkey::Pubkey, - /// Initialize an account to store the pool state - pub pool: solana_pubkey::Pubkey, - /// Token a vault for the pool - pub base_vault: solana_pubkey::Pubkey, - /// Token b vault for the pool - pub quote_vault: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - /// Address paying to create the pool. Can be anyone - pub payer: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_quote_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeVirtualPoolWithSplToken { - pub fn instruction( - &self, - args: InitializeVirtualPoolWithSplTokenInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeVirtualPoolWithSplTokenInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_mint, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_quote_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = - borsh::to_vec(&InitializeVirtualPoolWithSplTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeVirtualPoolWithSplTokenInstructionData { - discriminator: [u8; 8], -} - -impl InitializeVirtualPoolWithSplTokenInstructionData { - pub fn new() -> Self { - Self { - discriminator: [140, 85, 215, 176, 102, 54, 104, 79], - } - } -} - -impl Default for InitializeVirtualPoolWithSplTokenInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeVirtualPoolWithSplTokenInstructionArgs { - pub params: InitializePoolParameters, -} - -/// Instruction builder for `InitializeVirtualPoolWithSplToken`. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 2. `[signer]` creator -/// 3. `[writable, signer]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` pool -/// 6. `[writable]` base_vault -/// 7. `[writable]` quote_vault -/// 8. `[writable]` mint_metadata -/// 9. `[optional]` metadata_program (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -/// 10. `[writable, signer]` payer -/// 11. `[]` token_quote_program -/// 12. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 13. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeVirtualPoolWithSplTokenBuilder { - config: Option, - pool_authority: Option, - creator: Option, - base_mint: Option, - quote_mint: Option, - pool: Option, - base_vault: Option, - quote_vault: Option, - mint_metadata: Option, - metadata_program: Option, - payer: Option, - token_quote_program: Option, - token_program: Option, - system_program: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl InitializeVirtualPoolWithSplTokenBuilder { - pub fn new() -> Self { Self::default() } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// Initialize an account to store the pool state - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// Token a vault for the pool - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// Token b vault for the pool - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_quote_program(&mut self, token_quote_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_program = Some(token_quote_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: InitializePoolParameters) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeVirtualPoolWithSplToken { - config: self.config.expect("config is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - creator: self.creator.expect("creator is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - pool: self.pool.expect("pool is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.unwrap_or(solana_pubkey::pubkey!( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - )), - payer: self.payer.expect("payer is not set"), - token_quote_program: self - .token_quote_program - .expect("token_quote_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeVirtualPoolWithSplTokenInstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_virtual_pool_with_spl_token` CPI accounts. -pub struct InitializeVirtualPoolWithSplTokenCpiAccounts<'a, 'b> { - /// Which config the pool belongs to. - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store the pool state - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Token a vault for the pool - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token b vault for the pool - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_virtual_pool_with_spl_token` CPI instruction. -pub struct InitializeVirtualPoolWithSplTokenCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store the pool state - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Token a vault for the pool - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token b vault for the pool - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeVirtualPoolWithSplTokenInstructionArgs, -} - -impl<'a, 'b> InitializeVirtualPoolWithSplTokenCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeVirtualPoolWithSplTokenCpiAccounts<'a, 'b>, - args: InitializeVirtualPoolWithSplTokenInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - pool_authority: accounts.pool_authority, - creator: accounts.creator, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - pool: accounts.pool, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - payer: accounts.payer, - token_quote_program: accounts.token_quote_program, - token_program: accounts.token_program, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_quote_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = - borsh::to_vec(&InitializeVirtualPoolWithSplTokenInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_quote_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeVirtualPoolWithSplToken` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[]` pool_authority -/// 2. `[signer]` creator -/// 3. `[writable, signer]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` pool -/// 6. `[writable]` base_vault -/// 7. `[writable]` quote_vault -/// 8. `[writable]` mint_metadata -/// 9. `[]` metadata_program -/// 10. `[writable, signer]` payer -/// 11. `[]` token_quote_program -/// 12. `[]` token_program -/// 13. `[]` system_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeVirtualPoolWithSplTokenCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeVirtualPoolWithSplTokenCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeVirtualPoolWithSplTokenCpiBuilderInstruction { - __program: program, - config: None, - pool_authority: None, - creator: None, - base_mint: None, - quote_mint: None, - pool: None, - base_vault: None, - quote_vault: None, - mint_metadata: None, - metadata_program: None, - payer: None, - token_quote_program: None, - token_program: None, - system_program: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// Initialize an account to store the pool state - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// Token a vault for the pool - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// Token b vault for the pool - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_quote_program( - &mut self, - token_quote_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: InitializePoolParameters) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeVirtualPoolWithSplTokenInstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = InitializeVirtualPoolWithSplTokenCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_quote_program: self - .instruction - .token_quote_program - .expect("token_quote_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeVirtualPoolWithSplTokenCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/initialize_virtual_pool_with_token2022.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/initialize_virtual_pool_with_token2022.rs deleted file mode 100644 index 2ac48396..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/initialize_virtual_pool_with_token2022.rs +++ /dev/null @@ -1,840 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::InitializePoolParameters; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeVirtualPoolWithToken2022 { - /// Which config the pool belongs to. - pub config: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - /// Unique token mint address, initialize in contract - pub base_mint: solana_pubkey::Pubkey, - - pub quote_mint: solana_pubkey::Pubkey, - /// Initialize an account to store the pool state - pub pool: solana_pubkey::Pubkey, - - pub base_vault: solana_pubkey::Pubkey, - /// Token quote vault for the pool - pub quote_vault: solana_pubkey::Pubkey, - /// Address paying to create the pool. Can be anyone - pub payer: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_quote_program: solana_pubkey::Pubkey, - /// token program for base mint - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeVirtualPoolWithToken2022 { - pub fn instruction( - &self, - args: InitializeVirtualPoolWithToken2022InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeVirtualPoolWithToken2022InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_mint, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_quote_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = - borsh::to_vec(&InitializeVirtualPoolWithToken2022InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeVirtualPoolWithToken2022InstructionData { - discriminator: [u8; 8], -} - -impl InitializeVirtualPoolWithToken2022InstructionData { - pub fn new() -> Self { - Self { - discriminator: [169, 118, 51, 78, 145, 110, 220, 155], - } - } -} - -impl Default for InitializeVirtualPoolWithToken2022InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeVirtualPoolWithToken2022InstructionArgs { - pub params: InitializePoolParameters, -} - -/// Instruction builder for `InitializeVirtualPoolWithToken2022`. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 2. `[signer]` creator -/// 3. `[writable, signer]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` pool -/// 6. `[writable]` base_vault -/// 7. `[writable]` quote_vault -/// 8. `[writable, signer]` payer -/// 9. `[]` token_quote_program -/// 10. `[optional]` token_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 11. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeVirtualPoolWithToken2022Builder { - config: Option, - pool_authority: Option, - creator: Option, - base_mint: Option, - quote_mint: Option, - pool: Option, - base_vault: Option, - quote_vault: Option, - payer: Option, - token_quote_program: Option, - token_program: Option, - system_program: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl InitializeVirtualPoolWithToken2022Builder { - pub fn new() -> Self { Self::default() } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Unique token mint address, initialize in contract - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// Initialize an account to store the pool state - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// Token quote vault for the pool - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_quote_program(&mut self, token_quote_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_program = Some(token_quote_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// token program for base mint - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: InitializePoolParameters) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeVirtualPoolWithToken2022 { - config: self.config.expect("config is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - creator: self.creator.expect("creator is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - pool: self.pool.expect("pool is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - payer: self.payer.expect("payer is not set"), - token_quote_program: self - .token_quote_program - .expect("token_quote_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeVirtualPoolWithToken2022InstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_virtual_pool_with_token2022` CPI accounts. -pub struct InitializeVirtualPoolWithToken2022CpiAccounts<'a, 'b> { - /// Which config the pool belongs to. - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Unique token mint address, initialize in contract - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store the pool state - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token quote vault for the pool - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - /// token program for base mint - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_virtual_pool_with_token2022` CPI instruction. -pub struct InitializeVirtualPoolWithToken2022Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Unique token mint address, initialize in contract - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store the pool state - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token quote vault for the pool - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - /// token program for base mint - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeVirtualPoolWithToken2022InstructionArgs, -} - -impl<'a, 'b> InitializeVirtualPoolWithToken2022Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeVirtualPoolWithToken2022CpiAccounts<'a, 'b>, - args: InitializeVirtualPoolWithToken2022InstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - pool_authority: accounts.pool_authority, - creator: accounts.creator, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - pool: accounts.pool, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - payer: accounts.payer, - token_quote_program: accounts.token_quote_program, - token_program: accounts.token_program, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_quote_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = - borsh::to_vec(&InitializeVirtualPoolWithToken2022InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_quote_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeVirtualPoolWithToken2022` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[]` pool_authority -/// 2. `[signer]` creator -/// 3. `[writable, signer]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` pool -/// 6. `[writable]` base_vault -/// 7. `[writable]` quote_vault -/// 8. `[writable, signer]` payer -/// 9. `[]` token_quote_program -/// 10. `[]` token_program -/// 11. `[]` system_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeVirtualPoolWithToken2022CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeVirtualPoolWithToken2022CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeVirtualPoolWithToken2022CpiBuilderInstruction { - __program: program, - config: None, - pool_authority: None, - creator: None, - base_mint: None, - quote_mint: None, - pool: None, - base_vault: None, - quote_vault: None, - payer: None, - token_quote_program: None, - token_program: None, - system_program: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Unique token mint address, initialize in contract - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// Initialize an account to store the pool state - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// Token quote vault for the pool - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_quote_program( - &mut self, - token_quote_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_program = Some(token_quote_program); - self - } - - /// token program for base mint - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: InitializePoolParameters) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeVirtualPoolWithToken2022InstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = InitializeVirtualPoolWithToken2022Cpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_quote_program: self - .instruction - .token_quote_program - .expect("token_quote_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeVirtualPoolWithToken2022CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migrate_meteora_damm.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/migrate_meteora_damm.rs deleted file mode 100644 index 690fc57f..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migrate_meteora_damm.rs +++ /dev/null @@ -1,1503 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MigrateMeteoraDamm { - /// virtual pool - pub virtual_pool: solana_pubkey::Pubkey, - - pub migration_metadata: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - /// pool config - pub damm_config: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub token_a_mint: solana_pubkey::Pubkey, - - pub token_b_mint: solana_pubkey::Pubkey, - - pub a_vault: solana_pubkey::Pubkey, - - pub b_vault: solana_pubkey::Pubkey, - - pub a_token_vault: solana_pubkey::Pubkey, - - pub b_token_vault: solana_pubkey::Pubkey, - - pub a_vault_lp_mint: solana_pubkey::Pubkey, - - pub b_vault_lp_mint: solana_pubkey::Pubkey, - - pub a_vault_lp: solana_pubkey::Pubkey, - - pub b_vault_lp: solana_pubkey::Pubkey, - - pub base_vault: solana_pubkey::Pubkey, - - pub quote_vault: solana_pubkey::Pubkey, - - pub virtual_pool_lp: solana_pubkey::Pubkey, - - pub protocol_token_a_fee: solana_pubkey::Pubkey, - - pub protocol_token_b_fee: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - - pub amm_program: solana_pubkey::Pubkey, - - pub vault_program: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, -} - -impl MigrateMeteoraDamm { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(31 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.migration_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.damm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtual_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_a_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_b_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigrateMeteoraDammInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateMeteoraDammInstructionData { - discriminator: [u8; 8], -} - -impl MigrateMeteoraDammInstructionData { - pub fn new() -> Self { - Self { - discriminator: [27, 1, 48, 22, 180, 63, 118, 217], - } - } -} - -impl Default for MigrateMeteoraDammInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigrateMeteoraDamm`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` virtual_pool -/// 1. `[writable]` migration_metadata -/// 2. `[]` config -/// 3. `[writable, optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 4. `[writable]` pool -/// 5. `[]` damm_config -/// 6. `[writable]` lp_mint -/// 7. `[writable]` token_a_mint -/// 8. `[]` token_b_mint -/// 9. `[writable]` a_vault -/// 10. `[writable]` b_vault -/// 11. `[writable]` a_token_vault -/// 12. `[writable]` b_token_vault -/// 13. `[writable]` a_vault_lp_mint -/// 14. `[writable]` b_vault_lp_mint -/// 15. `[writable]` a_vault_lp -/// 16. `[writable]` b_vault_lp -/// 17. `[writable]` base_vault -/// 18. `[writable]` quote_vault -/// 19. `[writable]` virtual_pool_lp -/// 20. `[writable]` protocol_token_a_fee -/// 21. `[writable]` protocol_token_b_fee -/// 22. `[writable, signer]` payer -/// 23. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 24. `[writable]` mint_metadata -/// 25. `[]` metadata_program -/// 26. `[optional]` amm_program (default to `Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB`) -/// 27. `[]` vault_program -/// 28. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 29. `[]` associated_token_program -/// 30. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct MigrateMeteoraDammBuilder { - virtual_pool: Option, - migration_metadata: Option, - config: Option, - pool_authority: Option, - pool: Option, - damm_config: Option, - lp_mint: Option, - token_a_mint: Option, - token_b_mint: Option, - a_vault: Option, - b_vault: Option, - a_token_vault: Option, - b_token_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_vault_lp: Option, - b_vault_lp: Option, - base_vault: Option, - quote_vault: Option, - virtual_pool_lp: Option, - protocol_token_a_fee: Option, - protocol_token_b_fee: Option, - payer: Option, - rent: Option, - mint_metadata: Option, - metadata_program: Option, - amm_program: Option, - vault_program: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl MigrateMeteoraDammBuilder { - pub fn new() -> Self { Self::default() } - - /// virtual pool - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - #[inline(always)] - pub fn migration_metadata(&mut self, migration_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.migration_metadata = Some(migration_metadata); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// pool config - #[inline(always)] - pub fn damm_config(&mut self, damm_config: solana_pubkey::Pubkey) -> &mut Self { - self.damm_config = Some(damm_config); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - #[inline(always)] - pub fn virtual_pool_lp(&mut self, virtual_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool_lp = Some(virtual_pool_lp); - self - } - - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// `[optional account, default to 'Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB']` - #[inline(always)] - pub fn amm_program(&mut self, amm_program: solana_pubkey::Pubkey) -> &mut Self { - self.amm_program = Some(amm_program); - self - } - - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrateMeteoraDamm { - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - migration_metadata: self - .migration_metadata - .expect("migration_metadata is not set"), - config: self.config.expect("config is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - pool: self.pool.expect("pool is not set"), - damm_config: self.damm_config.expect("damm_config is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - virtual_pool_lp: self.virtual_pool_lp.expect("virtual_pool_lp is not set"), - protocol_token_a_fee: self - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - protocol_token_b_fee: self - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - payer: self.payer.expect("payer is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - amm_program: self.amm_program.unwrap_or(solana_pubkey::pubkey!( - "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" - )), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migrate_meteora_damm` CPI accounts. -pub struct MigrateMeteoraDammCpiAccounts<'a, 'b> { - /// virtual pool - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// pool config - pub damm_config: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool_lp: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migrate_meteora_damm` CPI instruction. -pub struct MigrateMeteoraDammCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// virtual pool - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// pool config - pub damm_config: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool_lp: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrateMeteoraDammCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrateMeteoraDammCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - virtual_pool: accounts.virtual_pool, - migration_metadata: accounts.migration_metadata, - config: accounts.config, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - damm_config: accounts.damm_config, - lp_mint: accounts.lp_mint, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - virtual_pool_lp: accounts.virtual_pool_lp, - protocol_token_a_fee: accounts.protocol_token_a_fee, - protocol_token_b_fee: accounts.protocol_token_b_fee, - payer: accounts.payer, - rent: accounts.rent, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - amm_program: accounts.amm_program, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(31 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.migration_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.damm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtual_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_a_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_b_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigrateMeteoraDammInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(32 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.migration_metadata.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.damm_config.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.virtual_pool_lp.clone()); - account_infos.push(self.protocol_token_a_fee.clone()); - account_infos.push(self.protocol_token_b_fee.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.amm_program.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrateMeteoraDamm` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` virtual_pool -/// 1. `[writable]` migration_metadata -/// 2. `[]` config -/// 3. `[writable]` pool_authority -/// 4. `[writable]` pool -/// 5. `[]` damm_config -/// 6. `[writable]` lp_mint -/// 7. `[writable]` token_a_mint -/// 8. `[]` token_b_mint -/// 9. `[writable]` a_vault -/// 10. `[writable]` b_vault -/// 11. `[writable]` a_token_vault -/// 12. `[writable]` b_token_vault -/// 13. `[writable]` a_vault_lp_mint -/// 14. `[writable]` b_vault_lp_mint -/// 15. `[writable]` a_vault_lp -/// 16. `[writable]` b_vault_lp -/// 17. `[writable]` base_vault -/// 18. `[writable]` quote_vault -/// 19. `[writable]` virtual_pool_lp -/// 20. `[writable]` protocol_token_a_fee -/// 21. `[writable]` protocol_token_b_fee -/// 22. `[writable, signer]` payer -/// 23. `[]` rent -/// 24. `[writable]` mint_metadata -/// 25. `[]` metadata_program -/// 26. `[]` amm_program -/// 27. `[]` vault_program -/// 28. `[]` token_program -/// 29. `[]` associated_token_program -/// 30. `[]` system_program -#[derive(Clone, Debug)] -pub struct MigrateMeteoraDammCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrateMeteoraDammCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrateMeteoraDammCpiBuilderInstruction { - __program: program, - virtual_pool: None, - migration_metadata: None, - config: None, - pool_authority: None, - pool: None, - damm_config: None, - lp_mint: None, - token_a_mint: None, - token_b_mint: None, - a_vault: None, - b_vault: None, - a_token_vault: None, - b_token_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_vault_lp: None, - b_vault_lp: None, - base_vault: None, - quote_vault: None, - virtual_pool_lp: None, - protocol_token_a_fee: None, - protocol_token_b_fee: None, - payer: None, - rent: None, - mint_metadata: None, - metadata_program: None, - amm_program: None, - vault_program: None, - token_program: None, - associated_token_program: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// virtual pool - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - #[inline(always)] - pub fn migration_metadata( - &mut self, - migration_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migration_metadata = Some(migration_metadata); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// pool config - #[inline(always)] - pub fn damm_config( - &mut self, - damm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.damm_config = Some(damm_config); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - #[inline(always)] - pub fn virtual_pool_lp( - &mut self, - virtual_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool_lp = Some(virtual_pool_lp); - self - } - - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - #[inline(always)] - pub fn amm_program( - &mut self, - amm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_program = Some(amm_program); - self - } - - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrateMeteoraDammCpi { - __program: self.instruction.__program, - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - migration_metadata: self - .instruction - .migration_metadata - .expect("migration_metadata is not set"), - - config: self.instruction.config.expect("config is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - damm_config: self - .instruction - .damm_config - .expect("damm_config is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - virtual_pool_lp: self - .instruction - .virtual_pool_lp - .expect("virtual_pool_lp is not set"), - - protocol_token_a_fee: self - .instruction - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - - protocol_token_b_fee: self - .instruction - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - amm_program: self - .instruction - .amm_program - .expect("amm_program is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrateMeteoraDammCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - migration_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - damm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - virtual_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_a_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_b_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migrate_meteora_damm_claim_lp_token.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/migrate_meteora_damm_claim_lp_token.rs deleted file mode 100644 index 3c9c02b8..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migrate_meteora_damm_claim_lp_token.rs +++ /dev/null @@ -1,614 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MigrateMeteoraDammClaimLpToken { - pub virtual_pool: solana_pubkey::Pubkey, - /// migration metadata - pub migration_metadata: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub source_token: solana_pubkey::Pubkey, - - pub destination_token: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, -} - -impl MigrateMeteoraDammClaimLpToken { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.migration_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.source_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.destination_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigrateMeteoraDammClaimLpTokenInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateMeteoraDammClaimLpTokenInstructionData { - discriminator: [u8; 8], -} - -impl MigrateMeteoraDammClaimLpTokenInstructionData { - pub fn new() -> Self { - Self { - discriminator: [139, 133, 2, 30, 91, 145, 127, 154], - } - } -} - -impl Default for MigrateMeteoraDammClaimLpTokenInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigrateMeteoraDammClaimLpToken`. -/// -/// ### Accounts: -/// -/// 0. `[]` virtual_pool -/// 1. `[writable]` migration_metadata -/// 2. `[writable, optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 3. `[]` lp_mint -/// 4. `[writable]` source_token -/// 5. `[writable]` destination_token -/// 6. `[]` owner -/// 7. `[signer]` sender -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct MigrateMeteoraDammClaimLpTokenBuilder { - virtual_pool: Option, - migration_metadata: Option, - pool_authority: Option, - lp_mint: Option, - source_token: Option, - destination_token: Option, - owner: Option, - sender: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl MigrateMeteoraDammClaimLpTokenBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - /// migration metadata - #[inline(always)] - pub fn migration_metadata(&mut self, migration_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.migration_metadata = Some(migration_metadata); - self - } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn source_token(&mut self, source_token: solana_pubkey::Pubkey) -> &mut Self { - self.source_token = Some(source_token); - self - } - - #[inline(always)] - pub fn destination_token(&mut self, destination_token: solana_pubkey::Pubkey) -> &mut Self { - self.destination_token = Some(destination_token); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrateMeteoraDammClaimLpToken { - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - migration_metadata: self - .migration_metadata - .expect("migration_metadata is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - source_token: self.source_token.expect("source_token is not set"), - destination_token: self - .destination_token - .expect("destination_token is not set"), - owner: self.owner.expect("owner is not set"), - sender: self.sender.expect("sender is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migrate_meteora_damm_claim_lp_token` CPI accounts. -pub struct MigrateMeteoraDammClaimLpTokenCpiAccounts<'a, 'b> { - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// migration metadata - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub source_token: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migrate_meteora_damm_claim_lp_token` CPI instruction. -pub struct MigrateMeteoraDammClaimLpTokenCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// migration metadata - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub source_token: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrateMeteoraDammClaimLpTokenCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrateMeteoraDammClaimLpTokenCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - virtual_pool: accounts.virtual_pool, - migration_metadata: accounts.migration_metadata, - pool_authority: accounts.pool_authority, - lp_mint: accounts.lp_mint, - source_token: accounts.source_token, - destination_token: accounts.destination_token, - owner: accounts.owner, - sender: accounts.sender, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.migration_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.source_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.destination_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigrateMeteoraDammClaimLpTokenInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.migration_metadata.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.source_token.clone()); - account_infos.push(self.destination_token.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrateMeteoraDammClaimLpToken` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` virtual_pool -/// 1. `[writable]` migration_metadata -/// 2. `[writable]` pool_authority -/// 3. `[]` lp_mint -/// 4. `[writable]` source_token -/// 5. `[writable]` destination_token -/// 6. `[]` owner -/// 7. `[signer]` sender -/// 8. `[]` token_program -#[derive(Clone, Debug)] -pub struct MigrateMeteoraDammClaimLpTokenCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrateMeteoraDammClaimLpTokenCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrateMeteoraDammClaimLpTokenCpiBuilderInstruction { - __program: program, - virtual_pool: None, - migration_metadata: None, - pool_authority: None, - lp_mint: None, - source_token: None, - destination_token: None, - owner: None, - sender: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - /// migration metadata - #[inline(always)] - pub fn migration_metadata( - &mut self, - migration_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migration_metadata = Some(migration_metadata); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn source_token( - &mut self, - source_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_token = Some(source_token); - self - } - - #[inline(always)] - pub fn destination_token( - &mut self, - destination_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_token = Some(destination_token); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrateMeteoraDammClaimLpTokenCpi { - __program: self.instruction.__program, - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - migration_metadata: self - .instruction - .migration_metadata - .expect("migration_metadata is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - source_token: self - .instruction - .source_token - .expect("source_token is not set"), - - destination_token: self - .instruction - .destination_token - .expect("destination_token is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrateMeteoraDammClaimLpTokenCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - migration_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - source_token: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_token: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migrate_meteora_damm_lock_lp_token.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/migrate_meteora_damm_lock_lp_token.rs deleted file mode 100644 index 4f5f7a81..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migrate_meteora_damm_lock_lp_token.rs +++ /dev/null @@ -1,927 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MigrateMeteoraDammLockLpToken { - pub virtual_pool: solana_pubkey::Pubkey, - /// migration_metadata - pub migration_metadata: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub lock_escrow: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - - pub source_tokens: solana_pubkey::Pubkey, - - pub escrow_vault: solana_pubkey::Pubkey, - - pub amm_program: solana_pubkey::Pubkey, - - pub a_vault: solana_pubkey::Pubkey, - - pub b_vault: solana_pubkey::Pubkey, - - pub a_vault_lp: solana_pubkey::Pubkey, - - pub b_vault_lp: solana_pubkey::Pubkey, - - pub a_vault_lp_mint: solana_pubkey::Pubkey, - - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, -} - -impl MigrateMeteoraDammLockLpToken { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.migration_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lock_escrow, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.source_tokens, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.escrow_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.b_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigrateMeteoraDammLockLpTokenInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateMeteoraDammLockLpTokenInstructionData { - discriminator: [u8; 8], -} - -impl MigrateMeteoraDammLockLpTokenInstructionData { - pub fn new() -> Self { - Self { - discriminator: [177, 55, 238, 157, 251, 88, 165, 42], - } - } -} - -impl Default for MigrateMeteoraDammLockLpTokenInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigrateMeteoraDammLockLpToken`. -/// -/// ### Accounts: -/// -/// 0. `[]` virtual_pool -/// 1. `[writable]` migration_metadata -/// 2. `[writable, optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 3. `[writable]` pool -/// 4. `[]` lp_mint -/// 5. `[writable]` lock_escrow -/// 6. `[]` owner -/// 7. `[writable]` source_tokens -/// 8. `[writable]` escrow_vault -/// 9. `[optional]` amm_program (default to `Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB`) -/// 10. `[]` a_vault -/// 11. `[]` b_vault -/// 12. `[]` a_vault_lp -/// 13. `[]` b_vault_lp -/// 14. `[]` a_vault_lp_mint -/// 15. `[]` b_vault_lp_mint -/// 16. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct MigrateMeteoraDammLockLpTokenBuilder { - virtual_pool: Option, - migration_metadata: Option, - pool_authority: Option, - pool: Option, - lp_mint: Option, - lock_escrow: Option, - owner: Option, - source_tokens: Option, - escrow_vault: Option, - amm_program: Option, - a_vault: Option, - b_vault: Option, - a_vault_lp: Option, - b_vault_lp: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl MigrateMeteoraDammLockLpTokenBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - /// migration_metadata - #[inline(always)] - pub fn migration_metadata(&mut self, migration_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.migration_metadata = Some(migration_metadata); - self - } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn lock_escrow(&mut self, lock_escrow: solana_pubkey::Pubkey) -> &mut Self { - self.lock_escrow = Some(lock_escrow); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn source_tokens(&mut self, source_tokens: solana_pubkey::Pubkey) -> &mut Self { - self.source_tokens = Some(source_tokens); - self - } - - #[inline(always)] - pub fn escrow_vault(&mut self, escrow_vault: solana_pubkey::Pubkey) -> &mut Self { - self.escrow_vault = Some(escrow_vault); - self - } - - /// `[optional account, default to 'Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB']` - #[inline(always)] - pub fn amm_program(&mut self, amm_program: solana_pubkey::Pubkey) -> &mut Self { - self.amm_program = Some(amm_program); - self - } - - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrateMeteoraDammLockLpToken { - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - migration_metadata: self - .migration_metadata - .expect("migration_metadata is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - lock_escrow: self.lock_escrow.expect("lock_escrow is not set"), - owner: self.owner.expect("owner is not set"), - source_tokens: self.source_tokens.expect("source_tokens is not set"), - escrow_vault: self.escrow_vault.expect("escrow_vault is not set"), - amm_program: self.amm_program.unwrap_or(solana_pubkey::pubkey!( - "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" - )), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migrate_meteora_damm_lock_lp_token` CPI accounts. -pub struct MigrateMeteoraDammLockLpTokenCpiAccounts<'a, 'b> { - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// migration_metadata - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub source_tokens: &'b solana_account_info::AccountInfo<'a>, - - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - - pub amm_program: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migrate_meteora_damm_lock_lp_token` CPI instruction. -pub struct MigrateMeteoraDammLockLpTokenCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// migration_metadata - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub source_tokens: &'b solana_account_info::AccountInfo<'a>, - - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - - pub amm_program: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrateMeteoraDammLockLpTokenCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrateMeteoraDammLockLpTokenCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - virtual_pool: accounts.virtual_pool, - migration_metadata: accounts.migration_metadata, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - lock_escrow: accounts.lock_escrow, - owner: accounts.owner, - source_tokens: accounts.source_tokens, - escrow_vault: accounts.escrow_vault, - amm_program: accounts.amm_program, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.migration_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lock_escrow.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.source_tokens.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.escrow_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigrateMeteoraDammLockLpTokenInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(18 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.migration_metadata.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.lock_escrow.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.source_tokens.clone()); - account_infos.push(self.escrow_vault.clone()); - account_infos.push(self.amm_program.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrateMeteoraDammLockLpToken` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` virtual_pool -/// 1. `[writable]` migration_metadata -/// 2. `[writable]` pool_authority -/// 3. `[writable]` pool -/// 4. `[]` lp_mint -/// 5. `[writable]` lock_escrow -/// 6. `[]` owner -/// 7. `[writable]` source_tokens -/// 8. `[writable]` escrow_vault -/// 9. `[]` amm_program -/// 10. `[]` a_vault -/// 11. `[]` b_vault -/// 12. `[]` a_vault_lp -/// 13. `[]` b_vault_lp -/// 14. `[]` a_vault_lp_mint -/// 15. `[]` b_vault_lp_mint -/// 16. `[]` token_program -#[derive(Clone, Debug)] -pub struct MigrateMeteoraDammLockLpTokenCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrateMeteoraDammLockLpTokenCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrateMeteoraDammLockLpTokenCpiBuilderInstruction { - __program: program, - virtual_pool: None, - migration_metadata: None, - pool_authority: None, - pool: None, - lp_mint: None, - lock_escrow: None, - owner: None, - source_tokens: None, - escrow_vault: None, - amm_program: None, - a_vault: None, - b_vault: None, - a_vault_lp: None, - b_vault_lp: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - /// migration_metadata - #[inline(always)] - pub fn migration_metadata( - &mut self, - migration_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migration_metadata = Some(migration_metadata); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn lock_escrow( - &mut self, - lock_escrow: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_escrow = Some(lock_escrow); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn source_tokens( - &mut self, - source_tokens: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_tokens = Some(source_tokens); - self - } - - #[inline(always)] - pub fn escrow_vault( - &mut self, - escrow_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.escrow_vault = Some(escrow_vault); - self - } - - #[inline(always)] - pub fn amm_program( - &mut self, - amm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_program = Some(amm_program); - self - } - - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrateMeteoraDammLockLpTokenCpi { - __program: self.instruction.__program, - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - migration_metadata: self - .instruction - .migration_metadata - .expect("migration_metadata is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - lock_escrow: self - .instruction - .lock_escrow - .expect("lock_escrow is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - source_tokens: self - .instruction - .source_tokens - .expect("source_tokens is not set"), - - escrow_vault: self - .instruction - .escrow_vault - .expect("escrow_vault is not set"), - - amm_program: self - .instruction - .amm_program - .expect("amm_program is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrateMeteoraDammLockLpTokenCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - migration_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_escrow: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - source_tokens: Option<&'b solana_account_info::AccountInfo<'a>>, - escrow_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migration_damm_v2.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/migration_damm_v2.rs deleted file mode 100644 index c1e03c0f..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migration_damm_v2.rs +++ /dev/null @@ -1,1332 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MigrationDammV2 { - /// virtual pool - pub virtual_pool: solana_pubkey::Pubkey, - /// migration metadata - pub migration_metadata: solana_pubkey::Pubkey, - /// virtual pool config key - pub config: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub first_position_nft_mint: solana_pubkey::Pubkey, - - pub first_position_nft_account: solana_pubkey::Pubkey, - - pub first_position: solana_pubkey::Pubkey, - - pub second_position_nft_mint: Option, - - pub second_position_nft_account: Option, - - pub second_position: Option, - - pub damm_pool_authority: solana_pubkey::Pubkey, - - pub amm_program: solana_pubkey::Pubkey, - - pub base_mint: solana_pubkey::Pubkey, - - pub quote_mint: solana_pubkey::Pubkey, - - pub token_a_vault: solana_pubkey::Pubkey, - - pub token_b_vault: solana_pubkey::Pubkey, - - pub base_vault: solana_pubkey::Pubkey, - - pub quote_vault: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub token_base_program: solana_pubkey::Pubkey, - - pub token_quote_program: solana_pubkey::Pubkey, - - pub token2022_program: solana_pubkey::Pubkey, - - pub damm_event_authority: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, -} - -impl MigrationDammV2 { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(25 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.migration_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.first_position_nft_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.first_position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.first_position, - false, - )); - if let Some(second_position_nft_mint) = self.second_position_nft_mint { - accounts.push(solana_instruction::AccountMeta::new( - second_position_nft_mint, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::DYNAMIC_BONDING_CURVE_ID, - false, - )); - } - if let Some(second_position_nft_account) = self.second_position_nft_account { - accounts.push(solana_instruction::AccountMeta::new( - second_position_nft_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::DYNAMIC_BONDING_CURVE_ID, - false, - )); - } - if let Some(second_position) = self.second_position { - accounts.push(solana_instruction::AccountMeta::new(second_position, false)); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::DYNAMIC_BONDING_CURVE_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.damm_pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_mint, false)); - accounts.push(solana_instruction::AccountMeta::new(self.quote_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_base_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_quote_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.damm_event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigrationDammV2InstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrationDammV2InstructionData { - discriminator: [u8; 8], -} - -impl MigrationDammV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [156, 169, 230, 103, 53, 228, 80, 64], - } - } -} - -impl Default for MigrationDammV2InstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigrationDammV2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` virtual_pool -/// 1. `[]` migration_metadata -/// 2. `[]` config -/// 3. `[writable, optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 4. `[writable]` pool -/// 5. `[writable]` first_position_nft_mint -/// 6. `[writable]` first_position_nft_account -/// 7. `[writable]` first_position -/// 8. `[writable, optional]` second_position_nft_mint -/// 9. `[writable, optional]` second_position_nft_account -/// 10. `[writable, optional]` second_position -/// 11. `[]` damm_pool_authority -/// 12. `[optional]` amm_program (default to `cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG`) -/// 13. `[writable]` base_mint -/// 14. `[writable]` quote_mint -/// 15. `[writable]` token_a_vault -/// 16. `[writable]` token_b_vault -/// 17. `[writable]` base_vault -/// 18. `[writable]` quote_vault -/// 19. `[writable, signer]` payer -/// 20. `[]` token_base_program -/// 21. `[]` token_quote_program -/// 22. `[]` token2022_program -/// 23. `[]` damm_event_authority -/// 24. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct MigrationDammV2Builder { - virtual_pool: Option, - migration_metadata: Option, - config: Option, - pool_authority: Option, - pool: Option, - first_position_nft_mint: Option, - first_position_nft_account: Option, - first_position: Option, - second_position_nft_mint: Option, - second_position_nft_account: Option, - second_position: Option, - damm_pool_authority: Option, - amm_program: Option, - base_mint: Option, - quote_mint: Option, - token_a_vault: Option, - token_b_vault: Option, - base_vault: Option, - quote_vault: Option, - payer: Option, - token_base_program: Option, - token_quote_program: Option, - token2022_program: Option, - damm_event_authority: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl MigrationDammV2Builder { - pub fn new() -> Self { Self::default() } - - /// virtual pool - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - /// migration metadata - #[inline(always)] - pub fn migration_metadata(&mut self, migration_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.migration_metadata = Some(migration_metadata); - self - } - - /// virtual pool config key - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn first_position_nft_mint( - &mut self, - first_position_nft_mint: solana_pubkey::Pubkey, - ) -> &mut Self { - self.first_position_nft_mint = Some(first_position_nft_mint); - self - } - - #[inline(always)] - pub fn first_position_nft_account( - &mut self, - first_position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.first_position_nft_account = Some(first_position_nft_account); - self - } - - #[inline(always)] - pub fn first_position(&mut self, first_position: solana_pubkey::Pubkey) -> &mut Self { - self.first_position = Some(first_position); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn second_position_nft_mint( - &mut self, - second_position_nft_mint: Option, - ) -> &mut Self { - self.second_position_nft_mint = second_position_nft_mint; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn second_position_nft_account( - &mut self, - second_position_nft_account: Option, - ) -> &mut Self { - self.second_position_nft_account = second_position_nft_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn second_position(&mut self, second_position: Option) -> &mut Self { - self.second_position = second_position; - self - } - - #[inline(always)] - pub fn damm_pool_authority(&mut self, damm_pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.damm_pool_authority = Some(damm_pool_authority); - self - } - - /// `[optional account, default to 'cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG']` - #[inline(always)] - pub fn amm_program(&mut self, amm_program: solana_pubkey::Pubkey) -> &mut Self { - self.amm_program = Some(amm_program); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn token_a_vault(&mut self, token_a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_vault = Some(token_a_vault); - self - } - - #[inline(always)] - pub fn token_b_vault(&mut self, token_b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_vault = Some(token_b_vault); - self - } - - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn token_base_program(&mut self, token_base_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_base_program = Some(token_base_program); - self - } - - #[inline(always)] - pub fn token_quote_program(&mut self, token_quote_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn damm_event_authority( - &mut self, - damm_event_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.damm_event_authority = Some(damm_event_authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrationDammV2 { - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - migration_metadata: self - .migration_metadata - .expect("migration_metadata is not set"), - config: self.config.expect("config is not set"), - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - pool: self.pool.expect("pool is not set"), - first_position_nft_mint: self - .first_position_nft_mint - .expect("first_position_nft_mint is not set"), - first_position_nft_account: self - .first_position_nft_account - .expect("first_position_nft_account is not set"), - first_position: self.first_position.expect("first_position is not set"), - second_position_nft_mint: self.second_position_nft_mint, - second_position_nft_account: self.second_position_nft_account, - second_position: self.second_position, - damm_pool_authority: self - .damm_pool_authority - .expect("damm_pool_authority is not set"), - amm_program: self.amm_program.unwrap_or(solana_pubkey::pubkey!( - "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG" - )), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - token_a_vault: self.token_a_vault.expect("token_a_vault is not set"), - token_b_vault: self.token_b_vault.expect("token_b_vault is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - payer: self.payer.expect("payer is not set"), - token_base_program: self - .token_base_program - .expect("token_base_program is not set"), - token_quote_program: self - .token_quote_program - .expect("token_quote_program is not set"), - token2022_program: self - .token2022_program - .expect("token2022_program is not set"), - damm_event_authority: self - .damm_event_authority - .expect("damm_event_authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migration_damm_v2` CPI accounts. -pub struct MigrationDammV2CpiAccounts<'a, 'b> { - /// virtual pool - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// migration metadata - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - /// virtual pool config key - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub first_position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub first_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub first_position: &'b solana_account_info::AccountInfo<'a>, - - pub second_position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub second_position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub second_position: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub damm_pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_program: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub damm_event_authority: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migration_damm_v2` CPI instruction. -pub struct MigrationDammV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// virtual pool - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// migration metadata - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - /// virtual pool config key - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub first_position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub first_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub first_position: &'b solana_account_info::AccountInfo<'a>, - - pub second_position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub second_position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub second_position: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub damm_pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_program: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_a_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_b_vault: &'b solana_account_info::AccountInfo<'a>, - - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub damm_event_authority: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrationDammV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrationDammV2CpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - virtual_pool: accounts.virtual_pool, - migration_metadata: accounts.migration_metadata, - config: accounts.config, - pool_authority: accounts.pool_authority, - pool: accounts.pool, - first_position_nft_mint: accounts.first_position_nft_mint, - first_position_nft_account: accounts.first_position_nft_account, - first_position: accounts.first_position, - second_position_nft_mint: accounts.second_position_nft_mint, - second_position_nft_account: accounts.second_position_nft_account, - second_position: accounts.second_position, - damm_pool_authority: accounts.damm_pool_authority, - amm_program: accounts.amm_program, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - token_a_vault: accounts.token_a_vault, - token_b_vault: accounts.token_b_vault, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - payer: accounts.payer, - token_base_program: accounts.token_base_program, - token_quote_program: accounts.token_quote_program, - token2022_program: accounts.token2022_program, - damm_event_authority: accounts.damm_event_authority, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(25 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.migration_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.first_position_nft_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.first_position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.first_position.key, - false, - )); - if let Some(second_position_nft_mint) = self.second_position_nft_mint { - accounts.push(solana_instruction::AccountMeta::new( - *second_position_nft_mint.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::DYNAMIC_BONDING_CURVE_ID, - false, - )); - } - if let Some(second_position_nft_account) = self.second_position_nft_account { - accounts.push(solana_instruction::AccountMeta::new( - *second_position_nft_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::DYNAMIC_BONDING_CURVE_ID, - false, - )); - } - if let Some(second_position) = self.second_position { - accounts.push(solana_instruction::AccountMeta::new( - *second_position.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::DYNAMIC_BONDING_CURVE_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.damm_pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_base_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_quote_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.damm_event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigrationDammV2InstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(26 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.migration_metadata.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.first_position_nft_mint.clone()); - account_infos.push(self.first_position_nft_account.clone()); - account_infos.push(self.first_position.clone()); - if let Some(second_position_nft_mint) = self.second_position_nft_mint { - account_infos.push(second_position_nft_mint.clone()); - } - if let Some(second_position_nft_account) = self.second_position_nft_account { - account_infos.push(second_position_nft_account.clone()); - } - if let Some(second_position) = self.second_position { - account_infos.push(second_position.clone()); - } - account_infos.push(self.damm_pool_authority.clone()); - account_infos.push(self.amm_program.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.token_a_vault.clone()); - account_infos.push(self.token_b_vault.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_base_program.clone()); - account_infos.push(self.token_quote_program.clone()); - account_infos.push(self.token2022_program.clone()); - account_infos.push(self.damm_event_authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrationDammV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` virtual_pool -/// 1. `[]` migration_metadata -/// 2. `[]` config -/// 3. `[writable]` pool_authority -/// 4. `[writable]` pool -/// 5. `[writable]` first_position_nft_mint -/// 6. `[writable]` first_position_nft_account -/// 7. `[writable]` first_position -/// 8. `[writable, optional]` second_position_nft_mint -/// 9. `[writable, optional]` second_position_nft_account -/// 10. `[writable, optional]` second_position -/// 11. `[]` damm_pool_authority -/// 12. `[]` amm_program -/// 13. `[writable]` base_mint -/// 14. `[writable]` quote_mint -/// 15. `[writable]` token_a_vault -/// 16. `[writable]` token_b_vault -/// 17. `[writable]` base_vault -/// 18. `[writable]` quote_vault -/// 19. `[writable, signer]` payer -/// 20. `[]` token_base_program -/// 21. `[]` token_quote_program -/// 22. `[]` token2022_program -/// 23. `[]` damm_event_authority -/// 24. `[]` system_program -#[derive(Clone, Debug)] -pub struct MigrationDammV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrationDammV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrationDammV2CpiBuilderInstruction { - __program: program, - virtual_pool: None, - migration_metadata: None, - config: None, - pool_authority: None, - pool: None, - first_position_nft_mint: None, - first_position_nft_account: None, - first_position: None, - second_position_nft_mint: None, - second_position_nft_account: None, - second_position: None, - damm_pool_authority: None, - amm_program: None, - base_mint: None, - quote_mint: None, - token_a_vault: None, - token_b_vault: None, - base_vault: None, - quote_vault: None, - payer: None, - token_base_program: None, - token_quote_program: None, - token2022_program: None, - damm_event_authority: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// virtual pool - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - /// migration metadata - #[inline(always)] - pub fn migration_metadata( - &mut self, - migration_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migration_metadata = Some(migration_metadata); - self - } - - /// virtual pool config key - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn first_position_nft_mint( - &mut self, - first_position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.first_position_nft_mint = Some(first_position_nft_mint); - self - } - - #[inline(always)] - pub fn first_position_nft_account( - &mut self, - first_position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.first_position_nft_account = Some(first_position_nft_account); - self - } - - #[inline(always)] - pub fn first_position( - &mut self, - first_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.first_position = Some(first_position); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn second_position_nft_mint( - &mut self, - second_position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.second_position_nft_mint = second_position_nft_mint; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn second_position_nft_account( - &mut self, - second_position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.second_position_nft_account = second_position_nft_account; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn second_position( - &mut self, - second_position: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.second_position = second_position; - self - } - - #[inline(always)] - pub fn damm_pool_authority( - &mut self, - damm_pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.damm_pool_authority = Some(damm_pool_authority); - self - } - - #[inline(always)] - pub fn amm_program( - &mut self, - amm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_program = Some(amm_program); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn token_a_vault( - &mut self, - token_a_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_vault = Some(token_a_vault); - self - } - - #[inline(always)] - pub fn token_b_vault( - &mut self, - token_b_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_vault = Some(token_b_vault); - self - } - - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn token_base_program( - &mut self, - token_base_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_base_program = Some(token_base_program); - self - } - - #[inline(always)] - pub fn token_quote_program( - &mut self, - token_quote_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn damm_event_authority( - &mut self, - damm_event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.damm_event_authority = Some(damm_event_authority); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrationDammV2Cpi { - __program: self.instruction.__program, - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - migration_metadata: self - .instruction - .migration_metadata - .expect("migration_metadata is not set"), - - config: self.instruction.config.expect("config is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - first_position_nft_mint: self - .instruction - .first_position_nft_mint - .expect("first_position_nft_mint is not set"), - - first_position_nft_account: self - .instruction - .first_position_nft_account - .expect("first_position_nft_account is not set"), - - first_position: self - .instruction - .first_position - .expect("first_position is not set"), - - second_position_nft_mint: self.instruction.second_position_nft_mint, - - second_position_nft_account: self.instruction.second_position_nft_account, - - second_position: self.instruction.second_position, - - damm_pool_authority: self - .instruction - .damm_pool_authority - .expect("damm_pool_authority is not set"), - - amm_program: self - .instruction - .amm_program - .expect("amm_program is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - token_a_vault: self - .instruction - .token_a_vault - .expect("token_a_vault is not set"), - - token_b_vault: self - .instruction - .token_b_vault - .expect("token_b_vault is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_base_program: self - .instruction - .token_base_program - .expect("token_base_program is not set"), - - token_quote_program: self - .instruction - .token_quote_program - .expect("token_quote_program is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - - damm_event_authority: self - .instruction - .damm_event_authority - .expect("damm_event_authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrationDammV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - migration_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - first_position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - first_position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - first_position: Option<&'b solana_account_info::AccountInfo<'a>>, - second_position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - second_position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - second_position: Option<&'b solana_account_info::AccountInfo<'a>>, - damm_pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_base_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - damm_event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migration_damm_v2_create_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/migration_damm_v2_create_metadata.rs deleted file mode 100644 index f906ec31..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migration_damm_v2_create_metadata.rs +++ /dev/null @@ -1,516 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MigrationDammV2CreateMetadata { - pub virtual_pool: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub migration_metadata: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl MigrationDammV2CreateMetadata { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.migration_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigrationDammV2CreateMetadataInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrationDammV2CreateMetadataInstructionData { - discriminator: [u8; 8], -} - -impl MigrationDammV2CreateMetadataInstructionData { - pub fn new() -> Self { - Self { - discriminator: [109, 189, 19, 36, 195, 183, 222, 82], - } - } -} - -impl Default for MigrationDammV2CreateMetadataInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigrationDammV2CreateMetadata`. -/// -/// ### Accounts: -/// -/// 0. `[]` virtual_pool -/// 1. `[]` config -/// 2. `[writable]` migration_metadata -/// 3. `[writable, signer]` payer -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 5. `[]` event_authority -/// 6. `[]` program -#[derive(Clone, Debug, Default)] -pub struct MigrationDammV2CreateMetadataBuilder { - virtual_pool: Option, - config: Option, - migration_metadata: Option, - payer: Option, - system_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl MigrationDammV2CreateMetadataBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn migration_metadata(&mut self, migration_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.migration_metadata = Some(migration_metadata); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrationDammV2CreateMetadata { - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - config: self.config.expect("config is not set"), - migration_metadata: self - .migration_metadata - .expect("migration_metadata is not set"), - payer: self.payer.expect("payer is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migration_damm_v2_create_metadata` CPI accounts. -pub struct MigrationDammV2CreateMetadataCpiAccounts<'a, 'b> { - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migration_damm_v2_create_metadata` CPI instruction. -pub struct MigrationDammV2CreateMetadataCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrationDammV2CreateMetadataCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrationDammV2CreateMetadataCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - virtual_pool: accounts.virtual_pool, - config: accounts.config, - migration_metadata: accounts.migration_metadata, - payer: accounts.payer, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.migration_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigrationDammV2CreateMetadataInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.migration_metadata.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrationDammV2CreateMetadata` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` virtual_pool -/// 1. `[]` config -/// 2. `[writable]` migration_metadata -/// 3. `[writable, signer]` payer -/// 4. `[]` system_program -/// 5. `[]` event_authority -/// 6. `[]` program -#[derive(Clone, Debug)] -pub struct MigrationDammV2CreateMetadataCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrationDammV2CreateMetadataCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrationDammV2CreateMetadataCpiBuilderInstruction { - __program: program, - virtual_pool: None, - config: None, - migration_metadata: None, - payer: None, - system_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn migration_metadata( - &mut self, - migration_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migration_metadata = Some(migration_metadata); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrationDammV2CreateMetadataCpi { - __program: self.instruction.__program, - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - config: self.instruction.config.expect("config is not set"), - - migration_metadata: self - .instruction - .migration_metadata - .expect("migration_metadata is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrationDammV2CreateMetadataCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - migration_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migration_meteora_damm_create_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/migration_meteora_damm_create_metadata.rs deleted file mode 100644 index fa296b96..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/migration_meteora_damm_create_metadata.rs +++ /dev/null @@ -1,518 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MigrationMeteoraDammCreateMetadata { - pub virtual_pool: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub migration_metadata: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl MigrationMeteoraDammCreateMetadata { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.migration_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = - borsh::to_vec(&MigrationMeteoraDammCreateMetadataInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrationMeteoraDammCreateMetadataInstructionData { - discriminator: [u8; 8], -} - -impl MigrationMeteoraDammCreateMetadataInstructionData { - pub fn new() -> Self { - Self { - discriminator: [47, 94, 126, 115, 221, 226, 194, 133], - } - } -} - -impl Default for MigrationMeteoraDammCreateMetadataInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigrationMeteoraDammCreateMetadata`. -/// -/// ### Accounts: -/// -/// 0. `[]` virtual_pool -/// 1. `[]` config -/// 2. `[writable]` migration_metadata -/// 3. `[writable, signer]` payer -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 5. `[]` event_authority -/// 6. `[]` program -#[derive(Clone, Debug, Default)] -pub struct MigrationMeteoraDammCreateMetadataBuilder { - virtual_pool: Option, - config: Option, - migration_metadata: Option, - payer: Option, - system_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl MigrationMeteoraDammCreateMetadataBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn migration_metadata(&mut self, migration_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.migration_metadata = Some(migration_metadata); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrationMeteoraDammCreateMetadata { - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - config: self.config.expect("config is not set"), - migration_metadata: self - .migration_metadata - .expect("migration_metadata is not set"), - payer: self.payer.expect("payer is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migration_meteora_damm_create_metadata` CPI accounts. -pub struct MigrationMeteoraDammCreateMetadataCpiAccounts<'a, 'b> { - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migration_meteora_damm_create_metadata` CPI instruction. -pub struct MigrationMeteoraDammCreateMetadataCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub migration_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrationMeteoraDammCreateMetadataCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrationMeteoraDammCreateMetadataCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - virtual_pool: accounts.virtual_pool, - config: accounts.config, - migration_metadata: accounts.migration_metadata, - payer: accounts.payer, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.migration_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = - borsh::to_vec(&MigrationMeteoraDammCreateMetadataInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.migration_metadata.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrationMeteoraDammCreateMetadata` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` virtual_pool -/// 1. `[]` config -/// 2. `[writable]` migration_metadata -/// 3. `[writable, signer]` payer -/// 4. `[]` system_program -/// 5. `[]` event_authority -/// 6. `[]` program -#[derive(Clone, Debug)] -pub struct MigrationMeteoraDammCreateMetadataCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrationMeteoraDammCreateMetadataCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrationMeteoraDammCreateMetadataCpiBuilderInstruction { - __program: program, - virtual_pool: None, - config: None, - migration_metadata: None, - payer: None, - system_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn migration_metadata( - &mut self, - migration_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migration_metadata = Some(migration_metadata); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrationMeteoraDammCreateMetadataCpi { - __program: self.instruction.__program, - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - config: self.instruction.config.expect("config is not set"), - - migration_metadata: self - .instruction - .migration_metadata - .expect("migration_metadata is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrationMeteoraDammCreateMetadataCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - migration_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/mod.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index e7839008..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#claim_creator_trading_fee; -pub(crate) mod r#claim_protocol_fee; -pub(crate) mod r#claim_trading_fee; -pub(crate) mod r#close_claim_fee_operator; -pub(crate) mod r#create_claim_fee_operator; -pub(crate) mod r#create_config; -pub(crate) mod r#create_locker; -pub(crate) mod r#create_partner_metadata; -pub(crate) mod r#create_virtual_pool_metadata; -pub(crate) mod r#creator_withdraw_surplus; -pub(crate) mod r#initialize_virtual_pool_with_spl_token; -pub(crate) mod r#initialize_virtual_pool_with_token2022; -pub(crate) mod r#migrate_meteora_damm; -pub(crate) mod r#migrate_meteora_damm_claim_lp_token; -pub(crate) mod r#migrate_meteora_damm_lock_lp_token; -pub(crate) mod r#migration_damm_v2; -pub(crate) mod r#migration_damm_v2_create_metadata; -pub(crate) mod r#migration_meteora_damm_create_metadata; -pub(crate) mod r#partner_withdraw_surplus; -pub(crate) mod r#protocol_withdraw_surplus; -pub(crate) mod r#swap; -pub(crate) mod r#withdraw_leftover; - -pub use self::{ - r#claim_creator_trading_fee::*, r#claim_protocol_fee::*, r#claim_trading_fee::*, - r#close_claim_fee_operator::*, r#create_claim_fee_operator::*, r#create_config::*, - r#create_locker::*, r#create_partner_metadata::*, r#create_virtual_pool_metadata::*, - r#creator_withdraw_surplus::*, r#initialize_virtual_pool_with_spl_token::*, - r#initialize_virtual_pool_with_token2022::*, r#migrate_meteora_damm::*, - r#migrate_meteora_damm_claim_lp_token::*, r#migrate_meteora_damm_lock_lp_token::*, - r#migration_damm_v2::*, r#migration_damm_v2_create_metadata::*, - r#migration_meteora_damm_create_metadata::*, r#partner_withdraw_surplus::*, - r#protocol_withdraw_surplus::*, r#swap::*, r#withdraw_leftover::*, -}; diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/partner_withdraw_surplus.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/partner_withdraw_surplus.rs deleted file mode 100644 index d1f8b15c..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/partner_withdraw_surplus.rs +++ /dev/null @@ -1,661 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct PartnerWithdrawSurplus { - pub pool_authority: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub virtual_pool: solana_pubkey::Pubkey, - /// The receiver token account - pub token_quote_account: solana_pubkey::Pubkey, - /// The vault token account for output token - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of quote token - pub quote_mint: solana_pubkey::Pubkey, - - pub fee_claimer: solana_pubkey::Pubkey, - /// Token b program - pub token_quote_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl PartnerWithdrawSurplus { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_quote_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_claimer, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_quote_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&PartnerWithdrawSurplusInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PartnerWithdrawSurplusInstructionData { - discriminator: [u8; 8], -} - -impl PartnerWithdrawSurplusInstructionData { - pub fn new() -> Self { - Self { - discriminator: [168, 173, 72, 100, 201, 98, 38, 92], - } - } -} - -impl Default for PartnerWithdrawSurplusInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `PartnerWithdrawSurplus`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 1. `[]` config -/// 2. `[writable]` virtual_pool -/// 3. `[writable]` token_quote_account -/// 4. `[writable]` quote_vault -/// 5. `[]` quote_mint -/// 6. `[signer]` fee_claimer -/// 7. `[]` token_quote_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct PartnerWithdrawSurplusBuilder { - pool_authority: Option, - config: Option, - virtual_pool: Option, - token_quote_account: Option, - quote_vault: Option, - quote_mint: Option, - fee_claimer: Option, - token_quote_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl PartnerWithdrawSurplusBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - /// The receiver token account - #[inline(always)] - pub fn token_quote_account(&mut self, token_quote_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_account = Some(token_quote_account); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of quote token - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn fee_claimer(&mut self, fee_claimer: solana_pubkey::Pubkey) -> &mut Self { - self.fee_claimer = Some(fee_claimer); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program(&mut self, token_quote_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = PartnerWithdrawSurplus { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - config: self.config.expect("config is not set"), - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - token_quote_account: self - .token_quote_account - .expect("token_quote_account is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - fee_claimer: self.fee_claimer.expect("fee_claimer is not set"), - token_quote_program: self - .token_quote_program - .expect("token_quote_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `partner_withdraw_surplus` CPI accounts. -pub struct PartnerWithdrawSurplusCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// The receiver token account - pub token_quote_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub fee_claimer: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `partner_withdraw_surplus` CPI instruction. -pub struct PartnerWithdrawSurplusCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// The receiver token account - pub token_quote_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub fee_claimer: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> PartnerWithdrawSurplusCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: PartnerWithdrawSurplusCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - config: accounts.config, - virtual_pool: accounts.virtual_pool, - token_quote_account: accounts.token_quote_account, - quote_vault: accounts.quote_vault, - quote_mint: accounts.quote_mint, - fee_claimer: accounts.fee_claimer, - token_quote_program: accounts.token_quote_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_quote_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_claimer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_quote_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&PartnerWithdrawSurplusInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.token_quote_account.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.fee_claimer.clone()); - account_infos.push(self.token_quote_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `PartnerWithdrawSurplus` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[]` config -/// 2. `[writable]` virtual_pool -/// 3. `[writable]` token_quote_account -/// 4. `[writable]` quote_vault -/// 5. `[]` quote_mint -/// 6. `[signer]` fee_claimer -/// 7. `[]` token_quote_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct PartnerWithdrawSurplusCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> PartnerWithdrawSurplusCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(PartnerWithdrawSurplusCpiBuilderInstruction { - __program: program, - pool_authority: None, - config: None, - virtual_pool: None, - token_quote_account: None, - quote_vault: None, - quote_mint: None, - fee_claimer: None, - token_quote_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - /// The receiver token account - #[inline(always)] - pub fn token_quote_account( - &mut self, - token_quote_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_account = Some(token_quote_account); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of quote token - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn fee_claimer( - &mut self, - fee_claimer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_claimer = Some(fee_claimer); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program( - &mut self, - token_quote_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = PartnerWithdrawSurplusCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - token_quote_account: self - .instruction - .token_quote_account - .expect("token_quote_account is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - fee_claimer: self - .instruction - .fee_claimer - .expect("fee_claimer is not set"), - - token_quote_program: self - .instruction - .token_quote_program - .expect("token_quote_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct PartnerWithdrawSurplusCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_account: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_claimer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/protocol_withdraw_surplus.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/protocol_withdraw_surplus.rs deleted file mode 100644 index 3f89f763..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/protocol_withdraw_surplus.rs +++ /dev/null @@ -1,619 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ProtocolWithdrawSurplus { - pub pool_authority: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub virtual_pool: solana_pubkey::Pubkey, - /// The treasury quote token account - pub token_quote_account: solana_pubkey::Pubkey, - /// The vault token account for quote token - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of of token - pub quote_mint: solana_pubkey::Pubkey, - /// Token b program - pub token_quote_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ProtocolWithdrawSurplus { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_quote_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_quote_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ProtocolWithdrawSurplusInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ProtocolWithdrawSurplusInstructionData { - discriminator: [u8; 8], -} - -impl ProtocolWithdrawSurplusInstructionData { - pub fn new() -> Self { - Self { - discriminator: [54, 136, 225, 138, 172, 182, 214, 167], - } - } -} - -impl Default for ProtocolWithdrawSurplusInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ProtocolWithdrawSurplus`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 1. `[]` config -/// 2. `[writable]` virtual_pool -/// 3. `[writable]` token_quote_account -/// 4. `[writable]` quote_vault -/// 5. `[]` quote_mint -/// 6. `[]` token_quote_program -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ProtocolWithdrawSurplusBuilder { - pool_authority: Option, - config: Option, - virtual_pool: Option, - token_quote_account: Option, - quote_vault: Option, - quote_mint: Option, - token_quote_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl ProtocolWithdrawSurplusBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - /// The treasury quote token account - #[inline(always)] - pub fn token_quote_account(&mut self, token_quote_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_account = Some(token_quote_account); - self - } - - /// The vault token account for quote token - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of of token - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program(&mut self, token_quote_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ProtocolWithdrawSurplus { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - config: self.config.expect("config is not set"), - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - token_quote_account: self - .token_quote_account - .expect("token_quote_account is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - token_quote_program: self - .token_quote_program - .expect("token_quote_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `protocol_withdraw_surplus` CPI accounts. -pub struct ProtocolWithdrawSurplusCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// The treasury quote token account - pub token_quote_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for quote token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of of token - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `protocol_withdraw_surplus` CPI instruction. -pub struct ProtocolWithdrawSurplusCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// The treasury quote token account - pub token_quote_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for quote token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of of token - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token b program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ProtocolWithdrawSurplusCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ProtocolWithdrawSurplusCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - config: accounts.config, - virtual_pool: accounts.virtual_pool, - token_quote_account: accounts.token_quote_account, - quote_vault: accounts.quote_vault, - quote_mint: accounts.quote_mint, - token_quote_program: accounts.token_quote_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_quote_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_quote_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ProtocolWithdrawSurplusInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.token_quote_account.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.token_quote_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ProtocolWithdrawSurplus` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[]` config -/// 2. `[writable]` virtual_pool -/// 3. `[writable]` token_quote_account -/// 4. `[writable]` quote_vault -/// 5. `[]` quote_mint -/// 6. `[]` token_quote_program -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug)] -pub struct ProtocolWithdrawSurplusCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ProtocolWithdrawSurplusCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ProtocolWithdrawSurplusCpiBuilderInstruction { - __program: program, - pool_authority: None, - config: None, - virtual_pool: None, - token_quote_account: None, - quote_vault: None, - quote_mint: None, - token_quote_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - /// The treasury quote token account - #[inline(always)] - pub fn token_quote_account( - &mut self, - token_quote_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_account = Some(token_quote_account); - self - } - - /// The vault token account for quote token - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of of token - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// Token b program - #[inline(always)] - pub fn token_quote_program( - &mut self, - token_quote_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_program = Some(token_quote_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ProtocolWithdrawSurplusCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - token_quote_account: self - .instruction - .token_quote_account - .expect("token_quote_account is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - token_quote_program: self - .instruction - .token_quote_program - .expect("token_quote_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ProtocolWithdrawSurplusCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_account: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/swap.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/swap.rs deleted file mode 100644 index 017d5961..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/swap.rs +++ /dev/null @@ -1,920 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::SwapParameters; - -/// Accounts. -#[derive(Debug)] -pub struct Swap { - pub pool_authority: solana_pubkey::Pubkey, - /// config key - pub config: solana_pubkey::Pubkey, - /// Pool account - pub pool: solana_pubkey::Pubkey, - /// The user token account for input token - pub input_token_account: solana_pubkey::Pubkey, - /// The user token account for output token - pub output_token_account: solana_pubkey::Pubkey, - /// The vault token account for base token - pub base_vault: solana_pubkey::Pubkey, - /// The vault token account for quote token - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of base token - pub base_mint: solana_pubkey::Pubkey, - /// The mint of quote token - pub quote_mint: solana_pubkey::Pubkey, - /// The user performing the swap - pub payer: solana_pubkey::Pubkey, - /// Token base program - pub token_base_program: solana_pubkey::Pubkey, - /// Token quote program - pub token_quote_program: solana_pubkey::Pubkey, - /// referral token account - pub referral_token_account: Option, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Swap { - pub fn instruction(&self, args: SwapInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.input_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_base_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_quote_program, - false, - )); - if let Some(referral_token_account) = self.referral_token_account { - accounts.push(solana_instruction::AccountMeta::new( - referral_token_account, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::DYNAMIC_BONDING_CURVE_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionData { - discriminator: [u8; 8], -} - -impl SwapInstructionData { - pub fn new() -> Self { - Self { - discriminator: [248, 198, 158, 145, 225, 117, 135, 200], - } - } -} - -impl Default for SwapInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionArgs { - pub params: SwapParameters, -} - -/// Instruction builder for `Swap`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 1. `[]` config -/// 2. `[writable]` pool -/// 3. `[writable]` input_token_account -/// 4. `[writable]` output_token_account -/// 5. `[writable]` base_vault -/// 6. `[writable]` quote_vault -/// 7. `[]` base_mint -/// 8. `[]` quote_mint -/// 9. `[signer]` payer -/// 10. `[]` token_base_program -/// 11. `[]` token_quote_program -/// 12. `[writable, optional]` referral_token_account -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SwapBuilder { - pool_authority: Option, - config: Option, - pool: Option, - input_token_account: Option, - output_token_account: Option, - base_vault: Option, - quote_vault: Option, - base_mint: Option, - quote_mint: Option, - payer: Option, - token_base_program: Option, - token_quote_program: Option, - referral_token_account: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl SwapBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - /// config key - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// The user token account for input token - #[inline(always)] - pub fn input_token_account(&mut self, input_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_account = Some(input_token_account); - self - } - - /// The user token account for output token - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_account = Some(output_token_account); - self - } - - /// The vault token account for base token - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The vault token account for quote token - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of base token - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - /// The mint of quote token - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// The user performing the swap - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// Token base program - #[inline(always)] - pub fn token_base_program(&mut self, token_base_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_base_program = Some(token_base_program); - self - } - - /// Token quote program - #[inline(always)] - pub fn token_quote_program(&mut self, token_quote_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_quote_program = Some(token_quote_program); - self - } - - /// `[optional account]` - /// referral token account - #[inline(always)] - pub fn referral_token_account( - &mut self, - referral_token_account: Option, - ) -> &mut Self { - self.referral_token_account = referral_token_account; - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: SwapParameters) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Swap { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - config: self.config.expect("config is not set"), - pool: self.pool.expect("pool is not set"), - input_token_account: self - .input_token_account - .expect("input_token_account is not set"), - output_token_account: self - .output_token_account - .expect("output_token_account is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - payer: self.payer.expect("payer is not set"), - token_base_program: self - .token_base_program - .expect("token_base_program is not set"), - token_quote_program: self - .token_quote_program - .expect("token_quote_program is not set"), - referral_token_account: self.referral_token_account, - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SwapInstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap` CPI accounts. -pub struct SwapCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// config key - pub config: &'b solana_account_info::AccountInfo<'a>, - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for input token - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for output token - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for base token - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for quote token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of base token - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Token base program - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - /// Token quote program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - /// referral token account - pub referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap` CPI instruction. -pub struct SwapCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - /// config key - pub config: &'b solana_account_info::AccountInfo<'a>, - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for input token - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for output token - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for base token - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for quote token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of base token - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Token base program - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - /// Token quote program - pub token_quote_program: &'b solana_account_info::AccountInfo<'a>, - /// referral token account - pub referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapInstructionArgs, -} - -impl<'a, 'b> SwapCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapCpiAccounts<'a, 'b>, - args: SwapInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - config: accounts.config, - pool: accounts.pool, - input_token_account: accounts.input_token_account, - output_token_account: accounts.output_token_account, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - payer: accounts.payer, - token_base_program: accounts.token_base_program, - token_quote_program: accounts.token_quote_program, - referral_token_account: accounts.referral_token_account, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_base_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_quote_program.key, - false, - )); - if let Some(referral_token_account) = self.referral_token_account { - accounts.push(solana_instruction::AccountMeta::new( - *referral_token_account.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::DYNAMIC_BONDING_CURVE_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.input_token_account.clone()); - account_infos.push(self.output_token_account.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_base_program.clone()); - account_infos.push(self.token_quote_program.clone()); - if let Some(referral_token_account) = self.referral_token_account { - account_infos.push(referral_token_account.clone()); - } - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Swap` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[]` config -/// 2. `[writable]` pool -/// 3. `[writable]` input_token_account -/// 4. `[writable]` output_token_account -/// 5. `[writable]` base_vault -/// 6. `[writable]` quote_vault -/// 7. `[]` base_mint -/// 8. `[]` quote_mint -/// 9. `[signer]` payer -/// 10. `[]` token_base_program -/// 11. `[]` token_quote_program -/// 12. `[writable, optional]` referral_token_account -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct SwapCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapCpiBuilderInstruction { - __program: program, - pool_authority: None, - config: None, - pool: None, - input_token_account: None, - output_token_account: None, - base_vault: None, - quote_vault: None, - base_mint: None, - quote_mint: None, - payer: None, - token_base_program: None, - token_quote_program: None, - referral_token_account: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - /// config key - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// The user token account for input token - #[inline(always)] - pub fn input_token_account( - &mut self, - input_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_account = Some(input_token_account); - self - } - - /// The user token account for output token - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_account = Some(output_token_account); - self - } - - /// The vault token account for base token - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The vault token account for quote token - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of base token - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - /// The mint of quote token - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// The user performing the swap - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Token base program - #[inline(always)] - pub fn token_base_program( - &mut self, - token_base_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_base_program = Some(token_base_program); - self - } - - /// Token quote program - #[inline(always)] - pub fn token_quote_program( - &mut self, - token_quote_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_quote_program = Some(token_quote_program); - self - } - - /// `[optional account]` - /// referral token account - #[inline(always)] - pub fn referral_token_account( - &mut self, - referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.referral_token_account = referral_token_account; - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: SwapParameters) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapInstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = SwapCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - input_token_account: self - .instruction - .input_token_account - .expect("input_token_account is not set"), - - output_token_account: self - .instruction - .output_token_account - .expect("output_token_account is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_base_program: self - .instruction - .token_base_program - .expect("token_base_program is not set"), - - token_quote_program: self - .instruction - .token_quote_program - .expect("token_quote_program is not set"), - - referral_token_account: self.instruction.referral_token_account, - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_base_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_quote_program: Option<&'b solana_account_info::AccountInfo<'a>>, - referral_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/instructions/withdraw_leftover.rs b/crates/meteora-dbc-parser/src/generated_sdk/instructions/withdraw_leftover.rs deleted file mode 100644 index f0ad2e00..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/instructions/withdraw_leftover.rs +++ /dev/null @@ -1,654 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct WithdrawLeftover { - pub pool_authority: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub virtual_pool: solana_pubkey::Pubkey, - /// The receiver token account, withdraw to ATA - pub token_base_account: solana_pubkey::Pubkey, - /// The vault token account for output token - pub base_vault: solana_pubkey::Pubkey, - /// The mint of quote token - pub base_mint: solana_pubkey::Pubkey, - - pub leftover_receiver: solana_pubkey::Pubkey, - /// Token base program - pub token_base_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl WithdrawLeftover { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtual_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_base_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.leftover_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_base_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&WithdrawLeftoverInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawLeftoverInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawLeftoverInstructionData { - pub fn new() -> Self { - Self { - discriminator: [20, 198, 202, 237, 235, 243, 183, 66], - } - } -} - -impl Default for WithdrawLeftoverInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `WithdrawLeftover`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` pool_authority (default to `FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM`) -/// 1. `[]` config -/// 2. `[writable]` virtual_pool -/// 3. `[writable]` token_base_account -/// 4. `[writable]` base_vault -/// 5. `[]` base_mint -/// 6. `[]` leftover_receiver -/// 7. `[]` token_base_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct WithdrawLeftoverBuilder { - pool_authority: Option, - config: Option, - virtual_pool: Option, - token_base_account: Option, - base_vault: Option, - base_mint: Option, - leftover_receiver: Option, - token_base_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl WithdrawLeftoverBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM']` - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn virtual_pool(&mut self, virtual_pool: solana_pubkey::Pubkey) -> &mut Self { - self.virtual_pool = Some(virtual_pool); - self - } - - /// The receiver token account, withdraw to ATA - #[inline(always)] - pub fn token_base_account(&mut self, token_base_account: solana_pubkey::Pubkey) -> &mut Self { - self.token_base_account = Some(token_base_account); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The mint of quote token - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn leftover_receiver(&mut self, leftover_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.leftover_receiver = Some(leftover_receiver); - self - } - - /// Token base program - #[inline(always)] - pub fn token_base_program(&mut self, token_base_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_base_program = Some(token_base_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = WithdrawLeftover { - pool_authority: self.pool_authority.unwrap_or(solana_pubkey::pubkey!( - "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" - )), - config: self.config.expect("config is not set"), - virtual_pool: self.virtual_pool.expect("virtual_pool is not set"), - token_base_account: self - .token_base_account - .expect("token_base_account is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - leftover_receiver: self - .leftover_receiver - .expect("leftover_receiver is not set"), - token_base_program: self - .token_base_program - .expect("token_base_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `withdraw_leftover` CPI accounts. -pub struct WithdrawLeftoverCpiAccounts<'a, 'b> { - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// The receiver token account, withdraw to ATA - pub token_base_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub leftover_receiver: &'b solana_account_info::AccountInfo<'a>, - /// Token base program - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw_leftover` CPI instruction. -pub struct WithdrawLeftoverCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub virtual_pool: &'b solana_account_info::AccountInfo<'a>, - /// The receiver token account, withdraw to ATA - pub token_base_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub leftover_receiver: &'b solana_account_info::AccountInfo<'a>, - /// Token base program - pub token_base_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> WithdrawLeftoverCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawLeftoverCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool_authority: accounts.pool_authority, - config: accounts.config, - virtual_pool: accounts.virtual_pool, - token_base_account: accounts.token_base_account, - base_vault: accounts.base_vault, - base_mint: accounts.base_mint, - leftover_receiver: accounts.leftover_receiver, - token_base_program: accounts.token_base_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtual_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_base_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.leftover_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_base_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&WithdrawLeftoverInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::DYNAMIC_BONDING_CURVE_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.virtual_pool.clone()); - account_infos.push(self.token_base_account.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.leftover_receiver.clone()); - account_infos.push(self.token_base_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `WithdrawLeftover` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool_authority -/// 1. `[]` config -/// 2. `[writable]` virtual_pool -/// 3. `[writable]` token_base_account -/// 4. `[writable]` base_vault -/// 5. `[]` base_mint -/// 6. `[]` leftover_receiver -/// 7. `[]` token_base_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct WithdrawLeftoverCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawLeftoverCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawLeftoverCpiBuilderInstruction { - __program: program, - pool_authority: None, - config: None, - virtual_pool: None, - token_base_account: None, - base_vault: None, - base_mint: None, - leftover_receiver: None, - token_base_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn virtual_pool( - &mut self, - virtual_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtual_pool = Some(virtual_pool); - self - } - - /// The receiver token account, withdraw to ATA - #[inline(always)] - pub fn token_base_account( - &mut self, - token_base_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_base_account = Some(token_base_account); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The mint of quote token - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn leftover_receiver( - &mut self, - leftover_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.leftover_receiver = Some(leftover_receiver); - self - } - - /// Token base program - #[inline(always)] - pub fn token_base_program( - &mut self, - token_base_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_base_program = Some(token_base_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = WithdrawLeftoverCpi { - __program: self.instruction.__program, - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - config: self.instruction.config.expect("config is not set"), - - virtual_pool: self - .instruction - .virtual_pool - .expect("virtual_pool is not set"), - - token_base_account: self - .instruction - .token_base_account - .expect("token_base_account is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - leftover_receiver: self - .instruction - .leftover_receiver - .expect("leftover_receiver is not set"), - - token_base_program: self - .instruction - .token_base_program - .expect("token_base_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawLeftoverCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - virtual_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_base_account: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - leftover_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - token_base_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/mod.rs b/crates/meteora-dbc-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/meteora-dbc-parser/src/generated_sdk/programs.rs b/crates/meteora-dbc-parser/src/generated_sdk/programs.rs deleted file mode 100644 index c78a6290..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `dynamic_bonding_curve` program ID. -pub const DYNAMIC_BONDING_CURVE_ID: Pubkey = pubkey!("dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN"); diff --git a/crates/meteora-dbc-parser/src/generated_sdk/shared.rs b/crates/meteora-dbc-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/base_fee_config.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/base_fee_config.rs deleted file mode 100644 index f9a7969f..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/base_fee_config.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BaseFeeConfig { - pub cliff_fee_numerator: u64, - pub period_frequency: u64, - pub reduction_factor: u64, - pub number_of_period: u16, - pub fee_scheduler_mode: u8, - pub padding0: [u8; 5], -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/base_fee_parameters.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/base_fee_parameters.rs deleted file mode 100644 index d3f558eb..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/base_fee_parameters.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BaseFeeParameters { - pub cliff_fee_numerator: u64, - pub number_of_period: u16, - pub period_frequency: u64, - pub reduction_factor: u64, - pub fee_scheduler_mode: u8, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/dynamic_fee_config.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/dynamic_fee_config.rs deleted file mode 100644 index bb2fe3ca..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/dynamic_fee_config.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DynamicFeeConfig { - pub initialized: u8, - pub padding: [u8; 7], - pub max_volatility_accumulator: u32, - pub variable_fee_control: u32, - pub bin_step: u16, - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub padding2: [u8; 8], - pub bin_step_u128: u128, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/dynamic_fee_parameters.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/dynamic_fee_parameters.rs deleted file mode 100644 index 35fc67cd..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/dynamic_fee_parameters.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DynamicFeeParameters { - pub bin_step: u16, - pub bin_step_u128: u128, - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub max_volatility_accumulator: u32, - pub variable_fee_control: u32, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_claim_creator_trading_fee.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_claim_creator_trading_fee.rs deleted file mode 100644 index 30b7fb75..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_claim_creator_trading_fee.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtClaimCreatorTradingFee { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub token_base_amount: u64, - pub token_quote_amount: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_claim_protocol_fee.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_claim_protocol_fee.rs deleted file mode 100644 index a353df0c..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_claim_protocol_fee.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtClaimProtocolFee { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub token_base_amount: u64, - pub token_quote_amount: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_claim_trading_fee.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_claim_trading_fee.rs deleted file mode 100644 index 4edf8d45..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_claim_trading_fee.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtClaimTradingFee { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub token_base_amount: u64, - pub token_quote_amount: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_close_claim_fee_operator.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_close_claim_fee_operator.rs deleted file mode 100644 index 68f06abb..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_close_claim_fee_operator.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Close claim fee operator -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCloseClaimFeeOperator { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub claim_fee_operator: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub operator: Pubkey, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_claim_fee_operator.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_claim_fee_operator.rs deleted file mode 100644 index 89636344..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_claim_fee_operator.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Create claim fee operator -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCreateClaimFeeOperator { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub operator: Pubkey, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_config.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_config.rs deleted file mode 100644 index 22522a07..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_config.rs +++ /dev/null @@ -1,59 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{ - LiquidityDistributionParameters, LockedVestingParams, PoolFeeParameters, -}; - -/// Create config -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCreateConfig { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub quote_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_claimer: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - pub pool_fees: PoolFeeParameters, - pub collect_fee_mode: u8, - pub migration_option: u8, - pub activation_type: u8, - pub token_decimal: u8, - pub token_type: u8, - pub partner_locked_lp_percentage: u8, - pub partner_lp_percentage: u8, - pub creator_locked_lp_percentage: u8, - pub creator_lp_percentage: u8, - pub swap_base_amount: u64, - pub migration_quote_threshold: u64, - pub migration_base_amount: u64, - pub sqrt_start_price: u128, - pub locked_vesting: LockedVestingParams, - pub migration_fee_option: u8, - pub fixed_token_supply_flag: u8, - pub pre_migration_token_supply: u64, - pub post_migration_token_supply: u64, - pub curve: Vec, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_damm_v2_migration_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_damm_v2_migration_metadata.rs deleted file mode 100644 index bd4802e2..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_damm_v2_migration_metadata.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCreateDammV2MigrationMetadata { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub virtual_pool: Pubkey, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_meteora_migration_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_meteora_migration_metadata.rs deleted file mode 100644 index 7ce7f753..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_create_meteora_migration_metadata.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCreateMeteoraMigrationMetadata { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub virtual_pool: Pubkey, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_creator_withdraw_surplus.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_creator_withdraw_surplus.rs deleted file mode 100644 index 7b90e6fa..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_creator_withdraw_surplus.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCreatorWithdrawSurplus { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub surplus_amount: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_curve_complete.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_curve_complete.rs deleted file mode 100644 index 3f53db2d..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_curve_complete.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtCurveComplete { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config: Pubkey, - pub base_reserve: u64, - pub quote_reserve: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_initialize_pool.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_initialize_pool.rs deleted file mode 100644 index 01409c96..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_initialize_pool.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtInitializePool { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base_mint: Pubkey, - pub pool_type: u8, - pub activation_point: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_partner_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_partner_metadata.rs deleted file mode 100644 index 0bf0fcf4..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_partner_metadata.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Create partner metadata -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtPartnerMetadata { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub partner_metadata: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_claimer: Pubkey, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_partner_withdraw_surplus.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_partner_withdraw_surplus.rs deleted file mode 100644 index 4bcc7e20..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_partner_withdraw_surplus.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtPartnerWithdrawSurplus { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub surplus_amount: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_protocol_withdraw_surplus.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_protocol_withdraw_surplus.rs deleted file mode 100644 index 9d4b6607..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_protocol_withdraw_surplus.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtProtocolWithdrawSurplus { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - pub surplus_amount: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_swap.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_swap.rs deleted file mode 100644 index e35a828a..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_swap.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{SwapParameters, SwapResult}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtSwap { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config: Pubkey, - pub trade_direction: u8, - pub has_referral: bool, - pub params: SwapParameters, - pub swap_result: SwapResult, - pub amount_in: u64, - pub current_timestamp: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_virtual_pool_metadata.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_virtual_pool_metadata.rs deleted file mode 100644 index 69640545..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_virtual_pool_metadata.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Create virtual pool metadata -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtVirtualPoolMetadata { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub virtual_pool_metadata: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub virtual_pool: Pubkey, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_withdraw_leftover.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/evt_withdraw_leftover.rs deleted file mode 100644 index 6c2e3b72..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/evt_withdraw_leftover.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EvtWithdrawLeftover { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub leftover_receiver: Pubkey, - pub leftover_amount: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/initialize_pool_parameters.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/initialize_pool_parameters.rs deleted file mode 100644 index 16a9373c..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/initialize_pool_parameters.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolParameters { - pub name: String, - pub symbol: String, - pub uri: String, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/liquidity_distribution_config.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/liquidity_distribution_config.rs deleted file mode 100644 index 752abf7f..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/liquidity_distribution_config.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LiquidityDistributionConfig { - pub sqrt_price: u128, - pub liquidity: u128, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/liquidity_distribution_parameters.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/liquidity_distribution_parameters.rs deleted file mode 100644 index 2fa25e99..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/liquidity_distribution_parameters.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LiquidityDistributionParameters { - pub sqrt_price: u128, - pub liquidity: u128, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/locked_vesting_config.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/locked_vesting_config.rs deleted file mode 100644 index 3be9b1f8..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/locked_vesting_config.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockedVestingConfig { - pub amount_per_period: u64, - pub cliff_duration_from_migration_time: u64, - pub frequency: u64, - pub number_of_period: u64, - pub cliff_unlock_amount: u64, - pub padding: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/locked_vesting_params.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/locked_vesting_params.rs deleted file mode 100644 index bffa9161..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/locked_vesting_params.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockedVestingParams { - pub amount_per_period: u64, - pub cliff_duration_from_migration_time: u64, - pub frequency: u64, - pub number_of_period: u64, - pub cliff_unlock_amount: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/mod.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index c89a4e09..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,57 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#base_fee_config; -pub(crate) mod r#base_fee_parameters; -pub(crate) mod r#dynamic_fee_config; -pub(crate) mod r#dynamic_fee_parameters; -pub(crate) mod r#evt_claim_creator_trading_fee; -pub(crate) mod r#evt_claim_protocol_fee; -pub(crate) mod r#evt_claim_trading_fee; -pub(crate) mod r#evt_close_claim_fee_operator; -pub(crate) mod r#evt_create_claim_fee_operator; -pub(crate) mod r#evt_create_config; -pub(crate) mod r#evt_create_damm_v2_migration_metadata; -pub(crate) mod r#evt_create_meteora_migration_metadata; -pub(crate) mod r#evt_creator_withdraw_surplus; -pub(crate) mod r#evt_curve_complete; -pub(crate) mod r#evt_initialize_pool; -pub(crate) mod r#evt_partner_metadata; -pub(crate) mod r#evt_partner_withdraw_surplus; -pub(crate) mod r#evt_protocol_withdraw_surplus; -pub(crate) mod r#evt_swap; -pub(crate) mod r#evt_virtual_pool_metadata; -pub(crate) mod r#evt_withdraw_leftover; -pub(crate) mod r#initialize_pool_parameters; -pub(crate) mod r#liquidity_distribution_config; -pub(crate) mod r#liquidity_distribution_parameters; -pub(crate) mod r#locked_vesting_config; -pub(crate) mod r#locked_vesting_params; -pub(crate) mod r#pool_fee_parameters; -pub(crate) mod r#pool_fees; -pub(crate) mod r#pool_fees_config; -pub(crate) mod r#pool_metrics; -pub(crate) mod r#swap_parameters; -pub(crate) mod r#swap_result; -pub(crate) mod r#token_supply_params; -pub(crate) mod r#volatility_tracker; - -pub use self::{ - r#base_fee_config::*, r#base_fee_parameters::*, r#dynamic_fee_config::*, - r#dynamic_fee_parameters::*, r#evt_claim_creator_trading_fee::*, r#evt_claim_protocol_fee::*, - r#evt_claim_trading_fee::*, r#evt_close_claim_fee_operator::*, - r#evt_create_claim_fee_operator::*, r#evt_create_config::*, - r#evt_create_damm_v2_migration_metadata::*, r#evt_create_meteora_migration_metadata::*, - r#evt_creator_withdraw_surplus::*, r#evt_curve_complete::*, r#evt_initialize_pool::*, - r#evt_partner_metadata::*, r#evt_partner_withdraw_surplus::*, - r#evt_protocol_withdraw_surplus::*, r#evt_swap::*, r#evt_virtual_pool_metadata::*, - r#evt_withdraw_leftover::*, r#initialize_pool_parameters::*, - r#liquidity_distribution_config::*, r#liquidity_distribution_parameters::*, - r#locked_vesting_config::*, r#locked_vesting_params::*, r#pool_fee_parameters::*, - r#pool_fees::*, r#pool_fees_config::*, r#pool_metrics::*, r#swap_parameters::*, - r#swap_result::*, r#token_supply_params::*, r#volatility_tracker::*, -}; diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/pool_fee_parameters.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/pool_fee_parameters.rs deleted file mode 100644 index 5a720d60..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/pool_fee_parameters.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{BaseFeeParameters, DynamicFeeParameters}; - -/// Information regarding fee charges -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolFeeParameters { - /// Base fee - pub base_fee: BaseFeeParameters, - /// dynamic fee - pub dynamic_fee: Option, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/pool_fees.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/pool_fees.rs deleted file mode 100644 index d05dbe73..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/pool_fees.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Information regarding fee charges -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolFees { - pub trade_fee_numerator: u64, - pub trade_fee_denominator: u64, - pub protocol_trade_fee_numerator: u64, - pub protocol_trade_fee_denominator: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/pool_fees_config.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/pool_fees_config.rs deleted file mode 100644 index f69d089b..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/pool_fees_config.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{BaseFeeConfig, DynamicFeeConfig}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolFeesConfig { - pub base_fee: BaseFeeConfig, - pub dynamic_fee: DynamicFeeConfig, - pub padding0: [u64; 5], - pub padding1: [u8; 6], - pub protocol_fee_percent: u8, - pub referral_fee_percent: u8, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/pool_metrics.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/pool_metrics.rs deleted file mode 100644 index 8bb396eb..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/pool_metrics.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolMetrics { - pub total_protocol_base_fee: u64, - pub total_protocol_quote_fee: u64, - pub total_trading_base_fee: u64, - pub total_trading_quote_fee: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/swap_parameters.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/swap_parameters.rs deleted file mode 100644 index cbd11f27..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/swap_parameters.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapParameters { - pub amount_in: u64, - pub minimum_amount_out: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/swap_result.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/swap_result.rs deleted file mode 100644 index 90e1998c..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/swap_result.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Encodes all results of swapping -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapResult { - pub actual_input_amount: u64, - pub output_amount: u64, - pub next_sqrt_price: u128, - pub trading_fee: u64, - pub protocol_fee: u64, - pub referral_fee: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/token_supply_params.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/token_supply_params.rs deleted file mode 100644 index c7f5f5bd..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/token_supply_params.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenSupplyParams { - /// pre migration token supply - pub pre_migration_token_supply: u64, - /// post migration token supply - pub post_migration_token_supply: u64, -} diff --git a/crates/meteora-dbc-parser/src/generated_sdk/types/volatility_tracker.rs b/crates/meteora-dbc-parser/src/generated_sdk/types/volatility_tracker.rs deleted file mode 100644 index ecbe34d3..00000000 --- a/crates/meteora-dbc-parser/src/generated_sdk/types/volatility_tracker.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct VolatilityTracker { - pub last_update_timestamp: u64, - pub padding: [u8; 8], - pub sqrt_price_reference: u128, - pub volatility_accumulator: u128, - pub volatility_reference: u128, -} diff --git a/crates/meteora-dbc-parser/src/lib.rs b/crates/meteora-dbc-parser/src/lib.rs deleted file mode 100644 index dd08bc0f..00000000 --- a/crates/meteora-dbc-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = DYNAMIC_BONDING_CURVE_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.meteora_dbc"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/meteora-parser/Cargo.toml b/crates/meteora-parser/Cargo.toml deleted file mode 100644 index 142d9bc2..00000000 --- a/crates/meteora-parser/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "yellowstone-vixen-meteora-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Meteora program" -license.workspace = true -repository.workspace = true -authors.workspace = true - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info = { workspace = true } -solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction = { workspace = true } -solana-msg = { workspace = true } -solana-program-entrypoint = { workspace = true } -solana-program-error = { workspace = true } -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true \ No newline at end of file diff --git a/crates/meteora-parser/build.rs b/crates/meteora-parser/build.rs deleted file mode 100644 index fa683089..00000000 --- a/crates/meteora-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/meteora.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/meteora-parser/idl.json b/crates/meteora-parser/idl.json deleted file mode 100644 index dd114160..00000000 --- a/crates/meteora-parser/idl.json +++ /dev/null @@ -1,6919 +0,0 @@ -{ - "version": "0.9.0", - "name": "lb_clmm", - "metadata": { - "address": "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo" - }, - "constants": [ - { - "name": "BASIS_POINT_MAX", - "type": "i32", - "value": "10000" - }, - { - "name": "MAX_BIN_PER_ARRAY", - "type": { - "defined": "usize" - }, - "value": "70" - }, - { - "name": "MAX_BIN_PER_POSITION", - "type": { - "defined": "usize" - }, - "value": "70" - }, - { - "name": "MAX_RESIZE_LENGTH", - "type": { - "defined": "usize" - }, - "value": "70" - }, - { - "name": "POSITION_MAX_LENGTH", - "type": { - "defined": "usize" - }, - "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": "usize" - }, - "value": "2" - }, - { - "name": "MIN_REWARD_DURATION", - "type": "u64", - "value": "1" - }, - { - "name": "MAX_REWARD_DURATION", - "type": "u64", - "value": "31536000" - }, - { - "name": "EXTENSION_BINARRAY_BITMAP_SIZE", - "type": { - "defined": "usize" - }, - "value": "12" - }, - { - "name": "BIN_ARRAY_BITMAP_SIZE", - "type": "i32", - "value": "512" - }, - { - "name": "MAX_REWARD_BIN_SPLIT", - "type": { - "defined": "usize" - }, - "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]" - } - ], - "instructions": [ - { - "name": "initializeLbPair", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenMintX", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintY", - "isMut": false, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "presetParameter", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "activeId", - "type": "i32" - }, - { - "name": "binStep", - "type": "u16" - } - ] - }, - { - "name": "initializePermissionLbPair", - "accounts": [ - { - "name": "base", - "isMut": false, - "isSigner": true - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenMintX", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintY", - "isMut": false, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenBadgeX", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenBadgeY", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenProgramX", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramY", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "ixData", - "type": { - "defined": "InitPermissionPairIx" - } - } - ] - }, - { - "name": "initializeCustomizablePermissionlessLbPair", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenMintX", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintY", - "isMut": false, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenX", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": "CustomizableParams" - } - } - ] - }, - { - "name": "initializeBinArrayBitmapExtension", - "accounts": [ - { - "name": "lbPair", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "docs": ["Initialize an account to store if a bin array is initialized."] - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "initializeBinArray", - "accounts": [ - { - "name": "lbPair", - "isMut": false, - "isSigner": false - }, - { - "name": "binArray", - "isMut": true, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "index", - "type": "i64" - } - ] - }, - { - "name": "addLiquidity", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": "LiquidityParameter" - } - } - ] - }, - { - "name": "addLiquidityByWeight", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": "LiquidityParameterByWeight" - } - } - ] - }, - { - "name": "addLiquidityByStrategy", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": "LiquidityParameterByStrategy" - } - } - ] - }, - { - "name": "addLiquidityByStrategyOneSide", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userToken", - "isMut": true, - "isSigner": false - }, - { - "name": "reserve", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": "LiquidityParameterByStrategyOneSide" - } - } - ] - }, - { - "name": "addLiquidityOneSide", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userToken", - "isMut": true, - "isSigner": false - }, - { - "name": "reserve", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": "LiquidityOneSideParameter" - } - } - ] - }, - { - "name": "removeLiquidity", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "binLiquidityRemoval", - "type": { - "vec": { - "defined": "BinLiquidityReduction" - } - } - } - ] - }, - { - "name": "initializePosition", - "accounts": [ - { - "name": "payer", - "isMut": true, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": true - }, - { - "name": "lbPair", - "isMut": false, - "isSigner": false - }, - { - "name": "owner", - "isMut": false, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "lowerBinId", - "type": "i32" - }, - { - "name": "width", - "type": "i32" - } - ] - }, - { - "name": "initializePositionPda", - "accounts": [ - { - "name": "payer", - "isMut": true, - "isSigner": true - }, - { - "name": "base", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": false, - "isSigner": false - }, - { - "name": "owner", - "isMut": false, - "isSigner": true, - "docs": ["owner"] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "lowerBinId", - "type": "i32" - }, - { - "name": "width", - "type": "i32" - } - ] - }, - { - "name": "initializePositionByOperator", - "accounts": [ - { - "name": "payer", - "isMut": true, - "isSigner": true - }, - { - "name": "base", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": false, - "isSigner": false - }, - { - "name": "owner", - "isMut": false, - "isSigner": false - }, - { - "name": "operator", - "isMut": false, - "isSigner": true, - "docs": ["operator"] - }, - { - "name": "operatorTokenX", - "isMut": false, - "isSigner": false - }, - { - "name": "ownerTokenX", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "lowerBinId", - "type": "i32" - }, - { - "name": "width", - "type": "i32" - }, - { - "name": "feeOwner", - "type": "publicKey" - }, - { - "name": "lockReleasePoint", - "type": "u64" - } - ] - }, - { - "name": "updatePositionOperator", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "owner", - "isMut": false, - "isSigner": true - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "operator", - "type": "publicKey" - } - ] - }, - { - "name": "swap", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenIn", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenOut", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "hostFeeIn", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "user", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amountIn", - "type": "u64" - }, - { - "name": "minAmountOut", - "type": "u64" - } - ] - }, - { - "name": "swapExactOut", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenIn", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenOut", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "hostFeeIn", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "user", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "maxInAmount", - "type": "u64" - }, - { - "name": "outAmount", - "type": "u64" - } - ] - }, - { - "name": "swapWithPriceImpact", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenIn", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenOut", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "hostFeeIn", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "user", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amountIn", - "type": "u64" - }, - { - "name": "activeId", - "type": { - "option": "i32" - } - }, - { - "name": "maxPriceImpactBps", - "type": "u16" - } - ] - }, - { - "name": "withdrawProtocolFee", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "receiverTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "receiverTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "claimFeeOperator", - "isMut": false, - "isSigner": false - }, - { - "name": "operator", - "isMut": false, - "isSigner": true, - "docs": ["operator"] - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amountX", - "type": "u64" - }, - { - "name": "amountY", - "type": "u64" - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "initializeReward", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardVault", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenBadge", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u64" - }, - { - "name": "rewardDuration", - "type": "u64" - }, - { - "name": "funder", - "type": "publicKey" - } - ] - }, - { - "name": "fundReward", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardVault", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardMint", - "isMut": false, - "isSigner": false - }, - { - "name": "funderTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "funder", - "isMut": false, - "isSigner": true - }, - { - "name": "binArray", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u64" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "carryForward", - "type": "bool" - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "updateRewardFunder", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": false, - "isSigner": true - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u64" - }, - { - "name": "newFunder", - "type": "publicKey" - } - ] - }, - { - "name": "updateRewardDuration", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": false, - "isSigner": true - }, - { - "name": "binArray", - "isMut": true, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u64" - }, - { - "name": "newDuration", - "type": "u64" - } - ] - }, - { - "name": "claimReward", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "rewardVault", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardMint", - "isMut": false, - "isSigner": false - }, - { - "name": "userTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u64" - } - ] - }, - { - "name": "claimFee", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "closePosition", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "rentReceiver", - "isMut": true, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "updateBaseFeeParameters", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": false, - "isSigner": true - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "feeParameter", - "type": { - "defined": "BaseFeeParameter" - } - } - ] - }, - { - "name": "updateDynamicFeeParameters", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": false, - "isSigner": true - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "feeParameter", - "type": { - "defined": "DynamicFeeParameter" - } - } - ] - }, - { - "name": "increaseOracleLength", - "accounts": [ - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "lengthToAdd", - "type": "u64" - } - ] - }, - { - "name": "initializePresetParameter", - "accounts": [ - { - "name": "presetParameter", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "ix", - "type": { - "defined": "InitPresetParametersIx" - } - } - ] - }, - { - "name": "closePresetParameter", - "accounts": [ - { - "name": "presetParameter", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "rentReceiver", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "closePresetParameter2", - "accounts": [ - { - "name": "presetParameter", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "rentReceiver", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "removeAllLiquidity", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "setPairStatus", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "status", - "type": "u8" - } - ] - }, - { - "name": "migratePosition", - "accounts": [ - { - "name": "positionV2", - "isMut": true, - "isSigner": true - }, - { - "name": "positionV1", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "owner", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rentReceiver", - "isMut": true, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "migrateBinArray", - "accounts": [ - { - "name": "lbPair", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "updateFeesAndRewards", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "owner", - "isMut": false, - "isSigner": true - } - ], - "args": [] - }, - { - "name": "withdrawIneligibleReward", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardVault", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardMint", - "isMut": false, - "isSigner": false - }, - { - "name": "funderTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "funder", - "isMut": false, - "isSigner": true - }, - { - "name": "binArray", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u64" - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "setActivationPoint", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": true, - "isSigner": true - } - ], - "args": [ - { - "name": "activationPoint", - "type": "u64" - } - ] - }, - { - "name": "removeLiquidityByRange", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "fromBinId", - "type": "i32" - }, - { - "name": "toBinId", - "type": "i32" - }, - { - "name": "bpsToRemove", - "type": "u16" - } - ] - }, - { - "name": "addLiquidityOneSidePrecise", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userToken", - "isMut": true, - "isSigner": false - }, - { - "name": "reserve", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "binArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "parameter", - "type": { - "defined": "AddLiquiditySingleSidePreciseParameter" - } - } - ] - }, - { - "name": "goToABin", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "fromBinArray", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "toBinArray", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "binId", - "type": "i32" - } - ] - }, - { - "name": "setPreActivationDuration", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "creator", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "preActivationDuration", - "type": "u64" - } - ] - }, - { - "name": "setPreActivationSwapAddress", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "creator", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "preActivationSwapAddress", - "type": "publicKey" - } - ] - }, - { - "name": "setPairStatusPermissionless", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "creator", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "status", - "type": "u8" - } - ] - }, - { - "name": "initializeTokenBadge", - "accounts": [ - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenBadge", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "createClaimProtocolFeeOperator", - "accounts": [ - { - "name": "claimFeeOperator", - "isMut": true, - "isSigner": false - }, - { - "name": "operator", - "isMut": false, - "isSigner": false - }, - { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "closeClaimProtocolFeeOperator", - "accounts": [ - { - "name": "claimFeeOperator", - "isMut": true, - "isSigner": false - }, - { - "name": "rentReceiver", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": false, - "isSigner": true - } - ], - "args": [] - }, - { - "name": "initializePresetParameter2", - "accounts": [ - { - "name": "presetParameter", - "isMut": true, - "isSigner": false - }, - { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "ix", - "type": { - "defined": "InitPresetParameters2Ix" - } - } - ] - }, - { - "name": "initializeLbPair2", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenMintX", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintY", - "isMut": false, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "presetParameter", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenBadgeX", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenBadgeY", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenProgramX", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramY", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": "InitializeLbPair2Params" - } - } - ] - }, - { - "name": "initializeCustomizablePermissionlessLbPair2", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenMintX", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintY", - "isMut": false, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenX", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenBadgeX", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenBadgeY", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "tokenProgramX", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramY", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": "CustomizableParams" - } - } - ] - }, - { - "name": "claimFee2", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramX", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramY", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "minBinId", - "type": "i32" - }, - { - "name": "maxBinId", - "type": "i32" - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "claimReward2", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "rewardVault", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardMint", - "isMut": false, - "isSigner": false - }, - { - "name": "userTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u64" - }, - { - "name": "minBinId", - "type": "i32" - }, - { - "name": "maxBinId", - "type": "i32" - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "addLiquidity2", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": "LiquidityParameter" - } - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "addLiquidityByStrategy2", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": "LiquidityParameterByStrategy" - } - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "addLiquidityOneSidePrecise2", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userToken", - "isMut": true, - "isSigner": false - }, - { - "name": "reserve", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": "AddLiquiditySingleSidePreciseParameter2" - } - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "removeLiquidity2", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "binLiquidityRemoval", - "type": { - "vec": { - "defined": "BinLiquidityReduction" - } - } - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "removeLiquidityByRange2", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "userTokenX", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenY", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "fromBinId", - "type": "i32" - }, - { - "name": "toBinId", - "type": "i32" - }, - { - "name": "bpsToRemove", - "type": "u16" - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "swap2", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenIn", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenOut", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "hostFeeIn", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "user", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amountIn", - "type": "u64" - }, - { - "name": "minAmountOut", - "type": "u64" - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "swapExactOut2", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenIn", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenOut", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "hostFeeIn", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "user", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "maxInAmount", - "type": "u64" - }, - { - "name": "outAmount", - "type": "u64" - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "swapWithPriceImpact2", - "accounts": [ - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "binArrayBitmapExtension", - "isMut": false, - "isSigner": false, - "isOptional": true - }, - { - "name": "reserveX", - "isMut": true, - "isSigner": false - }, - { - "name": "reserveY", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenIn", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenOut", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenXMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYMint", - "isMut": false, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "hostFeeIn", - "isMut": true, - "isSigner": false, - "isOptional": true - }, - { - "name": "user", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenXProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenYProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amountIn", - "type": "u64" - }, - { - "name": "activeId", - "type": { - "option": "i32" - } - }, - { - "name": "maxPriceImpactBps", - "type": "u16" - }, - { - "name": "remainingAccountsInfo", - "type": { - "defined": "RemainingAccountsInfo" - } - } - ] - }, - { - "name": "closePosition2", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "rentReceiver", - "isMut": true, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "updateFeesAndReward2", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "lbPair", - "isMut": true, - "isSigner": false - }, - { - "name": "owner", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "minBinId", - "type": "i32" - }, - { - "name": "maxBinId", - "type": "i32" - } - ] - }, - { - "name": "closePositionIfEmpty", - "accounts": [ - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "sender", - "isMut": false, - "isSigner": true - }, - { - "name": "rentReceiver", - "isMut": true, - "isSigner": false - }, - { - "name": "eventAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "program", - "isMut": false, - "isSigner": false - } - ], - "args": [] - } - ], - "accounts": [ - { - "name": "BinArrayBitmapExtension", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lbPair", - "type": "publicKey" - }, - { - "name": "positiveBinArrayBitmap", - "docs": ["Packed initialized bin array state for start_bin_index is positive"], - "type": { - "array": [ - { - "array": ["u64", 8] - }, - 12 - ] - } - }, - { - "name": "negativeBinArrayBitmap", - "docs": ["Packed initialized bin array state for start_bin_index is negative"], - "type": { - "array": [ - { - "array": ["u64", 8] - }, - 12 - ] - } - } - ] - } - }, - { - "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": "lbPair", - "type": "publicKey" - }, - { - "name": "bins", - "type": { - "array": [ - { - "defined": "Bin" - }, - 70 - ] - } - } - ] - } - }, - { - "name": "ClaimFeeOperator", - "docs": ["Parameter that set by the protocol"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "operator", - "docs": ["operator"], - "type": "publicKey" - }, - { - "name": "padding", - "docs": ["Reserve"], - "type": { - "array": ["u8", 128] - } - } - ] - } - }, - { - "name": "LbPair", - "type": { - "kind": "struct", - "fields": [ - { - "name": "parameters", - "type": { - "defined": "StaticParameters" - } - }, - { - "name": "vParameters", - "type": { - "defined": "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": "publicKey" - }, - { - "name": "tokenYMint", - "docs": ["Token Y mint"], - "type": "publicKey" - }, - { - "name": "reserveX", - "docs": ["LB token X vault"], - "type": "publicKey" - }, - { - "name": "reserveY", - "docs": ["LB token Y vault"], - "type": "publicKey" - }, - { - "name": "protocolFee", - "docs": ["Uncollected protocol fee"], - "type": { - "defined": "ProtocolFee" - } - }, - { - "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": [ - { - "defined": "RewardInfo" - }, - 2 - ] - } - }, - { - "name": "oracle", - "docs": ["Oracle pubkey"], - "type": "publicKey" - }, - { - "name": "binArrayBitmap", - "docs": ["Packed initialized bin array state"], - "type": { - "array": ["u64", 16] - } - }, - { - "name": "lastUpdatedAt", - "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": "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": "publicKey" - }, - { - "name": "baseKey", - "docs": ["Base keypair. Only required for permission pair"], - "type": "publicKey" - }, - { - "name": "activationPoint", - "docs": ["Time point to enable the pair. Only applicable for permission pair."], - "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": "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": "publicKey" - }, - { - "name": "tokenMintXProgramFlag", - "docs": ["token_mint_x_program_flag"], - "type": "u8" - }, - { - "name": "tokenMintYProgramFlag", - "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": "activeSize", - "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": "lbPair", - "docs": ["The LB pair of this position"], - "type": "publicKey" - }, - { - "name": "owner", - "docs": ["Owner of the position. Client rely on this to to fetch their positions."], - "type": "publicKey" - }, - { - "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": "rewardInfos", - "docs": ["Farming reward information"], - "type": { - "array": [ - { - "defined": "UserRewardInfo" - }, - 70 - ] - } - }, - { - "name": "feeInfos", - "docs": ["Swap fee to claim information"], - "type": { - "array": [ - { - "defined": "FeeInfo" - }, - 70 - ] - } - }, - { - "name": "lowerBinId", - "docs": ["Lower bin ID"], - "type": "i32" - }, - { - "name": "upperBinId", - "docs": ["Upper bin ID"], - "type": "i32" - }, - { - "name": "lastUpdatedAt", - "docs": ["Last updated timestamp"], - "type": "i64" - }, - { - "name": "totalClaimedFeeXAmount", - "docs": ["Total claimed token fee X"], - "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": "publicKey" - }, - { - "name": "owner", - "docs": ["Owner of the position. Client rely on this to to fetch their positions."], - "type": "publicKey" - }, - { - "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": "rewardInfos", - "docs": ["Farming reward information"], - "type": { - "array": [ - { - "defined": "UserRewardInfo" - }, - 70 - ] - } - }, - { - "name": "feeInfos", - "docs": ["Swap fee to claim information"], - "type": { - "array": [ - { - "defined": "FeeInfo" - }, - 70 - ] - } - }, - { - "name": "lowerBinId", - "docs": ["Lower bin ID"], - "type": "i32" - }, - { - "name": "upperBinId", - "docs": ["Upper bin ID"], - "type": "i32" - }, - { - "name": "lastUpdatedAt", - "docs": ["Last updated timestamp"], - "type": "i64" - }, - { - "name": "totalClaimedFeeXAmount", - "docs": ["Total claimed token fee X"], - "type": "u64" - }, - { - "name": "totalClaimedFeeYAmount", - "docs": ["Total claimed token fee Y"], - "type": "u64" - }, - { - "name": "totalClaimedRewards", - "docs": ["Total claimed rewards"], - "type": { - "array": ["u64", 2] - } - }, - { - "name": "operator", - "docs": ["Operator of position"], - "type": "publicKey" - }, - { - "name": "lockReleasePoint", - "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": "feeOwner", - "docs": [ - "Address is able to claim fee in this position, only valid for bootstrap_liquidity_position" - ], - "type": "publicKey" - }, - { - "name": "reserved", - "docs": ["Reserved space for future use"], - "type": { - "array": ["u8", 87] - } - } - ] - } - }, - { - "name": "PresetParameter2", - "type": { - "kind": "struct", - "fields": [ - { - "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": "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": "reductionFactor", - "docs": ["Reduction factor controls the volatile fee rate decrement rate."], - "type": "u16" - }, - { - "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": "index", - "docs": ["index"], - "type": "u16" - }, - { - "name": "baseFeePowerFactor", - "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": "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" - }, - { - "name": "maxVolatilityAccumulator", - "docs": ["Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate."], - "type": "u32" - }, - { - "name": "minBinId", - "docs": ["Min bin id supported by the pool based on the configured bin step."], - "type": "i32" - }, - { - "name": "maxBinId", - "docs": ["Max 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": "TokenBadge", - "docs": ["Parameter that set by the protocol"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenMint", - "docs": ["token mint"], - "type": "publicKey" - }, - { - "name": "padding", - "docs": ["Reserve"], - "type": { - "array": ["u8", 128] - } - } - ] - } - } - ], - "types": [ - { - "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" - }, - { - "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": "InitPresetParametersIx", - "type": { - "kind": "struct", - "fields": [ - { - "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" - }, - { - "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": "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": "baseFactor", - "docs": ["Base factor for base fee rate"], - "type": "u16" - }, - { - "name": "baseFeePowerFactor", - "docs": ["Base fee power factor"], - "type": "u8" - } - ] - } - }, - { - "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": "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": "LiquidityParameterByStrategyOneSide", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "docs": ["Amount of X token or Y token to deposit"], - "type": "u64" - }, - { - "name": "activeId", - "docs": ["Active bin that integrator observe off-chain"], - "type": "i32" - }, - { - "name": "maxActiveBinSlippage", - "docs": ["max active bin slippage allowed"], - "type": "i32" - }, - { - "name": "strategyParameters", - "docs": ["strategy parameters"], - "type": { - "defined": "StrategyParameters" - } - } - ] - } - }, - { - "name": "LiquidityParameterByStrategy", - "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": "activeId", - "docs": ["Active bin that integrator observe off-chain"], - "type": "i32" - }, - { - "name": "maxActiveBinSlippage", - "docs": ["max active bin slippage allowed"], - "type": "i32" - }, - { - "name": "strategyParameters", - "docs": ["strategy parameters"], - "type": { - "defined": "StrategyParameters" - } - } - ] - } - }, - { - "name": "StrategyParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "minBinId", - "docs": ["min bin id"], - "type": "i32" - }, - { - "name": "maxBinId", - "docs": ["max bin id"], - "type": "i32" - }, - { - "name": "strategyType", - "docs": ["strategy type"], - "type": { - "defined": "StrategyType" - } - }, - { - "name": "parameteres", - "docs": ["parameters"], - "type": { - "array": ["u8", 64] - } - } - ] - } - }, - { - "name": "LiquidityOneSideParameter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "docs": ["Amount of X token or Y token to deposit"], - "type": "u64" - }, - { - "name": "activeId", - "docs": ["Active bin that integrator observe off-chain"], - "type": "i32" - }, - { - "name": "maxActiveBinSlippage", - "docs": ["max active bin slippage allowed"], - "type": "i32" - }, - { - "name": "binLiquidityDist", - "docs": ["Liquidity distribution to each bins"], - "type": { - "vec": { - "defined": "BinLiquidityDistributionByWeight" - } - } - } - ] - } - }, - { - "name": "BinLiquidityDistributionByWeight", - "type": { - "kind": "struct", - "fields": [ - { - "name": "binId", - "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": "LiquidityParameterByWeight", - "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": "activeId", - "docs": ["Active bin that integrator observe off-chain"], - "type": "i32" - }, - { - "name": "maxActiveBinSlippage", - "docs": ["max active bin slippage allowed"], - "type": "i32" - }, - { - "name": "binLiquidityDist", - "docs": ["Liquidity distribution to each bins"], - "type": { - "vec": { - "defined": "BinLiquidityDistributionByWeight" - } - } - } - ] - } - }, - { - "name": "AddLiquiditySingleSidePreciseParameter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bins", - "type": { - "vec": { - "defined": "CompressedBinDepositAmount" - } - } - }, - { - "name": "decompressMultiplier", - "type": "u64" - } - ] - } - }, - { - "name": "CompressedBinDepositAmount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "binId", - "type": "i32" - }, - { - "name": "amount", - "type": "u32" - } - ] - } - }, - { - "name": "BinLiquidityDistribution", - "type": { - "kind": "struct", - "fields": [ - { - "name": "binId", - "docs": ["Define the bin ID wish to deposit to."], - "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": "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": "BinLiquidityDistribution" - } - } - } - ] - } - }, - { - "name": "CustomizableParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "activeId", - "docs": ["Pool price"], - "type": "i32" - }, - { - "name": "binStep", - "docs": ["Bin step"], - "type": "u16" - }, - { - "name": "baseFactor", - "docs": ["Base factor"], - "type": "u16" - }, - { - "name": "activationType", - "docs": ["Activation type. 0 = Slot, 1 = Time. Check ActivationType enum"], - "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": "baseFeePowerFactor", - "docs": ["Base fee power factor"], - "type": "u8" - }, - { - "name": "padding", - "docs": ["Padding, for future use"], - "type": { - "array": ["u8", 62] - } - } - ] - } - }, - { - "name": "InitPermissionPairIx", - "type": { - "kind": "struct", - "fields": [ - { - "name": "activeId", - "type": "i32" - }, - { - "name": "binStep", - "type": "u16" - }, - { - "name": "baseFactor", - "type": "u16" - }, - { - "name": "baseFeePowerFactor", - "type": "u8" - }, - { - "name": "activationType", - "type": "u8" - }, - { - "name": "protocolShare", - "type": "u16" - } - ] - } - }, - { - "name": "AddLiquiditySingleSidePreciseParameter2", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bins", - "type": { - "vec": { - "defined": "CompressedBinDepositAmount" - } - } - }, - { - "name": "decompressMultiplier", - "type": "u64" - }, - { - "name": "maxAmount", - "type": "u64" - } - ] - } - }, - { - "name": "CompressedBinDepositAmount2", - "type": { - "kind": "struct", - "fields": [ - { - "name": "binId", - "type": "i32" - }, - { - "name": "amount", - "type": "u32" - } - ] - } - }, - { - "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": "BinLiquidityReduction", - "type": { - "kind": "struct", - "fields": [ - { - "name": "binId", - "type": "i32" - }, - { - "name": "bpsToRemove", - "type": "u16" - } - ] - } - }, - { - "name": "Bin", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amountX", - "docs": ["Amount of token X in the bin. This already excluded protocol fees."], - "type": "u64" - }, - { - "name": "amountY", - "docs": ["Amount of token Y in the bin. This already excluded protocol fees."], - "type": "u64" - }, - { - "name": "price", - "docs": ["Bin price"], - "type": "u128" - }, - { - "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": "ProtocolFee", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amountX", - "type": "u64" - }, - { - "name": "amountY", - "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": "publicKey" - }, - { - "name": "vault", - "docs": ["Reward vault token account."], - "type": "publicKey" - }, - { - "name": "funder", - "docs": ["Authority account that allows to fund rewards"], - "type": "publicKey" - }, - { - "name": "rewardDuration", - "docs": ["TODO check whether we need to store it in pool"], - "type": "u64" - }, - { - "name": "rewardDurationEnd", - "docs": ["TODO check whether we need to store it in pool"], - "type": "u64" - }, - { - "name": "rewardRate", - "docs": ["TODO check whether we need to store it in pool"], - "type": "u128" - }, - { - "name": "lastUpdateTime", - "docs": ["The last time reward states were updated."], - "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": "Observation", - "type": { - "kind": "struct", - "fields": [ - { - "name": "cumulativeActiveBinId", - "docs": ["Cumulative active bin ID"], - "type": "i128" - }, - { - "name": "createdAt", - "docs": ["Observation sample created timestamp"], - "type": "i64" - }, - { - "name": "lastUpdatedAt", - "docs": ["Observation sample last updated timestamp"], - "type": "i64" - } - ] - } - }, - { - "name": "StaticParameters", - "docs": ["Parameter that set by the protocol"], - "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": "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": "minBinId", - "docs": ["Min bin id supported by the pool based on the configured bin step."], - "type": "i32" - }, - { - "name": "maxBinId", - "docs": ["Max 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": "baseFeePowerFactor", - "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"], - "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": "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": "FeeInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "feeXPerTokenComplete", - "type": "u128" - }, - { - "name": "feeYPerTokenComplete", - "type": "u128" - }, - { - "name": "feeXPending", - "type": "u64" - }, - { - "name": "feeYPending", - "type": "u64" - } - ] - } - }, - { - "name": "UserRewardInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rewardPerTokenCompletes", - "type": { - "array": ["u128", 2] - } - }, - { - "name": "rewardPendings", - "type": { - "array": ["u64", 2] - } - } - ] - } - }, - { - "name": "RemainingAccountsSlice", - "type": { - "kind": "struct", - "fields": [ - { - "name": "accountsType", - "type": { - "defined": "AccountsType" - } - }, - { - "name": "length", - "type": "u8" - } - ] - } - }, - { - "name": "RemainingAccountsInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "slices", - "type": { - "vec": { - "defined": "RemainingAccountsSlice" - } - } - } - ] - } - }, - { - "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": "Rounding", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Up" - }, - { - "name": "Down" - } - ] - } - }, - { - "name": "ActivationType", - "docs": ["Type of the activation"], - "type": { - "kind": "enum", - "variants": [ - { - "name": "Slot" - }, - { - "name": "Timestamp" - } - ] - } - }, - { - "name": "LayoutVersion", - "docs": ["Layout version"], - "type": { - "kind": "enum", - "variants": [ - { - "name": "V0" - }, - { - "name": "V1" - } - ] - } - }, - { - "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" - } - ] - } - }, - { - "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": "TokenProgramFlags", - "type": { - "kind": "enum", - "variants": [ - { - "name": "TokenProgram" - }, - { - "name": "TokenProgram2022" - } - ] - } - }, - { - "name": "AccountsType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "TransferHookX" - }, - { - "name": "TransferHookY" - }, - { - "name": "TransferHookReward" - } - ] - } - } - ], - "events": [ - { - "name": "CompositionFee", - "fields": [ - { - "name": "from", - "type": "publicKey", - "index": false - }, - { - "name": "binId", - "type": "i16", - "index": false - }, - { - "name": "tokenXFeeAmount", - "type": "u64", - "index": false - }, - { - "name": "tokenYFeeAmount", - "type": "u64", - "index": false - }, - { - "name": "protocolTokenXFeeAmount", - "type": "u64", - "index": false - }, - { - "name": "protocolTokenYFeeAmount", - "type": "u64", - "index": false - } - ] - }, - { - "name": "AddLiquidity", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "from", - "type": "publicKey", - "index": false - }, - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "amounts", - "type": { - "array": ["u64", 2] - }, - "index": false - }, - { - "name": "activeBinId", - "type": "i32", - "index": false - } - ] - }, - { - "name": "RemoveLiquidity", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "from", - "type": "publicKey", - "index": false - }, - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "amounts", - "type": { - "array": ["u64", 2] - }, - "index": false - }, - { - "name": "activeBinId", - "type": "i32", - "index": false - } - ] - }, - { - "name": "Swap", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "from", - "type": "publicKey", - "index": false - }, - { - "name": "startBinId", - "type": "i32", - "index": false - }, - { - "name": "endBinId", - "type": "i32", - "index": false - }, - { - "name": "amountIn", - "type": "u64", - "index": false - }, - { - "name": "amountOut", - "type": "u64", - "index": false - }, - { - "name": "swapForY", - "type": "bool", - "index": false - }, - { - "name": "fee", - "type": "u64", - "index": false - }, - { - "name": "protocolFee", - "type": "u64", - "index": false - }, - { - "name": "feeBps", - "type": "u128", - "index": false - }, - { - "name": "hostFee", - "type": "u64", - "index": false - } - ] - }, - { - "name": "ClaimReward", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "owner", - "type": "publicKey", - "index": false - }, - { - "name": "rewardIndex", - "type": "u64", - "index": false - }, - { - "name": "totalReward", - "type": "u64", - "index": false - } - ] - }, - { - "name": "FundReward", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "funder", - "type": "publicKey", - "index": false - }, - { - "name": "rewardIndex", - "type": "u64", - "index": false - }, - { - "name": "amount", - "type": "u64", - "index": false - } - ] - }, - { - "name": "InitializeReward", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "rewardMint", - "type": "publicKey", - "index": false - }, - { - "name": "funder", - "type": "publicKey", - "index": false - }, - { - "name": "rewardIndex", - "type": "u64", - "index": false - }, - { - "name": "rewardDuration", - "type": "u64", - "index": false - } - ] - }, - { - "name": "UpdateRewardDuration", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "rewardIndex", - "type": "u64", - "index": false - }, - { - "name": "oldRewardDuration", - "type": "u64", - "index": false - }, - { - "name": "newRewardDuration", - "type": "u64", - "index": false - } - ] - }, - { - "name": "UpdateRewardFunder", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "rewardIndex", - "type": "u64", - "index": false - }, - { - "name": "oldFunder", - "type": "publicKey", - "index": false - }, - { - "name": "newFunder", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "PositionClose", - "fields": [ - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "owner", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "ClaimFee", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "owner", - "type": "publicKey", - "index": false - }, - { - "name": "feeX", - "type": "u64", - "index": false - }, - { - "name": "feeY", - "type": "u64", - "index": false - } - ] - }, - { - "name": "LbPairCreate", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "binStep", - "type": "u16", - "index": false - }, - { - "name": "tokenX", - "type": "publicKey", - "index": false - }, - { - "name": "tokenY", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "PositionCreate", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "owner", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "IncreasePositionLength", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "owner", - "type": "publicKey", - "index": false - }, - { - "name": "lengthToAdd", - "type": "u16", - "index": false - }, - { - "name": "side", - "type": "u8", - "index": false - } - ] - }, - { - "name": "DecreasePositionLength", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "owner", - "type": "publicKey", - "index": false - }, - { - "name": "lengthToRemove", - "type": "u16", - "index": false - }, - { - "name": "side", - "type": "u8", - "index": false - } - ] - }, - { - "name": "FeeParameterUpdate", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "protocolShare", - "type": "u16", - "index": false - }, - { - "name": "baseFactor", - "type": "u16", - "index": false - } - ] - }, - { - "name": "DynamicFeeParameterUpdate", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "filterPeriod", - "type": "u16", - "index": false - }, - { - "name": "decayPeriod", - "type": "u16", - "index": false - }, - { - "name": "reductionFactor", - "type": "u16", - "index": false - }, - { - "name": "variableFeeControl", - "type": "u32", - "index": false - }, - { - "name": "maxVolatilityAccumulator", - "type": "u32", - "index": false - } - ] - }, - { - "name": "IncreaseObservation", - "fields": [ - { - "name": "oracle", - "type": "publicKey", - "index": false - }, - { - "name": "newObservationLength", - "type": "u64", - "index": false - } - ] - }, - { - "name": "WithdrawIneligibleReward", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "rewardMint", - "type": "publicKey", - "index": false - }, - { - "name": "amount", - "type": "u64", - "index": false - } - ] - }, - { - "name": "UpdatePositionOperator", - "fields": [ - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "oldOperator", - "type": "publicKey", - "index": false - }, - { - "name": "newOperator", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "UpdatePositionLockReleasePoint", - "fields": [ - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "currentPoint", - "type": "u64", - "index": false - }, - { - "name": "newLockReleasePoint", - "type": "u64", - "index": false - }, - { - "name": "oldLockReleasePoint", - "type": "u64", - "index": false - }, - { - "name": "sender", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "GoToABin", - "fields": [ - { - "name": "lbPair", - "type": "publicKey", - "index": false - }, - { - "name": "fromBinId", - "type": "i32", - "index": false - }, - { - "name": "toBinId", - "type": "i32", - "index": false - } - ] - } - ], - "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" - } - ] -} diff --git a/crates/meteora-parser/proto/meteora.proto b/crates/meteora-parser/proto/meteora.proto deleted file mode 100644 index f937f354..00000000 --- a/crates/meteora-parser/proto/meteora.proto +++ /dev/null @@ -1,1818 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.meteora; - -message InitializeLbPairIx { - InitializeLbPairIxAccounts accounts = 1; - InitializeLbPairIxData data = 2; -} - -message InitializePermissionLbPairIx { - InitializePermissionLbPairIxAccounts accounts = 1; - InitializePermissionLbPairIxData data = 2; -} - -message InitializeCustomizablePermissionlessLbPairIx { - InitializeCustomizablePermissionlessLbPairIxAccounts accounts = 1; - InitializeCustomizablePermissionlessLbPairIxData data = 2; -} - -message InitializeBinArrayBitmapExtensionIx { - InitializeBinArrayBitmapExtensionIxAccounts accounts = 1; -} - -message InitializeBinArrayIx { - InitializeBinArrayIxAccounts accounts = 1; - InitializeBinArrayIxData data = 2; -} - -message AddLiquidityIx { - AddLiquidityIxAccounts accounts = 1; - AddLiquidityIxData data = 2; -} - -message AddLiquidityByWeightIx { - AddLiquidityByWeightIxAccounts accounts = 1; - AddLiquidityByWeightIxData data = 2; -} - -message AddLiquidityByStrategyIx { - AddLiquidityByStrategyIxAccounts accounts = 1; - AddLiquidityByStrategyIxData data = 2; -} - -message AddLiquidityByStrategyOneSideIx { - AddLiquidityByStrategyOneSideIxAccounts accounts = 1; - AddLiquidityByStrategyOneSideIxData data = 2; -} - -message AddLiquidityOneSideIx { - AddLiquidityOneSideIxAccounts accounts = 1; - AddLiquidityOneSideIxData data = 2; -} - -message RemoveLiquidityIx { - RemoveLiquidityIxAccounts accounts = 1; - RemoveLiquidityIxData data = 2; -} - -message InitializePositionIx { - InitializePositionIxAccounts accounts = 1; - InitializePositionIxData data = 2; -} - -message InitializePositionPdaIx { - InitializePositionPdaIxAccounts accounts = 1; - InitializePositionPdaIxData data = 2; -} - -message InitializePositionByOperatorIx { - InitializePositionByOperatorIxAccounts accounts = 1; - InitializePositionByOperatorIxData data = 2; -} - -message UpdatePositionOperatorIx { - UpdatePositionOperatorIxAccounts accounts = 1; - UpdatePositionOperatorIxData data = 2; -} - -message SwapIx { - SwapIxAccounts accounts = 1; - SwapIxData data = 2; -} - -message SwapExactOutIx { - SwapExactOutIxAccounts accounts = 1; - SwapExactOutIxData data = 2; -} - -message SwapWithPriceImpactIx { - SwapWithPriceImpactIxAccounts accounts = 1; - SwapWithPriceImpactIxData data = 2; -} - -message WithdrawProtocolFeeIx { - WithdrawProtocolFeeIxAccounts accounts = 1; - WithdrawProtocolFeeIxData data = 2; -} - -message InitializeRewardIx { - InitializeRewardIxAccounts accounts = 1; - InitializeRewardIxData data = 2; -} - -message FundRewardIx { - FundRewardIxAccounts accounts = 1; - FundRewardIxData data = 2; -} - -message UpdateRewardFunderIx { - UpdateRewardFunderIxAccounts accounts = 1; - UpdateRewardFunderIxData data = 2; -} - -message UpdateRewardDurationIx { - UpdateRewardDurationIxAccounts accounts = 1; - UpdateRewardDurationIxData data = 2; -} - -message ClaimRewardIx { - ClaimRewardIxAccounts accounts = 1; - ClaimRewardIxData data = 2; -} - -message ClaimFeeIx { - ClaimFeeIxAccounts accounts = 1; -} - -message ClosePositionIx { - ClosePositionIxAccounts accounts = 1; -} - -message UpdateBaseFeeParametersIx { - UpdateBaseFeeParametersIxAccounts accounts = 1; - UpdateBaseFeeParametersIxData data = 2; -} - -message UpdateDynamicFeeParametersIx { - UpdateDynamicFeeParametersIxAccounts accounts = 1; - UpdateDynamicFeeParametersIxData data = 2; -} - -message IncreaseOracleLengthIx { - IncreaseOracleLengthIxAccounts accounts = 1; - IncreaseOracleLengthIxData data = 2; -} - -message InitializePresetParameterIx { - InitializePresetParameterIxAccounts accounts = 1; - InitializePresetParameterIxData data = 2; -} - -message ClosePresetParameterIx { - ClosePresetParameterIxAccounts accounts = 1; -} - -message ClosePresetParameter2Ix { - ClosePresetParameter2IxAccounts accounts = 1; -} - -message RemoveAllLiquidityIx { - RemoveAllLiquidityIxAccounts accounts = 1; -} - -message SetPairStatusIx { - SetPairStatusIxAccounts accounts = 1; - SetPairStatusIxData data = 2; -} - -message MigratePositionIx { - MigratePositionIxAccounts accounts = 1; -} - -message MigrateBinArrayIx { - MigrateBinArrayIxAccounts accounts = 1; -} - -message UpdateFeesAndRewardsIx { - UpdateFeesAndRewardsIxAccounts accounts = 1; -} - -message WithdrawIneligibleRewardIx { - WithdrawIneligibleRewardIxAccounts accounts = 1; - WithdrawIneligibleRewardIxData data = 2; -} - -message SetActivationPointIx { - SetActivationPointIxAccounts accounts = 1; - SetActivationPointIxData data = 2; -} - -message RemoveLiquidityByRangeIx { - RemoveLiquidityByRangeIxAccounts accounts = 1; - RemoveLiquidityByRangeIxData data = 2; -} - -message AddLiquidityOneSidePreciseIx { - AddLiquidityOneSidePreciseIxAccounts accounts = 1; - AddLiquidityOneSidePreciseIxData data = 2; -} - -message GoToABinIx { - GoToABinIxAccounts accounts = 1; - GoToABinIxData data = 2; -} - -message SetPreActivationDurationIx { - SetPreActivationDurationIxAccounts accounts = 1; - SetPreActivationDurationIxData data = 2; -} - -message SetPreActivationSwapAddressIx { - SetPreActivationSwapAddressIxAccounts accounts = 1; - SetPreActivationSwapAddressIxData data = 2; -} - -message SetPairStatusPermissionlessIx { - SetPairStatusPermissionlessIxAccounts accounts = 1; - SetPairStatusPermissionlessIxData data = 2; -} - -message InitializeTokenBadgeIx { - InitializeTokenBadgeIxAccounts accounts = 1; -} - -message CreateClaimProtocolFeeOperatorIx { - CreateClaimProtocolFeeOperatorIxAccounts accounts = 1; -} - -message CloseClaimProtocolFeeOperatorIx { - CloseClaimProtocolFeeOperatorIxAccounts accounts = 1; -} - -message InitializePresetParameter2Ix { - InitializePresetParameter2IxAccounts accounts = 1; - InitializePresetParameter2IxData data = 2; -} - -message InitializeLbPair2Ix { - InitializeLbPair2IxAccounts accounts = 1; - InitializeLbPair2IxData data = 2; -} - -message InitializeCustomizablePermissionlessLbPair2Ix { - InitializeCustomizablePermissionlessLbPair2IxAccounts accounts = 1; - InitializeCustomizablePermissionlessLbPair2IxData data = 2; -} - -message ClaimFee2Ix { - ClaimFee2IxAccounts accounts = 1; - ClaimFee2IxData data = 2; -} - -message ClaimReward2Ix { - ClaimReward2IxAccounts accounts = 1; - ClaimReward2IxData data = 2; -} - -message AddLiquidity2Ix { - AddLiquidity2IxAccounts accounts = 1; - AddLiquidity2IxData data = 2; -} - -message AddLiquidityByStrategy2Ix { - AddLiquidityByStrategy2IxAccounts accounts = 1; - AddLiquidityByStrategy2IxData data = 2; -} - -message AddLiquidityOneSidePrecise2Ix { - AddLiquidityOneSidePrecise2IxAccounts accounts = 1; - AddLiquidityOneSidePrecise2IxData data = 2; -} - -message RemoveLiquidity2Ix { - RemoveLiquidity2IxAccounts accounts = 1; - RemoveLiquidity2IxData data = 2; -} - -message RemoveLiquidityByRange2Ix { - RemoveLiquidityByRange2IxAccounts accounts = 1; - RemoveLiquidityByRange2IxData data = 2; -} - -message Swap2Ix { - Swap2IxAccounts accounts = 1; - Swap2IxData data = 2; -} - -message SwapExactOut2Ix { - SwapExactOut2IxAccounts accounts = 1; - SwapExactOut2IxData data = 2; -} - -message SwapWithPriceImpact2Ix { - SwapWithPriceImpact2IxAccounts accounts = 1; - SwapWithPriceImpact2IxData data = 2; -} - -message ClosePosition2Ix { - ClosePosition2IxAccounts accounts = 1; -} - -message UpdateFeesAndReward2Ix { - UpdateFeesAndReward2IxAccounts accounts = 1; - UpdateFeesAndReward2IxData data = 2; -} - -message ClosePositionIfEmptyIx { - ClosePositionIfEmptyIxAccounts accounts = 1; -} - -message RepeatedUint64Row { - repeated uint64 rows = 1; -} - -message RepeatedUint32Row { - repeated uint32 rows = 1; -} - - -message LiquidityParameterByStrategy { - uint64 amount_x = 1; - uint64 amount_y = 2; - int32 active_id = 3; - int32 max_active_bin_slippage = 4; - StrategyParameters strategy_parameters = 5; -} - -message StrategyParameters { - int32 min_bin_id = 1; - int32 max_bin_id = 2; - StrategyType strategy_type = 3; - repeated uint32 parameteres = 4; -} - -message BinLiquidityDistributionByWeight { - int32 bin_id = 1; - uint32 weight = 2; -} - -message CompressedBinDepositAmount { - int32 bin_id = 1; - uint32 amount = 2; -} - -message BinLiquidityDistribution { - int32 bin_id = 1; - uint32 distribution_x = 2; - uint32 distribution_y = 3; -} - -message LiquidityParameter { - uint64 amount_x = 1; - uint64 amount_y = 2; - repeated BinLiquidityDistribution bin_liquidity_dist = 3; -} - -message CustomizableParams { - int32 active_id = 1; - uint32 bin_step = 2; - uint32 base_factor = 3; - uint32 activation_type = 4; - bool has_alpha_vault = 5; - optional uint64 activation_point = 6; - bool creator_pool_on_off_control = 7; - uint32 base_fee_power_factor = 8; - repeated uint32 padding = 9; -} - -message CompressedBinDepositAmount2 { - int32 bin_id = 1; - uint32 amount = 2; -} - -message BinLiquidityReduction { - int32 bin_id = 1; - uint32 bps_to_remove = 2; -} - -message Bin { - uint64 amount_x = 1; - uint64 amount_y = 2; - string price = 3; - string liquidity_supply = 4; - repeated string reward_per_token_stored = 5; - string fee_amount_x_per_token_stored = 6; - string fee_amount_y_per_token_stored = 7; - string amount_x_in = 8; - string amount_y_in = 9; -} - -message ProtocolFee { - uint64 amount_x = 1; - uint64 amount_y = 2; -} - -message RewardInfo { - string mint = 1; - string vault = 2; - string funder = 3; - uint64 reward_duration = 4; - uint64 reward_duration_end = 5; - string reward_rate = 6; - uint64 last_update_time = 7; - uint64 cumulative_seconds_with_empty_liquidity_reward = 8; -} - -message Observation { - string cumulative_active_bin_id = 1; - int64 created_at = 2; - int64 last_updated_at = 3; -} - -message StaticParameters { - uint32 base_factor = 1; - uint32 filter_period = 2; - uint32 decay_period = 3; - uint32 reduction_factor = 4; - uint32 variable_fee_control = 5; - uint32 max_volatility_accumulator = 6; - int32 min_bin_id = 7; - int32 max_bin_id = 8; - uint32 protocol_share = 9; - uint32 base_fee_power_factor = 10; - repeated uint32 padding = 11; -} - -message VariableParameters { - uint32 volatility_accumulator = 1; - uint32 volatility_reference = 2; - int32 index_reference = 3; - repeated uint32 padding = 4; - int64 last_update_timestamp = 5; - repeated uint32 padding1 = 6; -} - -message FeeInfo { - string fee_x_per_token_complete = 1; - string fee_y_per_token_complete = 2; - uint64 fee_x_pending = 3; - uint64 fee_y_pending = 4; -} - -message UserRewardInfo { - repeated string reward_per_token_completes = 1; - repeated uint64 reward_pendings = 2; -} - -message RemainingAccountsSlice { - AccountsType accounts_type = 1; - uint32 length = 2; -} - -message RemainingAccountsInfo { - repeated RemainingAccountsSlice slices = 1; -} - -enum StrategyType { - StrategyTypeSpotOneSide = 0; - StrategyTypeCurveOneSide = 1; - StrategyTypeBidAskOneSide = 2; - StrategyTypeSpotBalanced = 3; - StrategyTypeCurveBalanced = 4; - StrategyTypeBidAskBalanced = 5; - StrategyTypeSpotImBalanced = 6; - StrategyTypeCurveImBalanced = 7; - StrategyTypeBidAskImBalanced = 8; -} - -enum Rounding { - RoundingUp = 0; - RoundingDown = 1; -} - -enum ActivationType { - ActivationTypeSlot = 0; - ActivationTypeTimestamp = 1; -} - -enum LayoutVersion { - LayoutVersionV0 = 0; - LayoutVersionV1 = 1; -} - -enum PairType { - PairTypePermissionless = 0; - PairTypePermission = 1; - PairTypeCustomizablePermissionless = 2; - PairTypePermissionlessV2 = 3; -} - -enum PairStatus { - PairStatusEnabled = 0; - PairStatusDisabled = 1; -} - -enum TokenProgramFlags { - TokenProgramFlagsTokenProgram = 0; - TokenProgramFlagsTokenProgram2022 = 1; -} - -enum AccountsType { - AccountsTypeTransferHookX = 0; - AccountsTypeTransferHookY = 1; - AccountsTypeTransferHookReward = 2; -} - - -message BinArrayBitmapExtension { - string lb_pair = 1; - repeated RepeatedUint64Row positive_bin_array_bitmap = 2; - repeated RepeatedUint64Row negative_bin_array_bitmap = 3; -} - -message BinArray { - int64 index = 1; - uint32 version = 2; - repeated uint32 padding = 3; - string lb_pair = 4; - repeated Bin bins = 5; -} - -message ClaimFeeOperator { - string operator = 1; - repeated uint32 padding = 2; -} - -message LbPair { - StaticParameters parameters = 1; - VariableParameters v_parameters = 2; - repeated uint32 bump_seed = 3; - repeated uint32 bin_step_seed = 4; - uint32 pair_type = 5; - int32 active_id = 6; - uint32 bin_step = 7; - uint32 status = 8; - uint32 require_base_factor_seed = 9; - repeated uint32 base_factor_seed = 10; - uint32 activation_type = 11; - uint32 creator_pool_on_off_control = 12; - string token_x_mint = 13; - string token_y_mint = 14; - string reserve_x = 15; - string reserve_y = 16; - ProtocolFee protocol_fee = 17; - repeated uint32 padding1 = 18; - repeated RewardInfo reward_infos = 19; - string oracle = 20; - repeated uint64 bin_array_bitmap = 21; - int64 last_updated_at = 22; - repeated uint32 padding2 = 23; - string pre_activation_swap_address = 24; - string base_key = 25; - uint64 activation_point = 26; - uint64 pre_activation_duration = 27; - repeated uint32 padding3 = 28; - uint64 padding4 = 29; - string creator = 30; - uint32 token_mint_x_program_flag = 31; - uint32 token_mint_y_program_flag = 32; - repeated uint32 reserved = 33; -} - -message Oracle { - uint64 idx = 1; - uint64 active_size = 2; - uint64 length = 3; - repeated RepeatedUint32Row observations = 4; -} - -message Position { - string lb_pair = 1; - string owner = 2; - repeated uint64 liquidity_shares = 3; - repeated UserRewardInfo reward_infos = 4; - repeated FeeInfo fee_infos = 5; - int32 lower_bin_id = 6; - int32 upper_bin_id = 7; - int64 last_updated_at = 8; - uint64 total_claimed_fee_x_amount = 9; - uint64 total_claimed_fee_y_amount = 10; - repeated uint64 total_claimed_rewards = 11; - repeated uint32 reserved = 12; -} - -message PositionV2 { - string lb_pair = 1; - string owner = 2; - repeated string liquidity_shares = 3; - repeated UserRewardInfo reward_infos = 4; - repeated FeeInfo fee_infos = 5; - int32 lower_bin_id = 6; - int32 upper_bin_id = 7; - int64 last_updated_at = 8; - uint64 total_claimed_fee_x_amount = 9; - uint64 total_claimed_fee_y_amount = 10; - repeated uint64 total_claimed_rewards = 11; - string operator = 12; - uint64 lock_release_point = 13; - uint32 padding0 = 14; - string fee_owner = 15; - repeated uint32 reserved = 16; -} - -message PresetParameter2 { - uint32 bin_step = 1; - uint32 base_factor = 2; - uint32 filter_period = 3; - uint32 decay_period = 4; - uint32 variable_fee_control = 5; - uint32 max_volatility_accumulator = 6; - uint32 reduction_factor = 7; - uint32 protocol_share = 8; - uint32 index = 9; - uint32 base_fee_power_factor = 10; - uint32 padding0 = 11; - repeated uint64 padding1 = 12; -} - -message PresetParameter { - uint32 bin_step = 1; - uint32 base_factor = 2; - uint32 filter_period = 3; - uint32 decay_period = 4; - uint32 reduction_factor = 5; - uint32 variable_fee_control = 6; - uint32 max_volatility_accumulator = 7; - int32 min_bin_id = 8; - int32 max_bin_id = 9; - uint32 protocol_share = 10; -} - -message TokenBadge { - string token_mint = 1; - repeated uint32 padding = 2; -} - - -message InitializeLbPairIxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - string token_mint_x = 3; - string token_mint_y = 4; - string reserve_x = 5; - string reserve_y = 6; - string oracle = 7; - string preset_parameter = 8; - string funder = 9; - string token_program = 10; - string system_program = 11; - string rent = 12; - string event_authority = 13; - string program = 14; -} - -message InitializeLbPairIxData { - int32 active_id = 1; - uint32 bin_step = 2; -} - -message InitializePermissionLbPairIxAccounts { - string base = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string token_mint_x = 4; - string token_mint_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string oracle = 8; - string admin = 9; - optional string token_badge_x = 10; - optional string token_badge_y = 11; - string token_program_x = 12; - string token_program_y = 13; - string system_program = 14; - string rent = 15; - string event_authority = 16; - string program = 17; -} - -message InitializePermissionLbPairIxData { - int32 active_id = 1; - uint32 bin_step = 2; - uint32 base_factor = 3; - uint32 base_fee_power_factor = 4; - uint32 activation_type = 5; - uint32 protocol_share = 6; -} - -message InitializeCustomizablePermissionlessLbPairIxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - string token_mint_x = 3; - string token_mint_y = 4; - string reserve_x = 5; - string reserve_y = 6; - string oracle = 7; - string user_token_x = 8; - string funder = 9; - string token_program = 10; - string system_program = 11; - string user_token_y = 12; - string event_authority = 13; - string program = 14; -} - -message InitializeCustomizablePermissionlessLbPairIxData { - CustomizableParams params = 1; -} - -message InitializeBinArrayBitmapExtensionIxAccounts { - string lb_pair = 1; - string bin_array_bitmap_extension = 2; - string funder = 3; - string system_program = 4; - string rent = 5; -} - - -message InitializeBinArrayIxAccounts { - string lb_pair = 1; - string bin_array = 2; - string funder = 3; - string system_program = 4; -} - -message InitializeBinArrayIxData { - int64 index = 1; -} - -message AddLiquidityIxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token_x = 4; - string user_token_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string bin_array_lower = 10; - string bin_array_upper = 11; - string sender = 12; - string token_x_program = 13; - string token_y_program = 14; - string event_authority = 15; - string program = 16; -} - -message AddLiquidityIxData { - LiquidityParameter liquidity_parameter = 1; -} - -message AddLiquidityByWeightIxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token_x = 4; - string user_token_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string bin_array_lower = 10; - string bin_array_upper = 11; - string sender = 12; - string token_x_program = 13; - string token_y_program = 14; - string event_authority = 15; - string program = 16; -} - -message AddLiquidityByWeightIxData { - uint64 amount_x = 1; - uint64 amount_y = 2; - int32 active_id = 3; - int32 max_active_bin_slippage = 4; - repeated BinLiquidityDistributionByWeight bin_liquidity_dist = 5; -} - -message AddLiquidityByStrategyIxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token_x = 4; - string user_token_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string bin_array_lower = 10; - string bin_array_upper = 11; - string sender = 12; - string token_x_program = 13; - string token_y_program = 14; - string event_authority = 15; - string program = 16; -} - -message AddLiquidityByStrategyIxData { - LiquidityParameterByStrategy liquidity_parameter = 1; -} - -message AddLiquidityByStrategyOneSideIxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token = 4; - string reserve = 5; - string token_mint = 6; - string bin_array_lower = 7; - string bin_array_upper = 8; - string sender = 9; - string token_program = 10; - string event_authority = 11; - string program = 12; -} - -message AddLiquidityByStrategyOneSideIxData { - uint64 amount = 1; - int32 active_id = 2; - int32 max_active_bin_slippage = 3; - StrategyParameters strategy_parameters = 4; -} - -message AddLiquidityOneSideIxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token = 4; - string reserve = 5; - string token_mint = 6; - string bin_array_lower = 7; - string bin_array_upper = 8; - string sender = 9; - string token_program = 10; - string event_authority = 11; - string program = 12; -} - -message AddLiquidityOneSideIxData { - uint64 amount = 1; - int32 active_id = 2; - int32 max_active_bin_slippage = 3; - repeated BinLiquidityDistributionByWeight bin_liquidity_dist = 4; -} - -message RemoveLiquidityIxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token_x = 4; - string user_token_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string bin_array_lower = 10; - string bin_array_upper = 11; - string sender = 12; - string token_x_program = 13; - string token_y_program = 14; - string event_authority = 15; - string program = 16; -} - -message RemoveLiquidityIxData { - repeated BinLiquidityReduction bin_liquidity_removal = 1; -} - -message InitializePositionIxAccounts { - string payer = 1; - string position = 2; - string lb_pair = 3; - string owner = 4; - string system_program = 5; - string rent = 6; - string event_authority = 7; - string program = 8; -} - -message InitializePositionIxData { - int32 lower_bin_id = 1; - int32 width = 2; -} - -message InitializePositionPdaIxAccounts { - string payer = 1; - string base = 2; - string position = 3; - string lb_pair = 4; - string owner = 5; - string system_program = 6; - string rent = 7; - string event_authority = 8; - string program = 9; -} - -message InitializePositionPdaIxData { - int32 lower_bin_id = 1; - int32 width = 2; -} - -message InitializePositionByOperatorIxAccounts { - string payer = 1; - string base = 2; - string position = 3; - string lb_pair = 4; - string owner = 5; - string operator = 6; - string operator_token_x = 7; - string owner_token_x = 8; - string system_program = 9; - string event_authority = 10; - string program = 11; -} - -message InitializePositionByOperatorIxData { - int32 lower_bin_id = 1; - int32 width = 2; - string fee_owner = 3; - uint64 lock_release_point = 4; -} - -message UpdatePositionOperatorIxAccounts { - string position = 1; - string owner = 2; - string event_authority = 3; - string program = 4; -} - -message UpdatePositionOperatorIxData { - string operator = 1; -} - -message SwapIxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - string reserve_x = 3; - string reserve_y = 4; - string user_token_in = 5; - string user_token_out = 6; - string token_x_mint = 7; - string token_y_mint = 8; - string oracle = 9; - optional string host_fee_in = 10; - string user = 11; - string token_x_program = 12; - string token_y_program = 13; - string event_authority = 14; - string program = 15; -} - -message SwapIxData { - uint64 amount_in = 1; - uint64 min_amount_out = 2; -} - -message SwapExactOutIxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - string reserve_x = 3; - string reserve_y = 4; - string user_token_in = 5; - string user_token_out = 6; - string token_x_mint = 7; - string token_y_mint = 8; - string oracle = 9; - optional string host_fee_in = 10; - string user = 11; - string token_x_program = 12; - string token_y_program = 13; - string event_authority = 14; - string program = 15; -} - -message SwapExactOutIxData { - uint64 max_in_amount = 1; - uint64 out_amount = 2; -} - -message SwapWithPriceImpactIxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - string reserve_x = 3; - string reserve_y = 4; - string user_token_in = 5; - string user_token_out = 6; - string token_x_mint = 7; - string token_y_mint = 8; - string oracle = 9; - optional string host_fee_in = 10; - string user = 11; - string token_x_program = 12; - string token_y_program = 13; - string event_authority = 14; - string program = 15; -} - -message SwapWithPriceImpactIxData { - uint64 amount_in = 1; - optional int32 active_id = 2; - uint32 max_price_impact_bps = 3; -} - -message WithdrawProtocolFeeIxAccounts { - string lb_pair = 1; - string reserve_x = 2; - string reserve_y = 3; - string token_x_mint = 4; - string token_y_mint = 5; - string receiver_token_x = 6; - string receiver_token_y = 7; - string claim_fee_operator = 8; - string operator = 9; - string token_x_program = 10; - string token_y_program = 11; - string memo_program = 12; -} - -message WithdrawProtocolFeeIxData { - uint64 amount_x = 1; - uint64 amount_y = 2; - RemainingAccountsInfo remaining_accounts_info = 3; -} - -message InitializeRewardIxAccounts { - string lb_pair = 1; - string reward_vault = 2; - string reward_mint = 3; - optional string token_badge = 4; - string admin = 5; - string token_program = 6; - string system_program = 7; - string rent = 8; - string event_authority = 9; - string program = 10; -} - -message InitializeRewardIxData { - uint64 reward_index = 1; - uint64 reward_duration = 2; - string funder = 3; -} - -message FundRewardIxAccounts { - string lb_pair = 1; - string reward_vault = 2; - string reward_mint = 3; - string funder_token_account = 4; - string funder = 5; - string bin_array = 6; - string token_program = 7; - string event_authority = 8; - string program = 9; -} - -message FundRewardIxData { - uint64 reward_index = 1; - uint64 amount = 2; - bool carry_forward = 3; - RemainingAccountsInfo remaining_accounts_info = 4; -} - -message UpdateRewardFunderIxAccounts { - string lb_pair = 1; - string admin = 2; - string event_authority = 3; - string program = 4; -} - -message UpdateRewardFunderIxData { - uint64 reward_index = 1; - string new_funder = 2; -} - -message UpdateRewardDurationIxAccounts { - string lb_pair = 1; - string admin = 2; - string bin_array = 3; - string event_authority = 4; - string program = 5; -} - -message UpdateRewardDurationIxData { - uint64 reward_index = 1; - uint64 new_duration = 2; -} - -message ClaimRewardIxAccounts { - string lb_pair = 1; - string position = 2; - string bin_array_lower = 3; - string bin_array_upper = 4; - string sender = 5; - string reward_vault = 6; - string reward_mint = 7; - string user_token_account = 8; - string token_program = 9; - string event_authority = 10; - string program = 11; -} - -message ClaimRewardIxData { - uint64 reward_index = 1; -} - -message ClaimFeeIxAccounts { - string lb_pair = 1; - string position = 2; - string bin_array_lower = 3; - string bin_array_upper = 4; - string sender = 5; - string reserve_x = 6; - string reserve_y = 7; - string user_token_x = 8; - string user_token_y = 9; - string token_x_mint = 10; - string token_y_mint = 11; - string token_program = 12; - string event_authority = 13; - string program = 14; -} - - -message ClosePositionIxAccounts { - string position = 1; - string lb_pair = 2; - string bin_array_lower = 3; - string bin_array_upper = 4; - string sender = 5; - string rent_receiver = 6; - string event_authority = 7; - string program = 8; -} - - -message UpdateBaseFeeParametersIxAccounts { - string lb_pair = 1; - string admin = 2; - string event_authority = 3; - string program = 4; -} - -message UpdateBaseFeeParametersIxData { - uint32 protocol_share = 1; - uint32 base_factor = 2; - uint32 base_fee_power_factor = 3; -} - -message UpdateDynamicFeeParametersIxAccounts { - string lb_pair = 1; - string admin = 2; - string event_authority = 3; - string program = 4; -} - -message UpdateDynamicFeeParametersIxData { - uint32 filter_period = 1; - uint32 decay_period = 2; - uint32 reduction_factor = 3; - uint32 variable_fee_control = 4; - uint32 max_volatility_accumulator = 5; -} - -message IncreaseOracleLengthIxAccounts { - string oracle = 1; - string funder = 2; - string system_program = 3; - string event_authority = 4; - string program = 5; -} - -message IncreaseOracleLengthIxData { - uint64 length_to_add = 1; -} - -message InitializePresetParameterIxAccounts { - string preset_parameter = 1; - string admin = 2; - string system_program = 3; - string rent = 4; -} - -message InitializePresetParameterIxData { - uint32 bin_step = 1; - uint32 base_factor = 2; - uint32 filter_period = 3; - uint32 decay_period = 4; - uint32 reduction_factor = 5; - uint32 variable_fee_control = 6; - uint32 max_volatility_accumulator = 7; - uint32 protocol_share = 8; -} - -message ClosePresetParameterIxAccounts { - string preset_parameter = 1; - string admin = 2; - string rent_receiver = 3; -} - - -message ClosePresetParameter2IxAccounts { - string preset_parameter = 1; - string admin = 2; - string rent_receiver = 3; -} - - -message RemoveAllLiquidityIxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token_x = 4; - string user_token_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string bin_array_lower = 10; - string bin_array_upper = 11; - string sender = 12; - string token_x_program = 13; - string token_y_program = 14; - string event_authority = 15; - string program = 16; -} - - -message SetPairStatusIxAccounts { - string lb_pair = 1; - string admin = 2; -} - -message SetPairStatusIxData { - uint32 status = 1; -} - -message MigratePositionIxAccounts { - string position_v2 = 1; - string position_v1 = 2; - string lb_pair = 3; - string bin_array_lower = 4; - string bin_array_upper = 5; - string owner = 6; - string system_program = 7; - string rent_receiver = 8; - string event_authority = 9; - string program = 10; -} - - -message MigrateBinArrayIxAccounts { - string lb_pair = 1; -} - - -message UpdateFeesAndRewardsIxAccounts { - string position = 1; - string lb_pair = 2; - string bin_array_lower = 3; - string bin_array_upper = 4; - string owner = 5; -} - - -message WithdrawIneligibleRewardIxAccounts { - string lb_pair = 1; - string reward_vault = 2; - string reward_mint = 3; - string funder_token_account = 4; - string funder = 5; - string bin_array = 6; - string token_program = 7; - string memo_program = 8; - string event_authority = 9; - string program = 10; -} - -message WithdrawIneligibleRewardIxData { - uint64 reward_index = 1; - RemainingAccountsInfo remaining_accounts_info = 2; -} - -message SetActivationPointIxAccounts { - string lb_pair = 1; - string admin = 2; -} - -message SetActivationPointIxData { - uint64 activation_point = 1; -} - -message RemoveLiquidityByRangeIxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token_x = 4; - string user_token_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string bin_array_lower = 10; - string bin_array_upper = 11; - string sender = 12; - string token_x_program = 13; - string token_y_program = 14; - string event_authority = 15; - string program = 16; -} - -message RemoveLiquidityByRangeIxData { - int32 from_bin_id = 1; - int32 to_bin_id = 2; - uint32 bps_to_remove = 3; -} - -message AddLiquidityOneSidePreciseIxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token = 4; - string reserve = 5; - string token_mint = 6; - string bin_array_lower = 7; - string bin_array_upper = 8; - string sender = 9; - string token_program = 10; - string event_authority = 11; - string program = 12; -} - -message AddLiquidityOneSidePreciseIxData { - repeated CompressedBinDepositAmount bins = 1; - uint64 decompress_multiplier = 2; -} - -message GoToABinIxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - optional string from_bin_array = 3; - optional string to_bin_array = 4; - string event_authority = 5; - string program = 6; -} - -message GoToABinIxData { - int32 bin_id = 1; -} - -message SetPreActivationDurationIxAccounts { - string lb_pair = 1; - string creator = 2; -} - -message SetPreActivationDurationIxData { - uint64 pre_activation_duration = 1; -} - -message SetPreActivationSwapAddressIxAccounts { - string lb_pair = 1; - string creator = 2; -} - -message SetPreActivationSwapAddressIxData { - string pre_activation_swap_address = 1; -} - -message SetPairStatusPermissionlessIxAccounts { - string lb_pair = 1; - string creator = 2; -} - -message SetPairStatusPermissionlessIxData { - uint32 status = 1; -} - -message InitializeTokenBadgeIxAccounts { - string token_mint = 1; - string token_badge = 2; - string admin = 3; - string system_program = 4; -} - - -message CreateClaimProtocolFeeOperatorIxAccounts { - string claim_fee_operator = 1; - string operator = 2; - string admin = 3; - string system_program = 4; -} - - -message CloseClaimProtocolFeeOperatorIxAccounts { - string claim_fee_operator = 1; - string rent_receiver = 2; - string admin = 3; -} - - -message InitializePresetParameter2IxAccounts { - string preset_parameter = 1; - string admin = 2; - string system_program = 3; -} - -message InitializePresetParameter2IxData { - uint32 index = 1; - uint32 bin_step = 2; - uint32 base_factor = 3; - uint32 filter_period = 4; - uint32 decay_period = 5; - uint32 reduction_factor = 6; - uint32 variable_fee_control = 7; - uint32 max_volatility_accumulator = 8; - uint32 protocol_share = 9; - uint32 base_fee_power_factor = 10; -} - -message InitializeLbPair2IxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - string token_mint_x = 3; - string token_mint_y = 4; - string reserve_x = 5; - string reserve_y = 6; - string oracle = 7; - string preset_parameter = 8; - string funder = 9; - optional string token_badge_x = 10; - optional string token_badge_y = 11; - string token_program_x = 12; - string token_program_y = 13; - string system_program = 14; - string event_authority = 15; - string program = 16; -} - -message InitializeLbPair2IxData { - int32 active_id = 1; - repeated uint32 padding = 2; -} - -message InitializeCustomizablePermissionlessLbPair2IxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - string token_mint_x = 3; - string token_mint_y = 4; - string reserve_x = 5; - string reserve_y = 6; - string oracle = 7; - string user_token_x = 8; - string funder = 9; - optional string token_badge_x = 10; - optional string token_badge_y = 11; - string token_program_x = 12; - string token_program_y = 13; - string system_program = 14; - string user_token_y = 15; - string event_authority = 16; - string program = 17; -} - -message InitializeCustomizablePermissionlessLbPair2IxData { - CustomizableParams params = 1; -} - -message ClaimFee2IxAccounts { - string lb_pair = 1; - string position = 2; - string sender = 3; - string reserve_x = 4; - string reserve_y = 5; - string user_token_x = 6; - string user_token_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string token_program_x = 10; - string token_program_y = 11; - string memo_program = 12; - string event_authority = 13; - string program = 14; -} - -message ClaimFee2IxData { - int32 min_bin_id = 1; - int32 max_bin_id = 2; - RemainingAccountsInfo remaining_accounts_info = 3; -} - -message ClaimReward2IxAccounts { - string lb_pair = 1; - string position = 2; - string sender = 3; - string reward_vault = 4; - string reward_mint = 5; - string user_token_account = 6; - string token_program = 7; - string memo_program = 8; - string event_authority = 9; - string program = 10; -} - -message ClaimReward2IxData { - uint64 reward_index = 1; - int32 min_bin_id = 2; - int32 max_bin_id = 3; - RemainingAccountsInfo remaining_accounts_info = 4; -} - -message AddLiquidity2IxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token_x = 4; - string user_token_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string sender = 10; - string token_x_program = 11; - string token_y_program = 12; - string event_authority = 13; - string program = 14; -} - -message AddLiquidity2IxData { - LiquidityParameter liquidity_parameter = 1; - RemainingAccountsInfo remaining_accounts_info = 2; -} - -message AddLiquidityByStrategy2IxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token_x = 4; - string user_token_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string sender = 10; - string token_x_program = 11; - string token_y_program = 12; - string event_authority = 13; - string program = 14; -} - -message AddLiquidityByStrategy2IxData { - LiquidityParameterByStrategy liquidity_parameter = 1; - RemainingAccountsInfo remaining_accounts_info = 2; -} - -message AddLiquidityOneSidePrecise2IxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token = 4; - string reserve = 5; - string token_mint = 6; - string sender = 7; - string token_program = 8; - string event_authority = 9; - string program = 10; -} - -message AddLiquidityOneSidePrecise2IxData { - repeated CompressedBinDepositAmount bins = 1; - uint64 decompress_multiplier = 2; - uint64 max_amount = 3; - RemainingAccountsInfo remaining_accounts_info = 4; -} - -message RemoveLiquidity2IxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token_x = 4; - string user_token_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string sender = 10; - string token_x_program = 11; - string token_y_program = 12; - string memo_program = 13; - string event_authority = 14; - string program = 15; -} - -message RemoveLiquidity2IxData { - repeated BinLiquidityReduction bin_liquidity_removal = 1; - RemainingAccountsInfo remaining_accounts_info = 2; -} - -message RemoveLiquidityByRange2IxAccounts { - string position = 1; - string lb_pair = 2; - optional string bin_array_bitmap_extension = 3; - string user_token_x = 4; - string user_token_y = 5; - string reserve_x = 6; - string reserve_y = 7; - string token_x_mint = 8; - string token_y_mint = 9; - string sender = 10; - string token_x_program = 11; - string token_y_program = 12; - string memo_program = 13; - string event_authority = 14; - string program = 15; -} - -message RemoveLiquidityByRange2IxData { - int32 from_bin_id = 1; - int32 to_bin_id = 2; - uint32 bps_to_remove = 3; - RemainingAccountsInfo remaining_accounts_info = 4; -} - -message Swap2IxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - string reserve_x = 3; - string reserve_y = 4; - string user_token_in = 5; - string user_token_out = 6; - string token_x_mint = 7; - string token_y_mint = 8; - string oracle = 9; - optional string host_fee_in = 10; - string user = 11; - string token_x_program = 12; - string token_y_program = 13; - string memo_program = 14; - string event_authority = 15; - string program = 16; -} - -message Swap2IxData { - uint64 amount_in = 1; - uint64 min_amount_out = 2; - RemainingAccountsInfo remaining_accounts_info = 3; -} - -message SwapExactOut2IxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - string reserve_x = 3; - string reserve_y = 4; - string user_token_in = 5; - string user_token_out = 6; - string token_x_mint = 7; - string token_y_mint = 8; - string oracle = 9; - optional string host_fee_in = 10; - string user = 11; - string token_x_program = 12; - string token_y_program = 13; - string memo_program = 14; - string event_authority = 15; - string program = 16; -} - -message SwapExactOut2IxData { - uint64 max_in_amount = 1; - uint64 out_amount = 2; - RemainingAccountsInfo remaining_accounts_info = 3; -} - -message SwapWithPriceImpact2IxAccounts { - string lb_pair = 1; - optional string bin_array_bitmap_extension = 2; - string reserve_x = 3; - string reserve_y = 4; - string user_token_in = 5; - string user_token_out = 6; - string token_x_mint = 7; - string token_y_mint = 8; - string oracle = 9; - optional string host_fee_in = 10; - string user = 11; - string token_x_program = 12; - string token_y_program = 13; - string memo_program = 14; - string event_authority = 15; - string program = 16; -} - -message SwapWithPriceImpact2IxData { - uint64 amount_in = 1; - optional int32 active_id = 2; - uint32 max_price_impact_bps = 3; - RemainingAccountsInfo remaining_accounts_info = 4; -} - -message ClosePosition2IxAccounts { - string position = 1; - string sender = 2; - string rent_receiver = 3; - string event_authority = 4; - string program = 5; -} - - -message UpdateFeesAndReward2IxAccounts { - string position = 1; - string lb_pair = 2; - string owner = 3; -} - -message UpdateFeesAndReward2IxData { - int32 min_bin_id = 1; - int32 max_bin_id = 2; -} - -message ClosePositionIfEmptyIxAccounts { - string position = 1; - string sender = 2; - string rent_receiver = 3; - string event_authority = 4; - string program = 5; -} - - - -message ProgramState { - oneof state_oneof { - BinArrayBitmapExtension bin_array_bitmap_extension = 1; - BinArray bin_array = 2; - ClaimFeeOperator claim_fee_operator = 3; - LbPair lb_pair = 4; - Oracle oracle = 5; - Position position = 6; - PositionV2 position_v2 = 7; - PresetParameter2 preset_parameter2 = 8; - PresetParameter preset_parameter = 9; - TokenBadge token_badge = 10; - } -} - -message ProgramIxs { - oneof ix_oneof { - InitializeLbPairIx initialize_lb_pair = 1; - InitializePermissionLbPairIx initialize_permission_lb_pair = 2; - InitializeCustomizablePermissionlessLbPairIx initialize_customizable_permissionless_lb_pair = 3; - InitializeBinArrayBitmapExtensionIx initialize_bin_array_bitmap_extension = 4; - InitializeBinArrayIx initialize_bin_array = 5; - AddLiquidityIx add_liquidity = 6; - AddLiquidityByWeightIx add_liquidity_by_weight = 7; - AddLiquidityByStrategyIx add_liquidity_by_strategy = 8; - AddLiquidityByStrategyOneSideIx add_liquidity_by_strategy_one_side = 9; - AddLiquidityOneSideIx add_liquidity_one_side = 10; - RemoveLiquidityIx remove_liquidity = 11; - InitializePositionIx initialize_position = 12; - InitializePositionPdaIx initialize_position_pda = 13; - InitializePositionByOperatorIx initialize_position_by_operator = 14; - UpdatePositionOperatorIx update_position_operator = 15; - SwapIx swap = 16; - SwapExactOutIx swap_exact_out = 17; - SwapWithPriceImpactIx swap_with_price_impact = 18; - WithdrawProtocolFeeIx withdraw_protocol_fee = 19; - InitializeRewardIx initialize_reward = 20; - FundRewardIx fund_reward = 21; - UpdateRewardFunderIx update_reward_funder = 22; - UpdateRewardDurationIx update_reward_duration = 23; - ClaimRewardIx claim_reward = 24; - ClaimFeeIx claim_fee = 25; - ClosePositionIx close_position = 26; - UpdateBaseFeeParametersIx update_base_fee_parameters = 27; - UpdateDynamicFeeParametersIx update_dynamic_fee_parameters = 28; - IncreaseOracleLengthIx increase_oracle_length = 29; - InitializePresetParameterIx initialize_preset_parameter = 30; - ClosePresetParameterIx close_preset_parameter = 31; - ClosePresetParameter2Ix close_preset_parameter2 = 32; - RemoveAllLiquidityIx remove_all_liquidity = 33; - SetPairStatusIx set_pair_status = 34; - MigratePositionIx migrate_position = 35; - MigrateBinArrayIx migrate_bin_array = 36; - UpdateFeesAndRewardsIx update_fees_and_rewards = 37; - WithdrawIneligibleRewardIx withdraw_ineligible_reward = 38; - SetActivationPointIx set_activation_point = 39; - RemoveLiquidityByRangeIx remove_liquidity_by_range = 40; - AddLiquidityOneSidePreciseIx add_liquidity_one_side_precise = 41; - GoToABinIx go_to_a_bin = 42; - SetPreActivationDurationIx set_pre_activation_duration = 43; - SetPreActivationSwapAddressIx set_pre_activation_swap_address = 44; - SetPairStatusPermissionlessIx set_pair_status_permissionless = 45; - InitializeTokenBadgeIx initialize_token_badge = 46; - CreateClaimProtocolFeeOperatorIx create_claim_protocol_fee_operator = 47; - CloseClaimProtocolFeeOperatorIx close_claim_protocol_fee_operator = 48; - InitializePresetParameter2Ix initialize_preset_parameter2 = 49; - InitializeLbPair2Ix initialize_lb_pair2 = 50; - InitializeCustomizablePermissionlessLbPair2Ix initialize_customizable_permissionless_lb_pair2 = 51; - ClaimFee2Ix claim_fee2 = 52; - ClaimReward2Ix claim_reward2 = 53; - AddLiquidity2Ix add_liquidity2 = 54; - AddLiquidityByStrategy2Ix add_liquidity_by_strategy2 = 55; - AddLiquidityOneSidePrecise2Ix add_liquidity_one_side_precise2 = 56; - RemoveLiquidity2Ix remove_liquidity2 = 57; - RemoveLiquidityByRange2Ix remove_liquidity_by_range2 = 58; - Swap2Ix swap2 = 59; - SwapExactOut2Ix swap_exact_out2 = 60; - SwapWithPriceImpact2Ix swap_with_price_impact2 = 61; - ClosePosition2Ix close_position2 = 62; - UpdateFeesAndReward2Ix update_fees_and_reward2 = 63; - ClosePositionIfEmptyIx close_position_if_empty = 64; - } -} - diff --git a/crates/meteora-parser/src/custom_impl/mod.rs b/crates/meteora-parser/src/custom_impl/mod.rs deleted file mode 100644 index a83b75c3..00000000 --- a/crates/meteora-parser/src/custom_impl/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Placeholder for custom impls that are not overriden by the generated code. - -mod oracle; diff --git a/crates/meteora-parser/src/custom_impl/oracle.rs b/crates/meteora-parser/src/custom_impl/oracle.rs deleted file mode 100644 index e9b031f4..00000000 --- a/crates/meteora-parser/src/custom_impl/oracle.rs +++ /dev/null @@ -1,24 +0,0 @@ -use borsh::BorshDeserialize; - -impl BorshDeserialize for crate::accounts::Oracle { - fn deserialize_reader(reader: &mut R) -> std::io::Result { - let discriminator = BorshDeserialize::deserialize_reader(reader)?; - let idx = BorshDeserialize::deserialize_reader(reader)?; - let active_size = BorshDeserialize::deserialize_reader(reader)?; - let length = BorshDeserialize::deserialize_reader(reader)?; - - let mut observations = Vec::with_capacity(length as usize); - for _ in 0..length { - let observation = BorshDeserialize::deserialize_reader(reader)?; - observations.push(observation); - } - - Ok(Self { - discriminator, - idx, - active_size, - length, - observations, - }) - } -} diff --git a/crates/meteora-parser/src/generated_parser/accounts_parser.rs b/crates/meteora-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index 8be0931d..00000000 --- a/crates/meteora-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,401 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{ - BinArray, BinArrayBitmapExtension, ClaimFeeOperator, LbPair, Oracle, Position, PositionV2, - PresetParameter, PresetParameter2, TokenBadge, - }, - deserialize_checked, ID, -}; - -/// LbClmm Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum LbClmmProgramState { - BinArrayBitmapExtension(BinArrayBitmapExtension), - BinArray(BinArray), - ClaimFeeOperator(ClaimFeeOperator), - LbPair(LbPair), - Oracle(Oracle), - Position(Position), - PositionV2(PositionV2), - PresetParameter2(PresetParameter2), - PresetParameter(PresetParameter), - TokenBadge(TokenBadge), -} - -impl LbClmmProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [80, 111, 124, 113, 55, 237, 18, 5] => Ok(LbClmmProgramState::BinArrayBitmapExtension( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [92, 142, 92, 220, 5, 148, 70, 181] => Ok(LbClmmProgramState::BinArray( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [166, 48, 134, 86, 34, 200, 188, 150] => Ok(LbClmmProgramState::ClaimFeeOperator( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [33, 11, 49, 98, 181, 101, 177, 13] => Ok(LbClmmProgramState::LbPair( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [139, 194, 131, 179, 140, 179, 229, 244] => Ok(LbClmmProgramState::Oracle( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [170, 188, 143, 228, 122, 64, 247, 208] => Ok(LbClmmProgramState::Position( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [117, 176, 212, 199, 245, 180, 133, 182] => Ok(LbClmmProgramState::PositionV2( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [171, 236, 148, 115, 162, 113, 222, 174] => Ok(LbClmmProgramState::PresetParameter2( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [242, 62, 244, 34, 181, 112, 58, 170] => Ok(LbClmmProgramState::PresetParameter( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [116, 219, 204, 229, 249, 116, 255, 150] => Ok(LbClmmProgramState::TokenBadge( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = LbClmmProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "lb_clmm::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = LbClmmProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, BinArrayBitmapExtension, LbClmmProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for BinArrayBitmapExtension { - fn into_proto(self) -> proto_def::BinArrayBitmapExtension { - proto_def::BinArrayBitmapExtension { - lb_pair: self.lb_pair.to_string(), - positive_bin_array_bitmap: self - .positive_bin_array_bitmap - .into_iter() - .map(|x| proto_def::RepeatedUint64Row { rows: x.to_vec() }) - .collect(), - negative_bin_array_bitmap: self - .negative_bin_array_bitmap - .into_iter() - .map(|x| proto_def::RepeatedUint64Row { rows: x.to_vec() }) - .collect(), - } - } - } - use super::BinArray; - impl IntoProto for BinArray { - fn into_proto(self) -> proto_def::BinArray { - proto_def::BinArray { - index: self.index, - version: self.version.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - lb_pair: self.lb_pair.to_string(), - bins: self.bins.into_iter().map(|x| x.into_proto()).collect(), - } - } - } - use super::ClaimFeeOperator; - impl IntoProto for ClaimFeeOperator { - fn into_proto(self) -> proto_def::ClaimFeeOperator { - proto_def::ClaimFeeOperator { - operator: self.operator.to_string(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::LbPair; - impl IntoProto for LbPair { - fn into_proto(self) -> proto_def::LbPair { - proto_def::LbPair { - parameters: Some(self.parameters.into_proto()), - v_parameters: Some(self.v_parameters.into_proto()), - bump_seed: self.bump_seed.into_iter().map(|x| x.into()).collect(), - bin_step_seed: self.bin_step_seed.into_iter().map(|x| x.into()).collect(), - pair_type: self.pair_type.into(), - active_id: self.active_id, - bin_step: self.bin_step.into(), - status: self.status.into(), - require_base_factor_seed: self.require_base_factor_seed.into(), - base_factor_seed: self - .base_factor_seed - .into_iter() - .map(|x| x.into()) - .collect(), - activation_type: self.activation_type.into(), - creator_pool_on_off_control: self.creator_pool_on_off_control.into(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - protocol_fee: Some(self.protocol_fee.into_proto()), - padding1: self.padding1.into_iter().map(|x| x.into()).collect(), - reward_infos: self - .reward_infos - .into_iter() - .map(|x| x.into_proto()) - .collect(), - oracle: self.oracle.to_string(), - bin_array_bitmap: self.bin_array_bitmap.to_vec(), - last_updated_at: self.last_updated_at, - padding2: self.padding2.into_iter().map(|x| x.into()).collect(), - pre_activation_swap_address: self.pre_activation_swap_address.to_string(), - base_key: self.base_key.to_string(), - activation_point: self.activation_point, - pre_activation_duration: self.pre_activation_duration, - padding3: self.padding3.into_iter().map(|x| x.into()).collect(), - padding4: self.padding4, - creator: self.creator.to_string(), - token_mint_x_program_flag: self.token_mint_x_program_flag.into(), - token_mint_y_program_flag: self.token_mint_y_program_flag.into(), - reserved: self.reserved.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::Oracle; - impl IntoProto for Oracle { - fn into_proto(self) -> proto_def::Oracle { - proto_def::Oracle { - idx: self.idx, - active_size: self.active_size, - length: self.length, - observations: self - .observations - .iter() - .map(|x| proto_def::RepeatedUint32Row { - rows: x.iter().map(|x| *x as u32).collect(), - }) - .collect(), - } - } - } - use super::Position; - impl IntoProto for Position { - fn into_proto(self) -> proto_def::Position { - proto_def::Position { - lb_pair: self.lb_pair.to_string(), - owner: self.owner.to_string(), - liquidity_shares: self.liquidity_shares.to_vec(), - reward_infos: self - .reward_infos - .into_iter() - .map(|x| x.into_proto()) - .collect(), - fee_infos: self.fee_infos.into_iter().map(|x| x.into_proto()).collect(), - lower_bin_id: self.lower_bin_id, - upper_bin_id: self.upper_bin_id, - last_updated_at: self.last_updated_at, - total_claimed_fee_x_amount: self.total_claimed_fee_x_amount, - total_claimed_fee_y_amount: self.total_claimed_fee_y_amount, - total_claimed_rewards: self.total_claimed_rewards.to_vec(), - reserved: self.reserved.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::PositionV2; - impl IntoProto for PositionV2 { - fn into_proto(self) -> proto_def::PositionV2 { - proto_def::PositionV2 { - lb_pair: self.lb_pair.to_string(), - owner: self.owner.to_string(), - liquidity_shares: self - .liquidity_shares - .into_iter() - .map(|x| x.to_string()) - .collect(), - reward_infos: self - .reward_infos - .into_iter() - .map(|x| x.into_proto()) - .collect(), - fee_infos: self.fee_infos.into_iter().map(|x| x.into_proto()).collect(), - lower_bin_id: self.lower_bin_id, - upper_bin_id: self.upper_bin_id, - last_updated_at: self.last_updated_at, - total_claimed_fee_x_amount: self.total_claimed_fee_x_amount, - total_claimed_fee_y_amount: self.total_claimed_fee_y_amount, - total_claimed_rewards: self.total_claimed_rewards.to_vec(), - operator: self.operator.to_string(), - lock_release_point: self.lock_release_point, - padding0: self.padding0.into(), - fee_owner: self.fee_owner.to_string(), - reserved: self.reserved.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::PresetParameter2; - impl IntoProto for PresetParameter2 { - fn into_proto(self) -> proto_def::PresetParameter2 { - proto_def::PresetParameter2 { - bin_step: self.bin_step.into(), - base_factor: self.base_factor.into(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - variable_fee_control: self.variable_fee_control, - max_volatility_accumulator: self.max_volatility_accumulator, - reduction_factor: self.reduction_factor.into(), - protocol_share: self.protocol_share.into(), - index: self.index.into(), - base_fee_power_factor: self.base_fee_power_factor.into(), - padding0: self.padding0.into(), - padding1: self.padding1.to_vec(), - } - } - } - use super::PresetParameter; - impl IntoProto for PresetParameter { - fn into_proto(self) -> proto_def::PresetParameter { - proto_def::PresetParameter { - bin_step: self.bin_step.into(), - base_factor: self.base_factor.into(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - variable_fee_control: self.variable_fee_control, - max_volatility_accumulator: self.max_volatility_accumulator, - min_bin_id: self.min_bin_id, - max_bin_id: self.max_bin_id, - protocol_share: self.protocol_share.into(), - } - } - } - use super::TokenBadge; - impl IntoProto for TokenBadge { - fn into_proto(self) -> proto_def::TokenBadge { - proto_def::TokenBadge { - token_mint: self.token_mint.to_string(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - - impl IntoProto for LbClmmProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - LbClmmProgramState::BinArrayBitmapExtension(data) => { - proto_def::program_state::StateOneof::BinArrayBitmapExtension(data.into_proto()) - }, - LbClmmProgramState::BinArray(data) => { - proto_def::program_state::StateOneof::BinArray(data.into_proto()) - }, - LbClmmProgramState::ClaimFeeOperator(data) => { - proto_def::program_state::StateOneof::ClaimFeeOperator(data.into_proto()) - }, - LbClmmProgramState::LbPair(data) => { - proto_def::program_state::StateOneof::LbPair(data.into_proto()) - }, - LbClmmProgramState::Oracle(data) => { - proto_def::program_state::StateOneof::Oracle(data.into_proto()) - }, - LbClmmProgramState::Position(data) => { - proto_def::program_state::StateOneof::Position(data.into_proto()) - }, - LbClmmProgramState::PositionV2(data) => { - proto_def::program_state::StateOneof::PositionV2(data.into_proto()) - }, - LbClmmProgramState::PresetParameter2(data) => { - proto_def::program_state::StateOneof::PresetParameter2(data.into_proto()) - }, - LbClmmProgramState::PresetParameter(data) => { - proto_def::program_state::StateOneof::PresetParameter(data.into_proto()) - }, - LbClmmProgramState::TokenBadge(data) => { - proto_def::program_state::StateOneof::TokenBadge(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/meteora-parser/src/generated_parser/instructions_parser.rs b/crates/meteora-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index e4749cc7..00000000 --- a/crates/meteora-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,3629 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - AddLiquidity as AddLiquidityIxAccounts, AddLiquidity2 as AddLiquidity2IxAccounts, - AddLiquidity2InstructionArgs as AddLiquidity2IxData, - AddLiquidityByStrategy as AddLiquidityByStrategyIxAccounts, - AddLiquidityByStrategy2 as AddLiquidityByStrategy2IxAccounts, - AddLiquidityByStrategy2InstructionArgs as AddLiquidityByStrategy2IxData, - AddLiquidityByStrategyInstructionArgs as AddLiquidityByStrategyIxData, - AddLiquidityByStrategyOneSide as AddLiquidityByStrategyOneSideIxAccounts, - AddLiquidityByStrategyOneSideInstructionArgs as AddLiquidityByStrategyOneSideIxData, - AddLiquidityByWeight as AddLiquidityByWeightIxAccounts, - AddLiquidityByWeightInstructionArgs as AddLiquidityByWeightIxData, - AddLiquidityInstructionArgs as AddLiquidityIxData, - AddLiquidityOneSide as AddLiquidityOneSideIxAccounts, - AddLiquidityOneSideInstructionArgs as AddLiquidityOneSideIxData, - AddLiquidityOneSidePrecise as AddLiquidityOneSidePreciseIxAccounts, - AddLiquidityOneSidePrecise2 as AddLiquidityOneSidePrecise2IxAccounts, - AddLiquidityOneSidePrecise2InstructionArgs as AddLiquidityOneSidePrecise2IxData, - AddLiquidityOneSidePreciseInstructionArgs as AddLiquidityOneSidePreciseIxData, - ClaimFee as ClaimFeeIxAccounts, ClaimFee2 as ClaimFee2IxAccounts, - ClaimFee2InstructionArgs as ClaimFee2IxData, ClaimReward as ClaimRewardIxAccounts, - ClaimReward2 as ClaimReward2IxAccounts, ClaimReward2InstructionArgs as ClaimReward2IxData, - ClaimRewardInstructionArgs as ClaimRewardIxData, - CloseClaimProtocolFeeOperator as CloseClaimProtocolFeeOperatorIxAccounts, - ClosePosition as ClosePositionIxAccounts, ClosePosition2 as ClosePosition2IxAccounts, - ClosePositionIfEmpty as ClosePositionIfEmptyIxAccounts, - ClosePresetParameter as ClosePresetParameterIxAccounts, - ClosePresetParameter2 as ClosePresetParameter2IxAccounts, - CreateClaimProtocolFeeOperator as CreateClaimProtocolFeeOperatorIxAccounts, - FundReward as FundRewardIxAccounts, FundRewardInstructionArgs as FundRewardIxData, - GoToABin as GoToABinIxAccounts, GoToABinInstructionArgs as GoToABinIxData, - IncreaseOracleLength as IncreaseOracleLengthIxAccounts, - IncreaseOracleLengthInstructionArgs as IncreaseOracleLengthIxData, - InitializeBinArray as InitializeBinArrayIxAccounts, - InitializeBinArrayBitmapExtension as InitializeBinArrayBitmapExtensionIxAccounts, - InitializeBinArrayInstructionArgs as InitializeBinArrayIxData, - InitializeCustomizablePermissionlessLbPair as InitializeCustomizablePermissionlessLbPairIxAccounts, - InitializeCustomizablePermissionlessLbPair2 as InitializeCustomizablePermissionlessLbPair2IxAccounts, - InitializeCustomizablePermissionlessLbPair2InstructionArgs as InitializeCustomizablePermissionlessLbPair2IxData, - InitializeCustomizablePermissionlessLbPairInstructionArgs as InitializeCustomizablePermissionlessLbPairIxData, - InitializeLbPair as InitializeLbPairIxAccounts, - InitializeLbPair2 as InitializeLbPair2IxAccounts, - InitializeLbPair2InstructionArgs as InitializeLbPair2IxData, - InitializeLbPairInstructionArgs as InitializeLbPairIxData, - InitializePermissionLbPair as InitializePermissionLbPairIxAccounts, - InitializePermissionLbPairInstructionArgs as InitializePermissionLbPairIxData, - InitializePosition as InitializePositionIxAccounts, - InitializePositionByOperator as InitializePositionByOperatorIxAccounts, - InitializePositionByOperatorInstructionArgs as InitializePositionByOperatorIxData, - InitializePositionInstructionArgs as InitializePositionIxData, - InitializePositionPda as InitializePositionPdaIxAccounts, - InitializePositionPdaInstructionArgs as InitializePositionPdaIxData, - InitializePresetParameter as InitializePresetParameterIxAccounts, - InitializePresetParameter2 as InitializePresetParameter2IxAccounts, - InitializePresetParameter2InstructionArgs as InitializePresetParameter2IxData, - InitializePresetParameterInstructionArgs as InitializePresetParameterIxData, - InitializeReward as InitializeRewardIxAccounts, - InitializeRewardInstructionArgs as InitializeRewardIxData, - InitializeTokenBadge as InitializeTokenBadgeIxAccounts, - MigrateBinArray as MigrateBinArrayIxAccounts, MigratePosition as MigratePositionIxAccounts, - RemoveAllLiquidity as RemoveAllLiquidityIxAccounts, - RemoveLiquidity as RemoveLiquidityIxAccounts, - RemoveLiquidity2 as RemoveLiquidity2IxAccounts, - RemoveLiquidity2InstructionArgs as RemoveLiquidity2IxData, - RemoveLiquidityByRange as RemoveLiquidityByRangeIxAccounts, - RemoveLiquidityByRange2 as RemoveLiquidityByRange2IxAccounts, - RemoveLiquidityByRange2InstructionArgs as RemoveLiquidityByRange2IxData, - RemoveLiquidityByRangeInstructionArgs as RemoveLiquidityByRangeIxData, - RemoveLiquidityInstructionArgs as RemoveLiquidityIxData, - SetActivationPoint as SetActivationPointIxAccounts, - SetActivationPointInstructionArgs as SetActivationPointIxData, - SetPairStatus as SetPairStatusIxAccounts, - SetPairStatusInstructionArgs as SetPairStatusIxData, - SetPairStatusPermissionless as SetPairStatusPermissionlessIxAccounts, - SetPairStatusPermissionlessInstructionArgs as SetPairStatusPermissionlessIxData, - SetPreActivationDuration as SetPreActivationDurationIxAccounts, - SetPreActivationDurationInstructionArgs as SetPreActivationDurationIxData, - SetPreActivationSwapAddress as SetPreActivationSwapAddressIxAccounts, - SetPreActivationSwapAddressInstructionArgs as SetPreActivationSwapAddressIxData, - Swap as SwapIxAccounts, Swap2 as Swap2IxAccounts, Swap2InstructionArgs as Swap2IxData, - SwapExactOut as SwapExactOutIxAccounts, SwapExactOut2 as SwapExactOut2IxAccounts, - SwapExactOut2InstructionArgs as SwapExactOut2IxData, - SwapExactOutInstructionArgs as SwapExactOutIxData, SwapInstructionArgs as SwapIxData, - SwapWithPriceImpact as SwapWithPriceImpactIxAccounts, - SwapWithPriceImpact2 as SwapWithPriceImpact2IxAccounts, - SwapWithPriceImpact2InstructionArgs as SwapWithPriceImpact2IxData, - SwapWithPriceImpactInstructionArgs as SwapWithPriceImpactIxData, - UpdateBaseFeeParameters as UpdateBaseFeeParametersIxAccounts, - UpdateBaseFeeParametersInstructionArgs as UpdateBaseFeeParametersIxData, - UpdateDynamicFeeParameters as UpdateDynamicFeeParametersIxAccounts, - UpdateDynamicFeeParametersInstructionArgs as UpdateDynamicFeeParametersIxData, - UpdateFeesAndReward2 as UpdateFeesAndReward2IxAccounts, - UpdateFeesAndReward2InstructionArgs as UpdateFeesAndReward2IxData, - UpdateFeesAndRewards as UpdateFeesAndRewardsIxAccounts, - UpdatePositionOperator as UpdatePositionOperatorIxAccounts, - UpdatePositionOperatorInstructionArgs as UpdatePositionOperatorIxData, - UpdateRewardDuration as UpdateRewardDurationIxAccounts, - UpdateRewardDurationInstructionArgs as UpdateRewardDurationIxData, - UpdateRewardFunder as UpdateRewardFunderIxAccounts, - UpdateRewardFunderInstructionArgs as UpdateRewardFunderIxData, - WithdrawIneligibleReward as WithdrawIneligibleRewardIxAccounts, - WithdrawIneligibleRewardInstructionArgs as WithdrawIneligibleRewardIxData, - WithdrawProtocolFee as WithdrawProtocolFeeIxAccounts, - WithdrawProtocolFeeInstructionArgs as WithdrawProtocolFeeIxData, - }, - ID, -}; - -/// LbClmm Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum LbClmmProgramIx { - InitializeLbPair(InitializeLbPairIxAccounts, InitializeLbPairIxData), - InitializePermissionLbPair( - InitializePermissionLbPairIxAccounts, - InitializePermissionLbPairIxData, - ), - InitializeCustomizablePermissionlessLbPair( - InitializeCustomizablePermissionlessLbPairIxAccounts, - InitializeCustomizablePermissionlessLbPairIxData, - ), - InitializeBinArrayBitmapExtension(InitializeBinArrayBitmapExtensionIxAccounts), - InitializeBinArray(InitializeBinArrayIxAccounts, InitializeBinArrayIxData), - AddLiquidity(AddLiquidityIxAccounts, AddLiquidityIxData), - AddLiquidityByWeight(AddLiquidityByWeightIxAccounts, AddLiquidityByWeightIxData), - AddLiquidityByStrategy( - AddLiquidityByStrategyIxAccounts, - AddLiquidityByStrategyIxData, - ), - AddLiquidityByStrategyOneSide( - AddLiquidityByStrategyOneSideIxAccounts, - AddLiquidityByStrategyOneSideIxData, - ), - AddLiquidityOneSide(AddLiquidityOneSideIxAccounts, AddLiquidityOneSideIxData), - RemoveLiquidity(RemoveLiquidityIxAccounts, RemoveLiquidityIxData), - InitializePosition(InitializePositionIxAccounts, InitializePositionIxData), - InitializePositionPda(InitializePositionPdaIxAccounts, InitializePositionPdaIxData), - InitializePositionByOperator( - InitializePositionByOperatorIxAccounts, - InitializePositionByOperatorIxData, - ), - UpdatePositionOperator( - UpdatePositionOperatorIxAccounts, - UpdatePositionOperatorIxData, - ), - Swap(SwapIxAccounts, SwapIxData), - SwapExactOut(SwapExactOutIxAccounts, SwapExactOutIxData), - SwapWithPriceImpact(SwapWithPriceImpactIxAccounts, SwapWithPriceImpactIxData), - WithdrawProtocolFee(WithdrawProtocolFeeIxAccounts, WithdrawProtocolFeeIxData), - InitializeReward(InitializeRewardIxAccounts, InitializeRewardIxData), - FundReward(FundRewardIxAccounts, FundRewardIxData), - UpdateRewardFunder(UpdateRewardFunderIxAccounts, UpdateRewardFunderIxData), - UpdateRewardDuration(UpdateRewardDurationIxAccounts, UpdateRewardDurationIxData), - ClaimReward(ClaimRewardIxAccounts, ClaimRewardIxData), - ClaimFee(ClaimFeeIxAccounts), - ClosePosition(ClosePositionIxAccounts), - UpdateBaseFeeParameters( - UpdateBaseFeeParametersIxAccounts, - UpdateBaseFeeParametersIxData, - ), - UpdateDynamicFeeParameters( - UpdateDynamicFeeParametersIxAccounts, - UpdateDynamicFeeParametersIxData, - ), - IncreaseOracleLength(IncreaseOracleLengthIxAccounts, IncreaseOracleLengthIxData), - InitializePresetParameter( - InitializePresetParameterIxAccounts, - InitializePresetParameterIxData, - ), - ClosePresetParameter(ClosePresetParameterIxAccounts), - ClosePresetParameter2(ClosePresetParameter2IxAccounts), - RemoveAllLiquidity(RemoveAllLiquidityIxAccounts), - SetPairStatus(SetPairStatusIxAccounts, SetPairStatusIxData), - MigratePosition(MigratePositionIxAccounts), - MigrateBinArray(MigrateBinArrayIxAccounts), - UpdateFeesAndRewards(UpdateFeesAndRewardsIxAccounts), - WithdrawIneligibleReward( - WithdrawIneligibleRewardIxAccounts, - WithdrawIneligibleRewardIxData, - ), - SetActivationPoint(SetActivationPointIxAccounts, SetActivationPointIxData), - RemoveLiquidityByRange( - RemoveLiquidityByRangeIxAccounts, - RemoveLiquidityByRangeIxData, - ), - AddLiquidityOneSidePrecise( - AddLiquidityOneSidePreciseIxAccounts, - AddLiquidityOneSidePreciseIxData, - ), - GoToABin(GoToABinIxAccounts, GoToABinIxData), - SetPreActivationDuration( - SetPreActivationDurationIxAccounts, - SetPreActivationDurationIxData, - ), - SetPreActivationSwapAddress( - SetPreActivationSwapAddressIxAccounts, - SetPreActivationSwapAddressIxData, - ), - SetPairStatusPermissionless( - SetPairStatusPermissionlessIxAccounts, - SetPairStatusPermissionlessIxData, - ), - InitializeTokenBadge(InitializeTokenBadgeIxAccounts), - CreateClaimProtocolFeeOperator(CreateClaimProtocolFeeOperatorIxAccounts), - CloseClaimProtocolFeeOperator(CloseClaimProtocolFeeOperatorIxAccounts), - InitializePresetParameter2( - InitializePresetParameter2IxAccounts, - InitializePresetParameter2IxData, - ), - InitializeLbPair2(InitializeLbPair2IxAccounts, InitializeLbPair2IxData), - InitializeCustomizablePermissionlessLbPair2( - InitializeCustomizablePermissionlessLbPair2IxAccounts, - InitializeCustomizablePermissionlessLbPair2IxData, - ), - ClaimFee2(ClaimFee2IxAccounts, ClaimFee2IxData), - ClaimReward2(ClaimReward2IxAccounts, ClaimReward2IxData), - AddLiquidity2(AddLiquidity2IxAccounts, AddLiquidity2IxData), - AddLiquidityByStrategy2( - AddLiquidityByStrategy2IxAccounts, - AddLiquidityByStrategy2IxData, - ), - AddLiquidityOneSidePrecise2( - AddLiquidityOneSidePrecise2IxAccounts, - AddLiquidityOneSidePrecise2IxData, - ), - RemoveLiquidity2(RemoveLiquidity2IxAccounts, RemoveLiquidity2IxData), - RemoveLiquidityByRange2( - RemoveLiquidityByRange2IxAccounts, - RemoveLiquidityByRange2IxData, - ), - Swap2(Swap2IxAccounts, Swap2IxData), - SwapExactOut2(SwapExactOut2IxAccounts, SwapExactOut2IxData), - SwapWithPriceImpact2(SwapWithPriceImpact2IxAccounts, SwapWithPriceImpact2IxData), - ClosePosition2(ClosePosition2IxAccounts), - UpdateFeesAndReward2(UpdateFeesAndReward2IxAccounts, UpdateFeesAndReward2IxData), - ClosePositionIfEmpty(ClosePositionIfEmptyIxAccounts), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = LbClmmProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "LbClmm::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [45, 154, 237, 210, 221, 15, 166, 92] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeLbPairIxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - token_mint_x: next_account(accounts)?, - token_mint_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - oracle: next_account(accounts)?, - preset_parameter: next_account(accounts)?, - funder: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeLbPairIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializeLbPair(ix_accounts, de_ix_data)) - }, - [108, 102, 213, 85, 251, 3, 53, 21] => { - let expected_accounts_len = 17; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePermissionLbPairIxAccounts { - base: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - token_mint_x: next_account(accounts)?, - token_mint_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - oracle: next_account(accounts)?, - admin: next_account(accounts)?, - token_badge_x: next_program_id_optional_account(accounts)?, - token_badge_y: next_program_id_optional_account(accounts)?, - token_program_x: next_account(accounts)?, - token_program_y: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializePermissionLbPairIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializePermissionLbPair( - ix_accounts, - de_ix_data, - )) - }, - [46, 39, 41, 135, 111, 183, 200, 64] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeCustomizablePermissionlessLbPairIxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - token_mint_x: next_account(accounts)?, - token_mint_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - oracle: next_account(accounts)?, - user_token_x: next_account(accounts)?, - funder: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - user_token_y: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeCustomizablePermissionlessLbPairIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializeCustomizablePermissionlessLbPair( - ix_accounts, - de_ix_data, - )) - }, - [47, 157, 226, 180, 12, 240, 33, 71] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeBinArrayBitmapExtensionIxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_account(accounts)?, - funder: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::InitializeBinArrayBitmapExtension( - ix_accounts, - )) - }, - [35, 86, 19, 185, 78, 212, 75, 211] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeBinArrayIxAccounts { - lb_pair: next_account(accounts)?, - bin_array: next_account(accounts)?, - funder: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializeBinArrayIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializeBinArray(ix_accounts, de_ix_data)) - }, - [181, 157, 89, 67, 143, 182, 52, 72] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddLiquidityIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: AddLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::AddLiquidity(ix_accounts, de_ix_data)) - }, - [28, 140, 238, 99, 231, 162, 21, 149] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddLiquidityByWeightIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: AddLiquidityByWeightIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::AddLiquidityByWeight( - ix_accounts, - de_ix_data, - )) - }, - [7, 3, 150, 127, 148, 40, 61, 200] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddLiquidityByStrategyIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: AddLiquidityByStrategyIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::AddLiquidityByStrategy( - ix_accounts, - de_ix_data, - )) - }, - [41, 5, 238, 175, 100, 225, 6, 205] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddLiquidityByStrategyOneSideIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token: next_account(accounts)?, - reserve: next_account(accounts)?, - token_mint: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: AddLiquidityByStrategyOneSideIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::AddLiquidityByStrategyOneSide( - ix_accounts, - de_ix_data, - )) - }, - [94, 155, 103, 151, 70, 95, 220, 165] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddLiquidityOneSideIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token: next_account(accounts)?, - reserve: next_account(accounts)?, - token_mint: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: AddLiquidityOneSideIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::AddLiquidityOneSide( - ix_accounts, - de_ix_data, - )) - }, - [80, 85, 209, 72, 24, 206, 177, 108] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveLiquidityIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: RemoveLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::RemoveLiquidity(ix_accounts, de_ix_data)) - }, - [219, 192, 234, 71, 190, 191, 102, 80] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePositionIxAccounts { - payer: next_account(accounts)?, - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - owner: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializePositionIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializePosition(ix_accounts, de_ix_data)) - }, - [46, 82, 125, 146, 85, 141, 228, 153] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePositionPdaIxAccounts { - payer: next_account(accounts)?, - base: next_account(accounts)?, - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - owner: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializePositionPdaIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializePositionPda( - ix_accounts, - de_ix_data, - )) - }, - [251, 189, 190, 244, 117, 254, 35, 148] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePositionByOperatorIxAccounts { - payer: next_account(accounts)?, - base: next_account(accounts)?, - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - owner: next_account(accounts)?, - operator: next_account(accounts)?, - operator_token_x: next_account(accounts)?, - owner_token_x: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializePositionByOperatorIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializePositionByOperator( - ix_accounts, - de_ix_data, - )) - }, - [202, 184, 103, 143, 180, 191, 116, 217] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdatePositionOperatorIxAccounts { - position: next_account(accounts)?, - owner: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: UpdatePositionOperatorIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::UpdatePositionOperator( - ix_accounts, - de_ix_data, - )) - }, - [248, 198, 158, 145, 225, 117, 135, 200] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapIxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - user_token_in: next_account(accounts)?, - user_token_out: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - oracle: next_account(accounts)?, - host_fee_in: next_program_id_optional_account(accounts)?, - user: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SwapIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::Swap(ix_accounts, de_ix_data)) - }, - [250, 73, 101, 33, 38, 207, 75, 184] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapExactOutIxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - user_token_in: next_account(accounts)?, - user_token_out: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - oracle: next_account(accounts)?, - host_fee_in: next_program_id_optional_account(accounts)?, - user: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SwapExactOutIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::SwapExactOut(ix_accounts, de_ix_data)) - }, - [56, 173, 230, 208, 173, 228, 156, 205] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapWithPriceImpactIxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - user_token_in: next_account(accounts)?, - user_token_out: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - oracle: next_account(accounts)?, - host_fee_in: next_program_id_optional_account(accounts)?, - user: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SwapWithPriceImpactIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::SwapWithPriceImpact( - ix_accounts, - de_ix_data, - )) - }, - [158, 201, 158, 189, 33, 93, 162, 103] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawProtocolFeeIxAccounts { - lb_pair: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - receiver_token_x: next_account(accounts)?, - receiver_token_y: next_account(accounts)?, - claim_fee_operator: next_account(accounts)?, - operator: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - memo_program: next_account(accounts)?, - }; - let de_ix_data: WithdrawProtocolFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::WithdrawProtocolFee( - ix_accounts, - de_ix_data, - )) - }, - [95, 135, 192, 196, 242, 129, 230, 68] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeRewardIxAccounts { - lb_pair: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_mint: next_account(accounts)?, - token_badge: next_program_id_optional_account(accounts)?, - admin: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeRewardIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializeReward(ix_accounts, de_ix_data)) - }, - [188, 50, 249, 165, 93, 151, 38, 63] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = FundRewardIxAccounts { - lb_pair: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_mint: next_account(accounts)?, - funder_token_account: next_account(accounts)?, - funder: next_account(accounts)?, - bin_array: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: FundRewardIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::FundReward(ix_accounts, de_ix_data)) - }, - [211, 28, 48, 32, 215, 160, 35, 23] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateRewardFunderIxAccounts { - lb_pair: next_account(accounts)?, - admin: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: UpdateRewardFunderIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::UpdateRewardFunder(ix_accounts, de_ix_data)) - }, - [138, 174, 196, 169, 213, 235, 254, 107] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateRewardDurationIxAccounts { - lb_pair: next_account(accounts)?, - admin: next_account(accounts)?, - bin_array: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: UpdateRewardDurationIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::UpdateRewardDuration( - ix_accounts, - de_ix_data, - )) - }, - [149, 95, 181, 242, 94, 90, 158, 162] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimRewardIxAccounts { - lb_pair: next_account(accounts)?, - position: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_mint: next_account(accounts)?, - user_token_account: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: ClaimRewardIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::ClaimReward(ix_accounts, de_ix_data)) - }, - [169, 32, 79, 137, 136, 232, 70, 137] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimFeeIxAccounts { - lb_pair: next_account(accounts)?, - position: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::ClaimFee(ix_accounts)) - }, - [123, 134, 81, 0, 49, 68, 98, 98] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClosePositionIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::ClosePosition(ix_accounts)) - }, - [75, 168, 223, 161, 16, 195, 3, 47] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateBaseFeeParametersIxAccounts { - lb_pair: next_account(accounts)?, - admin: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: UpdateBaseFeeParametersIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::UpdateBaseFeeParameters( - ix_accounts, - de_ix_data, - )) - }, - [92, 161, 46, 246, 255, 189, 22, 22] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateDynamicFeeParametersIxAccounts { - lb_pair: next_account(accounts)?, - admin: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: UpdateDynamicFeeParametersIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::UpdateDynamicFeeParameters( - ix_accounts, - de_ix_data, - )) - }, - [190, 61, 125, 87, 103, 79, 158, 173] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = IncreaseOracleLengthIxAccounts { - oracle: next_account(accounts)?, - funder: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: IncreaseOracleLengthIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::IncreaseOracleLength( - ix_accounts, - de_ix_data, - )) - }, - [66, 188, 71, 211, 98, 109, 14, 186] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePresetParameterIxAccounts { - preset_parameter: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: InitializePresetParameterIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializePresetParameter( - ix_accounts, - de_ix_data, - )) - }, - [4, 148, 145, 100, 134, 26, 181, 61] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClosePresetParameterIxAccounts { - preset_parameter: next_account(accounts)?, - admin: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::ClosePresetParameter(ix_accounts)) - }, - [39, 25, 95, 107, 116, 17, 115, 28] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClosePresetParameter2IxAccounts { - preset_parameter: next_account(accounts)?, - admin: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::ClosePresetParameter2(ix_accounts)) - }, - [10, 51, 61, 35, 112, 105, 24, 85] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveAllLiquidityIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::RemoveAllLiquidity(ix_accounts)) - }, - [67, 248, 231, 137, 154, 149, 217, 174] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetPairStatusIxAccounts { - lb_pair: next_account(accounts)?, - admin: next_account(accounts)?, - }; - let de_ix_data: SetPairStatusIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::SetPairStatus(ix_accounts, de_ix_data)) - }, - [15, 132, 59, 50, 199, 6, 251, 46] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigratePositionIxAccounts { - position_v2: next_account(accounts)?, - position_v1: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - owner: next_account(accounts)?, - system_program: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::MigratePosition(ix_accounts)) - }, - [17, 23, 159, 211, 101, 184, 41, 241] => { - let expected_accounts_len = 1; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrateBinArrayIxAccounts { - lb_pair: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::MigrateBinArray(ix_accounts)) - }, - [154, 230, 250, 13, 236, 209, 75, 223] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateFeesAndRewardsIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - owner: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::UpdateFeesAndRewards(ix_accounts)) - }, - [148, 206, 42, 195, 247, 49, 103, 8] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawIneligibleRewardIxAccounts { - lb_pair: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_mint: next_account(accounts)?, - funder_token_account: next_account(accounts)?, - funder: next_account(accounts)?, - bin_array: next_account(accounts)?, - token_program: next_account(accounts)?, - memo_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: WithdrawIneligibleRewardIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::WithdrawIneligibleReward( - ix_accounts, - de_ix_data, - )) - }, - [91, 249, 15, 165, 26, 129, 254, 125] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetActivationPointIxAccounts { - lb_pair: next_account(accounts)?, - admin: next_account(accounts)?, - }; - let de_ix_data: SetActivationPointIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::SetActivationPoint(ix_accounts, de_ix_data)) - }, - [26, 82, 102, 152, 240, 74, 105, 26] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveLiquidityByRangeIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: RemoveLiquidityByRangeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::RemoveLiquidityByRange( - ix_accounts, - de_ix_data, - )) - }, - [161, 194, 103, 84, 171, 71, 250, 154] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddLiquidityOneSidePreciseIxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token: next_account(accounts)?, - reserve: next_account(accounts)?, - token_mint: next_account(accounts)?, - bin_array_lower: next_account(accounts)?, - bin_array_upper: next_account(accounts)?, - sender: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: AddLiquidityOneSidePreciseIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::AddLiquidityOneSidePrecise( - ix_accounts, - de_ix_data, - )) - }, - [146, 72, 174, 224, 40, 253, 84, 174] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = GoToABinIxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - from_bin_array: next_program_id_optional_account(accounts)?, - to_bin_array: next_program_id_optional_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: GoToABinIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::GoToABin(ix_accounts, de_ix_data)) - }, - [165, 61, 201, 244, 130, 159, 22, 100] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetPreActivationDurationIxAccounts { - lb_pair: next_account(accounts)?, - creator: next_account(accounts)?, - }; - let de_ix_data: SetPreActivationDurationIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::SetPreActivationDuration( - ix_accounts, - de_ix_data, - )) - }, - [57, 139, 47, 123, 216, 80, 223, 10] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetPreActivationSwapAddressIxAccounts { - lb_pair: next_account(accounts)?, - creator: next_account(accounts)?, - }; - let de_ix_data: SetPreActivationSwapAddressIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::SetPreActivationSwapAddress( - ix_accounts, - de_ix_data, - )) - }, - [78, 59, 152, 211, 70, 183, 46, 208] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetPairStatusPermissionlessIxAccounts { - lb_pair: next_account(accounts)?, - creator: next_account(accounts)?, - }; - let de_ix_data: SetPairStatusPermissionlessIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::SetPairStatusPermissionless( - ix_accounts, - de_ix_data, - )) - }, - [253, 77, 205, 95, 27, 224, 89, 223] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeTokenBadgeIxAccounts { - token_mint: next_account(accounts)?, - token_badge: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::InitializeTokenBadge(ix_accounts)) - }, - [51, 19, 150, 252, 105, 157, 48, 91] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateClaimProtocolFeeOperatorIxAccounts { - claim_fee_operator: next_account(accounts)?, - operator: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::CreateClaimProtocolFeeOperator(ix_accounts)) - }, - [8, 41, 87, 35, 80, 48, 121, 26] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CloseClaimProtocolFeeOperatorIxAccounts { - claim_fee_operator: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - admin: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::CloseClaimProtocolFeeOperator(ix_accounts)) - }, - [184, 7, 240, 171, 103, 47, 183, 121] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePresetParameter2IxAccounts { - preset_parameter: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializePresetParameter2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializePresetParameter2( - ix_accounts, - de_ix_data, - )) - }, - [73, 59, 36, 120, 237, 83, 108, 198] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeLbPair2IxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - token_mint_x: next_account(accounts)?, - token_mint_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - oracle: next_account(accounts)?, - preset_parameter: next_account(accounts)?, - funder: next_account(accounts)?, - token_badge_x: next_program_id_optional_account(accounts)?, - token_badge_y: next_program_id_optional_account(accounts)?, - token_program_x: next_account(accounts)?, - token_program_y: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeLbPair2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::InitializeLbPair2(ix_accounts, de_ix_data)) - }, - [243, 73, 129, 126, 51, 19, 241, 107] => { - let expected_accounts_len = 17; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeCustomizablePermissionlessLbPair2IxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - token_mint_x: next_account(accounts)?, - token_mint_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - oracle: next_account(accounts)?, - user_token_x: next_account(accounts)?, - funder: next_account(accounts)?, - token_badge_x: next_program_id_optional_account(accounts)?, - token_badge_y: next_program_id_optional_account(accounts)?, - token_program_x: next_account(accounts)?, - token_program_y: next_account(accounts)?, - system_program: next_account(accounts)?, - user_token_y: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeCustomizablePermissionlessLbPair2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok( - LbClmmProgramIx::InitializeCustomizablePermissionlessLbPair2( - ix_accounts, - de_ix_data, - ), - ) - }, - [112, 191, 101, 171, 28, 144, 127, 187] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimFee2IxAccounts { - lb_pair: next_account(accounts)?, - position: next_account(accounts)?, - sender: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - token_program_x: next_account(accounts)?, - token_program_y: next_account(accounts)?, - memo_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: ClaimFee2IxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::ClaimFee2(ix_accounts, de_ix_data)) - }, - [190, 3, 127, 119, 178, 87, 157, 183] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimReward2IxAccounts { - lb_pair: next_account(accounts)?, - position: next_account(accounts)?, - sender: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_mint: next_account(accounts)?, - user_token_account: next_account(accounts)?, - token_program: next_account(accounts)?, - memo_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: ClaimReward2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::ClaimReward2(ix_accounts, de_ix_data)) - }, - [228, 162, 78, 28, 70, 219, 116, 115] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddLiquidity2IxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - sender: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: AddLiquidity2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::AddLiquidity2(ix_accounts, de_ix_data)) - }, - [3, 221, 149, 218, 111, 141, 118, 213] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddLiquidityByStrategy2IxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - sender: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: AddLiquidityByStrategy2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::AddLiquidityByStrategy2( - ix_accounts, - de_ix_data, - )) - }, - [33, 51, 163, 201, 117, 98, 125, 231] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddLiquidityOneSidePrecise2IxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token: next_account(accounts)?, - reserve: next_account(accounts)?, - token_mint: next_account(accounts)?, - sender: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: AddLiquidityOneSidePrecise2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::AddLiquidityOneSidePrecise2( - ix_accounts, - de_ix_data, - )) - }, - [230, 215, 82, 127, 241, 101, 227, 146] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveLiquidity2IxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - sender: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - memo_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: RemoveLiquidity2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::RemoveLiquidity2(ix_accounts, de_ix_data)) - }, - [204, 2, 195, 145, 53, 145, 145, 205] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveLiquidityByRange2IxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - user_token_x: next_account(accounts)?, - user_token_y: next_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - sender: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - memo_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: RemoveLiquidityByRange2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::RemoveLiquidityByRange2( - ix_accounts, - de_ix_data, - )) - }, - [65, 75, 63, 76, 235, 91, 91, 136] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = Swap2IxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - user_token_in: next_account(accounts)?, - user_token_out: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - oracle: next_account(accounts)?, - host_fee_in: next_program_id_optional_account(accounts)?, - user: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - memo_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: Swap2IxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::Swap2(ix_accounts, de_ix_data)) - }, - [43, 215, 247, 132, 137, 60, 243, 81] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapExactOut2IxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - user_token_in: next_account(accounts)?, - user_token_out: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - oracle: next_account(accounts)?, - host_fee_in: next_program_id_optional_account(accounts)?, - user: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - memo_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SwapExactOut2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::SwapExactOut2(ix_accounts, de_ix_data)) - }, - [74, 98, 192, 214, 177, 51, 75, 51] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapWithPriceImpact2IxAccounts { - lb_pair: next_account(accounts)?, - bin_array_bitmap_extension: next_program_id_optional_account(accounts)?, - reserve_x: next_account(accounts)?, - reserve_y: next_account(accounts)?, - user_token_in: next_account(accounts)?, - user_token_out: next_account(accounts)?, - token_x_mint: next_account(accounts)?, - token_y_mint: next_account(accounts)?, - oracle: next_account(accounts)?, - host_fee_in: next_program_id_optional_account(accounts)?, - user: next_account(accounts)?, - token_x_program: next_account(accounts)?, - token_y_program: next_account(accounts)?, - memo_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SwapWithPriceImpact2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::SwapWithPriceImpact2( - ix_accounts, - de_ix_data, - )) - }, - [174, 90, 35, 115, 186, 40, 147, 226] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClosePosition2IxAccounts { - position: next_account(accounts)?, - sender: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::ClosePosition2(ix_accounts)) - }, - [32, 142, 184, 154, 103, 65, 184, 88] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateFeesAndReward2IxAccounts { - position: next_account(accounts)?, - lb_pair: next_account(accounts)?, - owner: next_account(accounts)?, - }; - let de_ix_data: UpdateFeesAndReward2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(LbClmmProgramIx::UpdateFeesAndReward2( - ix_accounts, - de_ix_data, - )) - }, - [59, 124, 212, 118, 91, 152, 110, 157] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClosePositionIfEmptyIxAccounts { - position: next_account(accounts)?, - sender: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(LbClmmProgramIx::ClosePositionIfEmpty(ix_accounts)) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{InitializeLbPairIxAccounts, InstructionParser, LbClmmProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for InitializeLbPairIxAccounts { - fn into_proto(self) -> proto_def::InitializeLbPairIxAccounts { - proto_def::InitializeLbPairIxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - token_mint_x: self.token_mint_x.to_string(), - token_mint_y: self.token_mint_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - oracle: self.oracle.to_string(), - preset_parameter: self.preset_parameter.to_string(), - funder: self.funder.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeLbPairIxData; - impl IntoProto for InitializeLbPairIxData { - fn into_proto(self) -> proto_def::InitializeLbPairIxData { - proto_def::InitializeLbPairIxData { - active_id: self.active_id, - bin_step: self.bin_step.into(), - } - } - } - use super::InitializePermissionLbPairIxAccounts; - impl IntoProto - for InitializePermissionLbPairIxAccounts - { - fn into_proto(self) -> proto_def::InitializePermissionLbPairIxAccounts { - proto_def::InitializePermissionLbPairIxAccounts { - base: self.base.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - token_mint_x: self.token_mint_x.to_string(), - token_mint_y: self.token_mint_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - oracle: self.oracle.to_string(), - admin: self.admin.to_string(), - token_badge_x: self.token_badge_x.map(|p| p.to_string()), - token_badge_y: self.token_badge_y.map(|p| p.to_string()), - token_program_x: self.token_program_x.to_string(), - token_program_y: self.token_program_y.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializePermissionLbPairIxData; - impl IntoProto for InitializePermissionLbPairIxData { - fn into_proto(self) -> proto_def::InitializePermissionLbPairIxData { - proto_def::InitializePermissionLbPairIxData { - active_id: self.active_id, - bin_step: self.bin_step.into(), - base_factor: self.base_factor.into(), - base_fee_power_factor: self.base_fee_power_factor.into(), - activation_type: self.activation_type.into(), - protocol_share: self.protocol_share.into(), - } - } - } - use super::InitializeCustomizablePermissionlessLbPairIxAccounts; - impl IntoProto - for InitializeCustomizablePermissionlessLbPairIxAccounts - { - fn into_proto(self) -> proto_def::InitializeCustomizablePermissionlessLbPairIxAccounts { - proto_def::InitializeCustomizablePermissionlessLbPairIxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - token_mint_x: self.token_mint_x.to_string(), - token_mint_y: self.token_mint_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - oracle: self.oracle.to_string(), - user_token_x: self.user_token_x.to_string(), - funder: self.funder.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - user_token_y: self.user_token_y.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeCustomizablePermissionlessLbPairIxData; - impl IntoProto - for InitializeCustomizablePermissionlessLbPairIxData - { - fn into_proto(self) -> proto_def::InitializeCustomizablePermissionlessLbPairIxData { - proto_def::InitializeCustomizablePermissionlessLbPairIxData { - params: Some(self.params.into_proto()), - } - } - } - use super::InitializeBinArrayBitmapExtensionIxAccounts; - impl IntoProto - for InitializeBinArrayBitmapExtensionIxAccounts - { - fn into_proto(self) -> proto_def::InitializeBinArrayBitmapExtensionIxAccounts { - proto_def::InitializeBinArrayBitmapExtensionIxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.to_string(), - funder: self.funder.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::InitializeBinArrayIxAccounts; - impl IntoProto for InitializeBinArrayIxAccounts { - fn into_proto(self) -> proto_def::InitializeBinArrayIxAccounts { - proto_def::InitializeBinArrayIxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array: self.bin_array.to_string(), - funder: self.funder.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializeBinArrayIxData; - impl IntoProto for InitializeBinArrayIxData { - fn into_proto(self) -> proto_def::InitializeBinArrayIxData { - proto_def::InitializeBinArrayIxData { index: self.index } - } - } - use super::AddLiquidityIxAccounts; - impl IntoProto for AddLiquidityIxAccounts { - fn into_proto(self) -> proto_def::AddLiquidityIxAccounts { - proto_def::AddLiquidityIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::AddLiquidityIxData; - impl IntoProto for AddLiquidityIxData { - fn into_proto(self) -> proto_def::AddLiquidityIxData { - proto_def::AddLiquidityIxData { - liquidity_parameter: Some(self.liquidity_parameter.into_proto()), - } - } - } - use super::AddLiquidityByWeightIxAccounts; - impl IntoProto for AddLiquidityByWeightIxAccounts { - fn into_proto(self) -> proto_def::AddLiquidityByWeightIxAccounts { - proto_def::AddLiquidityByWeightIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::AddLiquidityByWeightIxData; - impl IntoProto for AddLiquidityByWeightIxData { - fn into_proto(self) -> proto_def::AddLiquidityByWeightIxData { - proto_def::AddLiquidityByWeightIxData { - amount_x: self.amount_x, - amount_y: self.amount_y, - active_id: self.active_id, - max_active_bin_slippage: self.max_active_bin_slippage, - bin_liquidity_dist: self - .bin_liquidity_dist - .into_iter() - .map(|x| x.into_proto()) - .collect(), - } - } - } - use super::AddLiquidityByStrategyIxAccounts; - impl IntoProto for AddLiquidityByStrategyIxAccounts { - fn into_proto(self) -> proto_def::AddLiquidityByStrategyIxAccounts { - proto_def::AddLiquidityByStrategyIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::AddLiquidityByStrategyIxData; - impl IntoProto for AddLiquidityByStrategyIxData { - fn into_proto(self) -> proto_def::AddLiquidityByStrategyIxData { - proto_def::AddLiquidityByStrategyIxData { - liquidity_parameter: Some(self.liquidity_parameter.into_proto()), - } - } - } - use super::AddLiquidityByStrategyOneSideIxAccounts; - impl IntoProto - for AddLiquidityByStrategyOneSideIxAccounts - { - fn into_proto(self) -> proto_def::AddLiquidityByStrategyOneSideIxAccounts { - proto_def::AddLiquidityByStrategyOneSideIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token: self.user_token.to_string(), - reserve: self.reserve.to_string(), - token_mint: self.token_mint.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::AddLiquidityByStrategyOneSideIxData; - impl IntoProto - for AddLiquidityByStrategyOneSideIxData - { - fn into_proto(self) -> proto_def::AddLiquidityByStrategyOneSideIxData { - proto_def::AddLiquidityByStrategyOneSideIxData { - amount: self.amount, - active_id: self.active_id, - max_active_bin_slippage: self.max_active_bin_slippage, - strategy_parameters: Some(self.strategy_parameters.into_proto()), - } - } - } - use super::AddLiquidityOneSideIxAccounts; - impl IntoProto for AddLiquidityOneSideIxAccounts { - fn into_proto(self) -> proto_def::AddLiquidityOneSideIxAccounts { - proto_def::AddLiquidityOneSideIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token: self.user_token.to_string(), - reserve: self.reserve.to_string(), - token_mint: self.token_mint.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::AddLiquidityOneSideIxData; - impl IntoProto for AddLiquidityOneSideIxData { - fn into_proto(self) -> proto_def::AddLiquidityOneSideIxData { - proto_def::AddLiquidityOneSideIxData { - amount: self.amount, - active_id: self.active_id, - max_active_bin_slippage: self.max_active_bin_slippage, - bin_liquidity_dist: self - .bin_liquidity_dist - .into_iter() - .map(|x| x.into_proto()) - .collect(), - } - } - } - use super::RemoveLiquidityIxAccounts; - impl IntoProto for RemoveLiquidityIxAccounts { - fn into_proto(self) -> proto_def::RemoveLiquidityIxAccounts { - proto_def::RemoveLiquidityIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::RemoveLiquidityIxData; - impl IntoProto for RemoveLiquidityIxData { - fn into_proto(self) -> proto_def::RemoveLiquidityIxData { - proto_def::RemoveLiquidityIxData { - bin_liquidity_removal: self - .bin_liquidity_removal - .into_iter() - .map(|x| x.into_proto()) - .collect(), - } - } - } - use super::InitializePositionIxAccounts; - impl IntoProto for InitializePositionIxAccounts { - fn into_proto(self) -> proto_def::InitializePositionIxAccounts { - proto_def::InitializePositionIxAccounts { - payer: self.payer.to_string(), - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - owner: self.owner.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializePositionIxData; - impl IntoProto for InitializePositionIxData { - fn into_proto(self) -> proto_def::InitializePositionIxData { - proto_def::InitializePositionIxData { - lower_bin_id: self.lower_bin_id, - width: self.width, - } - } - } - use super::InitializePositionPdaIxAccounts; - impl IntoProto for InitializePositionPdaIxAccounts { - fn into_proto(self) -> proto_def::InitializePositionPdaIxAccounts { - proto_def::InitializePositionPdaIxAccounts { - payer: self.payer.to_string(), - base: self.base.to_string(), - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - owner: self.owner.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializePositionPdaIxData; - impl IntoProto for InitializePositionPdaIxData { - fn into_proto(self) -> proto_def::InitializePositionPdaIxData { - proto_def::InitializePositionPdaIxData { - lower_bin_id: self.lower_bin_id, - width: self.width, - } - } - } - use super::InitializePositionByOperatorIxAccounts; - impl IntoProto - for InitializePositionByOperatorIxAccounts - { - fn into_proto(self) -> proto_def::InitializePositionByOperatorIxAccounts { - proto_def::InitializePositionByOperatorIxAccounts { - payer: self.payer.to_string(), - base: self.base.to_string(), - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - owner: self.owner.to_string(), - operator: self.operator.to_string(), - operator_token_x: self.operator_token_x.to_string(), - owner_token_x: self.owner_token_x.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializePositionByOperatorIxData; - impl IntoProto - for InitializePositionByOperatorIxData - { - fn into_proto(self) -> proto_def::InitializePositionByOperatorIxData { - proto_def::InitializePositionByOperatorIxData { - lower_bin_id: self.lower_bin_id, - width: self.width, - fee_owner: self.fee_owner.to_string(), - lock_release_point: self.lock_release_point, - } - } - } - use super::UpdatePositionOperatorIxAccounts; - impl IntoProto for UpdatePositionOperatorIxAccounts { - fn into_proto(self) -> proto_def::UpdatePositionOperatorIxAccounts { - proto_def::UpdatePositionOperatorIxAccounts { - position: self.position.to_string(), - owner: self.owner.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdatePositionOperatorIxData; - impl IntoProto for UpdatePositionOperatorIxData { - fn into_proto(self) -> proto_def::UpdatePositionOperatorIxData { - proto_def::UpdatePositionOperatorIxData { - operator: self.operator.to_string(), - } - } - } - use super::SwapIxAccounts; - impl IntoProto for SwapIxAccounts { - fn into_proto(self) -> proto_def::SwapIxAccounts { - proto_def::SwapIxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - user_token_in: self.user_token_in.to_string(), - user_token_out: self.user_token_out.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - oracle: self.oracle.to_string(), - host_fee_in: self.host_fee_in.map(|p| p.to_string()), - user: self.user.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SwapIxData; - impl IntoProto for SwapIxData { - fn into_proto(self) -> proto_def::SwapIxData { - proto_def::SwapIxData { - amount_in: self.amount_in, - min_amount_out: self.min_amount_out, - } - } - } - use super::SwapExactOutIxAccounts; - impl IntoProto for SwapExactOutIxAccounts { - fn into_proto(self) -> proto_def::SwapExactOutIxAccounts { - proto_def::SwapExactOutIxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - user_token_in: self.user_token_in.to_string(), - user_token_out: self.user_token_out.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - oracle: self.oracle.to_string(), - host_fee_in: self.host_fee_in.map(|p| p.to_string()), - user: self.user.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SwapExactOutIxData; - impl IntoProto for SwapExactOutIxData { - fn into_proto(self) -> proto_def::SwapExactOutIxData { - proto_def::SwapExactOutIxData { - max_in_amount: self.max_in_amount, - out_amount: self.out_amount, - } - } - } - use super::SwapWithPriceImpactIxAccounts; - impl IntoProto for SwapWithPriceImpactIxAccounts { - fn into_proto(self) -> proto_def::SwapWithPriceImpactIxAccounts { - proto_def::SwapWithPriceImpactIxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - user_token_in: self.user_token_in.to_string(), - user_token_out: self.user_token_out.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - oracle: self.oracle.to_string(), - host_fee_in: self.host_fee_in.map(|p| p.to_string()), - user: self.user.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SwapWithPriceImpactIxData; - impl IntoProto for SwapWithPriceImpactIxData { - fn into_proto(self) -> proto_def::SwapWithPriceImpactIxData { - proto_def::SwapWithPriceImpactIxData { - amount_in: self.amount_in, - active_id: self.active_id, - max_price_impact_bps: self.max_price_impact_bps.into(), - } - } - } - use super::WithdrawProtocolFeeIxAccounts; - impl IntoProto for WithdrawProtocolFeeIxAccounts { - fn into_proto(self) -> proto_def::WithdrawProtocolFeeIxAccounts { - proto_def::WithdrawProtocolFeeIxAccounts { - lb_pair: self.lb_pair.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - receiver_token_x: self.receiver_token_x.to_string(), - receiver_token_y: self.receiver_token_y.to_string(), - claim_fee_operator: self.claim_fee_operator.to_string(), - operator: self.operator.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - memo_program: self.memo_program.to_string(), - } - } - } - use super::WithdrawProtocolFeeIxData; - impl IntoProto for WithdrawProtocolFeeIxData { - fn into_proto(self) -> proto_def::WithdrawProtocolFeeIxData { - proto_def::WithdrawProtocolFeeIxData { - amount_x: self.amount_x, - amount_y: self.amount_y, - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::InitializeRewardIxAccounts; - impl IntoProto for InitializeRewardIxAccounts { - fn into_proto(self) -> proto_def::InitializeRewardIxAccounts { - proto_def::InitializeRewardIxAccounts { - lb_pair: self.lb_pair.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_mint: self.reward_mint.to_string(), - token_badge: self.token_badge.map(|p| p.to_string()), - admin: self.admin.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeRewardIxData; - impl IntoProto for InitializeRewardIxData { - fn into_proto(self) -> proto_def::InitializeRewardIxData { - proto_def::InitializeRewardIxData { - reward_index: self.reward_index, - reward_duration: self.reward_duration, - funder: self.funder.to_string(), - } - } - } - use super::FundRewardIxAccounts; - impl IntoProto for FundRewardIxAccounts { - fn into_proto(self) -> proto_def::FundRewardIxAccounts { - proto_def::FundRewardIxAccounts { - lb_pair: self.lb_pair.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_mint: self.reward_mint.to_string(), - funder_token_account: self.funder_token_account.to_string(), - funder: self.funder.to_string(), - bin_array: self.bin_array.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::FundRewardIxData; - impl IntoProto for FundRewardIxData { - fn into_proto(self) -> proto_def::FundRewardIxData { - proto_def::FundRewardIxData { - reward_index: self.reward_index, - amount: self.amount, - carry_forward: self.carry_forward, - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::UpdateRewardFunderIxAccounts; - impl IntoProto for UpdateRewardFunderIxAccounts { - fn into_proto(self) -> proto_def::UpdateRewardFunderIxAccounts { - proto_def::UpdateRewardFunderIxAccounts { - lb_pair: self.lb_pair.to_string(), - admin: self.admin.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateRewardFunderIxData; - impl IntoProto for UpdateRewardFunderIxData { - fn into_proto(self) -> proto_def::UpdateRewardFunderIxData { - proto_def::UpdateRewardFunderIxData { - reward_index: self.reward_index, - new_funder: self.new_funder.to_string(), - } - } - } - use super::UpdateRewardDurationIxAccounts; - impl IntoProto for UpdateRewardDurationIxAccounts { - fn into_proto(self) -> proto_def::UpdateRewardDurationIxAccounts { - proto_def::UpdateRewardDurationIxAccounts { - lb_pair: self.lb_pair.to_string(), - admin: self.admin.to_string(), - bin_array: self.bin_array.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateRewardDurationIxData; - impl IntoProto for UpdateRewardDurationIxData { - fn into_proto(self) -> proto_def::UpdateRewardDurationIxData { - proto_def::UpdateRewardDurationIxData { - reward_index: self.reward_index, - new_duration: self.new_duration, - } - } - } - use super::ClaimRewardIxAccounts; - impl IntoProto for ClaimRewardIxAccounts { - fn into_proto(self) -> proto_def::ClaimRewardIxAccounts { - proto_def::ClaimRewardIxAccounts { - lb_pair: self.lb_pair.to_string(), - position: self.position.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_mint: self.reward_mint.to_string(), - user_token_account: self.user_token_account.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClaimRewardIxData; - impl IntoProto for ClaimRewardIxData { - fn into_proto(self) -> proto_def::ClaimRewardIxData { - proto_def::ClaimRewardIxData { - reward_index: self.reward_index, - } - } - } - use super::ClaimFeeIxAccounts; - impl IntoProto for ClaimFeeIxAccounts { - fn into_proto(self) -> proto_def::ClaimFeeIxAccounts { - proto_def::ClaimFeeIxAccounts { - lb_pair: self.lb_pair.to_string(), - position: self.position.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClosePositionIxAccounts; - impl IntoProto for ClosePositionIxAccounts { - fn into_proto(self) -> proto_def::ClosePositionIxAccounts { - proto_def::ClosePositionIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - rent_receiver: self.rent_receiver.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateBaseFeeParametersIxAccounts; - impl IntoProto for UpdateBaseFeeParametersIxAccounts { - fn into_proto(self) -> proto_def::UpdateBaseFeeParametersIxAccounts { - proto_def::UpdateBaseFeeParametersIxAccounts { - lb_pair: self.lb_pair.to_string(), - admin: self.admin.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateBaseFeeParametersIxData; - impl IntoProto for UpdateBaseFeeParametersIxData { - fn into_proto(self) -> proto_def::UpdateBaseFeeParametersIxData { - proto_def::UpdateBaseFeeParametersIxData { - protocol_share: self.protocol_share.into(), - base_factor: self.base_factor.into(), - base_fee_power_factor: self.base_fee_power_factor.into(), - } - } - } - use super::UpdateDynamicFeeParametersIxAccounts; - impl IntoProto - for UpdateDynamicFeeParametersIxAccounts - { - fn into_proto(self) -> proto_def::UpdateDynamicFeeParametersIxAccounts { - proto_def::UpdateDynamicFeeParametersIxAccounts { - lb_pair: self.lb_pair.to_string(), - admin: self.admin.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateDynamicFeeParametersIxData; - impl IntoProto for UpdateDynamicFeeParametersIxData { - fn into_proto(self) -> proto_def::UpdateDynamicFeeParametersIxData { - proto_def::UpdateDynamicFeeParametersIxData { - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - variable_fee_control: self.variable_fee_control, - max_volatility_accumulator: self.max_volatility_accumulator, - } - } - } - use super::IncreaseOracleLengthIxAccounts; - impl IntoProto for IncreaseOracleLengthIxAccounts { - fn into_proto(self) -> proto_def::IncreaseOracleLengthIxAccounts { - proto_def::IncreaseOracleLengthIxAccounts { - oracle: self.oracle.to_string(), - funder: self.funder.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::IncreaseOracleLengthIxData; - impl IntoProto for IncreaseOracleLengthIxData { - fn into_proto(self) -> proto_def::IncreaseOracleLengthIxData { - proto_def::IncreaseOracleLengthIxData { - length_to_add: self.length_to_add, - } - } - } - use super::InitializePresetParameterIxAccounts; - impl IntoProto - for InitializePresetParameterIxAccounts - { - fn into_proto(self) -> proto_def::InitializePresetParameterIxAccounts { - proto_def::InitializePresetParameterIxAccounts { - preset_parameter: self.preset_parameter.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::InitializePresetParameterIxData; - impl IntoProto for InitializePresetParameterIxData { - fn into_proto(self) -> proto_def::InitializePresetParameterIxData { - proto_def::InitializePresetParameterIxData { - bin_step: self.bin_step.into(), - base_factor: self.base_factor.into(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - variable_fee_control: self.variable_fee_control, - max_volatility_accumulator: self.max_volatility_accumulator, - protocol_share: self.protocol_share.into(), - } - } - } - use super::ClosePresetParameterIxAccounts; - impl IntoProto for ClosePresetParameterIxAccounts { - fn into_proto(self) -> proto_def::ClosePresetParameterIxAccounts { - proto_def::ClosePresetParameterIxAccounts { - preset_parameter: self.preset_parameter.to_string(), - admin: self.admin.to_string(), - rent_receiver: self.rent_receiver.to_string(), - } - } - } - use super::ClosePresetParameter2IxAccounts; - impl IntoProto for ClosePresetParameter2IxAccounts { - fn into_proto(self) -> proto_def::ClosePresetParameter2IxAccounts { - proto_def::ClosePresetParameter2IxAccounts { - preset_parameter: self.preset_parameter.to_string(), - admin: self.admin.to_string(), - rent_receiver: self.rent_receiver.to_string(), - } - } - } - use super::RemoveAllLiquidityIxAccounts; - impl IntoProto for RemoveAllLiquidityIxAccounts { - fn into_proto(self) -> proto_def::RemoveAllLiquidityIxAccounts { - proto_def::RemoveAllLiquidityIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SetPairStatusIxAccounts; - impl IntoProto for SetPairStatusIxAccounts { - fn into_proto(self) -> proto_def::SetPairStatusIxAccounts { - proto_def::SetPairStatusIxAccounts { - lb_pair: self.lb_pair.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::SetPairStatusIxData; - impl IntoProto for SetPairStatusIxData { - fn into_proto(self) -> proto_def::SetPairStatusIxData { - proto_def::SetPairStatusIxData { - status: self.status.into(), - } - } - } - use super::MigratePositionIxAccounts; - impl IntoProto for MigratePositionIxAccounts { - fn into_proto(self) -> proto_def::MigratePositionIxAccounts { - proto_def::MigratePositionIxAccounts { - position_v2: self.position_v2.to_string(), - position_v1: self.position_v1.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - owner: self.owner.to_string(), - system_program: self.system_program.to_string(), - rent_receiver: self.rent_receiver.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::MigrateBinArrayIxAccounts; - impl IntoProto for MigrateBinArrayIxAccounts { - fn into_proto(self) -> proto_def::MigrateBinArrayIxAccounts { - proto_def::MigrateBinArrayIxAccounts { - lb_pair: self.lb_pair.to_string(), - } - } - } - use super::UpdateFeesAndRewardsIxAccounts; - impl IntoProto for UpdateFeesAndRewardsIxAccounts { - fn into_proto(self) -> proto_def::UpdateFeesAndRewardsIxAccounts { - proto_def::UpdateFeesAndRewardsIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - owner: self.owner.to_string(), - } - } - } - use super::WithdrawIneligibleRewardIxAccounts; - impl IntoProto - for WithdrawIneligibleRewardIxAccounts - { - fn into_proto(self) -> proto_def::WithdrawIneligibleRewardIxAccounts { - proto_def::WithdrawIneligibleRewardIxAccounts { - lb_pair: self.lb_pair.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_mint: self.reward_mint.to_string(), - funder_token_account: self.funder_token_account.to_string(), - funder: self.funder.to_string(), - bin_array: self.bin_array.to_string(), - token_program: self.token_program.to_string(), - memo_program: self.memo_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::WithdrawIneligibleRewardIxData; - impl IntoProto for WithdrawIneligibleRewardIxData { - fn into_proto(self) -> proto_def::WithdrawIneligibleRewardIxData { - proto_def::WithdrawIneligibleRewardIxData { - reward_index: self.reward_index, - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::SetActivationPointIxAccounts; - impl IntoProto for SetActivationPointIxAccounts { - fn into_proto(self) -> proto_def::SetActivationPointIxAccounts { - proto_def::SetActivationPointIxAccounts { - lb_pair: self.lb_pair.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::SetActivationPointIxData; - impl IntoProto for SetActivationPointIxData { - fn into_proto(self) -> proto_def::SetActivationPointIxData { - proto_def::SetActivationPointIxData { - activation_point: self.activation_point, - } - } - } - use super::RemoveLiquidityByRangeIxAccounts; - impl IntoProto for RemoveLiquidityByRangeIxAccounts { - fn into_proto(self) -> proto_def::RemoveLiquidityByRangeIxAccounts { - proto_def::RemoveLiquidityByRangeIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::RemoveLiquidityByRangeIxData; - impl IntoProto for RemoveLiquidityByRangeIxData { - fn into_proto(self) -> proto_def::RemoveLiquidityByRangeIxData { - proto_def::RemoveLiquidityByRangeIxData { - from_bin_id: self.from_bin_id, - to_bin_id: self.to_bin_id, - bps_to_remove: self.bps_to_remove.into(), - } - } - } - use super::AddLiquidityOneSidePreciseIxAccounts; - impl IntoProto - for AddLiquidityOneSidePreciseIxAccounts - { - fn into_proto(self) -> proto_def::AddLiquidityOneSidePreciseIxAccounts { - proto_def::AddLiquidityOneSidePreciseIxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token: self.user_token.to_string(), - reserve: self.reserve.to_string(), - token_mint: self.token_mint.to_string(), - bin_array_lower: self.bin_array_lower.to_string(), - bin_array_upper: self.bin_array_upper.to_string(), - sender: self.sender.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::AddLiquidityOneSidePreciseIxData; - impl IntoProto for AddLiquidityOneSidePreciseIxData { - fn into_proto(self) -> proto_def::AddLiquidityOneSidePreciseIxData { - proto_def::AddLiquidityOneSidePreciseIxData { - bins: self.bins.into_iter().map(|x| x.into_proto()).collect(), - decompress_multiplier: self.decompress_multiplier, - } - } - } - use super::GoToABinIxAccounts; - impl IntoProto for GoToABinIxAccounts { - fn into_proto(self) -> proto_def::GoToABinIxAccounts { - proto_def::GoToABinIxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - from_bin_array: self.from_bin_array.map(|p| p.to_string()), - to_bin_array: self.to_bin_array.map(|p| p.to_string()), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::GoToABinIxData; - impl IntoProto for GoToABinIxData { - fn into_proto(self) -> proto_def::GoToABinIxData { - proto_def::GoToABinIxData { - bin_id: self.bin_id, - } - } - } - use super::SetPreActivationDurationIxAccounts; - impl IntoProto - for SetPreActivationDurationIxAccounts - { - fn into_proto(self) -> proto_def::SetPreActivationDurationIxAccounts { - proto_def::SetPreActivationDurationIxAccounts { - lb_pair: self.lb_pair.to_string(), - creator: self.creator.to_string(), - } - } - } - use super::SetPreActivationDurationIxData; - impl IntoProto for SetPreActivationDurationIxData { - fn into_proto(self) -> proto_def::SetPreActivationDurationIxData { - proto_def::SetPreActivationDurationIxData { - pre_activation_duration: self.pre_activation_duration, - } - } - } - use super::SetPreActivationSwapAddressIxAccounts; - impl IntoProto - for SetPreActivationSwapAddressIxAccounts - { - fn into_proto(self) -> proto_def::SetPreActivationSwapAddressIxAccounts { - proto_def::SetPreActivationSwapAddressIxAccounts { - lb_pair: self.lb_pair.to_string(), - creator: self.creator.to_string(), - } - } - } - use super::SetPreActivationSwapAddressIxData; - impl IntoProto for SetPreActivationSwapAddressIxData { - fn into_proto(self) -> proto_def::SetPreActivationSwapAddressIxData { - proto_def::SetPreActivationSwapAddressIxData { - pre_activation_swap_address: self.pre_activation_swap_address.to_string(), - } - } - } - use super::SetPairStatusPermissionlessIxAccounts; - impl IntoProto - for SetPairStatusPermissionlessIxAccounts - { - fn into_proto(self) -> proto_def::SetPairStatusPermissionlessIxAccounts { - proto_def::SetPairStatusPermissionlessIxAccounts { - lb_pair: self.lb_pair.to_string(), - creator: self.creator.to_string(), - } - } - } - use super::SetPairStatusPermissionlessIxData; - impl IntoProto for SetPairStatusPermissionlessIxData { - fn into_proto(self) -> proto_def::SetPairStatusPermissionlessIxData { - proto_def::SetPairStatusPermissionlessIxData { - status: self.status.into(), - } - } - } - use super::InitializeTokenBadgeIxAccounts; - impl IntoProto for InitializeTokenBadgeIxAccounts { - fn into_proto(self) -> proto_def::InitializeTokenBadgeIxAccounts { - proto_def::InitializeTokenBadgeIxAccounts { - token_mint: self.token_mint.to_string(), - token_badge: self.token_badge.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreateClaimProtocolFeeOperatorIxAccounts; - impl IntoProto - for CreateClaimProtocolFeeOperatorIxAccounts - { - fn into_proto(self) -> proto_def::CreateClaimProtocolFeeOperatorIxAccounts { - proto_def::CreateClaimProtocolFeeOperatorIxAccounts { - claim_fee_operator: self.claim_fee_operator.to_string(), - operator: self.operator.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CloseClaimProtocolFeeOperatorIxAccounts; - impl IntoProto - for CloseClaimProtocolFeeOperatorIxAccounts - { - fn into_proto(self) -> proto_def::CloseClaimProtocolFeeOperatorIxAccounts { - proto_def::CloseClaimProtocolFeeOperatorIxAccounts { - claim_fee_operator: self.claim_fee_operator.to_string(), - rent_receiver: self.rent_receiver.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::InitializePresetParameter2IxAccounts; - impl IntoProto - for InitializePresetParameter2IxAccounts - { - fn into_proto(self) -> proto_def::InitializePresetParameter2IxAccounts { - proto_def::InitializePresetParameter2IxAccounts { - preset_parameter: self.preset_parameter.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializePresetParameter2IxData; - impl IntoProto for InitializePresetParameter2IxData { - fn into_proto(self) -> proto_def::InitializePresetParameter2IxData { - proto_def::InitializePresetParameter2IxData { - index: self.index.into(), - bin_step: self.bin_step.into(), - base_factor: self.base_factor.into(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - variable_fee_control: self.variable_fee_control, - max_volatility_accumulator: self.max_volatility_accumulator, - protocol_share: self.protocol_share.into(), - base_fee_power_factor: self.base_fee_power_factor.into(), - } - } - } - use super::InitializeLbPair2IxAccounts; - impl IntoProto for InitializeLbPair2IxAccounts { - fn into_proto(self) -> proto_def::InitializeLbPair2IxAccounts { - proto_def::InitializeLbPair2IxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - token_mint_x: self.token_mint_x.to_string(), - token_mint_y: self.token_mint_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - oracle: self.oracle.to_string(), - preset_parameter: self.preset_parameter.to_string(), - funder: self.funder.to_string(), - token_badge_x: self.token_badge_x.map(|p| p.to_string()), - token_badge_y: self.token_badge_y.map(|p| p.to_string()), - token_program_x: self.token_program_x.to_string(), - token_program_y: self.token_program_y.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeLbPair2IxData; - impl IntoProto for InitializeLbPair2IxData { - fn into_proto(self) -> proto_def::InitializeLbPair2IxData { - proto_def::InitializeLbPair2IxData { - active_id: self.active_id, - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::InitializeCustomizablePermissionlessLbPair2IxAccounts; - impl IntoProto - for InitializeCustomizablePermissionlessLbPair2IxAccounts - { - fn into_proto(self) -> proto_def::InitializeCustomizablePermissionlessLbPair2IxAccounts { - proto_def::InitializeCustomizablePermissionlessLbPair2IxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - token_mint_x: self.token_mint_x.to_string(), - token_mint_y: self.token_mint_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - oracle: self.oracle.to_string(), - user_token_x: self.user_token_x.to_string(), - funder: self.funder.to_string(), - token_badge_x: self.token_badge_x.map(|p| p.to_string()), - token_badge_y: self.token_badge_y.map(|p| p.to_string()), - token_program_x: self.token_program_x.to_string(), - token_program_y: self.token_program_y.to_string(), - system_program: self.system_program.to_string(), - user_token_y: self.user_token_y.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeCustomizablePermissionlessLbPair2IxData; - impl IntoProto - for InitializeCustomizablePermissionlessLbPair2IxData - { - fn into_proto(self) -> proto_def::InitializeCustomizablePermissionlessLbPair2IxData { - proto_def::InitializeCustomizablePermissionlessLbPair2IxData { - params: Some(self.params.into_proto()), - } - } - } - use super::ClaimFee2IxAccounts; - impl IntoProto for ClaimFee2IxAccounts { - fn into_proto(self) -> proto_def::ClaimFee2IxAccounts { - proto_def::ClaimFee2IxAccounts { - lb_pair: self.lb_pair.to_string(), - position: self.position.to_string(), - sender: self.sender.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - token_program_x: self.token_program_x.to_string(), - token_program_y: self.token_program_y.to_string(), - memo_program: self.memo_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClaimFee2IxData; - impl IntoProto for ClaimFee2IxData { - fn into_proto(self) -> proto_def::ClaimFee2IxData { - proto_def::ClaimFee2IxData { - min_bin_id: self.min_bin_id, - max_bin_id: self.max_bin_id, - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::ClaimReward2IxAccounts; - impl IntoProto for ClaimReward2IxAccounts { - fn into_proto(self) -> proto_def::ClaimReward2IxAccounts { - proto_def::ClaimReward2IxAccounts { - lb_pair: self.lb_pair.to_string(), - position: self.position.to_string(), - sender: self.sender.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_mint: self.reward_mint.to_string(), - user_token_account: self.user_token_account.to_string(), - token_program: self.token_program.to_string(), - memo_program: self.memo_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::ClaimReward2IxData; - impl IntoProto for ClaimReward2IxData { - fn into_proto(self) -> proto_def::ClaimReward2IxData { - proto_def::ClaimReward2IxData { - reward_index: self.reward_index, - min_bin_id: self.min_bin_id, - max_bin_id: self.max_bin_id, - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::AddLiquidity2IxAccounts; - impl IntoProto for AddLiquidity2IxAccounts { - fn into_proto(self) -> proto_def::AddLiquidity2IxAccounts { - proto_def::AddLiquidity2IxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - sender: self.sender.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::AddLiquidity2IxData; - impl IntoProto for AddLiquidity2IxData { - fn into_proto(self) -> proto_def::AddLiquidity2IxData { - proto_def::AddLiquidity2IxData { - liquidity_parameter: Some(self.liquidity_parameter.into_proto()), - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::AddLiquidityByStrategy2IxAccounts; - impl IntoProto for AddLiquidityByStrategy2IxAccounts { - fn into_proto(self) -> proto_def::AddLiquidityByStrategy2IxAccounts { - proto_def::AddLiquidityByStrategy2IxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - sender: self.sender.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::AddLiquidityByStrategy2IxData; - impl IntoProto for AddLiquidityByStrategy2IxData { - fn into_proto(self) -> proto_def::AddLiquidityByStrategy2IxData { - proto_def::AddLiquidityByStrategy2IxData { - liquidity_parameter: Some(self.liquidity_parameter.into_proto()), - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::AddLiquidityOneSidePrecise2IxAccounts; - impl IntoProto - for AddLiquidityOneSidePrecise2IxAccounts - { - fn into_proto(self) -> proto_def::AddLiquidityOneSidePrecise2IxAccounts { - proto_def::AddLiquidityOneSidePrecise2IxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token: self.user_token.to_string(), - reserve: self.reserve.to_string(), - token_mint: self.token_mint.to_string(), - sender: self.sender.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::AddLiquidityOneSidePrecise2IxData; - impl IntoProto for AddLiquidityOneSidePrecise2IxData { - fn into_proto(self) -> proto_def::AddLiquidityOneSidePrecise2IxData { - proto_def::AddLiquidityOneSidePrecise2IxData { - bins: self.bins.into_iter().map(|x| x.into_proto()).collect(), - decompress_multiplier: self.decompress_multiplier, - max_amount: self.max_amount, - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::RemoveLiquidity2IxAccounts; - impl IntoProto for RemoveLiquidity2IxAccounts { - fn into_proto(self) -> proto_def::RemoveLiquidity2IxAccounts { - proto_def::RemoveLiquidity2IxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - sender: self.sender.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - memo_program: self.memo_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::RemoveLiquidity2IxData; - impl IntoProto for RemoveLiquidity2IxData { - fn into_proto(self) -> proto_def::RemoveLiquidity2IxData { - proto_def::RemoveLiquidity2IxData { - bin_liquidity_removal: self - .bin_liquidity_removal - .into_iter() - .map(|x| x.into_proto()) - .collect(), - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::RemoveLiquidityByRange2IxAccounts; - impl IntoProto for RemoveLiquidityByRange2IxAccounts { - fn into_proto(self) -> proto_def::RemoveLiquidityByRange2IxAccounts { - proto_def::RemoveLiquidityByRange2IxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - user_token_x: self.user_token_x.to_string(), - user_token_y: self.user_token_y.to_string(), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - sender: self.sender.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - memo_program: self.memo_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::RemoveLiquidityByRange2IxData; - impl IntoProto for RemoveLiquidityByRange2IxData { - fn into_proto(self) -> proto_def::RemoveLiquidityByRange2IxData { - proto_def::RemoveLiquidityByRange2IxData { - from_bin_id: self.from_bin_id, - to_bin_id: self.to_bin_id, - bps_to_remove: self.bps_to_remove.into(), - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::Swap2IxAccounts; - impl IntoProto for Swap2IxAccounts { - fn into_proto(self) -> proto_def::Swap2IxAccounts { - proto_def::Swap2IxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - user_token_in: self.user_token_in.to_string(), - user_token_out: self.user_token_out.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - oracle: self.oracle.to_string(), - host_fee_in: self.host_fee_in.map(|p| p.to_string()), - user: self.user.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - memo_program: self.memo_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::Swap2IxData; - impl IntoProto for Swap2IxData { - fn into_proto(self) -> proto_def::Swap2IxData { - proto_def::Swap2IxData { - amount_in: self.amount_in, - min_amount_out: self.min_amount_out, - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::SwapExactOut2IxAccounts; - impl IntoProto for SwapExactOut2IxAccounts { - fn into_proto(self) -> proto_def::SwapExactOut2IxAccounts { - proto_def::SwapExactOut2IxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - user_token_in: self.user_token_in.to_string(), - user_token_out: self.user_token_out.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - oracle: self.oracle.to_string(), - host_fee_in: self.host_fee_in.map(|p| p.to_string()), - user: self.user.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - memo_program: self.memo_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SwapExactOut2IxData; - impl IntoProto for SwapExactOut2IxData { - fn into_proto(self) -> proto_def::SwapExactOut2IxData { - proto_def::SwapExactOut2IxData { - max_in_amount: self.max_in_amount, - out_amount: self.out_amount, - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::SwapWithPriceImpact2IxAccounts; - impl IntoProto for SwapWithPriceImpact2IxAccounts { - fn into_proto(self) -> proto_def::SwapWithPriceImpact2IxAccounts { - proto_def::SwapWithPriceImpact2IxAccounts { - lb_pair: self.lb_pair.to_string(), - bin_array_bitmap_extension: self.bin_array_bitmap_extension.map(|p| p.to_string()), - reserve_x: self.reserve_x.to_string(), - reserve_y: self.reserve_y.to_string(), - user_token_in: self.user_token_in.to_string(), - user_token_out: self.user_token_out.to_string(), - token_x_mint: self.token_x_mint.to_string(), - token_y_mint: self.token_y_mint.to_string(), - oracle: self.oracle.to_string(), - host_fee_in: self.host_fee_in.map(|p| p.to_string()), - user: self.user.to_string(), - token_x_program: self.token_x_program.to_string(), - token_y_program: self.token_y_program.to_string(), - memo_program: self.memo_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SwapWithPriceImpact2IxData; - impl IntoProto for SwapWithPriceImpact2IxData { - fn into_proto(self) -> proto_def::SwapWithPriceImpact2IxData { - proto_def::SwapWithPriceImpact2IxData { - amount_in: self.amount_in, - active_id: self.active_id, - max_price_impact_bps: self.max_price_impact_bps.into(), - remaining_accounts_info: Some(self.remaining_accounts_info.into_proto()), - } - } - } - use super::ClosePosition2IxAccounts; - impl IntoProto for ClosePosition2IxAccounts { - fn into_proto(self) -> proto_def::ClosePosition2IxAccounts { - proto_def::ClosePosition2IxAccounts { - position: self.position.to_string(), - sender: self.sender.to_string(), - rent_receiver: self.rent_receiver.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateFeesAndReward2IxAccounts; - impl IntoProto for UpdateFeesAndReward2IxAccounts { - fn into_proto(self) -> proto_def::UpdateFeesAndReward2IxAccounts { - proto_def::UpdateFeesAndReward2IxAccounts { - position: self.position.to_string(), - lb_pair: self.lb_pair.to_string(), - owner: self.owner.to_string(), - } - } - } - use super::UpdateFeesAndReward2IxData; - impl IntoProto for UpdateFeesAndReward2IxData { - fn into_proto(self) -> proto_def::UpdateFeesAndReward2IxData { - proto_def::UpdateFeesAndReward2IxData { - min_bin_id: self.min_bin_id, - max_bin_id: self.max_bin_id, - } - } - } - use super::ClosePositionIfEmptyIxAccounts; - impl IntoProto for ClosePositionIfEmptyIxAccounts { - fn into_proto(self) -> proto_def::ClosePositionIfEmptyIxAccounts { - proto_def::ClosePositionIfEmptyIxAccounts { - position: self.position.to_string(), - sender: self.sender.to_string(), - rent_receiver: self.rent_receiver.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - - impl IntoProto for LbClmmProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - LbClmmProgramIx::InitializeLbPair(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeLbPair(proto_def::InitializeLbPairIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializePermissionLbPair(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePermissionLbPair(proto_def::InitializePermissionLbPairIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializeCustomizablePermissionlessLbPair(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeCustomizablePermissionlessLbPair(proto_def::InitializeCustomizablePermissionlessLbPairIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializeBinArrayBitmapExtension(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeBinArrayBitmapExtension(proto_def::InitializeBinArrayBitmapExtensionIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::InitializeBinArray(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeBinArray(proto_def::InitializeBinArrayIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::AddLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddLiquidity(proto_def::AddLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::AddLiquidityByWeight(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddLiquidityByWeight(proto_def::AddLiquidityByWeightIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::AddLiquidityByStrategy(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddLiquidityByStrategy(proto_def::AddLiquidityByStrategyIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::AddLiquidityByStrategyOneSide(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddLiquidityByStrategyOneSide(proto_def::AddLiquidityByStrategyOneSideIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::AddLiquidityOneSide(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddLiquidityOneSide(proto_def::AddLiquidityOneSideIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::RemoveLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveLiquidity(proto_def::RemoveLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializePosition(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePosition(proto_def::InitializePositionIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializePositionPda(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePositionPda(proto_def::InitializePositionPdaIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializePositionByOperator(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePositionByOperator(proto_def::InitializePositionByOperatorIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::UpdatePositionOperator(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdatePositionOperator(proto_def::UpdatePositionOperatorIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::Swap(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Swap(proto_def::SwapIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::SwapExactOut(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapExactOut(proto_def::SwapExactOutIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::SwapWithPriceImpact(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapWithPriceImpact(proto_def::SwapWithPriceImpactIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::WithdrawProtocolFee(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::WithdrawProtocolFee(proto_def::WithdrawProtocolFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializeReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeReward(proto_def::InitializeRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::FundReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::FundReward(proto_def::FundRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::UpdateRewardFunder(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateRewardFunder(proto_def::UpdateRewardFunderIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::UpdateRewardDuration(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateRewardDuration(proto_def::UpdateRewardDurationIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::ClaimReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimReward(proto_def::ClaimRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::ClaimFee(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimFee(proto_def::ClaimFeeIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::ClosePosition(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClosePosition(proto_def::ClosePositionIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::UpdateBaseFeeParameters(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateBaseFeeParameters(proto_def::UpdateBaseFeeParametersIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::UpdateDynamicFeeParameters(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateDynamicFeeParameters(proto_def::UpdateDynamicFeeParametersIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::IncreaseOracleLength(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::IncreaseOracleLength(proto_def::IncreaseOracleLengthIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializePresetParameter(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePresetParameter(proto_def::InitializePresetParameterIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::ClosePresetParameter(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClosePresetParameter(proto_def::ClosePresetParameterIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::ClosePresetParameter2(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClosePresetParameter2(proto_def::ClosePresetParameter2Ix { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::RemoveAllLiquidity(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveAllLiquidity(proto_def::RemoveAllLiquidityIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::SetPairStatus(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetPairStatus(proto_def::SetPairStatusIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::MigratePosition(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::MigratePosition(proto_def::MigratePositionIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::MigrateBinArray(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::MigrateBinArray(proto_def::MigrateBinArrayIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::UpdateFeesAndRewards(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateFeesAndRewards(proto_def::UpdateFeesAndRewardsIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::WithdrawIneligibleReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::WithdrawIneligibleReward(proto_def::WithdrawIneligibleRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::SetActivationPoint(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetActivationPoint(proto_def::SetActivationPointIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::RemoveLiquidityByRange(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveLiquidityByRange(proto_def::RemoveLiquidityByRangeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::AddLiquidityOneSidePrecise(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddLiquidityOneSidePrecise(proto_def::AddLiquidityOneSidePreciseIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::GoToABin(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::GoToABin(proto_def::GoToABinIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::SetPreActivationDuration(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetPreActivationDuration(proto_def::SetPreActivationDurationIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::SetPreActivationSwapAddress(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetPreActivationSwapAddress(proto_def::SetPreActivationSwapAddressIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::SetPairStatusPermissionless(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetPairStatusPermissionless(proto_def::SetPairStatusPermissionlessIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializeTokenBadge(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeTokenBadge(proto_def::InitializeTokenBadgeIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::CreateClaimProtocolFeeOperator(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateClaimProtocolFeeOperator(proto_def::CreateClaimProtocolFeeOperatorIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::CloseClaimProtocolFeeOperator(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CloseClaimProtocolFeeOperator(proto_def::CloseClaimProtocolFeeOperatorIx { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::InitializePresetParameter2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePresetParameter2(proto_def::InitializePresetParameter2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializeLbPair2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeLbPair2(proto_def::InitializeLbPair2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::InitializeCustomizablePermissionlessLbPair2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeCustomizablePermissionlessLbPair2(proto_def::InitializeCustomizablePermissionlessLbPair2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::ClaimFee2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimFee2(proto_def::ClaimFee2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::ClaimReward2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimReward2(proto_def::ClaimReward2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::AddLiquidity2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddLiquidity2(proto_def::AddLiquidity2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::AddLiquidityByStrategy2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddLiquidityByStrategy2(proto_def::AddLiquidityByStrategy2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::AddLiquidityOneSidePrecise2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddLiquidityOneSidePrecise2(proto_def::AddLiquidityOneSidePrecise2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::RemoveLiquidity2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveLiquidity2(proto_def::RemoveLiquidity2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::RemoveLiquidityByRange2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveLiquidityByRange2(proto_def::RemoveLiquidityByRange2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::Swap2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Swap2(proto_def::Swap2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::SwapExactOut2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapExactOut2(proto_def::SwapExactOut2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::SwapWithPriceImpact2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapWithPriceImpact2(proto_def::SwapWithPriceImpact2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::ClosePosition2(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClosePosition2(proto_def::ClosePosition2Ix { - accounts: Some(acc.into_proto()), - })), - }, - LbClmmProgramIx::UpdateFeesAndReward2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateFeesAndReward2(proto_def::UpdateFeesAndReward2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - LbClmmProgramIx::ClosePositionIfEmpty(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClosePositionIfEmpty(proto_def::ClosePositionIfEmptyIx { - accounts: Some(acc.into_proto()), - })), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/meteora-parser/src/generated_parser/mod.rs b/crates/meteora-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/meteora-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/meteora-parser/src/generated_parser/proto_helpers.rs b/crates/meteora-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index d3485c19..00000000 --- a/crates/meteora-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,238 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::LiquidityParameterByStrategy}; - impl IntoProto for LiquidityParameterByStrategy { - fn into_proto(self) -> proto_def::LiquidityParameterByStrategy { - proto_def::LiquidityParameterByStrategy { - amount_x: self.amount_x, - amount_y: self.amount_y, - active_id: self.active_id, - max_active_bin_slippage: self.max_active_bin_slippage, - strategy_parameters: Some(self.strategy_parameters.into_proto()), - } - } - } - use crate::types::StrategyParameters; - impl IntoProto for StrategyParameters { - fn into_proto(self) -> proto_def::StrategyParameters { - proto_def::StrategyParameters { - min_bin_id: self.min_bin_id, - max_bin_id: self.max_bin_id, - strategy_type: self.strategy_type as i32, - parameteres: self.parameteres.into_iter().map(|x| x.into()).collect(), - } - } - } - use crate::types::BinLiquidityDistributionByWeight; - impl IntoProto for BinLiquidityDistributionByWeight { - fn into_proto(self) -> proto_def::BinLiquidityDistributionByWeight { - proto_def::BinLiquidityDistributionByWeight { - bin_id: self.bin_id, - weight: self.weight.into(), - } - } - } - use crate::types::CompressedBinDepositAmount; - impl IntoProto for CompressedBinDepositAmount { - fn into_proto(self) -> proto_def::CompressedBinDepositAmount { - proto_def::CompressedBinDepositAmount { - bin_id: self.bin_id, - amount: self.amount, - } - } - } - use crate::types::BinLiquidityDistribution; - impl IntoProto for BinLiquidityDistribution { - fn into_proto(self) -> proto_def::BinLiquidityDistribution { - proto_def::BinLiquidityDistribution { - bin_id: self.bin_id, - distribution_x: self.distribution_x.into(), - distribution_y: self.distribution_y.into(), - } - } - } - use crate::types::LiquidityParameter; - impl IntoProto for LiquidityParameter { - fn into_proto(self) -> proto_def::LiquidityParameter { - proto_def::LiquidityParameter { - amount_x: self.amount_x, - amount_y: self.amount_y, - bin_liquidity_dist: self - .bin_liquidity_dist - .into_iter() - .map(|x| x.into_proto()) - .collect(), - } - } - } - use crate::types::CustomizableParams; - impl IntoProto for CustomizableParams { - fn into_proto(self) -> proto_def::CustomizableParams { - proto_def::CustomizableParams { - active_id: self.active_id, - bin_step: self.bin_step.into(), - base_factor: self.base_factor.into(), - activation_type: self.activation_type.into(), - has_alpha_vault: self.has_alpha_vault, - activation_point: self.activation_point, - creator_pool_on_off_control: self.creator_pool_on_off_control, - base_fee_power_factor: self.base_fee_power_factor.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use crate::types::CompressedBinDepositAmount2; - impl IntoProto for CompressedBinDepositAmount2 { - fn into_proto(self) -> proto_def::CompressedBinDepositAmount2 { - proto_def::CompressedBinDepositAmount2 { - bin_id: self.bin_id, - amount: self.amount, - } - } - } - use crate::types::BinLiquidityReduction; - impl IntoProto for BinLiquidityReduction { - fn into_proto(self) -> proto_def::BinLiquidityReduction { - proto_def::BinLiquidityReduction { - bin_id: self.bin_id, - bps_to_remove: self.bps_to_remove.into(), - } - } - } - use crate::types::Bin; - impl IntoProto for Bin { - fn into_proto(self) -> proto_def::Bin { - proto_def::Bin { - amount_x: self.amount_x, - amount_y: self.amount_y, - price: self.price.to_string(), - liquidity_supply: self.liquidity_supply.to_string(), - reward_per_token_stored: self - .reward_per_token_stored - .into_iter() - .map(|x| x.to_string()) - .collect(), - fee_amount_x_per_token_stored: self.fee_amount_x_per_token_stored.to_string(), - fee_amount_y_per_token_stored: self.fee_amount_y_per_token_stored.to_string(), - amount_x_in: self.amount_x_in.to_string(), - amount_y_in: self.amount_y_in.to_string(), - } - } - } - use crate::types::ProtocolFee; - impl IntoProto for ProtocolFee { - fn into_proto(self) -> proto_def::ProtocolFee { - proto_def::ProtocolFee { - amount_x: self.amount_x, - amount_y: self.amount_y, - } - } - } - use crate::types::RewardInfo; - impl IntoProto for RewardInfo { - fn into_proto(self) -> proto_def::RewardInfo { - proto_def::RewardInfo { - mint: self.mint.to_string(), - vault: self.vault.to_string(), - funder: self.funder.to_string(), - reward_duration: self.reward_duration, - reward_duration_end: self.reward_duration_end, - reward_rate: self.reward_rate.to_string(), - last_update_time: self.last_update_time, - cumulative_seconds_with_empty_liquidity_reward: self - .cumulative_seconds_with_empty_liquidity_reward, - } - } - } - use crate::types::Observation; - impl IntoProto for Observation { - fn into_proto(self) -> proto_def::Observation { - proto_def::Observation { - cumulative_active_bin_id: self.cumulative_active_bin_id.to_string(), - created_at: self.created_at, - last_updated_at: self.last_updated_at, - } - } - } - use crate::types::StaticParameters; - impl IntoProto for StaticParameters { - fn into_proto(self) -> proto_def::StaticParameters { - proto_def::StaticParameters { - base_factor: self.base_factor.into(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - variable_fee_control: self.variable_fee_control, - max_volatility_accumulator: self.max_volatility_accumulator, - min_bin_id: self.min_bin_id, - max_bin_id: self.max_bin_id, - protocol_share: self.protocol_share.into(), - base_fee_power_factor: self.base_fee_power_factor.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use crate::types::VariableParameters; - impl IntoProto for VariableParameters { - fn into_proto(self) -> proto_def::VariableParameters { - proto_def::VariableParameters { - volatility_accumulator: self.volatility_accumulator, - volatility_reference: self.volatility_reference, - index_reference: self.index_reference, - padding: self.padding.into_iter().map(|x| x.into()).collect(), - last_update_timestamp: self.last_update_timestamp, - padding1: self.padding1.into_iter().map(|x| x.into()).collect(), - } - } - } - use crate::types::FeeInfo; - impl IntoProto for FeeInfo { - fn into_proto(self) -> proto_def::FeeInfo { - proto_def::FeeInfo { - fee_x_per_token_complete: self.fee_x_per_token_complete.to_string(), - fee_y_per_token_complete: self.fee_y_per_token_complete.to_string(), - fee_x_pending: self.fee_x_pending, - fee_y_pending: self.fee_y_pending, - } - } - } - use crate::types::UserRewardInfo; - impl IntoProto for UserRewardInfo { - fn into_proto(self) -> proto_def::UserRewardInfo { - proto_def::UserRewardInfo { - reward_per_token_completes: self - .reward_per_token_completes - .into_iter() - .map(|x| x.to_string()) - .collect(), - reward_pendings: self.reward_pendings.to_vec(), - } - } - } - use crate::types::RemainingAccountsSlice; - impl IntoProto for RemainingAccountsSlice { - fn into_proto(self) -> proto_def::RemainingAccountsSlice { - proto_def::RemainingAccountsSlice { - accounts_type: self.accounts_type as i32, - length: self.length.into(), - } - } - } - use crate::types::RemainingAccountsInfo; - impl IntoProto for RemainingAccountsInfo { - fn into_proto(self) -> proto_def::RemainingAccountsInfo { - proto_def::RemainingAccountsInfo { - slices: self.slices.into_iter().map(|x| x.into_proto()).collect(), - } - } - } -} diff --git a/crates/meteora-parser/src/generated_sdk/accounts/bin_array.rs b/crates/meteora-parser/src/generated_sdk/accounts/bin_array.rs deleted file mode 100644 index f928fe7d..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/bin_array.rs +++ /dev/null @@ -1,145 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::Bin; - -/// 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, ... - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BinArray { - pub discriminator: [u8; 8], - pub index: i64, - /// Version of binArray - pub version: u8, - pub padding: [u8; 7], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lb_pair: Pubkey, - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub bins: [Bin; 70], -} - -impl BinArray { - pub const LEN: usize = 10136; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for BinArray { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_bin_array( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_bin_array(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_bin_array( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = BinArray::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_bin_array( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_bin_array(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_bin_array( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = BinArray::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for BinArray { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for BinArray {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for BinArray { - fn owner() -> Pubkey { crate::LB_CLMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for BinArray {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for BinArray { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-parser/src/generated_sdk/accounts/bin_array_bitmap_extension.rs b/crates/meteora-parser/src/generated_sdk/accounts/bin_array_bitmap_extension.rs deleted file mode 100644 index 96999448..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/bin_array_bitmap_extension.rs +++ /dev/null @@ -1,138 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BinArrayBitmapExtension { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lb_pair: Pubkey, - /// Packed initialized bin array state for start_bin_index is positive - pub positive_bin_array_bitmap: [[u64; 8]; 12], - /// Packed initialized bin array state for start_bin_index is negative - pub negative_bin_array_bitmap: [[u64; 8]; 12], -} - -impl BinArrayBitmapExtension { - pub const LEN: usize = 1576; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for BinArrayBitmapExtension { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_bin_array_bitmap_extension( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_bin_array_bitmap_extension(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_bin_array_bitmap_extension( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = BinArrayBitmapExtension::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_bin_array_bitmap_extension( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_bin_array_bitmap_extension(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_bin_array_bitmap_extension( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = BinArrayBitmapExtension::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for BinArrayBitmapExtension { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for BinArrayBitmapExtension {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for BinArrayBitmapExtension { - fn owner() -> Pubkey { crate::LB_CLMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for BinArrayBitmapExtension {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for BinArrayBitmapExtension { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-parser/src/generated_sdk/accounts/claim_fee_operator.rs b/crates/meteora-parser/src/generated_sdk/accounts/claim_fee_operator.rs deleted file mode 100644 index 7cdecffa..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/claim_fee_operator.rs +++ /dev/null @@ -1,138 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Parameter that set by the protocol - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimFeeOperator { - pub discriminator: [u8; 8], - /// operator - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub operator: Pubkey, - /// Reserve - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 128], -} - -impl ClaimFeeOperator { - pub const LEN: usize = 168; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for ClaimFeeOperator { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_claim_fee_operator(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = ClaimFeeOperator::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_claim_fee_operator(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_claim_fee_operator( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = ClaimFeeOperator::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for ClaimFeeOperator { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for ClaimFeeOperator {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for ClaimFeeOperator { - fn owner() -> Pubkey { crate::LB_CLMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for ClaimFeeOperator {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for ClaimFeeOperator { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-parser/src/generated_sdk/accounts/lb_pair.rs b/crates/meteora-parser/src/generated_sdk/accounts/lb_pair.rs deleted file mode 100644 index 5102862c..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/lb_pair.rs +++ /dev/null @@ -1,224 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{ProtocolFee, RewardInfo, StaticParameters, VariableParameters}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LbPair { - pub discriminator: [u8; 8], - pub parameters: StaticParameters, - pub v_parameters: VariableParameters, - pub bump_seed: [u8; 1], - /// Bin step signer seed - pub bin_step_seed: [u8; 2], - /// Type of the pair - pub pair_type: u8, - /// Active bin id - pub active_id: i32, - /// Bin step. Represent the price increment / decrement. - pub bin_step: u16, - /// Status of the pair. Check PairStatus enum. - pub status: u8, - /// Require base factor seed - pub require_base_factor_seed: u8, - /// Base factor seed - pub base_factor_seed: [u8; 2], - /// Activation type - pub activation_type: u8, - /// Allow pool creator to enable/disable pool with restricted validation. Only applicable for customizable permissionless pair type. - pub creator_pool_on_off_control: u8, - /// Token X mint - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_x_mint: Pubkey, - /// Token Y mint - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_y_mint: Pubkey, - /// LB token X vault - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub reserve_x: Pubkey, - /// LB token Y vault - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub reserve_y: Pubkey, - /// Uncollected protocol fee - pub protocol_fee: ProtocolFee, - /// _padding_1, previous Fee owner, BE CAREFUL FOR TOMBSTONE WHEN REUSE !! - pub padding1: [u8; 32], - /// Farming reward information - pub reward_infos: [RewardInfo; 2], - /// Oracle pubkey - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub oracle: Pubkey, - /// Packed initialized bin array state - pub bin_array_bitmap: [u64; 16], - /// Last time the pool fee parameter was updated - pub last_updated_at: i64, - /// _padding_2, previous whitelisted_wallet, BE CAREFUL FOR TOMBSTONE WHEN REUSE !! - pub padding2: [u8; 32], - /// 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`. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pre_activation_swap_address: Pubkey, - /// Base keypair. Only required for permission pair - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base_key: Pubkey, - /// Time point to enable the pair. Only applicable for permission pair. - pub activation_point: u64, - /// Duration before activation activation_point. Used to calculate pre-activation time point for pre_activation_swap_address - pub pre_activation_duration: u64, - /// _padding 3 is reclaimed free space from swap_cap_deactivate_point and swap_cap_amount before, BE CAREFUL FOR TOMBSTONE WHEN REUSE !! - pub padding3: [u8; 8], - /// _padding_4, previous lock_duration, BE CAREFUL FOR TOMBSTONE WHEN REUSE !! - pub padding4: u64, - /// Pool creator - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - /// token_mint_x_program_flag - pub token_mint_x_program_flag: u8, - /// token_mint_y_program_flag - pub token_mint_y_program_flag: u8, - /// Reserved space for future use - pub reserved: [u8; 22], -} - -impl LbPair { - pub const LEN: usize = 904; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for LbPair { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_lb_pair( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_lb_pair(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_lb_pair( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = LbPair::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_lb_pair( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_lb_pair(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_lb_pair( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = LbPair::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for LbPair { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for LbPair {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for LbPair { - fn owner() -> Pubkey { crate::LB_CLMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for LbPair {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for LbPair { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-parser/src/generated_sdk/accounts/mod.rs b/crates/meteora-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index 9b087630..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#bin_array; -pub(crate) mod r#bin_array_bitmap_extension; -pub(crate) mod r#claim_fee_operator; -pub(crate) mod r#lb_pair; -pub(crate) mod r#oracle; -pub(crate) mod r#position; -pub(crate) mod r#position_v2; -pub(crate) mod r#preset_parameter; -pub(crate) mod r#preset_parameter2; -pub(crate) mod r#token_badge; - -pub use self::{ - r#bin_array::*, r#bin_array_bitmap_extension::*, r#claim_fee_operator::*, r#lb_pair::*, - r#oracle::*, r#position::*, r#position_v2::*, r#preset_parameter::*, r#preset_parameter2::*, - r#token_badge::*, -}; diff --git a/crates/meteora-parser/src/generated_sdk/accounts/oracle.rs b/crates/meteora-parser/src/generated_sdk/accounts/oracle.rs deleted file mode 100644 index 6c8f5b5b..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/oracle.rs +++ /dev/null @@ -1,134 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Oracle { - pub discriminator: [u8; 8], - /// Index of latest observation - pub idx: u64, - /// Size of active sample. Active sample is initialized observation. - pub active_size: u64, - /// Number of observations - pub length: u64, - /// Observations - pub observations: Vec<[u8; 32]>, -} - -impl Oracle { - pub const LEN: usize = 32; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Oracle { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_oracle( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_oracle(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_oracle( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Oracle::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_oracle( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_oracle(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_oracle( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Oracle::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Oracle { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Oracle {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Oracle { - fn owner() -> Pubkey { crate::LB_CLMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Oracle {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Oracle { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-parser/src/generated_sdk/accounts/position.rs b/crates/meteora-parser/src/generated_sdk/accounts/position.rs deleted file mode 100644 index 530de025..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/position.rs +++ /dev/null @@ -1,165 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{FeeInfo, UserRewardInfo}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Position { - pub discriminator: [u8; 8], - /// The LB pair of this position - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lb_pair: Pubkey, - /// Owner of the position. Client rely on this to to fetch their positions. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - /// Liquidity shares of this position in bins (lower_bin_id <-> upper_bin_id). This is the same as LP concept. - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub liquidity_shares: [u64; 70], - /// Farming reward information - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub reward_infos: [UserRewardInfo; 70], - /// Swap fee to claim information - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub fee_infos: [FeeInfo; 70], - /// Lower bin ID - pub lower_bin_id: i32, - /// Upper bin ID - pub upper_bin_id: i32, - /// Last updated timestamp - pub last_updated_at: i64, - /// Total claimed token fee X - pub total_claimed_fee_x_amount: u64, - /// Total claimed token fee Y - pub total_claimed_fee_y_amount: u64, - /// Total claimed rewards - pub total_claimed_rewards: [u64; 2], - /// Reserved space for future use - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub reserved: [u8; 160], -} - -impl Position { - pub const LEN: usize = 7560; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Position { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_position( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_position(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_position( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Position::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_position( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_position(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_position( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Position::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Position { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Position {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Position { - fn owner() -> Pubkey { crate::LB_CLMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Position {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Position { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-parser/src/generated_sdk/accounts/position_v2.rs b/crates/meteora-parser/src/generated_sdk/accounts/position_v2.rs deleted file mode 100644 index ec4c00fa..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/position_v2.rs +++ /dev/null @@ -1,181 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{FeeInfo, UserRewardInfo}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PositionV2 { - pub discriminator: [u8; 8], - /// The LB pair of this position - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lb_pair: Pubkey, - /// Owner of the position. Client rely on this to to fetch their positions. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - /// Liquidity shares of this position in bins (lower_bin_id <-> upper_bin_id). This is the same as LP concept. - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub liquidity_shares: [u128; 70], - /// Farming reward information - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub reward_infos: [UserRewardInfo; 70], - /// Swap fee to claim information - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub fee_infos: [FeeInfo; 70], - /// Lower bin ID - pub lower_bin_id: i32, - /// Upper bin ID - pub upper_bin_id: i32, - /// Last updated timestamp - pub last_updated_at: i64, - /// Total claimed token fee X - pub total_claimed_fee_x_amount: u64, - /// Total claimed token fee Y - pub total_claimed_fee_y_amount: u64, - /// Total claimed rewards - pub total_claimed_rewards: [u64; 2], - /// Operator of position - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub operator: Pubkey, - /// Time point which the locked liquidity can be withdraw - pub lock_release_point: u64, - /// _padding_0, previous subjected_to_bootstrap_liquidity_locking, BE CAREFUL FOR TOMBSTONE WHEN REUSE !! - pub padding0: u8, - /// Address is able to claim fee in this position, only valid for bootstrap_liquidity_position - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_owner: Pubkey, - /// Reserved space for future use - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub reserved: [u8; 87], -} - -impl PositionV2 { - pub const LEN: usize = 8120; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PositionV2 { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_position_v2( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_position_v2(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_position_v2( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PositionV2::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_position_v2( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_position_v2(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_position_v2( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PositionV2::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PositionV2 { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PositionV2 {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PositionV2 { - fn owner() -> Pubkey { crate::LB_CLMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PositionV2 {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PositionV2 { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-parser/src/generated_sdk/accounts/preset_parameter.rs b/crates/meteora-parser/src/generated_sdk/accounts/preset_parameter.rs deleted file mode 100644 index 21f58987..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/preset_parameter.rs +++ /dev/null @@ -1,146 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PresetParameter { - pub discriminator: [u8; 8], - /// Bin step. Represent the price increment / decrement. - pub bin_step: u16, - /// Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor - pub base_factor: u16, - /// Filter period determine high frequency trading time window. - pub filter_period: u16, - /// Decay period determine when the volatile fee start decay / decrease. - pub decay_period: u16, - /// Reduction factor controls the volatile fee rate decrement rate. - pub reduction_factor: u16, - /// Used to scale the variable fee component depending on the dynamic of the market - pub variable_fee_control: u32, - /// Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate. - pub max_volatility_accumulator: u32, - /// Min bin id supported by the pool based on the configured bin step. - pub min_bin_id: i32, - /// Max bin id supported by the pool based on the configured bin step. - pub max_bin_id: i32, - /// Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee - pub protocol_share: u16, -} - -impl PresetParameter { - pub const LEN: usize = 36; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PresetParameter { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_preset_parameter( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_preset_parameter(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_preset_parameter( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PresetParameter::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_preset_parameter( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_preset_parameter(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_preset_parameter( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PresetParameter::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PresetParameter { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PresetParameter {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PresetParameter { - fn owner() -> Pubkey { crate::LB_CLMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PresetParameter {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PresetParameter { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-parser/src/generated_sdk/accounts/preset_parameter2.rs b/crates/meteora-parser/src/generated_sdk/accounts/preset_parameter2.rs deleted file mode 100644 index 4b897fb3..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/preset_parameter2.rs +++ /dev/null @@ -1,150 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PresetParameter2 { - pub discriminator: [u8; 8], - /// Bin step. Represent the price increment / decrement. - pub bin_step: u16, - /// Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor - pub base_factor: u16, - /// Filter period determine high frequency trading time window. - pub filter_period: u16, - /// Decay period determine when the volatile fee start decay / decrease. - pub decay_period: u16, - /// Used to scale the variable fee component depending on the dynamic of the market - pub variable_fee_control: u32, - /// Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate. - pub max_volatility_accumulator: u32, - /// Reduction factor controls the volatile fee rate decrement rate. - pub reduction_factor: u16, - /// Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee - pub protocol_share: u16, - /// index - pub index: u16, - /// Base fee power factor - pub base_fee_power_factor: u8, - /// Padding 0 for future use - pub padding0: u8, - /// Padding 1 for future use - pub padding1: [u64; 20], -} - -impl PresetParameter2 { - pub const LEN: usize = 192; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PresetParameter2 { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_preset_parameter2( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_preset_parameter2(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_preset_parameter2( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PresetParameter2::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_preset_parameter2( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_preset_parameter2(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_preset_parameter2( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PresetParameter2::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PresetParameter2 { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PresetParameter2 {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PresetParameter2 { - fn owner() -> Pubkey { crate::LB_CLMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PresetParameter2 {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PresetParameter2 { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-parser/src/generated_sdk/accounts/token_badge.rs b/crates/meteora-parser/src/generated_sdk/accounts/token_badge.rs deleted file mode 100644 index 255637f8..00000000 --- a/crates/meteora-parser/src/generated_sdk/accounts/token_badge.rs +++ /dev/null @@ -1,138 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Parameter that set by the protocol - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenBadge { - pub discriminator: [u8; 8], - /// token mint - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_mint: Pubkey, - /// Reserve - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 128], -} - -impl TokenBadge { - pub const LEN: usize = 168; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for TokenBadge { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_token_badge(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = TokenBadge::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_token_badge(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = TokenBadge::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for TokenBadge { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for TokenBadge {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for TokenBadge { - fn owner() -> Pubkey { crate::LB_CLMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for TokenBadge {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for TokenBadge { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-parser/src/generated_sdk/errors/lb_clmm.rs b/crates/meteora-parser/src/generated_sdk/errors/lb_clmm.rs deleted file mode 100644 index 148256ac..00000000 --- a/crates/meteora-parser/src/generated_sdk/errors/lb_clmm.rs +++ /dev/null @@ -1,274 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum LbClmmError { - /// 6000 - Invalid start bin index - #[error("Invalid start bin index")] - InvalidStartBinIndex = 0x1770, - /// 6001 - Invalid bin id - #[error("Invalid bin id")] - InvalidBinId = 0x1771, - /// 6002 - Invalid input data - #[error("Invalid input data")] - InvalidInput = 0x1772, - /// 6003 - Exceeded amount slippage tolerance - #[error("Exceeded amount slippage tolerance")] - ExceededAmountSlippageTolerance = 0x1773, - /// 6004 - Exceeded bin slippage tolerance - #[error("Exceeded bin slippage tolerance")] - ExceededBinSlippageTolerance = 0x1774, - /// 6005 - Composition factor flawed - #[error("Composition factor flawed")] - CompositionFactorFlawed = 0x1775, - /// 6006 - Non preset bin step - #[error("Non preset bin step")] - NonPresetBinStep = 0x1776, - /// 6007 - Zero liquidity - #[error("Zero liquidity")] - ZeroLiquidity = 0x1777, - /// 6008 - Invalid position - #[error("Invalid position")] - InvalidPosition = 0x1778, - /// 6009 - Bin array not found - #[error("Bin array not found")] - BinArrayNotFound = 0x1779, - /// 6010 - Invalid token mint - #[error("Invalid token mint")] - InvalidTokenMint = 0x177a, - /// 6011 - Invalid account for single deposit - #[error("Invalid account for single deposit")] - InvalidAccountForSingleDeposit = 0x177b, - /// 6012 - Pair insufficient liquidity - #[error("Pair insufficient liquidity")] - PairInsufficientLiquidity = 0x177c, - /// 6013 - Invalid fee owner - #[error("Invalid fee owner")] - InvalidFeeOwner = 0x177d, - /// 6014 - Invalid fee withdraw amount - #[error("Invalid fee withdraw amount")] - InvalidFeeWithdrawAmount = 0x177e, - /// 6015 - Invalid admin - #[error("Invalid admin")] - InvalidAdmin = 0x177f, - /// 6016 - Identical fee owner - #[error("Identical fee owner")] - IdenticalFeeOwner = 0x1780, - /// 6017 - Invalid basis point - #[error("Invalid basis point")] - InvalidBps = 0x1781, - /// 6018 - Math operation overflow - #[error("Math operation overflow")] - MathOverflow = 0x1782, - /// 6019 - Type cast error - #[error("Type cast error")] - TypeCastFailed = 0x1783, - /// 6020 - Invalid reward index - #[error("Invalid reward index")] - InvalidRewardIndex = 0x1784, - /// 6021 - Invalid reward duration - #[error("Invalid reward duration")] - InvalidRewardDuration = 0x1785, - /// 6022 - Reward already initialized - #[error("Reward already initialized")] - RewardInitialized = 0x1786, - /// 6023 - Reward not initialized - #[error("Reward not initialized")] - RewardUninitialized = 0x1787, - /// 6024 - Identical funder - #[error("Identical funder")] - IdenticalFunder = 0x1788, - /// 6025 - Reward campaign in progress - #[error("Reward campaign in progress")] - RewardCampaignInProgress = 0x1789, - /// 6026 - Reward duration is the same - #[error("Reward duration is the same")] - IdenticalRewardDuration = 0x178a, - /// 6027 - Invalid bin array - #[error("Invalid bin array")] - InvalidBinArray = 0x178b, - /// 6028 - Bin arrays must be continuous - #[error("Bin arrays must be continuous")] - NonContinuousBinArrays = 0x178c, - /// 6029 - Invalid reward vault - #[error("Invalid reward vault")] - InvalidRewardVault = 0x178d, - /// 6030 - Position is not empty - #[error("Position is not empty")] - NonEmptyPosition = 0x178e, - /// 6031 - Unauthorized access - #[error("Unauthorized access")] - UnauthorizedAccess = 0x178f, - /// 6032 - Invalid fee parameter - #[error("Invalid fee parameter")] - InvalidFeeParameter = 0x1790, - /// 6033 - Missing oracle account - #[error("Missing oracle account")] - MissingOracle = 0x1791, - /// 6034 - Insufficient observation sample - #[error("Insufficient observation sample")] - InsufficientSample = 0x1792, - /// 6035 - Invalid lookup timestamp - #[error("Invalid lookup timestamp")] - InvalidLookupTimestamp = 0x1793, - /// 6036 - Bitmap extension account is not provided - #[error("Bitmap extension account is not provided")] - BitmapExtensionAccountIsNotProvided = 0x1794, - /// 6037 - Cannot find non-zero liquidity binArrayId - #[error("Cannot find non-zero liquidity binArrayId")] - CannotFindNonZeroLiquidityBinArrayId = 0x1795, - /// 6038 - Bin id out of bound - #[error("Bin id out of bound")] - BinIdOutOfBound = 0x1796, - /// 6039 - Insufficient amount in for minimum out - #[error("Insufficient amount in for minimum out")] - InsufficientOutAmount = 0x1797, - /// 6040 - Invalid position width - #[error("Invalid position width")] - InvalidPositionWidth = 0x1798, - /// 6041 - Excessive fee update - #[error("Excessive fee update")] - ExcessiveFeeUpdate = 0x1799, - /// 6042 - Pool disabled - #[error("Pool disabled")] - PoolDisabled = 0x179a, - /// 6043 - Invalid pool type - #[error("Invalid pool type")] - InvalidPoolType = 0x179b, - /// 6044 - Whitelist for wallet is full - #[error("Whitelist for wallet is full")] - ExceedMaxWhitelist = 0x179c, - /// 6045 - Invalid index - #[error("Invalid index")] - InvalidIndex = 0x179d, - /// 6046 - Reward not ended - #[error("Reward not ended")] - RewardNotEnded = 0x179e, - /// 6047 - Must withdraw ineligible reward - #[error("Must withdraw ineligible reward")] - MustWithdrawnIneligibleReward = 0x179f, - /// 6048 - Unauthorized address - #[error("Unauthorized address")] - UnauthorizedAddress = 0x17a0, - /// 6049 - Cannot update because operators are the same - #[error("Cannot update because operators are the same")] - OperatorsAreTheSame = 0x17a1, - /// 6050 - Withdraw to wrong token account - #[error("Withdraw to wrong token account")] - WithdrawToWrongTokenAccount = 0x17a2, - /// 6051 - Wrong rent receiver - #[error("Wrong rent receiver")] - WrongRentReceiver = 0x17a3, - /// 6052 - Already activated - #[error("Already activated")] - AlreadyPassActivationPoint = 0x17a4, - /// 6053 - Swapped amount is exceeded max swapped amount - #[error("Swapped amount is exceeded max swapped amount")] - ExceedMaxSwappedAmount = 0x17a5, - /// 6054 - Invalid strategy parameters - #[error("Invalid strategy parameters")] - InvalidStrategyParameters = 0x17a6, - /// 6055 - Liquidity locked - #[error("Liquidity locked")] - LiquidityLocked = 0x17a7, - /// 6056 - Bin range is not empty - #[error("Bin range is not empty")] - BinRangeIsNotEmpty = 0x17a8, - /// 6057 - Amount out is not matched with exact amount out - #[error("Amount out is not matched with exact amount out")] - NotExactAmountOut = 0x17a9, - /// 6058 - Invalid activation type - #[error("Invalid activation type")] - InvalidActivationType = 0x17aa, - /// 6059 - Invalid activation duration - #[error("Invalid activation duration")] - InvalidActivationDuration = 0x17ab, - /// 6060 - Missing token amount as token launch owner proof - #[error("Missing token amount as token launch owner proof")] - MissingTokenAmountAsTokenLaunchProof = 0x17ac, - /// 6061 - Quote token must be SOL or USDC - #[error("Quote token must be SOL or USDC")] - InvalidQuoteToken = 0x17ad, - /// 6062 - Invalid bin step - #[error("Invalid bin step")] - InvalidBinStep = 0x17ae, - /// 6063 - Invalid base fee - #[error("Invalid base fee")] - InvalidBaseFee = 0x17af, - /// 6064 - Invalid pre-activation duration - #[error("Invalid pre-activation duration")] - InvalidPreActivationDuration = 0x17b0, - /// 6065 - Already pass pre-activation swap point - #[error("Already pass pre-activation swap point")] - AlreadyPassPreActivationSwapPoint = 0x17b1, - /// 6066 - Invalid status - #[error("Invalid status")] - InvalidStatus = 0x17b2, - /// 6067 - Exceed max oracle length - #[error("Exceed max oracle length")] - ExceededMaxOracleLength = 0x17b3, - /// 6068 - Invalid minimum liquidity - #[error("Invalid minimum liquidity")] - InvalidMinimumLiquidity = 0x17b4, - /// 6069 - Not support token_2022 mint extension - #[error("Not support token_2022 mint extension")] - NotSupportMint = 0x17b5, - /// 6070 - Unsupported mint extension - #[error("Unsupported mint extension")] - UnsupportedMintExtension = 0x17b6, - /// 6071 - Unsupported native mint token2022 - #[error("Unsupported native mint token2022")] - UnsupportNativeMintToken2022 = 0x17b7, - /// 6072 - Unmatch token mint - #[error("Unmatch token mint")] - UnmatchTokenMint = 0x17b8, - /// 6073 - Unsupported token mint - #[error("Unsupported token mint")] - UnsupportedTokenMint = 0x17b9, - /// 6074 - Insufficient remaining accounts - #[error("Insufficient remaining accounts")] - InsufficientRemainingAccounts = 0x17ba, - /// 6075 - Invalid remaining account slice - #[error("Invalid remaining account slice")] - InvalidRemainingAccountSlice = 0x17bb, - /// 6076 - Duplicated remaining account types - #[error("Duplicated remaining account types")] - DuplicatedRemainingAccountTypes = 0x17bc, - /// 6077 - Missing remaining account for transfer hook - #[error("Missing remaining account for transfer hook")] - MissingRemainingAccountForTransferHook = 0x17bd, - /// 6078 - Remaining account was passed for transfer hook but there's no hook program - #[error("Remaining account was passed for transfer hook but there's no hook program")] - NoTransferHookProgram = 0x17be, - /// 6079 - Zero funded amount - #[error("Zero funded amount")] - ZeroFundedAmount = 0x17bf, - /// 6080 - Invalid side - #[error("Invalid side")] - InvalidSide = 0x17c0, - /// 6081 - Invalid resize length - #[error("Invalid resize length")] - InvalidResizeLength = 0x17c1, - /// 6082 - Not support at the moment - #[error("Not support at the moment")] - NotSupportAtTheMoment = 0x17c2, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for LbClmmError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for LbClmmError { - fn type_of() -> &'static str { "LbClmmError" } -} diff --git a/crates/meteora-parser/src/generated_sdk/errors/mod.rs b/crates/meteora-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 47012ba9..00000000 --- a/crates/meteora-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod lb_clmm; - -pub use self::lb_clmm::LbClmmError; diff --git a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity.rs b/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity.rs deleted file mode 100644 index f5072e49..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity.rs +++ /dev/null @@ -1,932 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::LiquidityParameter; - -/// Accounts. -#[derive(Debug)] -pub struct AddLiquidity { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl AddLiquidity { - pub fn instruction( - &self, - args: AddLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl AddLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [181, 157, 89, 67, 143, 182, 52, 72], - } - } -} - -impl Default for AddLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityInstructionArgs { - pub liquidity_parameter: LiquidityParameter, -} - -/// Instruction builder for `AddLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct AddLiquidityBuilder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token_x: Option, - user_token_y: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - liquidity_parameter: Option, - __remaining_accounts: Vec, -} - -impl AddLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn liquidity_parameter(&mut self, liquidity_parameter: LiquidityParameter) -> &mut Self { - self.liquidity_parameter = Some(liquidity_parameter); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddLiquidity { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = AddLiquidityInstructionArgs { - liquidity_parameter: self - .liquidity_parameter - .clone() - .expect("liquidity_parameter is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_liquidity` CPI accounts. -pub struct AddLiquidityCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_liquidity` CPI instruction. -pub struct AddLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddLiquidityInstructionArgs, -} - -impl<'a, 'b> AddLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddLiquidityCpiAccounts<'a, 'b>, - args: AddLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct AddLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddLiquidityCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token_x: None, - user_token_y: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - liquidity_parameter: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn liquidity_parameter(&mut self, liquidity_parameter: LiquidityParameter) -> &mut Self { - self.instruction.liquidity_parameter = Some(liquidity_parameter); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddLiquidityInstructionArgs { - liquidity_parameter: self - .instruction - .liquidity_parameter - .clone() - .expect("liquidity_parameter is not set"), - }; - let instruction = AddLiquidityCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity_parameter: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity2.rs b/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity2.rs deleted file mode 100644 index f4e07043..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity2.rs +++ /dev/null @@ -1,879 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{LiquidityParameter, RemainingAccountsInfo}; - -/// Accounts. -#[derive(Debug)] -pub struct AddLiquidity2 { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl AddLiquidity2 { - pub fn instruction( - &self, - args: AddLiquidity2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddLiquidity2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddLiquidity2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidity2InstructionData { - discriminator: [u8; 8], -} - -impl AddLiquidity2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [228, 162, 78, 28, 70, 219, 116, 115], - } - } -} - -impl Default for AddLiquidity2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidity2InstructionArgs { - pub liquidity_parameter: LiquidityParameter, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `AddLiquidity2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[signer]` sender -/// 10. `[]` token_x_program -/// 11. `[]` token_y_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct AddLiquidity2Builder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token_x: Option, - user_token_y: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - sender: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - liquidity_parameter: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl AddLiquidity2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn liquidity_parameter(&mut self, liquidity_parameter: LiquidityParameter) -> &mut Self { - self.liquidity_parameter = Some(liquidity_parameter); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddLiquidity2 { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - sender: self.sender.expect("sender is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = AddLiquidity2InstructionArgs { - liquidity_parameter: self - .liquidity_parameter - .clone() - .expect("liquidity_parameter is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_liquidity2` CPI accounts. -pub struct AddLiquidity2CpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_liquidity2` CPI instruction. -pub struct AddLiquidity2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddLiquidity2InstructionArgs, -} - -impl<'a, 'b> AddLiquidity2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddLiquidity2CpiAccounts<'a, 'b>, - args: AddLiquidity2InstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - sender: accounts.sender, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddLiquidity2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddLiquidity2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[signer]` sender -/// 10. `[]` token_x_program -/// 11. `[]` token_y_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct AddLiquidity2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddLiquidity2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddLiquidity2CpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token_x: None, - user_token_y: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - sender: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - liquidity_parameter: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn liquidity_parameter(&mut self, liquidity_parameter: LiquidityParameter) -> &mut Self { - self.instruction.liquidity_parameter = Some(liquidity_parameter); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddLiquidity2InstructionArgs { - liquidity_parameter: self - .instruction - .liquidity_parameter - .clone() - .expect("liquidity_parameter is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = AddLiquidity2Cpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddLiquidity2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity_parameter: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_strategy.rs b/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_strategy.rs deleted file mode 100644 index 72a8ffb8..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_strategy.rs +++ /dev/null @@ -1,938 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::LiquidityParameterByStrategy; - -/// Accounts. -#[derive(Debug)] -pub struct AddLiquidityByStrategy { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl AddLiquidityByStrategy { - pub fn instruction( - &self, - args: AddLiquidityByStrategyInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddLiquidityByStrategyInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddLiquidityByStrategyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityByStrategyInstructionData { - discriminator: [u8; 8], -} - -impl AddLiquidityByStrategyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [7, 3, 150, 127, 148, 40, 61, 200], - } - } -} - -impl Default for AddLiquidityByStrategyInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityByStrategyInstructionArgs { - pub liquidity_parameter: LiquidityParameterByStrategy, -} - -/// Instruction builder for `AddLiquidityByStrategy`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct AddLiquidityByStrategyBuilder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token_x: Option, - user_token_y: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - liquidity_parameter: Option, - __remaining_accounts: Vec, -} - -impl AddLiquidityByStrategyBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn liquidity_parameter( - &mut self, - liquidity_parameter: LiquidityParameterByStrategy, - ) -> &mut Self { - self.liquidity_parameter = Some(liquidity_parameter); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddLiquidityByStrategy { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = AddLiquidityByStrategyInstructionArgs { - liquidity_parameter: self - .liquidity_parameter - .clone() - .expect("liquidity_parameter is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_liquidity_by_strategy` CPI accounts. -pub struct AddLiquidityByStrategyCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_liquidity_by_strategy` CPI instruction. -pub struct AddLiquidityByStrategyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddLiquidityByStrategyInstructionArgs, -} - -impl<'a, 'b> AddLiquidityByStrategyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddLiquidityByStrategyCpiAccounts<'a, 'b>, - args: AddLiquidityByStrategyInstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddLiquidityByStrategyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddLiquidityByStrategy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct AddLiquidityByStrategyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddLiquidityByStrategyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddLiquidityByStrategyCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token_x: None, - user_token_y: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - liquidity_parameter: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn liquidity_parameter( - &mut self, - liquidity_parameter: LiquidityParameterByStrategy, - ) -> &mut Self { - self.instruction.liquidity_parameter = Some(liquidity_parameter); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddLiquidityByStrategyInstructionArgs { - liquidity_parameter: self - .instruction - .liquidity_parameter - .clone() - .expect("liquidity_parameter is not set"), - }; - let instruction = AddLiquidityByStrategyCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddLiquidityByStrategyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity_parameter: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_strategy2.rs b/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_strategy2.rs deleted file mode 100644 index f66981c3..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_strategy2.rs +++ /dev/null @@ -1,885 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{LiquidityParameterByStrategy, RemainingAccountsInfo}; - -/// Accounts. -#[derive(Debug)] -pub struct AddLiquidityByStrategy2 { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl AddLiquidityByStrategy2 { - pub fn instruction( - &self, - args: AddLiquidityByStrategy2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddLiquidityByStrategy2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddLiquidityByStrategy2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityByStrategy2InstructionData { - discriminator: [u8; 8], -} - -impl AddLiquidityByStrategy2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [3, 221, 149, 218, 111, 141, 118, 213], - } - } -} - -impl Default for AddLiquidityByStrategy2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityByStrategy2InstructionArgs { - pub liquidity_parameter: LiquidityParameterByStrategy, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `AddLiquidityByStrategy2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[signer]` sender -/// 10. `[]` token_x_program -/// 11. `[]` token_y_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct AddLiquidityByStrategy2Builder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token_x: Option, - user_token_y: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - sender: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - liquidity_parameter: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl AddLiquidityByStrategy2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn liquidity_parameter( - &mut self, - liquidity_parameter: LiquidityParameterByStrategy, - ) -> &mut Self { - self.liquidity_parameter = Some(liquidity_parameter); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddLiquidityByStrategy2 { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - sender: self.sender.expect("sender is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = AddLiquidityByStrategy2InstructionArgs { - liquidity_parameter: self - .liquidity_parameter - .clone() - .expect("liquidity_parameter is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_liquidity_by_strategy2` CPI accounts. -pub struct AddLiquidityByStrategy2CpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_liquidity_by_strategy2` CPI instruction. -pub struct AddLiquidityByStrategy2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddLiquidityByStrategy2InstructionArgs, -} - -impl<'a, 'b> AddLiquidityByStrategy2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddLiquidityByStrategy2CpiAccounts<'a, 'b>, - args: AddLiquidityByStrategy2InstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - sender: accounts.sender, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddLiquidityByStrategy2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddLiquidityByStrategy2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[signer]` sender -/// 10. `[]` token_x_program -/// 11. `[]` token_y_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct AddLiquidityByStrategy2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddLiquidityByStrategy2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddLiquidityByStrategy2CpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token_x: None, - user_token_y: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - sender: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - liquidity_parameter: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn liquidity_parameter( - &mut self, - liquidity_parameter: LiquidityParameterByStrategy, - ) -> &mut Self { - self.instruction.liquidity_parameter = Some(liquidity_parameter); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddLiquidityByStrategy2InstructionArgs { - liquidity_parameter: self - .instruction - .liquidity_parameter - .clone() - .expect("liquidity_parameter is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = AddLiquidityByStrategy2Cpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddLiquidityByStrategy2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity_parameter: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_strategy_one_side.rs b/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_strategy_one_side.rs deleted file mode 100644 index d626ce13..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_strategy_one_side.rs +++ /dev/null @@ -1,832 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::StrategyParameters; - -/// Accounts. -#[derive(Debug)] -pub struct AddLiquidityByStrategyOneSide { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token: solana_pubkey::Pubkey, - - pub reserve: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl AddLiquidityByStrategyOneSide { - pub fn instruction( - &self, - args: AddLiquidityByStrategyOneSideInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddLiquidityByStrategyOneSideInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.user_token, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddLiquidityByStrategyOneSideInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityByStrategyOneSideInstructionData { - discriminator: [u8; 8], -} - -impl AddLiquidityByStrategyOneSideInstructionData { - pub fn new() -> Self { - Self { - discriminator: [41, 5, 238, 175, 100, 225, 6, 205], - } - } -} - -impl Default for AddLiquidityByStrategyOneSideInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityByStrategyOneSideInstructionArgs { - pub amount: u64, - pub active_id: i32, - pub max_active_bin_slippage: i32, - pub strategy_parameters: StrategyParameters, -} - -/// Instruction builder for `AddLiquidityByStrategyOneSide`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token -/// 4. `[writable]` reserve -/// 5. `[]` token_mint -/// 6. `[writable]` bin_array_lower -/// 7. `[writable]` bin_array_upper -/// 8. `[signer]` sender -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug, Default)] -pub struct AddLiquidityByStrategyOneSideBuilder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token: Option, - reserve: Option, - token_mint: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - token_program: Option, - event_authority: Option, - program: Option, - amount: Option, - active_id: Option, - max_active_bin_slippage: Option, - strategy_parameters: Option, - __remaining_accounts: Vec, -} - -impl AddLiquidityByStrategyOneSideBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token(&mut self, user_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_token = Some(user_token); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self { - self.reserve = Some(reserve); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn max_active_bin_slippage(&mut self, max_active_bin_slippage: i32) -> &mut Self { - self.max_active_bin_slippage = Some(max_active_bin_slippage); - self - } - - #[inline(always)] - pub fn strategy_parameters(&mut self, strategy_parameters: StrategyParameters) -> &mut Self { - self.strategy_parameters = Some(strategy_parameters); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddLiquidityByStrategyOneSide { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token: self.user_token.expect("user_token is not set"), - reserve: self.reserve.expect("reserve is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = AddLiquidityByStrategyOneSideInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - active_id: self.active_id.clone().expect("active_id is not set"), - max_active_bin_slippage: self - .max_active_bin_slippage - .clone() - .expect("max_active_bin_slippage is not set"), - strategy_parameters: self - .strategy_parameters - .clone() - .expect("strategy_parameters is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_liquidity_by_strategy_one_side` CPI accounts. -pub struct AddLiquidityByStrategyOneSideCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_liquidity_by_strategy_one_side` CPI instruction. -pub struct AddLiquidityByStrategyOneSideCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddLiquidityByStrategyOneSideInstructionArgs, -} - -impl<'a, 'b> AddLiquidityByStrategyOneSideCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddLiquidityByStrategyOneSideCpiAccounts<'a, 'b>, - args: AddLiquidityByStrategyOneSideInstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token: accounts.user_token, - reserve: accounts.reserve, - token_mint: accounts.token_mint, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddLiquidityByStrategyOneSideInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token.clone()); - account_infos.push(self.reserve.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddLiquidityByStrategyOneSide` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token -/// 4. `[writable]` reserve -/// 5. `[]` token_mint -/// 6. `[writable]` bin_array_lower -/// 7. `[writable]` bin_array_upper -/// 8. `[signer]` sender -/// 9. `[]` token_program -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug)] -pub struct AddLiquidityByStrategyOneSideCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddLiquidityByStrategyOneSideCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddLiquidityByStrategyOneSideCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token: None, - reserve: None, - token_mint: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - token_program: None, - event_authority: None, - program: None, - amount: None, - active_id: None, - max_active_bin_slippage: None, - strategy_parameters: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token( - &mut self, - user_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token = Some(user_token); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve = Some(reserve); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.instruction.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn max_active_bin_slippage(&mut self, max_active_bin_slippage: i32) -> &mut Self { - self.instruction.max_active_bin_slippage = Some(max_active_bin_slippage); - self - } - - #[inline(always)] - pub fn strategy_parameters(&mut self, strategy_parameters: StrategyParameters) -> &mut Self { - self.instruction.strategy_parameters = Some(strategy_parameters); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddLiquidityByStrategyOneSideInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - active_id: self - .instruction - .active_id - .clone() - .expect("active_id is not set"), - max_active_bin_slippage: self - .instruction - .max_active_bin_slippage - .clone() - .expect("max_active_bin_slippage is not set"), - strategy_parameters: self - .instruction - .strategy_parameters - .clone() - .expect("strategy_parameters is not set"), - }; - let instruction = AddLiquidityByStrategyOneSideCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token: self.instruction.user_token.expect("user_token is not set"), - - reserve: self.instruction.reserve.expect("reserve is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddLiquidityByStrategyOneSideCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - active_id: Option, - max_active_bin_slippage: Option, - strategy_parameters: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_weight.rs b/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_weight.rs deleted file mode 100644 index 41f29967..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_by_weight.rs +++ /dev/null @@ -1,1029 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::BinLiquidityDistributionByWeight; - -/// Accounts. -#[derive(Debug)] -pub struct AddLiquidityByWeight { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl AddLiquidityByWeight { - pub fn instruction( - &self, - args: AddLiquidityByWeightInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddLiquidityByWeightInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddLiquidityByWeightInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityByWeightInstructionData { - discriminator: [u8; 8], -} - -impl AddLiquidityByWeightInstructionData { - pub fn new() -> Self { - Self { - discriminator: [28, 140, 238, 99, 231, 162, 21, 149], - } - } -} - -impl Default for AddLiquidityByWeightInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityByWeightInstructionArgs { - pub amount_x: u64, - pub amount_y: u64, - pub active_id: i32, - pub max_active_bin_slippage: i32, - pub bin_liquidity_dist: Vec, -} - -/// Instruction builder for `AddLiquidityByWeight`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct AddLiquidityByWeightBuilder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token_x: Option, - user_token_y: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - amount_x: Option, - amount_y: Option, - active_id: Option, - max_active_bin_slippage: Option, - bin_liquidity_dist: Option>, - __remaining_accounts: Vec, -} - -impl AddLiquidityByWeightBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_x(&mut self, amount_x: u64) -> &mut Self { - self.amount_x = Some(amount_x); - self - } - - #[inline(always)] - pub fn amount_y(&mut self, amount_y: u64) -> &mut Self { - self.amount_y = Some(amount_y); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn max_active_bin_slippage(&mut self, max_active_bin_slippage: i32) -> &mut Self { - self.max_active_bin_slippage = Some(max_active_bin_slippage); - self - } - - #[inline(always)] - pub fn bin_liquidity_dist( - &mut self, - bin_liquidity_dist: Vec, - ) -> &mut Self { - self.bin_liquidity_dist = Some(bin_liquidity_dist); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddLiquidityByWeight { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = AddLiquidityByWeightInstructionArgs { - amount_x: self.amount_x.clone().expect("amount_x is not set"), - amount_y: self.amount_y.clone().expect("amount_y is not set"), - active_id: self.active_id.clone().expect("active_id is not set"), - max_active_bin_slippage: self - .max_active_bin_slippage - .clone() - .expect("max_active_bin_slippage is not set"), - bin_liquidity_dist: self - .bin_liquidity_dist - .clone() - .expect("bin_liquidity_dist is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_liquidity_by_weight` CPI accounts. -pub struct AddLiquidityByWeightCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_liquidity_by_weight` CPI instruction. -pub struct AddLiquidityByWeightCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddLiquidityByWeightInstructionArgs, -} - -impl<'a, 'b> AddLiquidityByWeightCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddLiquidityByWeightCpiAccounts<'a, 'b>, - args: AddLiquidityByWeightInstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddLiquidityByWeightInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddLiquidityByWeight` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct AddLiquidityByWeightCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddLiquidityByWeightCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddLiquidityByWeightCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token_x: None, - user_token_y: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - amount_x: None, - amount_y: None, - active_id: None, - max_active_bin_slippage: None, - bin_liquidity_dist: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_x(&mut self, amount_x: u64) -> &mut Self { - self.instruction.amount_x = Some(amount_x); - self - } - - #[inline(always)] - pub fn amount_y(&mut self, amount_y: u64) -> &mut Self { - self.instruction.amount_y = Some(amount_y); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.instruction.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn max_active_bin_slippage(&mut self, max_active_bin_slippage: i32) -> &mut Self { - self.instruction.max_active_bin_slippage = Some(max_active_bin_slippage); - self - } - - #[inline(always)] - pub fn bin_liquidity_dist( - &mut self, - bin_liquidity_dist: Vec, - ) -> &mut Self { - self.instruction.bin_liquidity_dist = Some(bin_liquidity_dist); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddLiquidityByWeightInstructionArgs { - amount_x: self - .instruction - .amount_x - .clone() - .expect("amount_x is not set"), - amount_y: self - .instruction - .amount_y - .clone() - .expect("amount_y is not set"), - active_id: self - .instruction - .active_id - .clone() - .expect("active_id is not set"), - max_active_bin_slippage: self - .instruction - .max_active_bin_slippage - .clone() - .expect("max_active_bin_slippage is not set"), - bin_liquidity_dist: self - .instruction - .bin_liquidity_dist - .clone() - .expect("bin_liquidity_dist is not set"), - }; - let instruction = AddLiquidityByWeightCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddLiquidityByWeightCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_x: Option, - amount_y: Option, - active_id: Option, - max_active_bin_slippage: Option, - bin_liquidity_dist: Option>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_one_side.rs b/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_one_side.rs deleted file mode 100644 index d5fb4ce6..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_one_side.rs +++ /dev/null @@ -1,838 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::BinLiquidityDistributionByWeight; - -/// Accounts. -#[derive(Debug)] -pub struct AddLiquidityOneSide { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token: solana_pubkey::Pubkey, - - pub reserve: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl AddLiquidityOneSide { - pub fn instruction( - &self, - args: AddLiquidityOneSideInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddLiquidityOneSideInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.user_token, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddLiquidityOneSideInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityOneSideInstructionData { - discriminator: [u8; 8], -} - -impl AddLiquidityOneSideInstructionData { - pub fn new() -> Self { - Self { - discriminator: [94, 155, 103, 151, 70, 95, 220, 165], - } - } -} - -impl Default for AddLiquidityOneSideInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityOneSideInstructionArgs { - pub amount: u64, - pub active_id: i32, - pub max_active_bin_slippage: i32, - pub bin_liquidity_dist: Vec, -} - -/// Instruction builder for `AddLiquidityOneSide`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token -/// 4. `[writable]` reserve -/// 5. `[]` token_mint -/// 6. `[writable]` bin_array_lower -/// 7. `[writable]` bin_array_upper -/// 8. `[signer]` sender -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug, Default)] -pub struct AddLiquidityOneSideBuilder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token: Option, - reserve: Option, - token_mint: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - token_program: Option, - event_authority: Option, - program: Option, - amount: Option, - active_id: Option, - max_active_bin_slippage: Option, - bin_liquidity_dist: Option>, - __remaining_accounts: Vec, -} - -impl AddLiquidityOneSideBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token(&mut self, user_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_token = Some(user_token); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self { - self.reserve = Some(reserve); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn max_active_bin_slippage(&mut self, max_active_bin_slippage: i32) -> &mut Self { - self.max_active_bin_slippage = Some(max_active_bin_slippage); - self - } - - #[inline(always)] - pub fn bin_liquidity_dist( - &mut self, - bin_liquidity_dist: Vec, - ) -> &mut Self { - self.bin_liquidity_dist = Some(bin_liquidity_dist); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddLiquidityOneSide { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token: self.user_token.expect("user_token is not set"), - reserve: self.reserve.expect("reserve is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = AddLiquidityOneSideInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - active_id: self.active_id.clone().expect("active_id is not set"), - max_active_bin_slippage: self - .max_active_bin_slippage - .clone() - .expect("max_active_bin_slippage is not set"), - bin_liquidity_dist: self - .bin_liquidity_dist - .clone() - .expect("bin_liquidity_dist is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_liquidity_one_side` CPI accounts. -pub struct AddLiquidityOneSideCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_liquidity_one_side` CPI instruction. -pub struct AddLiquidityOneSideCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddLiquidityOneSideInstructionArgs, -} - -impl<'a, 'b> AddLiquidityOneSideCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddLiquidityOneSideCpiAccounts<'a, 'b>, - args: AddLiquidityOneSideInstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token: accounts.user_token, - reserve: accounts.reserve, - token_mint: accounts.token_mint, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddLiquidityOneSideInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token.clone()); - account_infos.push(self.reserve.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddLiquidityOneSide` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token -/// 4. `[writable]` reserve -/// 5. `[]` token_mint -/// 6. `[writable]` bin_array_lower -/// 7. `[writable]` bin_array_upper -/// 8. `[signer]` sender -/// 9. `[]` token_program -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug)] -pub struct AddLiquidityOneSideCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddLiquidityOneSideCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddLiquidityOneSideCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token: None, - reserve: None, - token_mint: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - token_program: None, - event_authority: None, - program: None, - amount: None, - active_id: None, - max_active_bin_slippage: None, - bin_liquidity_dist: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token( - &mut self, - user_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token = Some(user_token); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve = Some(reserve); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.instruction.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn max_active_bin_slippage(&mut self, max_active_bin_slippage: i32) -> &mut Self { - self.instruction.max_active_bin_slippage = Some(max_active_bin_slippage); - self - } - - #[inline(always)] - pub fn bin_liquidity_dist( - &mut self, - bin_liquidity_dist: Vec, - ) -> &mut Self { - self.instruction.bin_liquidity_dist = Some(bin_liquidity_dist); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddLiquidityOneSideInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - active_id: self - .instruction - .active_id - .clone() - .expect("active_id is not set"), - max_active_bin_slippage: self - .instruction - .max_active_bin_slippage - .clone() - .expect("max_active_bin_slippage is not set"), - bin_liquidity_dist: self - .instruction - .bin_liquidity_dist - .clone() - .expect("bin_liquidity_dist is not set"), - }; - let instruction = AddLiquidityOneSideCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token: self.instruction.user_token.expect("user_token is not set"), - - reserve: self.instruction.reserve.expect("reserve is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddLiquidityOneSideCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - active_id: Option, - max_active_bin_slippage: Option, - bin_liquidity_dist: Option>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_one_side_precise.rs b/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_one_side_precise.rs deleted file mode 100644 index 8702288c..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_one_side_precise.rs +++ /dev/null @@ -1,785 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::CompressedBinDepositAmount; - -/// Accounts. -#[derive(Debug)] -pub struct AddLiquidityOneSidePrecise { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token: solana_pubkey::Pubkey, - - pub reserve: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl AddLiquidityOneSidePrecise { - pub fn instruction( - &self, - args: AddLiquidityOneSidePreciseInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddLiquidityOneSidePreciseInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.user_token, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddLiquidityOneSidePreciseInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityOneSidePreciseInstructionData { - discriminator: [u8; 8], -} - -impl AddLiquidityOneSidePreciseInstructionData { - pub fn new() -> Self { - Self { - discriminator: [161, 194, 103, 84, 171, 71, 250, 154], - } - } -} - -impl Default for AddLiquidityOneSidePreciseInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityOneSidePreciseInstructionArgs { - pub bins: Vec, - pub decompress_multiplier: u64, -} - -/// Instruction builder for `AddLiquidityOneSidePrecise`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token -/// 4. `[writable]` reserve -/// 5. `[]` token_mint -/// 6. `[writable]` bin_array_lower -/// 7. `[writable]` bin_array_upper -/// 8. `[signer]` sender -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug, Default)] -pub struct AddLiquidityOneSidePreciseBuilder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token: Option, - reserve: Option, - token_mint: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - token_program: Option, - event_authority: Option, - program: Option, - bins: Option>, - decompress_multiplier: Option, - __remaining_accounts: Vec, -} - -impl AddLiquidityOneSidePreciseBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token(&mut self, user_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_token = Some(user_token); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self { - self.reserve = Some(reserve); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn bins(&mut self, bins: Vec) -> &mut Self { - self.bins = Some(bins); - self - } - - #[inline(always)] - pub fn decompress_multiplier(&mut self, decompress_multiplier: u64) -> &mut Self { - self.decompress_multiplier = Some(decompress_multiplier); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddLiquidityOneSidePrecise { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token: self.user_token.expect("user_token is not set"), - reserve: self.reserve.expect("reserve is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = AddLiquidityOneSidePreciseInstructionArgs { - bins: self.bins.clone().expect("bins is not set"), - decompress_multiplier: self - .decompress_multiplier - .clone() - .expect("decompress_multiplier is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_liquidity_one_side_precise` CPI accounts. -pub struct AddLiquidityOneSidePreciseCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_liquidity_one_side_precise` CPI instruction. -pub struct AddLiquidityOneSidePreciseCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddLiquidityOneSidePreciseInstructionArgs, -} - -impl<'a, 'b> AddLiquidityOneSidePreciseCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddLiquidityOneSidePreciseCpiAccounts<'a, 'b>, - args: AddLiquidityOneSidePreciseInstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token: accounts.user_token, - reserve: accounts.reserve, - token_mint: accounts.token_mint, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddLiquidityOneSidePreciseInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token.clone()); - account_infos.push(self.reserve.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddLiquidityOneSidePrecise` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token -/// 4. `[writable]` reserve -/// 5. `[]` token_mint -/// 6. `[writable]` bin_array_lower -/// 7. `[writable]` bin_array_upper -/// 8. `[signer]` sender -/// 9. `[]` token_program -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug)] -pub struct AddLiquidityOneSidePreciseCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddLiquidityOneSidePreciseCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddLiquidityOneSidePreciseCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token: None, - reserve: None, - token_mint: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - token_program: None, - event_authority: None, - program: None, - bins: None, - decompress_multiplier: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token( - &mut self, - user_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token = Some(user_token); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve = Some(reserve); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn bins(&mut self, bins: Vec) -> &mut Self { - self.instruction.bins = Some(bins); - self - } - - #[inline(always)] - pub fn decompress_multiplier(&mut self, decompress_multiplier: u64) -> &mut Self { - self.instruction.decompress_multiplier = Some(decompress_multiplier); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddLiquidityOneSidePreciseInstructionArgs { - bins: self.instruction.bins.clone().expect("bins is not set"), - decompress_multiplier: self - .instruction - .decompress_multiplier - .clone() - .expect("decompress_multiplier is not set"), - }; - let instruction = AddLiquidityOneSidePreciseCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token: self.instruction.user_token.expect("user_token is not set"), - - reserve: self.instruction.reserve.expect("reserve is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddLiquidityOneSidePreciseCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - bins: Option>, - decompress_multiplier: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_one_side_precise2.rs b/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_one_side_precise2.rs deleted file mode 100644 index d6dbbf02..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/add_liquidity_one_side_precise2.rs +++ /dev/null @@ -1,754 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{CompressedBinDepositAmount, RemainingAccountsInfo}; - -/// Accounts. -#[derive(Debug)] -pub struct AddLiquidityOneSidePrecise2 { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token: solana_pubkey::Pubkey, - - pub reserve: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl AddLiquidityOneSidePrecise2 { - pub fn instruction( - &self, - args: AddLiquidityOneSidePrecise2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddLiquidityOneSidePrecise2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.user_token, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddLiquidityOneSidePrecise2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityOneSidePrecise2InstructionData { - discriminator: [u8; 8], -} - -impl AddLiquidityOneSidePrecise2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [33, 51, 163, 201, 117, 98, 125, 231], - } - } -} - -impl Default for AddLiquidityOneSidePrecise2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddLiquidityOneSidePrecise2InstructionArgs { - pub bins: Vec, - pub decompress_multiplier: u64, - pub max_amount: u64, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `AddLiquidityOneSidePrecise2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token -/// 4. `[writable]` reserve -/// 5. `[]` token_mint -/// 6. `[signer]` sender -/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct AddLiquidityOneSidePrecise2Builder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token: Option, - reserve: Option, - token_mint: Option, - sender: Option, - token_program: Option, - event_authority: Option, - program: Option, - bins: Option>, - decompress_multiplier: Option, - max_amount: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl AddLiquidityOneSidePrecise2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token(&mut self, user_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_token = Some(user_token); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self { - self.reserve = Some(reserve); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn bins(&mut self, bins: Vec) -> &mut Self { - self.bins = Some(bins); - self - } - - #[inline(always)] - pub fn decompress_multiplier(&mut self, decompress_multiplier: u64) -> &mut Self { - self.decompress_multiplier = Some(decompress_multiplier); - self - } - - #[inline(always)] - pub fn max_amount(&mut self, max_amount: u64) -> &mut Self { - self.max_amount = Some(max_amount); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddLiquidityOneSidePrecise2 { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token: self.user_token.expect("user_token is not set"), - reserve: self.reserve.expect("reserve is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - sender: self.sender.expect("sender is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = AddLiquidityOneSidePrecise2InstructionArgs { - bins: self.bins.clone().expect("bins is not set"), - decompress_multiplier: self - .decompress_multiplier - .clone() - .expect("decompress_multiplier is not set"), - max_amount: self.max_amount.clone().expect("max_amount is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_liquidity_one_side_precise2` CPI accounts. -pub struct AddLiquidityOneSidePrecise2CpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_liquidity_one_side_precise2` CPI instruction. -pub struct AddLiquidityOneSidePrecise2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddLiquidityOneSidePrecise2InstructionArgs, -} - -impl<'a, 'b> AddLiquidityOneSidePrecise2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddLiquidityOneSidePrecise2CpiAccounts<'a, 'b>, - args: AddLiquidityOneSidePrecise2InstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token: accounts.user_token, - reserve: accounts.reserve, - token_mint: accounts.token_mint, - sender: accounts.sender, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddLiquidityOneSidePrecise2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token.clone()); - account_infos.push(self.reserve.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddLiquidityOneSidePrecise2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token -/// 4. `[writable]` reserve -/// 5. `[]` token_mint -/// 6. `[signer]` sender -/// 7. `[]` token_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct AddLiquidityOneSidePrecise2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddLiquidityOneSidePrecise2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddLiquidityOneSidePrecise2CpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token: None, - reserve: None, - token_mint: None, - sender: None, - token_program: None, - event_authority: None, - program: None, - bins: None, - decompress_multiplier: None, - max_amount: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token( - &mut self, - user_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token = Some(user_token); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve = Some(reserve); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn bins(&mut self, bins: Vec) -> &mut Self { - self.instruction.bins = Some(bins); - self - } - - #[inline(always)] - pub fn decompress_multiplier(&mut self, decompress_multiplier: u64) -> &mut Self { - self.instruction.decompress_multiplier = Some(decompress_multiplier); - self - } - - #[inline(always)] - pub fn max_amount(&mut self, max_amount: u64) -> &mut Self { - self.instruction.max_amount = Some(max_amount); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddLiquidityOneSidePrecise2InstructionArgs { - bins: self.instruction.bins.clone().expect("bins is not set"), - decompress_multiplier: self - .instruction - .decompress_multiplier - .clone() - .expect("decompress_multiplier is not set"), - max_amount: self - .instruction - .max_amount - .clone() - .expect("max_amount is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = AddLiquidityOneSidePrecise2Cpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token: self.instruction.user_token.expect("user_token is not set"), - - reserve: self.instruction.reserve.expect("reserve is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddLiquidityOneSidePrecise2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - bins: Option>, - decompress_multiplier: Option, - max_amount: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/claim_fee.rs b/crates/meteora-parser/src/generated_sdk/instructions/claim_fee.rs deleted file mode 100644 index 6b4f892b..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/claim_fee.rs +++ /dev/null @@ -1,784 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimFee { - pub lb_pair: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimFee { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClaimFeeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimFeeInstructionData { - discriminator: [u8; 8], -} - -impl ClaimFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [169, 32, 79, 137, 136, 232, 70, 137], - } - } -} - -impl Default for ClaimFeeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClaimFee`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` position -/// 2. `[writable]` bin_array_lower -/// 3. `[writable]` bin_array_upper -/// 4. `[signer]` sender -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[writable]` user_token_x -/// 8. `[writable]` user_token_y -/// 9. `[]` token_x_mint -/// 10. `[]` token_y_mint -/// 11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimFeeBuilder { - lb_pair: Option, - position: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - reserve_x: Option, - reserve_y: Option, - user_token_x: Option, - user_token_y: Option, - token_x_mint: Option, - token_y_mint: Option, - token_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl ClaimFeeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimFee { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - position: self.position.expect("position is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `claim_fee` CPI accounts. -pub struct ClaimFeeCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_fee` CPI instruction. -pub struct ClaimFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClaimFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimFeeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - position: accounts.position, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClaimFeeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` position -/// 2. `[writable]` bin_array_lower -/// 3. `[writable]` bin_array_upper -/// 4. `[signer]` sender -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[writable]` user_token_x -/// 8. `[writable]` user_token_y -/// 9. `[]` token_x_mint -/// 10. `[]` token_y_mint -/// 11. `[]` token_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimFeeCpiBuilderInstruction { - __program: program, - lb_pair: None, - position: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - reserve_x: None, - reserve_y: None, - user_token_x: None, - user_token_y: None, - token_x_mint: None, - token_y_mint: None, - token_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClaimFeeCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - position: self.instruction.position.expect("position is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/claim_fee2.rs b/crates/meteora-parser/src/generated_sdk/instructions/claim_fee2.rs deleted file mode 100644 index 9ae8da90..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/claim_fee2.rs +++ /dev/null @@ -1,877 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimFee2 { - pub lb_pair: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub token_program_x: solana_pubkey::Pubkey, - - pub token_program_y: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimFee2 { - pub fn instruction(&self, args: ClaimFee2InstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimFee2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ClaimFee2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimFee2InstructionData { - discriminator: [u8; 8], -} - -impl ClaimFee2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [112, 191, 101, 171, 28, 144, 127, 187], - } - } -} - -impl Default for ClaimFee2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimFee2InstructionArgs { - pub min_bin_id: i32, - pub max_bin_id: i32, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `ClaimFee2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` position -/// 2. `[signer]` sender -/// 3. `[writable]` reserve_x -/// 4. `[writable]` reserve_y -/// 5. `[writable]` user_token_x -/// 6. `[writable]` user_token_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[]` token_program_x -/// 10. `[]` token_program_y -/// 11. `[]` memo_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimFee2Builder { - lb_pair: Option, - position: Option, - sender: Option, - reserve_x: Option, - reserve_y: Option, - user_token_x: Option, - user_token_y: Option, - token_x_mint: Option, - token_y_mint: Option, - token_program_x: Option, - token_program_y: Option, - memo_program: Option, - event_authority: Option, - program: Option, - min_bin_id: Option, - max_bin_id: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl ClaimFee2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn token_program_x(&mut self, token_program_x: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_x = Some(token_program_x); - self - } - - #[inline(always)] - pub fn token_program_y(&mut self, token_program_y: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_y = Some(token_program_y); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn min_bin_id(&mut self, min_bin_id: i32) -> &mut Self { - self.min_bin_id = Some(min_bin_id); - self - } - - #[inline(always)] - pub fn max_bin_id(&mut self, max_bin_id: i32) -> &mut Self { - self.max_bin_id = Some(max_bin_id); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimFee2 { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - position: self.position.expect("position is not set"), - sender: self.sender.expect("sender is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - token_program_x: self.token_program_x.expect("token_program_x is not set"), - token_program_y: self.token_program_y.expect("token_program_y is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = ClaimFee2InstructionArgs { - min_bin_id: self.min_bin_id.clone().expect("min_bin_id is not set"), - max_bin_id: self.max_bin_id.clone().expect("max_bin_id is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim_fee2` CPI accounts. -pub struct ClaimFee2CpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_y: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_fee2` CPI instruction. -pub struct ClaimFee2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_y: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimFee2InstructionArgs, -} - -impl<'a, 'b> ClaimFee2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimFee2CpiAccounts<'a, 'b>, - args: ClaimFee2InstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - position: accounts.position, - sender: accounts.sender, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - token_program_x: accounts.token_program_x, - token_program_y: accounts.token_program_y, - memo_program: accounts.memo_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ClaimFee2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.token_program_x.clone()); - account_infos.push(self.token_program_y.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimFee2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` position -/// 2. `[signer]` sender -/// 3. `[writable]` reserve_x -/// 4. `[writable]` reserve_y -/// 5. `[writable]` user_token_x -/// 6. `[writable]` user_token_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[]` token_program_x -/// 10. `[]` token_program_y -/// 11. `[]` memo_program -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimFee2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimFee2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimFee2CpiBuilderInstruction { - __program: program, - lb_pair: None, - position: None, - sender: None, - reserve_x: None, - reserve_y: None, - user_token_x: None, - user_token_y: None, - token_x_mint: None, - token_y_mint: None, - token_program_x: None, - token_program_y: None, - memo_program: None, - event_authority: None, - program: None, - min_bin_id: None, - max_bin_id: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn token_program_x( - &mut self, - token_program_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_x = Some(token_program_x); - self - } - - #[inline(always)] - pub fn token_program_y( - &mut self, - token_program_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_y = Some(token_program_y); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn min_bin_id(&mut self, min_bin_id: i32) -> &mut Self { - self.instruction.min_bin_id = Some(min_bin_id); - self - } - - #[inline(always)] - pub fn max_bin_id(&mut self, max_bin_id: i32) -> &mut Self { - self.instruction.max_bin_id = Some(max_bin_id); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ClaimFee2InstructionArgs { - min_bin_id: self - .instruction - .min_bin_id - .clone() - .expect("min_bin_id is not set"), - max_bin_id: self - .instruction - .max_bin_id - .clone() - .expect("max_bin_id is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = ClaimFee2Cpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - position: self.instruction.position.expect("position is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - token_program_x: self - .instruction - .token_program_x - .expect("token_program_x is not set"), - - token_program_y: self - .instruction - .token_program_y - .expect("token_program_y is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimFee2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_y: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - min_bin_id: Option, - max_bin_id: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/claim_reward.rs b/crates/meteora-parser/src/generated_sdk/instructions/claim_reward.rs deleted file mode 100644 index 901ba4ec..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/claim_reward.rs +++ /dev/null @@ -1,719 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimReward { - pub lb_pair: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub user_token_account: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimReward { - pub fn instruction(&self, args: ClaimRewardInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ClaimRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimRewardInstructionData { - discriminator: [u8; 8], -} - -impl ClaimRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [149, 95, 181, 242, 94, 90, 158, 162], - } - } -} - -impl Default for ClaimRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimRewardInstructionArgs { - pub reward_index: u64, -} - -/// Instruction builder for `ClaimReward`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` position -/// 2. `[writable]` bin_array_lower -/// 3. `[writable]` bin_array_upper -/// 4. `[signer]` sender -/// 5. `[writable]` reward_vault -/// 6. `[]` reward_mint -/// 7. `[writable]` user_token_account -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[]` event_authority -/// 10. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimRewardBuilder { - lb_pair: Option, - position: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - reward_vault: Option, - reward_mint: Option, - user_token_account: Option, - token_program: Option, - event_authority: Option, - program: Option, - reward_index: Option, - __remaining_accounts: Vec, -} - -impl ClaimRewardBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn user_token_account(&mut self, user_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_account = Some(user_token_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimReward { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - position: self.position.expect("position is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - user_token_account: self - .user_token_account - .expect("user_token_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = ClaimRewardInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim_reward` CPI accounts. -pub struct ClaimRewardCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_reward` CPI instruction. -pub struct ClaimRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimRewardInstructionArgs, -} - -impl<'a, 'b> ClaimRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimRewardCpiAccounts<'a, 'b>, - args: ClaimRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - position: accounts.position, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - reward_vault: accounts.reward_vault, - reward_mint: accounts.reward_mint, - user_token_account: accounts.user_token_account, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ClaimRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.user_token_account.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` position -/// 2. `[writable]` bin_array_lower -/// 3. `[writable]` bin_array_upper -/// 4. `[signer]` sender -/// 5. `[writable]` reward_vault -/// 6. `[]` reward_mint -/// 7. `[writable]` user_token_account -/// 8. `[]` token_program -/// 9. `[]` event_authority -/// 10. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimRewardCpiBuilderInstruction { - __program: program, - lb_pair: None, - position: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - reward_vault: None, - reward_mint: None, - user_token_account: None, - token_program: None, - event_authority: None, - program: None, - reward_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn user_token_account( - &mut self, - user_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_account = Some(user_token_account); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ClaimRewardInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - }; - let instruction = ClaimRewardCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - position: self.instruction.position.expect("position is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - user_token_account: self - .instruction - .user_token_account - .expect("user_token_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/claim_reward2.rs b/crates/meteora-parser/src/generated_sdk/instructions/claim_reward2.rs deleted file mode 100644 index 3aead57a..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/claim_reward2.rs +++ /dev/null @@ -1,757 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimReward2 { - pub lb_pair: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub user_token_account: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClaimReward2 { - pub fn instruction( - &self, - args: ClaimReward2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimReward2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ClaimReward2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimReward2InstructionData { - discriminator: [u8; 8], -} - -impl ClaimReward2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [190, 3, 127, 119, 178, 87, 157, 183], - } - } -} - -impl Default for ClaimReward2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimReward2InstructionArgs { - pub reward_index: u64, - pub min_bin_id: i32, - pub max_bin_id: i32, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `ClaimReward2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` position -/// 2. `[signer]` sender -/// 3. `[writable]` reward_vault -/// 4. `[]` reward_mint -/// 5. `[writable]` user_token_account -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[]` memo_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClaimReward2Builder { - lb_pair: Option, - position: Option, - sender: Option, - reward_vault: Option, - reward_mint: Option, - user_token_account: Option, - token_program: Option, - memo_program: Option, - event_authority: Option, - program: Option, - reward_index: Option, - min_bin_id: Option, - max_bin_id: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl ClaimReward2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn user_token_account(&mut self, user_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_account = Some(user_token_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn min_bin_id(&mut self, min_bin_id: i32) -> &mut Self { - self.min_bin_id = Some(min_bin_id); - self - } - - #[inline(always)] - pub fn max_bin_id(&mut self, max_bin_id: i32) -> &mut Self { - self.max_bin_id = Some(max_bin_id); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimReward2 { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - position: self.position.expect("position is not set"), - sender: self.sender.expect("sender is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - user_token_account: self - .user_token_account - .expect("user_token_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - memo_program: self.memo_program.expect("memo_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = ClaimReward2InstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - min_bin_id: self.min_bin_id.clone().expect("min_bin_id is not set"), - max_bin_id: self.max_bin_id.clone().expect("max_bin_id is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim_reward2` CPI accounts. -pub struct ClaimReward2CpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_reward2` CPI instruction. -pub struct ClaimReward2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimReward2InstructionArgs, -} - -impl<'a, 'b> ClaimReward2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimReward2CpiAccounts<'a, 'b>, - args: ClaimReward2InstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - position: accounts.position, - sender: accounts.sender, - reward_vault: accounts.reward_vault, - reward_mint: accounts.reward_mint, - user_token_account: accounts.user_token_account, - token_program: accounts.token_program, - memo_program: accounts.memo_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ClaimReward2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.user_token_account.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimReward2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` position -/// 2. `[signer]` sender -/// 3. `[writable]` reward_vault -/// 4. `[]` reward_mint -/// 5. `[writable]` user_token_account -/// 6. `[]` token_program -/// 7. `[]` memo_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct ClaimReward2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimReward2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimReward2CpiBuilderInstruction { - __program: program, - lb_pair: None, - position: None, - sender: None, - reward_vault: None, - reward_mint: None, - user_token_account: None, - token_program: None, - memo_program: None, - event_authority: None, - program: None, - reward_index: None, - min_bin_id: None, - max_bin_id: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn user_token_account( - &mut self, - user_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_account = Some(user_token_account); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn min_bin_id(&mut self, min_bin_id: i32) -> &mut Self { - self.instruction.min_bin_id = Some(min_bin_id); - self - } - - #[inline(always)] - pub fn max_bin_id(&mut self, max_bin_id: i32) -> &mut Self { - self.instruction.max_bin_id = Some(max_bin_id); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ClaimReward2InstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - min_bin_id: self - .instruction - .min_bin_id - .clone() - .expect("min_bin_id is not set"), - max_bin_id: self - .instruction - .max_bin_id - .clone() - .expect("max_bin_id is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = ClaimReward2Cpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - position: self.instruction.position.expect("position is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - user_token_account: self - .instruction - .user_token_account - .expect("user_token_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimReward2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - min_bin_id: Option, - max_bin_id: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/close_claim_protocol_fee_operator.rs b/crates/meteora-parser/src/generated_sdk/instructions/close_claim_protocol_fee_operator.rs deleted file mode 100644 index 02124122..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/close_claim_protocol_fee_operator.rs +++ /dev/null @@ -1,362 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CloseClaimProtocolFeeOperator { - pub claim_fee_operator: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, -} - -impl CloseClaimProtocolFeeOperator { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.claim_fee_operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CloseClaimProtocolFeeOperatorInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseClaimProtocolFeeOperatorInstructionData { - discriminator: [u8; 8], -} - -impl CloseClaimProtocolFeeOperatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [8, 41, 87, 35, 80, 48, 121, 26], - } - } -} - -impl Default for CloseClaimProtocolFeeOperatorInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CloseClaimProtocolFeeOperator`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[writable]` rent_receiver -/// 2. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct CloseClaimProtocolFeeOperatorBuilder { - claim_fee_operator: Option, - rent_receiver: Option, - admin: Option, - __remaining_accounts: Vec, -} - -impl CloseClaimProtocolFeeOperatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn claim_fee_operator(&mut self, claim_fee_operator: solana_pubkey::Pubkey) -> &mut Self { - self.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CloseClaimProtocolFeeOperator { - claim_fee_operator: self - .claim_fee_operator - .expect("claim_fee_operator is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - admin: self.admin.expect("admin is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_claim_protocol_fee_operator` CPI accounts. -pub struct CloseClaimProtocolFeeOperatorCpiAccounts<'a, 'b> { - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_claim_protocol_fee_operator` CPI instruction. -pub struct CloseClaimProtocolFeeOperatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CloseClaimProtocolFeeOperatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CloseClaimProtocolFeeOperatorCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - claim_fee_operator: accounts.claim_fee_operator, - rent_receiver: accounts.rent_receiver, - admin: accounts.admin, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.claim_fee_operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CloseClaimProtocolFeeOperatorInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.claim_fee_operator.clone()); - account_infos.push(self.rent_receiver.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CloseClaimProtocolFeeOperator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[writable]` rent_receiver -/// 2. `[signer]` admin -#[derive(Clone, Debug)] -pub struct CloseClaimProtocolFeeOperatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CloseClaimProtocolFeeOperatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CloseClaimProtocolFeeOperatorCpiBuilderInstruction { - __program: program, - claim_fee_operator: None, - rent_receiver: None, - admin: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn claim_fee_operator( - &mut self, - claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CloseClaimProtocolFeeOperatorCpi { - __program: self.instruction.__program, - - claim_fee_operator: self - .instruction - .claim_fee_operator - .expect("claim_fee_operator is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CloseClaimProtocolFeeOperatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - claim_fee_operator: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/close_position.rs b/crates/meteora-parser/src/generated_sdk/instructions/close_position.rs deleted file mode 100644 index 65afa46a..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/close_position.rs +++ /dev/null @@ -1,547 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClosePosition { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClosePosition { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClosePositionInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClosePositionInstructionData { - discriminator: [u8; 8], -} - -impl ClosePositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [123, 134, 81, 0, 49, 68, 98, 98], - } - } -} - -impl Default for ClosePositionInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClosePosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable]` bin_array_lower -/// 3. `[writable]` bin_array_upper -/// 4. `[signer]` sender -/// 5. `[writable]` rent_receiver -/// 6. `[]` event_authority -/// 7. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClosePositionBuilder { - position: Option, - lb_pair: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - rent_receiver: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl ClosePositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClosePosition { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_position` CPI accounts. -pub struct ClosePositionCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_position` CPI instruction. -pub struct ClosePositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClosePositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClosePositionCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - rent_receiver: accounts.rent_receiver, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClosePositionInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.rent_receiver.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClosePosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable]` bin_array_lower -/// 3. `[writable]` bin_array_upper -/// 4. `[signer]` sender -/// 5. `[writable]` rent_receiver -/// 6. `[]` event_authority -/// 7. `[]` program -#[derive(Clone, Debug)] -pub struct ClosePositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClosePositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClosePositionCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - rent_receiver: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClosePositionCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClosePositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/close_position2.rs b/crates/meteora-parser/src/generated_sdk/instructions/close_position2.rs deleted file mode 100644 index baafbb63..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/close_position2.rs +++ /dev/null @@ -1,430 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClosePosition2 { - pub position: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClosePosition2 { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClosePosition2InstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClosePosition2InstructionData { - discriminator: [u8; 8], -} - -impl ClosePosition2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [174, 90, 35, 115, 186, 40, 147, 226], - } - } -} - -impl Default for ClosePosition2InstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClosePosition2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[signer]` sender -/// 2. `[writable]` rent_receiver -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClosePosition2Builder { - position: Option, - sender: Option, - rent_receiver: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl ClosePosition2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClosePosition2 { - position: self.position.expect("position is not set"), - sender: self.sender.expect("sender is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_position2` CPI accounts. -pub struct ClosePosition2CpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_position2` CPI instruction. -pub struct ClosePosition2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClosePosition2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClosePosition2CpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position: accounts.position, - sender: accounts.sender, - rent_receiver: accounts.rent_receiver, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClosePosition2InstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.rent_receiver.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClosePosition2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[signer]` sender -/// 2. `[writable]` rent_receiver -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct ClosePosition2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClosePosition2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClosePosition2CpiBuilderInstruction { - __program: program, - position: None, - sender: None, - rent_receiver: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClosePosition2Cpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClosePosition2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/close_position_if_empty.rs b/crates/meteora-parser/src/generated_sdk/instructions/close_position_if_empty.rs deleted file mode 100644 index 0cafbd80..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/close_position_if_empty.rs +++ /dev/null @@ -1,430 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClosePositionIfEmpty { - pub position: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ClosePositionIfEmpty { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClosePositionIfEmptyInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClosePositionIfEmptyInstructionData { - discriminator: [u8; 8], -} - -impl ClosePositionIfEmptyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [59, 124, 212, 118, 91, 152, 110, 157], - } - } -} - -impl Default for ClosePositionIfEmptyInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClosePositionIfEmpty`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[signer]` sender -/// 2. `[writable]` rent_receiver -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ClosePositionIfEmptyBuilder { - position: Option, - sender: Option, - rent_receiver: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl ClosePositionIfEmptyBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClosePositionIfEmpty { - position: self.position.expect("position is not set"), - sender: self.sender.expect("sender is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_position_if_empty` CPI accounts. -pub struct ClosePositionIfEmptyCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_position_if_empty` CPI instruction. -pub struct ClosePositionIfEmptyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClosePositionIfEmptyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClosePositionIfEmptyCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position: accounts.position, - sender: accounts.sender, - rent_receiver: accounts.rent_receiver, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClosePositionIfEmptyInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.rent_receiver.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClosePositionIfEmpty` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[signer]` sender -/// 2. `[writable]` rent_receiver -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct ClosePositionIfEmptyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClosePositionIfEmptyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClosePositionIfEmptyCpiBuilderInstruction { - __program: program, - position: None, - sender: None, - rent_receiver: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClosePositionIfEmptyCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClosePositionIfEmptyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/close_preset_parameter.rs b/crates/meteora-parser/src/generated_sdk/instructions/close_preset_parameter.rs deleted file mode 100644 index 298bd318..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/close_preset_parameter.rs +++ /dev/null @@ -1,355 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClosePresetParameter { - pub preset_parameter: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, -} - -impl ClosePresetParameter { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.preset_parameter, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClosePresetParameterInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClosePresetParameterInstructionData { - discriminator: [u8; 8], -} - -impl ClosePresetParameterInstructionData { - pub fn new() -> Self { - Self { - discriminator: [4, 148, 145, 100, 134, 26, 181, 61], - } - } -} - -impl Default for ClosePresetParameterInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClosePresetParameter`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` preset_parameter -/// 1. `[writable, signer]` admin -/// 2. `[writable]` rent_receiver -#[derive(Clone, Debug, Default)] -pub struct ClosePresetParameterBuilder { - preset_parameter: Option, - admin: Option, - rent_receiver: Option, - __remaining_accounts: Vec, -} - -impl ClosePresetParameterBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn preset_parameter(&mut self, preset_parameter: solana_pubkey::Pubkey) -> &mut Self { - self.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClosePresetParameter { - preset_parameter: self.preset_parameter.expect("preset_parameter is not set"), - admin: self.admin.expect("admin is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_preset_parameter` CPI accounts. -pub struct ClosePresetParameterCpiAccounts<'a, 'b> { - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_preset_parameter` CPI instruction. -pub struct ClosePresetParameterCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClosePresetParameterCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClosePresetParameterCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - preset_parameter: accounts.preset_parameter, - admin: accounts.admin, - rent_receiver: accounts.rent_receiver, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.preset_parameter.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClosePresetParameterInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.preset_parameter.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.rent_receiver.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClosePresetParameter` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` preset_parameter -/// 1. `[writable, signer]` admin -/// 2. `[writable]` rent_receiver -#[derive(Clone, Debug)] -pub struct ClosePresetParameterCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClosePresetParameterCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClosePresetParameterCpiBuilderInstruction { - __program: program, - preset_parameter: None, - admin: None, - rent_receiver: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn preset_parameter( - &mut self, - preset_parameter: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClosePresetParameterCpi { - __program: self.instruction.__program, - - preset_parameter: self - .instruction - .preset_parameter - .expect("preset_parameter is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClosePresetParameterCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - preset_parameter: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/close_preset_parameter2.rs b/crates/meteora-parser/src/generated_sdk/instructions/close_preset_parameter2.rs deleted file mode 100644 index e4cfc77f..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/close_preset_parameter2.rs +++ /dev/null @@ -1,355 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClosePresetParameter2 { - pub preset_parameter: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, -} - -impl ClosePresetParameter2 { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.preset_parameter, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClosePresetParameter2InstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClosePresetParameter2InstructionData { - discriminator: [u8; 8], -} - -impl ClosePresetParameter2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [39, 25, 95, 107, 116, 17, 115, 28], - } - } -} - -impl Default for ClosePresetParameter2InstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClosePresetParameter2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` preset_parameter -/// 1. `[writable, signer]` admin -/// 2. `[writable]` rent_receiver -#[derive(Clone, Debug, Default)] -pub struct ClosePresetParameter2Builder { - preset_parameter: Option, - admin: Option, - rent_receiver: Option, - __remaining_accounts: Vec, -} - -impl ClosePresetParameter2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn preset_parameter(&mut self, preset_parameter: solana_pubkey::Pubkey) -> &mut Self { - self.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClosePresetParameter2 { - preset_parameter: self.preset_parameter.expect("preset_parameter is not set"), - admin: self.admin.expect("admin is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_preset_parameter2` CPI accounts. -pub struct ClosePresetParameter2CpiAccounts<'a, 'b> { - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_preset_parameter2` CPI instruction. -pub struct ClosePresetParameter2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClosePresetParameter2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClosePresetParameter2CpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - preset_parameter: accounts.preset_parameter, - admin: accounts.admin, - rent_receiver: accounts.rent_receiver, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.preset_parameter.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClosePresetParameter2InstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.preset_parameter.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.rent_receiver.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClosePresetParameter2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` preset_parameter -/// 1. `[writable, signer]` admin -/// 2. `[writable]` rent_receiver -#[derive(Clone, Debug)] -pub struct ClosePresetParameter2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClosePresetParameter2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClosePresetParameter2CpiBuilderInstruction { - __program: program, - preset_parameter: None, - admin: None, - rent_receiver: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn preset_parameter( - &mut self, - preset_parameter: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClosePresetParameter2Cpi { - __program: self.instruction.__program, - - preset_parameter: self - .instruction - .preset_parameter - .expect("preset_parameter is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClosePresetParameter2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - preset_parameter: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/create_claim_protocol_fee_operator.rs b/crates/meteora-parser/src/generated_sdk/instructions/create_claim_protocol_fee_operator.rs deleted file mode 100644 index a08fdfce..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/create_claim_protocol_fee_operator.rs +++ /dev/null @@ -1,396 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateClaimProtocolFeeOperator { - pub claim_fee_operator: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateClaimProtocolFeeOperator { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.claim_fee_operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateClaimProtocolFeeOperatorInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateClaimProtocolFeeOperatorInstructionData { - discriminator: [u8; 8], -} - -impl CreateClaimProtocolFeeOperatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [51, 19, 150, 252, 105, 157, 48, 91], - } - } -} - -impl Default for CreateClaimProtocolFeeOperatorInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateClaimProtocolFeeOperator`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[]` operator -/// 2. `[writable, signer]` admin -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateClaimProtocolFeeOperatorBuilder { - claim_fee_operator: Option, - operator: Option, - admin: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl CreateClaimProtocolFeeOperatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn claim_fee_operator(&mut self, claim_fee_operator: solana_pubkey::Pubkey) -> &mut Self { - self.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateClaimProtocolFeeOperator { - claim_fee_operator: self - .claim_fee_operator - .expect("claim_fee_operator is not set"), - operator: self.operator.expect("operator is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_claim_protocol_fee_operator` CPI accounts. -pub struct CreateClaimProtocolFeeOperatorCpiAccounts<'a, 'b> { - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_claim_protocol_fee_operator` CPI instruction. -pub struct CreateClaimProtocolFeeOperatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateClaimProtocolFeeOperatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateClaimProtocolFeeOperatorCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - claim_fee_operator: accounts.claim_fee_operator, - operator: accounts.operator, - admin: accounts.admin, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.claim_fee_operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateClaimProtocolFeeOperatorInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.claim_fee_operator.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateClaimProtocolFeeOperator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` claim_fee_operator -/// 1. `[]` operator -/// 2. `[writable, signer]` admin -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateClaimProtocolFeeOperatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateClaimProtocolFeeOperatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateClaimProtocolFeeOperatorCpiBuilderInstruction { - __program: program, - claim_fee_operator: None, - operator: None, - admin: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn claim_fee_operator( - &mut self, - claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.claim_fee_operator = Some(claim_fee_operator); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateClaimProtocolFeeOperatorCpi { - __program: self.instruction.__program, - - claim_fee_operator: self - .instruction - .claim_fee_operator - .expect("claim_fee_operator is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateClaimProtocolFeeOperatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - claim_fee_operator: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/fund_reward.rs b/crates/meteora-parser/src/generated_sdk/instructions/fund_reward.rs deleted file mode 100644 index 0088d867..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/fund_reward.rs +++ /dev/null @@ -1,714 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct FundReward { - pub lb_pair: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub funder_token_account: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub bin_array: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl FundReward { - pub fn instruction(&self, args: FundRewardInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: FundRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.funder_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.funder, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.bin_array, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&FundRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FundRewardInstructionData { - discriminator: [u8; 8], -} - -impl FundRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [188, 50, 249, 165, 93, 151, 38, 63], - } - } -} - -impl Default for FundRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FundRewardInstructionArgs { - pub reward_index: u64, - pub amount: u64, - pub carry_forward: bool, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `FundReward`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` reward_vault -/// 2. `[]` reward_mint -/// 3. `[writable]` funder_token_account -/// 4. `[signer]` funder -/// 5. `[writable]` bin_array -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug, Default)] -pub struct FundRewardBuilder { - lb_pair: Option, - reward_vault: Option, - reward_mint: Option, - funder_token_account: Option, - funder: Option, - bin_array: Option, - token_program: Option, - event_authority: Option, - program: Option, - reward_index: Option, - amount: Option, - carry_forward: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl FundRewardBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn bin_array(&mut self, bin_array: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array = Some(bin_array); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn carry_forward(&mut self, carry_forward: bool) -> &mut Self { - self.carry_forward = Some(carry_forward); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = FundReward { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - funder_token_account: self - .funder_token_account - .expect("funder_token_account is not set"), - funder: self.funder.expect("funder is not set"), - bin_array: self.bin_array.expect("bin_array is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = FundRewardInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - amount: self.amount.clone().expect("amount is not set"), - carry_forward: self - .carry_forward - .clone() - .expect("carry_forward is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `fund_reward` CPI accounts. -pub struct FundRewardCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `fund_reward` CPI instruction. -pub struct FundRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: FundRewardInstructionArgs, -} - -impl<'a, 'b> FundRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: FundRewardCpiAccounts<'a, 'b>, - args: FundRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - reward_vault: accounts.reward_vault, - reward_mint: accounts.reward_mint, - funder_token_account: accounts.funder_token_account, - funder: accounts.funder, - bin_array: accounts.bin_array, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.funder_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.funder.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&FundRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.funder_token_account.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.bin_array.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `FundReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` reward_vault -/// 2. `[]` reward_mint -/// 3. `[writable]` funder_token_account -/// 4. `[signer]` funder -/// 5. `[writable]` bin_array -/// 6. `[]` token_program -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug)] -pub struct FundRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> FundRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(FundRewardCpiBuilderInstruction { - __program: program, - lb_pair: None, - reward_vault: None, - reward_mint: None, - funder_token_account: None, - funder: None, - bin_array: None, - token_program: None, - event_authority: None, - program: None, - reward_index: None, - amount: None, - carry_forward: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn bin_array(&mut self, bin_array: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.bin_array = Some(bin_array); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn carry_forward(&mut self, carry_forward: bool) -> &mut Self { - self.instruction.carry_forward = Some(carry_forward); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = FundRewardInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - amount: self.instruction.amount.clone().expect("amount is not set"), - carry_forward: self - .instruction - .carry_forward - .clone() - .expect("carry_forward is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = FundRewardCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - funder_token_account: self - .instruction - .funder_token_account - .expect("funder_token_account is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - bin_array: self.instruction.bin_array.expect("bin_array is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct FundRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - funder_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - amount: Option, - carry_forward: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/go_to_a_bin.rs b/crates/meteora-parser/src/generated_sdk/instructions/go_to_a_bin.rs deleted file mode 100644 index 1d76dcc0..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/go_to_a_bin.rs +++ /dev/null @@ -1,563 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct GoToABin { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub from_bin_array: Option, - - pub to_bin_array: Option, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl GoToABin { - pub fn instruction(&self, args: GoToABinInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: GoToABinInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - if let Some(from_bin_array) = self.from_bin_array { - accounts.push(solana_instruction::AccountMeta::new_readonly( - from_bin_array, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - if let Some(to_bin_array) = self.to_bin_array { - accounts.push(solana_instruction::AccountMeta::new_readonly( - to_bin_array, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&GoToABinInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct GoToABinInstructionData { - discriminator: [u8; 8], -} - -impl GoToABinInstructionData { - pub fn new() -> Self { - Self { - discriminator: [146, 72, 174, 224, 40, 253, 84, 174], - } - } -} - -impl Default for GoToABinInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct GoToABinInstructionArgs { - pub bin_id: i32, -} - -/// Instruction builder for `GoToABin`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[optional]` from_bin_array -/// 3. `[optional]` to_bin_array -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug, Default)] -pub struct GoToABinBuilder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - from_bin_array: Option, - to_bin_array: Option, - event_authority: Option, - program: Option, - bin_id: Option, - __remaining_accounts: Vec, -} - -impl GoToABinBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn from_bin_array(&mut self, from_bin_array: Option) -> &mut Self { - self.from_bin_array = from_bin_array; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn to_bin_array(&mut self, to_bin_array: Option) -> &mut Self { - self.to_bin_array = to_bin_array; - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn bin_id(&mut self, bin_id: i32) -> &mut Self { - self.bin_id = Some(bin_id); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = GoToABin { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - from_bin_array: self.from_bin_array, - to_bin_array: self.to_bin_array, - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = GoToABinInstructionArgs { - bin_id: self.bin_id.clone().expect("bin_id is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `go_to_a_bin` CPI accounts. -pub struct GoToABinCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub from_bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub to_bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `go_to_a_bin` CPI instruction. -pub struct GoToABinCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub from_bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub to_bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: GoToABinInstructionArgs, -} - -impl<'a, 'b> GoToABinCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: GoToABinCpiAccounts<'a, 'b>, - args: GoToABinInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - from_bin_array: accounts.from_bin_array, - to_bin_array: accounts.to_bin_array, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - if let Some(from_bin_array) = self.from_bin_array { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *from_bin_array.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - if let Some(to_bin_array) = self.to_bin_array { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *to_bin_array.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&GoToABinInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - if let Some(from_bin_array) = self.from_bin_array { - account_infos.push(from_bin_array.clone()); - } - if let Some(to_bin_array) = self.to_bin_array { - account_infos.push(to_bin_array.clone()); - } - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `GoToABin` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[optional]` from_bin_array -/// 3. `[optional]` to_bin_array -/// 4. `[]` event_authority -/// 5. `[]` program -#[derive(Clone, Debug)] -pub struct GoToABinCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> GoToABinCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(GoToABinCpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - from_bin_array: None, - to_bin_array: None, - event_authority: None, - program: None, - bin_id: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn from_bin_array( - &mut self, - from_bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.from_bin_array = from_bin_array; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn to_bin_array( - &mut self, - to_bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.to_bin_array = to_bin_array; - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn bin_id(&mut self, bin_id: i32) -> &mut Self { - self.instruction.bin_id = Some(bin_id); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = GoToABinInstructionArgs { - bin_id: self.instruction.bin_id.clone().expect("bin_id is not set"), - }; - let instruction = GoToABinCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - from_bin_array: self.instruction.from_bin_array, - - to_bin_array: self.instruction.to_bin_array, - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct GoToABinCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - from_bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - to_bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_id: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/increase_oracle_length.rs b/crates/meteora-parser/src/generated_sdk/instructions/increase_oracle_length.rs deleted file mode 100644 index 26bcce85..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/increase_oracle_length.rs +++ /dev/null @@ -1,474 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct IncreaseOracleLength { - pub oracle: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl IncreaseOracleLength { - pub fn instruction( - &self, - args: IncreaseOracleLengthInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: IncreaseOracleLengthInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&IncreaseOracleLengthInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IncreaseOracleLengthInstructionData { - discriminator: [u8; 8], -} - -impl IncreaseOracleLengthInstructionData { - pub fn new() -> Self { - Self { - discriminator: [190, 61, 125, 87, 103, 79, 158, 173], - } - } -} - -impl Default for IncreaseOracleLengthInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IncreaseOracleLengthInstructionArgs { - pub length_to_add: u64, -} - -/// Instruction builder for `IncreaseOracleLength`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` oracle -/// 1. `[writable, signer]` funder -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct IncreaseOracleLengthBuilder { - oracle: Option, - funder: Option, - system_program: Option, - event_authority: Option, - program: Option, - length_to_add: Option, - __remaining_accounts: Vec, -} - -impl IncreaseOracleLengthBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn length_to_add(&mut self, length_to_add: u64) -> &mut Self { - self.length_to_add = Some(length_to_add); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = IncreaseOracleLength { - oracle: self.oracle.expect("oracle is not set"), - funder: self.funder.expect("funder is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = IncreaseOracleLengthInstructionArgs { - length_to_add: self - .length_to_add - .clone() - .expect("length_to_add is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `increase_oracle_length` CPI accounts. -pub struct IncreaseOracleLengthCpiAccounts<'a, 'b> { - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `increase_oracle_length` CPI instruction. -pub struct IncreaseOracleLengthCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: IncreaseOracleLengthInstructionArgs, -} - -impl<'a, 'b> IncreaseOracleLengthCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: IncreaseOracleLengthCpiAccounts<'a, 'b>, - args: IncreaseOracleLengthInstructionArgs, - ) -> Self { - Self { - __program: program, - oracle: accounts.oracle, - funder: accounts.funder, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&IncreaseOracleLengthInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.oracle.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `IncreaseOracleLength` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` oracle -/// 1. `[writable, signer]` funder -/// 2. `[]` system_program -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct IncreaseOracleLengthCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> IncreaseOracleLengthCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(IncreaseOracleLengthCpiBuilderInstruction { - __program: program, - oracle: None, - funder: None, - system_program: None, - event_authority: None, - program: None, - length_to_add: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn length_to_add(&mut self, length_to_add: u64) -> &mut Self { - self.instruction.length_to_add = Some(length_to_add); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = IncreaseOracleLengthInstructionArgs { - length_to_add: self - .instruction - .length_to_add - .clone() - .expect("length_to_add is not set"), - }; - let instruction = IncreaseOracleLengthCpi { - __program: self.instruction.__program, - - oracle: self.instruction.oracle.expect("oracle is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct IncreaseOracleLengthCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - length_to_add: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_bin_array.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_bin_array.rs deleted file mode 100644 index 2883bc95..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_bin_array.rs +++ /dev/null @@ -1,425 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeBinArray { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeBinArray { - pub fn instruction( - &self, - args: InitializeBinArrayInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeBinArrayInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lb_pair, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.bin_array, false)); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeBinArrayInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeBinArrayInstructionData { - discriminator: [u8; 8], -} - -impl InitializeBinArrayInstructionData { - pub fn new() -> Self { - Self { - discriminator: [35, 86, 19, 185, 78, 212, 75, 211], - } - } -} - -impl Default for InitializeBinArrayInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeBinArrayInstructionArgs { - pub index: i64, -} - -/// Instruction builder for `InitializeBinArray`. -/// -/// ### Accounts: -/// -/// 0. `[]` lb_pair -/// 1. `[writable]` bin_array -/// 2. `[writable, signer]` funder -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeBinArrayBuilder { - lb_pair: Option, - bin_array: Option, - funder: Option, - system_program: Option, - index: Option, - __remaining_accounts: Vec, -} - -impl InitializeBinArrayBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn bin_array(&mut self, bin_array: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array = Some(bin_array); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: i64) -> &mut Self { - self.index = Some(index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeBinArray { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array: self.bin_array.expect("bin_array is not set"), - funder: self.funder.expect("funder is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializeBinArrayInstructionArgs { - index: self.index.clone().expect("index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_bin_array` CPI accounts. -pub struct InitializeBinArrayCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_bin_array` CPI instruction. -pub struct InitializeBinArrayCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeBinArrayInstructionArgs, -} - -impl<'a, 'b> InitializeBinArrayCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeBinArrayCpiAccounts<'a, 'b>, - args: InitializeBinArrayInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array: accounts.bin_array, - funder: accounts.funder, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeBinArrayInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.bin_array.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeBinArray` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` lb_pair -/// 1. `[writable]` bin_array -/// 2. `[writable, signer]` funder -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeBinArrayCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeBinArrayCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeBinArrayCpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array: None, - funder: None, - system_program: None, - index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn bin_array(&mut self, bin_array: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.bin_array = Some(bin_array); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: i64) -> &mut Self { - self.instruction.index = Some(index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeBinArrayInstructionArgs { - index: self.instruction.index.clone().expect("index is not set"), - }; - let instruction = InitializeBinArrayCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array: self.instruction.bin_array.expect("bin_array is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeBinArrayCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_bin_array_bitmap_extension.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_bin_array_bitmap_extension.rs deleted file mode 100644 index bceb7f4b..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_bin_array_bitmap_extension.rs +++ /dev/null @@ -1,439 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeBinArrayBitmapExtension { - pub lb_pair: solana_pubkey::Pubkey, - /// Initialize an account to store if a bin array is initialized. - pub bin_array_bitmap_extension: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl InitializeBinArrayBitmapExtension { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lb_pair, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_bitmap_extension, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeBinArrayBitmapExtensionInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeBinArrayBitmapExtensionInstructionData { - discriminator: [u8; 8], -} - -impl InitializeBinArrayBitmapExtensionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [47, 157, 226, 180, 12, 240, 33, 71], - } - } -} - -impl Default for InitializeBinArrayBitmapExtensionInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `InitializeBinArrayBitmapExtension`. -/// -/// ### Accounts: -/// -/// 0. `[]` lb_pair -/// 1. `[writable]` bin_array_bitmap_extension -/// 2. `[writable, signer]` funder -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 4. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeBinArrayBitmapExtensionBuilder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - funder: Option, - system_program: Option, - rent: Option, - __remaining_accounts: Vec, -} - -impl InitializeBinArrayBitmapExtensionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// Initialize an account to store if a bin array is initialized. - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: solana_pubkey::Pubkey, - ) -> &mut Self { - self.bin_array_bitmap_extension = Some(bin_array_bitmap_extension); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeBinArrayBitmapExtension { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self - .bin_array_bitmap_extension - .expect("bin_array_bitmap_extension is not set"), - funder: self.funder.expect("funder is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize_bin_array_bitmap_extension` CPI accounts. -pub struct InitializeBinArrayBitmapExtensionCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store if a bin array is initialized. - pub bin_array_bitmap_extension: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_bin_array_bitmap_extension` CPI instruction. -pub struct InitializeBinArrayBitmapExtensionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - /// Initialize an account to store if a bin array is initialized. - pub bin_array_bitmap_extension: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializeBinArrayBitmapExtensionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeBinArrayBitmapExtensionCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - funder: accounts.funder, - system_program: accounts.system_program, - rent: accounts.rent, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_bitmap_extension.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializeBinArrayBitmapExtensionInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.bin_array_bitmap_extension.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeBinArrayBitmapExtension` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` lb_pair -/// 1. `[writable]` bin_array_bitmap_extension -/// 2. `[writable, signer]` funder -/// 3. `[]` system_program -/// 4. `[]` rent -#[derive(Clone, Debug)] -pub struct InitializeBinArrayBitmapExtensionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeBinArrayBitmapExtensionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeBinArrayBitmapExtensionCpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - funder: None, - system_program: None, - rent: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// Initialize an account to store if a bin array is initialized. - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = Some(bin_array_bitmap_extension); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializeBinArrayBitmapExtensionCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self - .instruction - .bin_array_bitmap_extension - .expect("bin_array_bitmap_extension is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeBinArrayBitmapExtensionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_customizable_permissionless_lb_pair.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_customizable_permissionless_lb_pair.rs deleted file mode 100644 index f94a6a47..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_customizable_permissionless_lb_pair.rs +++ /dev/null @@ -1,847 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::CustomizableParams; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeCustomizablePermissionlessLbPair { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub token_mint_x: solana_pubkey::Pubkey, - - pub token_mint_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub user_token_x: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeCustomizablePermissionlessLbPair { - pub fn instruction( - &self, - args: InitializeCustomizablePermissionlessLbPairInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeCustomizablePermissionlessLbPairInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = - borsh::to_vec(&InitializeCustomizablePermissionlessLbPairInstructionData::new()) - .unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeCustomizablePermissionlessLbPairInstructionData { - discriminator: [u8; 8], -} - -impl InitializeCustomizablePermissionlessLbPairInstructionData { - pub fn new() -> Self { - Self { - discriminator: [46, 39, 41, 135, 111, 183, 200, 64], - } - } -} - -impl Default for InitializeCustomizablePermissionlessLbPairInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeCustomizablePermissionlessLbPairInstructionArgs { - pub params: CustomizableParams, -} - -/// Instruction builder for `InitializeCustomizablePermissionlessLbPair`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable, optional]` bin_array_bitmap_extension -/// 2. `[]` token_mint_x -/// 3. `[]` token_mint_y -/// 4. `[writable]` reserve_x -/// 5. `[writable]` reserve_y -/// 6. `[writable]` oracle -/// 7. `[]` user_token_x -/// 8. `[writable, signer]` funder -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 10. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 11. `[]` user_token_y -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeCustomizablePermissionlessLbPairBuilder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - token_mint_x: Option, - token_mint_y: Option, - reserve_x: Option, - reserve_y: Option, - oracle: Option, - user_token_x: Option, - funder: Option, - token_program: Option, - system_program: Option, - user_token_y: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl InitializeCustomizablePermissionlessLbPairBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn token_mint_x(&mut self, token_mint_x: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_x = Some(token_mint_x); - self - } - - #[inline(always)] - pub fn token_mint_y(&mut self, token_mint_y: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_y = Some(token_mint_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: CustomizableParams) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeCustomizablePermissionlessLbPair { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - token_mint_x: self.token_mint_x.expect("token_mint_x is not set"), - token_mint_y: self.token_mint_y.expect("token_mint_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - oracle: self.oracle.expect("oracle is not set"), - user_token_x: self.user_token_x.expect("user_token_x is not set"), - funder: self.funder.expect("funder is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeCustomizablePermissionlessLbPairInstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_customizable_permissionless_lb_pair` CPI accounts. -pub struct InitializeCustomizablePermissionlessLbPairCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_mint_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_customizable_permissionless_lb_pair` CPI instruction. -pub struct InitializeCustomizablePermissionlessLbPairCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_mint_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeCustomizablePermissionlessLbPairInstructionArgs, -} - -impl<'a, 'b> InitializeCustomizablePermissionlessLbPairCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCustomizablePermissionlessLbPairCpiAccounts<'a, 'b>, - args: InitializeCustomizablePermissionlessLbPairInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - token_mint_x: accounts.token_mint_x, - token_mint_y: accounts.token_mint_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - oracle: accounts.oracle, - user_token_x: accounts.user_token_x, - funder: accounts.funder, - token_program: accounts.token_program, - system_program: accounts.system_program, - user_token_y: accounts.user_token_y, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = - borsh::to_vec(&InitializeCustomizablePermissionlessLbPairInstructionData::new()) - .unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.token_mint_x.clone()); - account_infos.push(self.token_mint_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.oracle.clone()); - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeCustomizablePermissionlessLbPair` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable, optional]` bin_array_bitmap_extension -/// 2. `[]` token_mint_x -/// 3. `[]` token_mint_y -/// 4. `[writable]` reserve_x -/// 5. `[writable]` reserve_y -/// 6. `[writable]` oracle -/// 7. `[]` user_token_x -/// 8. `[writable, signer]` funder -/// 9. `[]` token_program -/// 10. `[]` system_program -/// 11. `[]` user_token_y -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeCustomizablePermissionlessLbPairCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeCustomizablePermissionlessLbPairCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new( - InitializeCustomizablePermissionlessLbPairCpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - token_mint_x: None, - token_mint_y: None, - reserve_x: None, - reserve_y: None, - oracle: None, - user_token_x: None, - funder: None, - token_program: None, - system_program: None, - user_token_y: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }, - ); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn token_mint_x( - &mut self, - token_mint_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_x = Some(token_mint_x); - self - } - - #[inline(always)] - pub fn token_mint_y( - &mut self, - token_mint_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_y = Some(token_mint_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: CustomizableParams) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeCustomizablePermissionlessLbPairInstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = InitializeCustomizablePermissionlessLbPairCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - token_mint_x: self - .instruction - .token_mint_x - .expect("token_mint_x is not set"), - - token_mint_y: self - .instruction - .token_mint_y - .expect("token_mint_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCustomizablePermissionlessLbPairCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_customizable_permissionless_lb_pair2.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_customizable_permissionless_lb_pair2.rs deleted file mode 100644 index e0703be1..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_customizable_permissionless_lb_pair2.rs +++ /dev/null @@ -1,1000 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::CustomizableParams; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeCustomizablePermissionlessLbPair2 { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub token_mint_x: solana_pubkey::Pubkey, - - pub token_mint_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub user_token_x: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub token_badge_x: Option, - - pub token_badge_y: Option, - - pub token_program_x: solana_pubkey::Pubkey, - - pub token_program_y: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeCustomizablePermissionlessLbPair2 { - pub fn instruction( - &self, - args: InitializeCustomizablePermissionlessLbPair2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeCustomizablePermissionlessLbPair2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - if let Some(token_badge_x) = self.token_badge_x { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token_badge_x, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - if let Some(token_badge_y) = self.token_badge_y { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token_badge_y, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = - borsh::to_vec(&InitializeCustomizablePermissionlessLbPair2InstructionData::new()) - .unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeCustomizablePermissionlessLbPair2InstructionData { - discriminator: [u8; 8], -} - -impl InitializeCustomizablePermissionlessLbPair2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [243, 73, 129, 126, 51, 19, 241, 107], - } - } -} - -impl Default for InitializeCustomizablePermissionlessLbPair2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeCustomizablePermissionlessLbPair2InstructionArgs { - pub params: CustomizableParams, -} - -/// Instruction builder for `InitializeCustomizablePermissionlessLbPair2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable, optional]` bin_array_bitmap_extension -/// 2. `[]` token_mint_x -/// 3. `[]` token_mint_y -/// 4. `[writable]` reserve_x -/// 5. `[writable]` reserve_y -/// 6. `[writable]` oracle -/// 7. `[]` user_token_x -/// 8. `[writable, signer]` funder -/// 9. `[optional]` token_badge_x -/// 10. `[optional]` token_badge_y -/// 11. `[]` token_program_x -/// 12. `[]` token_program_y -/// 13. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 14. `[]` user_token_y -/// 15. `[]` event_authority -/// 16. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeCustomizablePermissionlessLbPair2Builder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - token_mint_x: Option, - token_mint_y: Option, - reserve_x: Option, - reserve_y: Option, - oracle: Option, - user_token_x: Option, - funder: Option, - token_badge_x: Option, - token_badge_y: Option, - token_program_x: Option, - token_program_y: Option, - system_program: Option, - user_token_y: Option, - event_authority: Option, - program: Option, - params: Option, - __remaining_accounts: Vec, -} - -impl InitializeCustomizablePermissionlessLbPair2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn token_mint_x(&mut self, token_mint_x: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_x = Some(token_mint_x); - self - } - - #[inline(always)] - pub fn token_mint_y(&mut self, token_mint_y: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_y = Some(token_mint_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_x(&mut self, token_badge_x: Option) -> &mut Self { - self.token_badge_x = token_badge_x; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_y(&mut self, token_badge_y: Option) -> &mut Self { - self.token_badge_y = token_badge_y; - self - } - - #[inline(always)] - pub fn token_program_x(&mut self, token_program_x: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_x = Some(token_program_x); - self - } - - #[inline(always)] - pub fn token_program_y(&mut self, token_program_y: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_y = Some(token_program_y); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: CustomizableParams) -> &mut Self { - self.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeCustomizablePermissionlessLbPair2 { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - token_mint_x: self.token_mint_x.expect("token_mint_x is not set"), - token_mint_y: self.token_mint_y.expect("token_mint_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - oracle: self.oracle.expect("oracle is not set"), - user_token_x: self.user_token_x.expect("user_token_x is not set"), - funder: self.funder.expect("funder is not set"), - token_badge_x: self.token_badge_x, - token_badge_y: self.token_badge_y, - token_program_x: self.token_program_x.expect("token_program_x is not set"), - token_program_y: self.token_program_y.expect("token_program_y is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeCustomizablePermissionlessLbPair2InstructionArgs { - params: self.params.clone().expect("params is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_customizable_permissionless_lb_pair2` CPI accounts. -pub struct InitializeCustomizablePermissionlessLbPair2CpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_mint_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_program_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_y: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_customizable_permissionless_lb_pair2` CPI instruction. -pub struct InitializeCustomizablePermissionlessLbPair2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_mint_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_program_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_y: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeCustomizablePermissionlessLbPair2InstructionArgs, -} - -impl<'a, 'b> InitializeCustomizablePermissionlessLbPair2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCustomizablePermissionlessLbPair2CpiAccounts<'a, 'b>, - args: InitializeCustomizablePermissionlessLbPair2InstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - token_mint_x: accounts.token_mint_x, - token_mint_y: accounts.token_mint_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - oracle: accounts.oracle, - user_token_x: accounts.user_token_x, - funder: accounts.funder, - token_badge_x: accounts.token_badge_x, - token_badge_y: accounts.token_badge_y, - token_program_x: accounts.token_program_x, - token_program_y: accounts.token_program_y, - system_program: accounts.system_program, - user_token_y: accounts.user_token_y, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - if let Some(token_badge_x) = self.token_badge_x { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token_badge_x.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - if let Some(token_badge_y) = self.token_badge_y { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token_badge_y.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = - borsh::to_vec(&InitializeCustomizablePermissionlessLbPair2InstructionData::new()) - .unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(18 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.token_mint_x.clone()); - account_infos.push(self.token_mint_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.oracle.clone()); - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.funder.clone()); - if let Some(token_badge_x) = self.token_badge_x { - account_infos.push(token_badge_x.clone()); - } - if let Some(token_badge_y) = self.token_badge_y { - account_infos.push(token_badge_y.clone()); - } - account_infos.push(self.token_program_x.clone()); - account_infos.push(self.token_program_y.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeCustomizablePermissionlessLbPair2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable, optional]` bin_array_bitmap_extension -/// 2. `[]` token_mint_x -/// 3. `[]` token_mint_y -/// 4. `[writable]` reserve_x -/// 5. `[writable]` reserve_y -/// 6. `[writable]` oracle -/// 7. `[]` user_token_x -/// 8. `[writable, signer]` funder -/// 9. `[optional]` token_badge_x -/// 10. `[optional]` token_badge_y -/// 11. `[]` token_program_x -/// 12. `[]` token_program_y -/// 13. `[]` system_program -/// 14. `[]` user_token_y -/// 15. `[]` event_authority -/// 16. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeCustomizablePermissionlessLbPair2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeCustomizablePermissionlessLbPair2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new( - InitializeCustomizablePermissionlessLbPair2CpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - token_mint_x: None, - token_mint_y: None, - reserve_x: None, - reserve_y: None, - oracle: None, - user_token_x: None, - funder: None, - token_badge_x: None, - token_badge_y: None, - token_program_x: None, - token_program_y: None, - system_program: None, - user_token_y: None, - event_authority: None, - program: None, - params: None, - __remaining_accounts: Vec::new(), - }, - ); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn token_mint_x( - &mut self, - token_mint_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_x = Some(token_mint_x); - self - } - - #[inline(always)] - pub fn token_mint_y( - &mut self, - token_mint_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_y = Some(token_mint_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_x( - &mut self, - token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token_badge_x = token_badge_x; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_y( - &mut self, - token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token_badge_y = token_badge_y; - self - } - - #[inline(always)] - pub fn token_program_x( - &mut self, - token_program_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_x = Some(token_program_x); - self - } - - #[inline(always)] - pub fn token_program_y( - &mut self, - token_program_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_y = Some(token_program_y); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn params(&mut self, params: CustomizableParams) -> &mut Self { - self.instruction.params = Some(params); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeCustomizablePermissionlessLbPair2InstructionArgs { - params: self.instruction.params.clone().expect("params is not set"), - }; - let instruction = InitializeCustomizablePermissionlessLbPair2Cpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - token_mint_x: self - .instruction - .token_mint_x - .expect("token_mint_x is not set"), - - token_mint_y: self - .instruction - .token_mint_y - .expect("token_mint_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - token_badge_x: self.instruction.token_badge_x, - - token_badge_y: self.instruction.token_badge_y, - - token_program_x: self - .instruction - .token_program_x - .expect("token_program_x is not set"), - - token_program_y: self - .instruction - .token_program_y - .expect("token_program_y is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCustomizablePermissionlessLbPair2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_y: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - params: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_lb_pair.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_lb_pair.rs deleted file mode 100644 index d26f49bd..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_lb_pair.rs +++ /dev/null @@ -1,861 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeLbPair { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub token_mint_x: solana_pubkey::Pubkey, - - pub token_mint_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub preset_parameter: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeLbPair { - pub fn instruction( - &self, - args: InitializeLbPairInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeLbPairInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.preset_parameter, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeLbPairInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeLbPairInstructionData { - discriminator: [u8; 8], -} - -impl InitializeLbPairInstructionData { - pub fn new() -> Self { - Self { - discriminator: [45, 154, 237, 210, 221, 15, 166, 92], - } - } -} - -impl Default for InitializeLbPairInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeLbPairInstructionArgs { - pub active_id: i32, - pub bin_step: u16, -} - -/// Instruction builder for `InitializeLbPair`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable, optional]` bin_array_bitmap_extension -/// 2. `[]` token_mint_x -/// 3. `[]` token_mint_y -/// 4. `[writable]` reserve_x -/// 5. `[writable]` reserve_y -/// 6. `[writable]` oracle -/// 7. `[]` preset_parameter -/// 8. `[writable, signer]` funder -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 10. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 11. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeLbPairBuilder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - token_mint_x: Option, - token_mint_y: Option, - reserve_x: Option, - reserve_y: Option, - oracle: Option, - preset_parameter: Option, - funder: Option, - token_program: Option, - system_program: Option, - rent: Option, - event_authority: Option, - program: Option, - active_id: Option, - bin_step: Option, - __remaining_accounts: Vec, -} - -impl InitializeLbPairBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn token_mint_x(&mut self, token_mint_x: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_x = Some(token_mint_x); - self - } - - #[inline(always)] - pub fn token_mint_y(&mut self, token_mint_y: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_y = Some(token_mint_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn preset_parameter(&mut self, preset_parameter: solana_pubkey::Pubkey) -> &mut Self { - self.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn bin_step(&mut self, bin_step: u16) -> &mut Self { - self.bin_step = Some(bin_step); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeLbPair { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - token_mint_x: self.token_mint_x.expect("token_mint_x is not set"), - token_mint_y: self.token_mint_y.expect("token_mint_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - oracle: self.oracle.expect("oracle is not set"), - preset_parameter: self.preset_parameter.expect("preset_parameter is not set"), - funder: self.funder.expect("funder is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeLbPairInstructionArgs { - active_id: self.active_id.clone().expect("active_id is not set"), - bin_step: self.bin_step.clone().expect("bin_step is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_lb_pair` CPI accounts. -pub struct InitializeLbPairCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_mint_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_lb_pair` CPI instruction. -pub struct InitializeLbPairCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_mint_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeLbPairInstructionArgs, -} - -impl<'a, 'b> InitializeLbPairCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeLbPairCpiAccounts<'a, 'b>, - args: InitializeLbPairInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - token_mint_x: accounts.token_mint_x, - token_mint_y: accounts.token_mint_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - oracle: accounts.oracle, - preset_parameter: accounts.preset_parameter, - funder: accounts.funder, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.preset_parameter.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeLbPairInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.token_mint_x.clone()); - account_infos.push(self.token_mint_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.oracle.clone()); - account_infos.push(self.preset_parameter.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeLbPair` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable, optional]` bin_array_bitmap_extension -/// 2. `[]` token_mint_x -/// 3. `[]` token_mint_y -/// 4. `[writable]` reserve_x -/// 5. `[writable]` reserve_y -/// 6. `[writable]` oracle -/// 7. `[]` preset_parameter -/// 8. `[writable, signer]` funder -/// 9. `[]` token_program -/// 10. `[]` system_program -/// 11. `[]` rent -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeLbPairCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeLbPairCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeLbPairCpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - token_mint_x: None, - token_mint_y: None, - reserve_x: None, - reserve_y: None, - oracle: None, - preset_parameter: None, - funder: None, - token_program: None, - system_program: None, - rent: None, - event_authority: None, - program: None, - active_id: None, - bin_step: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn token_mint_x( - &mut self, - token_mint_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_x = Some(token_mint_x); - self - } - - #[inline(always)] - pub fn token_mint_y( - &mut self, - token_mint_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_y = Some(token_mint_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn preset_parameter( - &mut self, - preset_parameter: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.instruction.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn bin_step(&mut self, bin_step: u16) -> &mut Self { - self.instruction.bin_step = Some(bin_step); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeLbPairInstructionArgs { - active_id: self - .instruction - .active_id - .clone() - .expect("active_id is not set"), - bin_step: self - .instruction - .bin_step - .clone() - .expect("bin_step is not set"), - }; - let instruction = InitializeLbPairCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - token_mint_x: self - .instruction - .token_mint_x - .expect("token_mint_x is not set"), - - token_mint_y: self - .instruction - .token_mint_y - .expect("token_mint_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - preset_parameter: self - .instruction - .preset_parameter - .expect("preset_parameter is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeLbPairCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - preset_parameter: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - active_id: Option, - bin_step: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_lb_pair2.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_lb_pair2.rs deleted file mode 100644 index a4923ffe..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_lb_pair2.rs +++ /dev/null @@ -1,976 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeLbPair2 { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub token_mint_x: solana_pubkey::Pubkey, - - pub token_mint_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub preset_parameter: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub token_badge_x: Option, - - pub token_badge_y: Option, - - pub token_program_x: solana_pubkey::Pubkey, - - pub token_program_y: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeLbPair2 { - pub fn instruction( - &self, - args: InitializeLbPair2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeLbPair2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.preset_parameter, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - if let Some(token_badge_x) = self.token_badge_x { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token_badge_x, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - if let Some(token_badge_y) = self.token_badge_y { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token_badge_y, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeLbPair2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeLbPair2InstructionData { - discriminator: [u8; 8], -} - -impl InitializeLbPair2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [73, 59, 36, 120, 237, 83, 108, 198], - } - } -} - -impl Default for InitializeLbPair2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeLbPair2InstructionArgs { - pub active_id: i32, - pub padding: [u8; 96], -} - -/// Instruction builder for `InitializeLbPair2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable, optional]` bin_array_bitmap_extension -/// 2. `[]` token_mint_x -/// 3. `[]` token_mint_y -/// 4. `[writable]` reserve_x -/// 5. `[writable]` reserve_y -/// 6. `[writable]` oracle -/// 7. `[]` preset_parameter -/// 8. `[writable, signer]` funder -/// 9. `[optional]` token_badge_x -/// 10. `[optional]` token_badge_y -/// 11. `[]` token_program_x -/// 12. `[]` token_program_y -/// 13. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeLbPair2Builder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - token_mint_x: Option, - token_mint_y: Option, - reserve_x: Option, - reserve_y: Option, - oracle: Option, - preset_parameter: Option, - funder: Option, - token_badge_x: Option, - token_badge_y: Option, - token_program_x: Option, - token_program_y: Option, - system_program: Option, - event_authority: Option, - program: Option, - active_id: Option, - padding: Option<[u8; 96]>, - __remaining_accounts: Vec, -} - -impl InitializeLbPair2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn token_mint_x(&mut self, token_mint_x: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_x = Some(token_mint_x); - self - } - - #[inline(always)] - pub fn token_mint_y(&mut self, token_mint_y: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_y = Some(token_mint_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn preset_parameter(&mut self, preset_parameter: solana_pubkey::Pubkey) -> &mut Self { - self.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_x(&mut self, token_badge_x: Option) -> &mut Self { - self.token_badge_x = token_badge_x; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_y(&mut self, token_badge_y: Option) -> &mut Self { - self.token_badge_y = token_badge_y; - self - } - - #[inline(always)] - pub fn token_program_x(&mut self, token_program_x: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_x = Some(token_program_x); - self - } - - #[inline(always)] - pub fn token_program_y(&mut self, token_program_y: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_y = Some(token_program_y); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 96]) -> &mut Self { - self.padding = Some(padding); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeLbPair2 { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - token_mint_x: self.token_mint_x.expect("token_mint_x is not set"), - token_mint_y: self.token_mint_y.expect("token_mint_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - oracle: self.oracle.expect("oracle is not set"), - preset_parameter: self.preset_parameter.expect("preset_parameter is not set"), - funder: self.funder.expect("funder is not set"), - token_badge_x: self.token_badge_x, - token_badge_y: self.token_badge_y, - token_program_x: self.token_program_x.expect("token_program_x is not set"), - token_program_y: self.token_program_y.expect("token_program_y is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeLbPair2InstructionArgs { - active_id: self.active_id.clone().expect("active_id is not set"), - padding: self.padding.clone().expect("padding is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_lb_pair2` CPI accounts. -pub struct InitializeLbPair2CpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_mint_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_program_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_y: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_lb_pair2` CPI instruction. -pub struct InitializeLbPair2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_mint_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_program_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_y: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeLbPair2InstructionArgs, -} - -impl<'a, 'b> InitializeLbPair2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeLbPair2CpiAccounts<'a, 'b>, - args: InitializeLbPair2InstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - token_mint_x: accounts.token_mint_x, - token_mint_y: accounts.token_mint_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - oracle: accounts.oracle, - preset_parameter: accounts.preset_parameter, - funder: accounts.funder, - token_badge_x: accounts.token_badge_x, - token_badge_y: accounts.token_badge_y, - token_program_x: accounts.token_program_x, - token_program_y: accounts.token_program_y, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.preset_parameter.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - if let Some(token_badge_x) = self.token_badge_x { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token_badge_x.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - if let Some(token_badge_y) = self.token_badge_y { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token_badge_y.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeLbPair2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.token_mint_x.clone()); - account_infos.push(self.token_mint_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.oracle.clone()); - account_infos.push(self.preset_parameter.clone()); - account_infos.push(self.funder.clone()); - if let Some(token_badge_x) = self.token_badge_x { - account_infos.push(token_badge_x.clone()); - } - if let Some(token_badge_y) = self.token_badge_y { - account_infos.push(token_badge_y.clone()); - } - account_infos.push(self.token_program_x.clone()); - account_infos.push(self.token_program_y.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeLbPair2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable, optional]` bin_array_bitmap_extension -/// 2. `[]` token_mint_x -/// 3. `[]` token_mint_y -/// 4. `[writable]` reserve_x -/// 5. `[writable]` reserve_y -/// 6. `[writable]` oracle -/// 7. `[]` preset_parameter -/// 8. `[writable, signer]` funder -/// 9. `[optional]` token_badge_x -/// 10. `[optional]` token_badge_y -/// 11. `[]` token_program_x -/// 12. `[]` token_program_y -/// 13. `[]` system_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeLbPair2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeLbPair2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeLbPair2CpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - token_mint_x: None, - token_mint_y: None, - reserve_x: None, - reserve_y: None, - oracle: None, - preset_parameter: None, - funder: None, - token_badge_x: None, - token_badge_y: None, - token_program_x: None, - token_program_y: None, - system_program: None, - event_authority: None, - program: None, - active_id: None, - padding: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn token_mint_x( - &mut self, - token_mint_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_x = Some(token_mint_x); - self - } - - #[inline(always)] - pub fn token_mint_y( - &mut self, - token_mint_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_y = Some(token_mint_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn preset_parameter( - &mut self, - preset_parameter: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_x( - &mut self, - token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token_badge_x = token_badge_x; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_y( - &mut self, - token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token_badge_y = token_badge_y; - self - } - - #[inline(always)] - pub fn token_program_x( - &mut self, - token_program_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_x = Some(token_program_x); - self - } - - #[inline(always)] - pub fn token_program_y( - &mut self, - token_program_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_y = Some(token_program_y); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.instruction.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 96]) -> &mut Self { - self.instruction.padding = Some(padding); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeLbPair2InstructionArgs { - active_id: self - .instruction - .active_id - .clone() - .expect("active_id is not set"), - padding: self - .instruction - .padding - .clone() - .expect("padding is not set"), - }; - let instruction = InitializeLbPair2Cpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - token_mint_x: self - .instruction - .token_mint_x - .expect("token_mint_x is not set"), - - token_mint_y: self - .instruction - .token_mint_y - .expect("token_mint_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - preset_parameter: self - .instruction - .preset_parameter - .expect("preset_parameter is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - token_badge_x: self.instruction.token_badge_x, - - token_badge_y: self.instruction.token_badge_y, - - token_program_x: self - .instruction - .token_program_x - .expect("token_program_x is not set"), - - token_program_y: self - .instruction - .token_program_y - .expect("token_program_y is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeLbPair2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - preset_parameter: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_y: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - active_id: Option, - padding: Option<[u8; 96]>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_permission_lb_pair.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_permission_lb_pair.rs deleted file mode 100644 index 1e59e1f5..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_permission_lb_pair.rs +++ /dev/null @@ -1,1104 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePermissionLbPair { - pub base: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub token_mint_x: solana_pubkey::Pubkey, - - pub token_mint_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub token_badge_x: Option, - - pub token_badge_y: Option, - - pub token_program_x: solana_pubkey::Pubkey, - - pub token_program_y: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializePermissionLbPair { - pub fn instruction( - &self, - args: InitializePermissionLbPairInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePermissionLbPairInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - if let Some(token_badge_x) = self.token_badge_x { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token_badge_x, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - if let Some(token_badge_y) = self.token_badge_y { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token_badge_y, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePermissionLbPairInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionLbPairInstructionData { - discriminator: [u8; 8], -} - -impl InitializePermissionLbPairInstructionData { - pub fn new() -> Self { - Self { - discriminator: [108, 102, 213, 85, 251, 3, 53, 21], - } - } -} - -impl Default for InitializePermissionLbPairInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionLbPairInstructionArgs { - pub active_id: i32, - pub bin_step: u16, - pub base_factor: u16, - pub base_fee_power_factor: u8, - pub activation_type: u8, - pub protocol_share: u16, -} - -/// Instruction builder for `InitializePermissionLbPair`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` base -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[]` token_mint_x -/// 4. `[]` token_mint_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[writable]` oracle -/// 8. `[writable, signer]` admin -/// 9. `[optional]` token_badge_x -/// 10. `[optional]` token_badge_y -/// 11. `[]` token_program_x -/// 12. `[]` token_program_y -/// 13. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 14. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 15. `[]` event_authority -/// 16. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializePermissionLbPairBuilder { - base: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - token_mint_x: Option, - token_mint_y: Option, - reserve_x: Option, - reserve_y: Option, - oracle: Option, - admin: Option, - token_badge_x: Option, - token_badge_y: Option, - token_program_x: Option, - token_program_y: Option, - system_program: Option, - rent: Option, - event_authority: Option, - program: Option, - active_id: Option, - bin_step: Option, - base_factor: Option, - base_fee_power_factor: Option, - activation_type: Option, - protocol_share: Option, - __remaining_accounts: Vec, -} - -impl InitializePermissionLbPairBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn base(&mut self, base: solana_pubkey::Pubkey) -> &mut Self { - self.base = Some(base); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn token_mint_x(&mut self, token_mint_x: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_x = Some(token_mint_x); - self - } - - #[inline(always)] - pub fn token_mint_y(&mut self, token_mint_y: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_y = Some(token_mint_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_x(&mut self, token_badge_x: Option) -> &mut Self { - self.token_badge_x = token_badge_x; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_y(&mut self, token_badge_y: Option) -> &mut Self { - self.token_badge_y = token_badge_y; - self - } - - #[inline(always)] - pub fn token_program_x(&mut self, token_program_x: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_x = Some(token_program_x); - self - } - - #[inline(always)] - pub fn token_program_y(&mut self, token_program_y: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_y = Some(token_program_y); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn bin_step(&mut self, bin_step: u16) -> &mut Self { - self.bin_step = Some(bin_step); - self - } - - #[inline(always)] - pub fn base_factor(&mut self, base_factor: u16) -> &mut Self { - self.base_factor = Some(base_factor); - self - } - - #[inline(always)] - pub fn base_fee_power_factor(&mut self, base_fee_power_factor: u8) -> &mut Self { - self.base_fee_power_factor = Some(base_fee_power_factor); - self - } - - #[inline(always)] - pub fn activation_type(&mut self, activation_type: u8) -> &mut Self { - self.activation_type = Some(activation_type); - self - } - - #[inline(always)] - pub fn protocol_share(&mut self, protocol_share: u16) -> &mut Self { - self.protocol_share = Some(protocol_share); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePermissionLbPair { - base: self.base.expect("base is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - token_mint_x: self.token_mint_x.expect("token_mint_x is not set"), - token_mint_y: self.token_mint_y.expect("token_mint_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - oracle: self.oracle.expect("oracle is not set"), - admin: self.admin.expect("admin is not set"), - token_badge_x: self.token_badge_x, - token_badge_y: self.token_badge_y, - token_program_x: self.token_program_x.expect("token_program_x is not set"), - token_program_y: self.token_program_y.expect("token_program_y is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializePermissionLbPairInstructionArgs { - active_id: self.active_id.clone().expect("active_id is not set"), - bin_step: self.bin_step.clone().expect("bin_step is not set"), - base_factor: self.base_factor.clone().expect("base_factor is not set"), - base_fee_power_factor: self - .base_fee_power_factor - .clone() - .expect("base_fee_power_factor is not set"), - activation_type: self - .activation_type - .clone() - .expect("activation_type is not set"), - protocol_share: self - .protocol_share - .clone() - .expect("protocol_share is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_permission_lb_pair` CPI accounts. -pub struct InitializePermissionLbPairCpiAccounts<'a, 'b> { - pub base: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_mint_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_program_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_y: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_permission_lb_pair` CPI instruction. -pub struct InitializePermissionLbPairCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub base: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_mint_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub token_program_x: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_y: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePermissionLbPairInstructionArgs, -} - -impl<'a, 'b> InitializePermissionLbPairCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePermissionLbPairCpiAccounts<'a, 'b>, - args: InitializePermissionLbPairInstructionArgs, - ) -> Self { - Self { - __program: program, - base: accounts.base, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - token_mint_x: accounts.token_mint_x, - token_mint_y: accounts.token_mint_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - oracle: accounts.oracle, - admin: accounts.admin, - token_badge_x: accounts.token_badge_x, - token_badge_y: accounts.token_badge_y, - token_program_x: accounts.token_program_x, - token_program_y: accounts.token_program_y, - system_program: accounts.system_program, - rent: accounts.rent, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - if let Some(token_badge_x) = self.token_badge_x { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token_badge_x.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - if let Some(token_badge_y) = self.token_badge_y { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token_badge_y.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePermissionLbPairInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(18 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.base.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.token_mint_x.clone()); - account_infos.push(self.token_mint_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.oracle.clone()); - account_infos.push(self.admin.clone()); - if let Some(token_badge_x) = self.token_badge_x { - account_infos.push(token_badge_x.clone()); - } - if let Some(token_badge_y) = self.token_badge_y { - account_infos.push(token_badge_y.clone()); - } - account_infos.push(self.token_program_x.clone()); - account_infos.push(self.token_program_y.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePermissionLbPair` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` base -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[]` token_mint_x -/// 4. `[]` token_mint_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[writable]` oracle -/// 8. `[writable, signer]` admin -/// 9. `[optional]` token_badge_x -/// 10. `[optional]` token_badge_y -/// 11. `[]` token_program_x -/// 12. `[]` token_program_y -/// 13. `[]` system_program -/// 14. `[]` rent -/// 15. `[]` event_authority -/// 16. `[]` program -#[derive(Clone, Debug)] -pub struct InitializePermissionLbPairCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePermissionLbPairCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePermissionLbPairCpiBuilderInstruction { - __program: program, - base: None, - lb_pair: None, - bin_array_bitmap_extension: None, - token_mint_x: None, - token_mint_y: None, - reserve_x: None, - reserve_y: None, - oracle: None, - admin: None, - token_badge_x: None, - token_badge_y: None, - token_program_x: None, - token_program_y: None, - system_program: None, - rent: None, - event_authority: None, - program: None, - active_id: None, - bin_step: None, - base_factor: None, - base_fee_power_factor: None, - activation_type: None, - protocol_share: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn base(&mut self, base: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base = Some(base); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn token_mint_x( - &mut self, - token_mint_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_x = Some(token_mint_x); - self - } - - #[inline(always)] - pub fn token_mint_y( - &mut self, - token_mint_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_y = Some(token_mint_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_x( - &mut self, - token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token_badge_x = token_badge_x; - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge_y( - &mut self, - token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token_badge_y = token_badge_y; - self - } - - #[inline(always)] - pub fn token_program_x( - &mut self, - token_program_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_x = Some(token_program_x); - self - } - - #[inline(always)] - pub fn token_program_y( - &mut self, - token_program_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_y = Some(token_program_y); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.instruction.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn bin_step(&mut self, bin_step: u16) -> &mut Self { - self.instruction.bin_step = Some(bin_step); - self - } - - #[inline(always)] - pub fn base_factor(&mut self, base_factor: u16) -> &mut Self { - self.instruction.base_factor = Some(base_factor); - self - } - - #[inline(always)] - pub fn base_fee_power_factor(&mut self, base_fee_power_factor: u8) -> &mut Self { - self.instruction.base_fee_power_factor = Some(base_fee_power_factor); - self - } - - #[inline(always)] - pub fn activation_type(&mut self, activation_type: u8) -> &mut Self { - self.instruction.activation_type = Some(activation_type); - self - } - - #[inline(always)] - pub fn protocol_share(&mut self, protocol_share: u16) -> &mut Self { - self.instruction.protocol_share = Some(protocol_share); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePermissionLbPairInstructionArgs { - active_id: self - .instruction - .active_id - .clone() - .expect("active_id is not set"), - bin_step: self - .instruction - .bin_step - .clone() - .expect("bin_step is not set"), - base_factor: self - .instruction - .base_factor - .clone() - .expect("base_factor is not set"), - base_fee_power_factor: self - .instruction - .base_fee_power_factor - .clone() - .expect("base_fee_power_factor is not set"), - activation_type: self - .instruction - .activation_type - .clone() - .expect("activation_type is not set"), - protocol_share: self - .instruction - .protocol_share - .clone() - .expect("protocol_share is not set"), - }; - let instruction = InitializePermissionLbPairCpi { - __program: self.instruction.__program, - - base: self.instruction.base.expect("base is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - token_mint_x: self - .instruction - .token_mint_x - .expect("token_mint_x is not set"), - - token_mint_y: self - .instruction - .token_mint_y - .expect("token_mint_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - token_badge_x: self.instruction.token_badge_x, - - token_badge_y: self.instruction.token_badge_y, - - token_program_x: self - .instruction - .token_program_x - .expect("token_program_x is not set"), - - token_program_y: self - .instruction - .token_program_y - .expect("token_program_y is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePermissionLbPairCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - base: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_x: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_y: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - active_id: Option, - bin_step: Option, - base_factor: Option, - base_fee_power_factor: Option, - activation_type: Option, - protocol_share: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_position.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_position.rs deleted file mode 100644 index eba14ae0..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_position.rs +++ /dev/null @@ -1,598 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePosition { - pub payer: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializePosition { - pub fn instruction( - &self, - args: InitializePositionInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePositionInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new(self.position, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lb_pair, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePositionInstructionData { - discriminator: [u8; 8], -} - -impl InitializePositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [219, 192, 234, 71, 190, 191, 102, 80], - } - } -} - -impl Default for InitializePositionInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePositionInstructionArgs { - pub lower_bin_id: i32, - pub width: i32, -} - -/// Instruction builder for `InitializePosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[writable, signer]` position -/// 2. `[]` lb_pair -/// 3. `[signer]` owner -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 5. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 6. `[]` event_authority -/// 7. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializePositionBuilder { - payer: Option, - position: Option, - lb_pair: Option, - owner: Option, - system_program: Option, - rent: Option, - event_authority: Option, - program: Option, - lower_bin_id: Option, - width: Option, - __remaining_accounts: Vec, -} - -impl InitializePositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn lower_bin_id(&mut self, lower_bin_id: i32) -> &mut Self { - self.lower_bin_id = Some(lower_bin_id); - self - } - - #[inline(always)] - pub fn width(&mut self, width: i32) -> &mut Self { - self.width = Some(width); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePosition { - payer: self.payer.expect("payer is not set"), - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - owner: self.owner.expect("owner is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializePositionInstructionArgs { - lower_bin_id: self.lower_bin_id.clone().expect("lower_bin_id is not set"), - width: self.width.clone().expect("width is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_position` CPI accounts. -pub struct InitializePositionCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_position` CPI instruction. -pub struct InitializePositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePositionInstructionArgs, -} - -impl<'a, 'b> InitializePositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePositionCpiAccounts<'a, 'b>, - args: InitializePositionInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - position: accounts.position, - lb_pair: accounts.lb_pair, - owner: accounts.owner, - system_program: accounts.system_program, - rent: accounts.rent, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[writable, signer]` position -/// 2. `[]` lb_pair -/// 3. `[signer]` owner -/// 4. `[]` system_program -/// 5. `[]` rent -/// 6. `[]` event_authority -/// 7. `[]` program -#[derive(Clone, Debug)] -pub struct InitializePositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePositionCpiBuilderInstruction { - __program: program, - payer: None, - position: None, - lb_pair: None, - owner: None, - system_program: None, - rent: None, - event_authority: None, - program: None, - lower_bin_id: None, - width: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn lower_bin_id(&mut self, lower_bin_id: i32) -> &mut Self { - self.instruction.lower_bin_id = Some(lower_bin_id); - self - } - - #[inline(always)] - pub fn width(&mut self, width: i32) -> &mut Self { - self.instruction.width = Some(width); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePositionInstructionArgs { - lower_bin_id: self - .instruction - .lower_bin_id - .clone() - .expect("lower_bin_id is not set"), - width: self.instruction.width.clone().expect("width is not set"), - }; - let instruction = InitializePositionCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - lower_bin_id: Option, - width: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_position_by_operator.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_position_by_operator.rs deleted file mode 100644 index 6787155c..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_position_by_operator.rs +++ /dev/null @@ -1,765 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePositionByOperator { - pub payer: solana_pubkey::Pubkey, - - pub base: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - /// operator - pub operator: solana_pubkey::Pubkey, - - pub operator_token_x: solana_pubkey::Pubkey, - - pub owner_token_x: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializePositionByOperator { - pub fn instruction( - &self, - args: InitializePositionByOperatorInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePositionByOperatorInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lb_pair, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePositionByOperatorInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePositionByOperatorInstructionData { - discriminator: [u8; 8], -} - -impl InitializePositionByOperatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [251, 189, 190, 244, 117, 254, 35, 148], - } - } -} - -impl Default for InitializePositionByOperatorInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePositionByOperatorInstructionArgs { - pub lower_bin_id: i32, - pub width: i32, - pub fee_owner: Pubkey, - pub lock_release_point: u64, -} - -/// Instruction builder for `InitializePositionByOperator`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[signer]` base -/// 2. `[writable]` position -/// 3. `[]` lb_pair -/// 4. `[]` owner -/// 5. `[signer]` operator -/// 6. `[]` operator_token_x -/// 7. `[]` owner_token_x -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[]` event_authority -/// 10. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializePositionByOperatorBuilder { - payer: Option, - base: Option, - position: Option, - lb_pair: Option, - owner: Option, - operator: Option, - operator_token_x: Option, - owner_token_x: Option, - system_program: Option, - event_authority: Option, - program: Option, - lower_bin_id: Option, - width: Option, - fee_owner: Option, - lock_release_point: Option, - __remaining_accounts: Vec, -} - -impl InitializePositionByOperatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn base(&mut self, base: solana_pubkey::Pubkey) -> &mut Self { - self.base = Some(base); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// operator - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn operator_token_x(&mut self, operator_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.operator_token_x = Some(operator_token_x); - self - } - - #[inline(always)] - pub fn owner_token_x(&mut self, owner_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.owner_token_x = Some(owner_token_x); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn lower_bin_id(&mut self, lower_bin_id: i32) -> &mut Self { - self.lower_bin_id = Some(lower_bin_id); - self - } - - #[inline(always)] - pub fn width(&mut self, width: i32) -> &mut Self { - self.width = Some(width); - self - } - - #[inline(always)] - pub fn fee_owner(&mut self, fee_owner: Pubkey) -> &mut Self { - self.fee_owner = Some(fee_owner); - self - } - - #[inline(always)] - pub fn lock_release_point(&mut self, lock_release_point: u64) -> &mut Self { - self.lock_release_point = Some(lock_release_point); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePositionByOperator { - payer: self.payer.expect("payer is not set"), - base: self.base.expect("base is not set"), - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - owner: self.owner.expect("owner is not set"), - operator: self.operator.expect("operator is not set"), - operator_token_x: self.operator_token_x.expect("operator_token_x is not set"), - owner_token_x: self.owner_token_x.expect("owner_token_x is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializePositionByOperatorInstructionArgs { - lower_bin_id: self.lower_bin_id.clone().expect("lower_bin_id is not set"), - width: self.width.clone().expect("width is not set"), - fee_owner: self.fee_owner.clone().expect("fee_owner is not set"), - lock_release_point: self - .lock_release_point - .clone() - .expect("lock_release_point is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_position_by_operator` CPI accounts. -pub struct InitializePositionByOperatorCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub base: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// operator - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub operator_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub owner_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_position_by_operator` CPI instruction. -pub struct InitializePositionByOperatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub base: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// operator - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub operator_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub owner_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePositionByOperatorInstructionArgs, -} - -impl<'a, 'b> InitializePositionByOperatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePositionByOperatorCpiAccounts<'a, 'b>, - args: InitializePositionByOperatorInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - base: accounts.base, - position: accounts.position, - lb_pair: accounts.lb_pair, - owner: accounts.owner, - operator: accounts.operator, - operator_token_x: accounts.operator_token_x, - owner_token_x: accounts.owner_token_x, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePositionByOperatorInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.base.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.operator_token_x.clone()); - account_infos.push(self.owner_token_x.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePositionByOperator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[signer]` base -/// 2. `[writable]` position -/// 3. `[]` lb_pair -/// 4. `[]` owner -/// 5. `[signer]` operator -/// 6. `[]` operator_token_x -/// 7. `[]` owner_token_x -/// 8. `[]` system_program -/// 9. `[]` event_authority -/// 10. `[]` program -#[derive(Clone, Debug)] -pub struct InitializePositionByOperatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePositionByOperatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePositionByOperatorCpiBuilderInstruction { - __program: program, - payer: None, - base: None, - position: None, - lb_pair: None, - owner: None, - operator: None, - operator_token_x: None, - owner_token_x: None, - system_program: None, - event_authority: None, - program: None, - lower_bin_id: None, - width: None, - fee_owner: None, - lock_release_point: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn base(&mut self, base: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base = Some(base); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// operator - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn operator_token_x( - &mut self, - operator_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.operator_token_x = Some(operator_token_x); - self - } - - #[inline(always)] - pub fn owner_token_x( - &mut self, - owner_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.owner_token_x = Some(owner_token_x); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn lower_bin_id(&mut self, lower_bin_id: i32) -> &mut Self { - self.instruction.lower_bin_id = Some(lower_bin_id); - self - } - - #[inline(always)] - pub fn width(&mut self, width: i32) -> &mut Self { - self.instruction.width = Some(width); - self - } - - #[inline(always)] - pub fn fee_owner(&mut self, fee_owner: Pubkey) -> &mut Self { - self.instruction.fee_owner = Some(fee_owner); - self - } - - #[inline(always)] - pub fn lock_release_point(&mut self, lock_release_point: u64) -> &mut Self { - self.instruction.lock_release_point = Some(lock_release_point); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePositionByOperatorInstructionArgs { - lower_bin_id: self - .instruction - .lower_bin_id - .clone() - .expect("lower_bin_id is not set"), - width: self.instruction.width.clone().expect("width is not set"), - fee_owner: self - .instruction - .fee_owner - .clone() - .expect("fee_owner is not set"), - lock_release_point: self - .instruction - .lock_release_point - .clone() - .expect("lock_release_point is not set"), - }; - let instruction = InitializePositionByOperatorCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - base: self.instruction.base.expect("base is not set"), - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - operator_token_x: self - .instruction - .operator_token_x - .expect("operator_token_x is not set"), - - owner_token_x: self - .instruction - .owner_token_x - .expect("owner_token_x is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePositionByOperatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - base: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - operator_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - owner_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - lower_bin_id: Option, - width: Option, - fee_owner: Option, - lock_release_point: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_position_pda.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_position_pda.rs deleted file mode 100644 index f2581c56..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_position_pda.rs +++ /dev/null @@ -1,635 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePositionPda { - pub payer: solana_pubkey::Pubkey, - - pub base: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - /// owner - pub owner: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializePositionPda { - pub fn instruction( - &self, - args: InitializePositionPdaInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePositionPdaInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lb_pair, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePositionPdaInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePositionPdaInstructionData { - discriminator: [u8; 8], -} - -impl InitializePositionPdaInstructionData { - pub fn new() -> Self { - Self { - discriminator: [46, 82, 125, 146, 85, 141, 228, 153], - } - } -} - -impl Default for InitializePositionPdaInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePositionPdaInstructionArgs { - pub lower_bin_id: i32, - pub width: i32, -} - -/// Instruction builder for `InitializePositionPda`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[signer]` base -/// 2. `[writable]` position -/// 3. `[]` lb_pair -/// 4. `[signer]` owner -/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 6. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializePositionPdaBuilder { - payer: Option, - base: Option, - position: Option, - lb_pair: Option, - owner: Option, - system_program: Option, - rent: Option, - event_authority: Option, - program: Option, - lower_bin_id: Option, - width: Option, - __remaining_accounts: Vec, -} - -impl InitializePositionPdaBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn base(&mut self, base: solana_pubkey::Pubkey) -> &mut Self { - self.base = Some(base); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// owner - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn lower_bin_id(&mut self, lower_bin_id: i32) -> &mut Self { - self.lower_bin_id = Some(lower_bin_id); - self - } - - #[inline(always)] - pub fn width(&mut self, width: i32) -> &mut Self { - self.width = Some(width); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePositionPda { - payer: self.payer.expect("payer is not set"), - base: self.base.expect("base is not set"), - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - owner: self.owner.expect("owner is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializePositionPdaInstructionArgs { - lower_bin_id: self.lower_bin_id.clone().expect("lower_bin_id is not set"), - width: self.width.clone().expect("width is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_position_pda` CPI accounts. -pub struct InitializePositionPdaCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub base: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - /// owner - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_position_pda` CPI instruction. -pub struct InitializePositionPdaCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub base: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - /// owner - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePositionPdaInstructionArgs, -} - -impl<'a, 'b> InitializePositionPdaCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePositionPdaCpiAccounts<'a, 'b>, - args: InitializePositionPdaInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - base: accounts.base, - position: accounts.position, - lb_pair: accounts.lb_pair, - owner: accounts.owner, - system_program: accounts.system_program, - rent: accounts.rent, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePositionPdaInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.base.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePositionPda` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[signer]` base -/// 2. `[writable]` position -/// 3. `[]` lb_pair -/// 4. `[signer]` owner -/// 5. `[]` system_program -/// 6. `[]` rent -/// 7. `[]` event_authority -/// 8. `[]` program -#[derive(Clone, Debug)] -pub struct InitializePositionPdaCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePositionPdaCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePositionPdaCpiBuilderInstruction { - __program: program, - payer: None, - base: None, - position: None, - lb_pair: None, - owner: None, - system_program: None, - rent: None, - event_authority: None, - program: None, - lower_bin_id: None, - width: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn base(&mut self, base: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base = Some(base); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// owner - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn lower_bin_id(&mut self, lower_bin_id: i32) -> &mut Self { - self.instruction.lower_bin_id = Some(lower_bin_id); - self - } - - #[inline(always)] - pub fn width(&mut self, width: i32) -> &mut Self { - self.instruction.width = Some(width); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePositionPdaInstructionArgs { - lower_bin_id: self - .instruction - .lower_bin_id - .clone() - .expect("lower_bin_id is not set"), - width: self.instruction.width.clone().expect("width is not set"), - }; - let instruction = InitializePositionPdaCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - base: self.instruction.base.expect("base is not set"), - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePositionPdaCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - base: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - lower_bin_id: Option, - width: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_preset_parameter.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_preset_parameter.rs deleted file mode 100644 index aa2c3d7a..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_preset_parameter.rs +++ /dev/null @@ -1,609 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePresetParameter { - pub preset_parameter: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl InitializePresetParameter { - pub fn instruction( - &self, - args: InitializePresetParameterInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePresetParameterInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.preset_parameter, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePresetParameterInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePresetParameterInstructionData { - discriminator: [u8; 8], -} - -impl InitializePresetParameterInstructionData { - pub fn new() -> Self { - Self { - discriminator: [66, 188, 71, 211, 98, 109, 14, 186], - } - } -} - -impl Default for InitializePresetParameterInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePresetParameterInstructionArgs { - pub bin_step: u16, - pub base_factor: u16, - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub variable_fee_control: u32, - pub max_volatility_accumulator: u32, - pub protocol_share: u16, -} - -/// Instruction builder for `InitializePresetParameter`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` preset_parameter -/// 1. `[writable, signer]` admin -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 3. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializePresetParameterBuilder { - preset_parameter: Option, - admin: Option, - system_program: Option, - rent: Option, - bin_step: Option, - base_factor: Option, - filter_period: Option, - decay_period: Option, - reduction_factor: Option, - variable_fee_control: Option, - max_volatility_accumulator: Option, - protocol_share: Option, - __remaining_accounts: Vec, -} - -impl InitializePresetParameterBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn preset_parameter(&mut self, preset_parameter: solana_pubkey::Pubkey) -> &mut Self { - self.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn bin_step(&mut self, bin_step: u16) -> &mut Self { - self.bin_step = Some(bin_step); - self - } - - #[inline(always)] - pub fn base_factor(&mut self, base_factor: u16) -> &mut Self { - self.base_factor = Some(base_factor); - self - } - - #[inline(always)] - pub fn filter_period(&mut self, filter_period: u16) -> &mut Self { - self.filter_period = Some(filter_period); - self - } - - #[inline(always)] - pub fn decay_period(&mut self, decay_period: u16) -> &mut Self { - self.decay_period = Some(decay_period); - self - } - - #[inline(always)] - pub fn reduction_factor(&mut self, reduction_factor: u16) -> &mut Self { - self.reduction_factor = Some(reduction_factor); - self - } - - #[inline(always)] - pub fn variable_fee_control(&mut self, variable_fee_control: u32) -> &mut Self { - self.variable_fee_control = Some(variable_fee_control); - self - } - - #[inline(always)] - pub fn max_volatility_accumulator(&mut self, max_volatility_accumulator: u32) -> &mut Self { - self.max_volatility_accumulator = Some(max_volatility_accumulator); - self - } - - #[inline(always)] - pub fn protocol_share(&mut self, protocol_share: u16) -> &mut Self { - self.protocol_share = Some(protocol_share); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePresetParameter { - preset_parameter: self.preset_parameter.expect("preset_parameter is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = InitializePresetParameterInstructionArgs { - bin_step: self.bin_step.clone().expect("bin_step is not set"), - base_factor: self.base_factor.clone().expect("base_factor is not set"), - filter_period: self - .filter_period - .clone() - .expect("filter_period is not set"), - decay_period: self.decay_period.clone().expect("decay_period is not set"), - reduction_factor: self - .reduction_factor - .clone() - .expect("reduction_factor is not set"), - variable_fee_control: self - .variable_fee_control - .clone() - .expect("variable_fee_control is not set"), - max_volatility_accumulator: self - .max_volatility_accumulator - .clone() - .expect("max_volatility_accumulator is not set"), - protocol_share: self - .protocol_share - .clone() - .expect("protocol_share is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_preset_parameter` CPI accounts. -pub struct InitializePresetParameterCpiAccounts<'a, 'b> { - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_preset_parameter` CPI instruction. -pub struct InitializePresetParameterCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePresetParameterInstructionArgs, -} - -impl<'a, 'b> InitializePresetParameterCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePresetParameterCpiAccounts<'a, 'b>, - args: InitializePresetParameterInstructionArgs, - ) -> Self { - Self { - __program: program, - preset_parameter: accounts.preset_parameter, - admin: accounts.admin, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.preset_parameter.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePresetParameterInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.preset_parameter.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePresetParameter` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` preset_parameter -/// 1. `[writable, signer]` admin -/// 2. `[]` system_program -/// 3. `[]` rent -#[derive(Clone, Debug)] -pub struct InitializePresetParameterCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePresetParameterCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePresetParameterCpiBuilderInstruction { - __program: program, - preset_parameter: None, - admin: None, - system_program: None, - rent: None, - bin_step: None, - base_factor: None, - filter_period: None, - decay_period: None, - reduction_factor: None, - variable_fee_control: None, - max_volatility_accumulator: None, - protocol_share: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn preset_parameter( - &mut self, - preset_parameter: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn bin_step(&mut self, bin_step: u16) -> &mut Self { - self.instruction.bin_step = Some(bin_step); - self - } - - #[inline(always)] - pub fn base_factor(&mut self, base_factor: u16) -> &mut Self { - self.instruction.base_factor = Some(base_factor); - self - } - - #[inline(always)] - pub fn filter_period(&mut self, filter_period: u16) -> &mut Self { - self.instruction.filter_period = Some(filter_period); - self - } - - #[inline(always)] - pub fn decay_period(&mut self, decay_period: u16) -> &mut Self { - self.instruction.decay_period = Some(decay_period); - self - } - - #[inline(always)] - pub fn reduction_factor(&mut self, reduction_factor: u16) -> &mut Self { - self.instruction.reduction_factor = Some(reduction_factor); - self - } - - #[inline(always)] - pub fn variable_fee_control(&mut self, variable_fee_control: u32) -> &mut Self { - self.instruction.variable_fee_control = Some(variable_fee_control); - self - } - - #[inline(always)] - pub fn max_volatility_accumulator(&mut self, max_volatility_accumulator: u32) -> &mut Self { - self.instruction.max_volatility_accumulator = Some(max_volatility_accumulator); - self - } - - #[inline(always)] - pub fn protocol_share(&mut self, protocol_share: u16) -> &mut Self { - self.instruction.protocol_share = Some(protocol_share); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePresetParameterInstructionArgs { - bin_step: self - .instruction - .bin_step - .clone() - .expect("bin_step is not set"), - base_factor: self - .instruction - .base_factor - .clone() - .expect("base_factor is not set"), - filter_period: self - .instruction - .filter_period - .clone() - .expect("filter_period is not set"), - decay_period: self - .instruction - .decay_period - .clone() - .expect("decay_period is not set"), - reduction_factor: self - .instruction - .reduction_factor - .clone() - .expect("reduction_factor is not set"), - variable_fee_control: self - .instruction - .variable_fee_control - .clone() - .expect("variable_fee_control is not set"), - max_volatility_accumulator: self - .instruction - .max_volatility_accumulator - .clone() - .expect("max_volatility_accumulator is not set"), - protocol_share: self - .instruction - .protocol_share - .clone() - .expect("protocol_share is not set"), - }; - let instruction = InitializePresetParameterCpi { - __program: self.instruction.__program, - - preset_parameter: self - .instruction - .preset_parameter - .expect("preset_parameter is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePresetParameterCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - preset_parameter: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_step: Option, - base_factor: Option, - filter_period: Option, - decay_period: Option, - reduction_factor: Option, - variable_fee_control: Option, - max_volatility_accumulator: Option, - protocol_share: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_preset_parameter2.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_preset_parameter2.rs deleted file mode 100644 index 1ee058c9..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_preset_parameter2.rs +++ /dev/null @@ -1,614 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePresetParameter2 { - pub preset_parameter: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializePresetParameter2 { - pub fn instruction( - &self, - args: InitializePresetParameter2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePresetParameter2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.preset_parameter, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePresetParameter2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePresetParameter2InstructionData { - discriminator: [u8; 8], -} - -impl InitializePresetParameter2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [184, 7, 240, 171, 103, 47, 183, 121], - } - } -} - -impl Default for InitializePresetParameter2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePresetParameter2InstructionArgs { - pub index: u16, - pub bin_step: u16, - pub base_factor: u16, - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub variable_fee_control: u32, - pub max_volatility_accumulator: u32, - pub protocol_share: u16, - pub base_fee_power_factor: u8, -} - -/// Instruction builder for `InitializePresetParameter2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` preset_parameter -/// 1. `[writable, signer]` admin -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializePresetParameter2Builder { - preset_parameter: Option, - admin: Option, - system_program: Option, - index: Option, - bin_step: Option, - base_factor: Option, - filter_period: Option, - decay_period: Option, - reduction_factor: Option, - variable_fee_control: Option, - max_volatility_accumulator: Option, - protocol_share: Option, - base_fee_power_factor: Option, - __remaining_accounts: Vec, -} - -impl InitializePresetParameter2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn preset_parameter(&mut self, preset_parameter: solana_pubkey::Pubkey) -> &mut Self { - self.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u16) -> &mut Self { - self.index = Some(index); - self - } - - #[inline(always)] - pub fn bin_step(&mut self, bin_step: u16) -> &mut Self { - self.bin_step = Some(bin_step); - self - } - - #[inline(always)] - pub fn base_factor(&mut self, base_factor: u16) -> &mut Self { - self.base_factor = Some(base_factor); - self - } - - #[inline(always)] - pub fn filter_period(&mut self, filter_period: u16) -> &mut Self { - self.filter_period = Some(filter_period); - self - } - - #[inline(always)] - pub fn decay_period(&mut self, decay_period: u16) -> &mut Self { - self.decay_period = Some(decay_period); - self - } - - #[inline(always)] - pub fn reduction_factor(&mut self, reduction_factor: u16) -> &mut Self { - self.reduction_factor = Some(reduction_factor); - self - } - - #[inline(always)] - pub fn variable_fee_control(&mut self, variable_fee_control: u32) -> &mut Self { - self.variable_fee_control = Some(variable_fee_control); - self - } - - #[inline(always)] - pub fn max_volatility_accumulator(&mut self, max_volatility_accumulator: u32) -> &mut Self { - self.max_volatility_accumulator = Some(max_volatility_accumulator); - self - } - - #[inline(always)] - pub fn protocol_share(&mut self, protocol_share: u16) -> &mut Self { - self.protocol_share = Some(protocol_share); - self - } - - #[inline(always)] - pub fn base_fee_power_factor(&mut self, base_fee_power_factor: u8) -> &mut Self { - self.base_fee_power_factor = Some(base_fee_power_factor); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePresetParameter2 { - preset_parameter: self.preset_parameter.expect("preset_parameter is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializePresetParameter2InstructionArgs { - index: self.index.clone().expect("index is not set"), - bin_step: self.bin_step.clone().expect("bin_step is not set"), - base_factor: self.base_factor.clone().expect("base_factor is not set"), - filter_period: self - .filter_period - .clone() - .expect("filter_period is not set"), - decay_period: self.decay_period.clone().expect("decay_period is not set"), - reduction_factor: self - .reduction_factor - .clone() - .expect("reduction_factor is not set"), - variable_fee_control: self - .variable_fee_control - .clone() - .expect("variable_fee_control is not set"), - max_volatility_accumulator: self - .max_volatility_accumulator - .clone() - .expect("max_volatility_accumulator is not set"), - protocol_share: self - .protocol_share - .clone() - .expect("protocol_share is not set"), - base_fee_power_factor: self - .base_fee_power_factor - .clone() - .expect("base_fee_power_factor is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_preset_parameter2` CPI accounts. -pub struct InitializePresetParameter2CpiAccounts<'a, 'b> { - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_preset_parameter2` CPI instruction. -pub struct InitializePresetParameter2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub preset_parameter: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePresetParameter2InstructionArgs, -} - -impl<'a, 'b> InitializePresetParameter2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePresetParameter2CpiAccounts<'a, 'b>, - args: InitializePresetParameter2InstructionArgs, - ) -> Self { - Self { - __program: program, - preset_parameter: accounts.preset_parameter, - admin: accounts.admin, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.preset_parameter.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePresetParameter2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.preset_parameter.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePresetParameter2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` preset_parameter -/// 1. `[writable, signer]` admin -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializePresetParameter2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePresetParameter2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePresetParameter2CpiBuilderInstruction { - __program: program, - preset_parameter: None, - admin: None, - system_program: None, - index: None, - bin_step: None, - base_factor: None, - filter_period: None, - decay_period: None, - reduction_factor: None, - variable_fee_control: None, - max_volatility_accumulator: None, - protocol_share: None, - base_fee_power_factor: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn preset_parameter( - &mut self, - preset_parameter: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.preset_parameter = Some(preset_parameter); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u16) -> &mut Self { - self.instruction.index = Some(index); - self - } - - #[inline(always)] - pub fn bin_step(&mut self, bin_step: u16) -> &mut Self { - self.instruction.bin_step = Some(bin_step); - self - } - - #[inline(always)] - pub fn base_factor(&mut self, base_factor: u16) -> &mut Self { - self.instruction.base_factor = Some(base_factor); - self - } - - #[inline(always)] - pub fn filter_period(&mut self, filter_period: u16) -> &mut Self { - self.instruction.filter_period = Some(filter_period); - self - } - - #[inline(always)] - pub fn decay_period(&mut self, decay_period: u16) -> &mut Self { - self.instruction.decay_period = Some(decay_period); - self - } - - #[inline(always)] - pub fn reduction_factor(&mut self, reduction_factor: u16) -> &mut Self { - self.instruction.reduction_factor = Some(reduction_factor); - self - } - - #[inline(always)] - pub fn variable_fee_control(&mut self, variable_fee_control: u32) -> &mut Self { - self.instruction.variable_fee_control = Some(variable_fee_control); - self - } - - #[inline(always)] - pub fn max_volatility_accumulator(&mut self, max_volatility_accumulator: u32) -> &mut Self { - self.instruction.max_volatility_accumulator = Some(max_volatility_accumulator); - self - } - - #[inline(always)] - pub fn protocol_share(&mut self, protocol_share: u16) -> &mut Self { - self.instruction.protocol_share = Some(protocol_share); - self - } - - #[inline(always)] - pub fn base_fee_power_factor(&mut self, base_fee_power_factor: u8) -> &mut Self { - self.instruction.base_fee_power_factor = Some(base_fee_power_factor); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePresetParameter2InstructionArgs { - index: self.instruction.index.clone().expect("index is not set"), - bin_step: self - .instruction - .bin_step - .clone() - .expect("bin_step is not set"), - base_factor: self - .instruction - .base_factor - .clone() - .expect("base_factor is not set"), - filter_period: self - .instruction - .filter_period - .clone() - .expect("filter_period is not set"), - decay_period: self - .instruction - .decay_period - .clone() - .expect("decay_period is not set"), - reduction_factor: self - .instruction - .reduction_factor - .clone() - .expect("reduction_factor is not set"), - variable_fee_control: self - .instruction - .variable_fee_control - .clone() - .expect("variable_fee_control is not set"), - max_volatility_accumulator: self - .instruction - .max_volatility_accumulator - .clone() - .expect("max_volatility_accumulator is not set"), - protocol_share: self - .instruction - .protocol_share - .clone() - .expect("protocol_share is not set"), - base_fee_power_factor: self - .instruction - .base_fee_power_factor - .clone() - .expect("base_fee_power_factor is not set"), - }; - let instruction = InitializePresetParameter2Cpi { - __program: self.instruction.__program, - - preset_parameter: self - .instruction - .preset_parameter - .expect("preset_parameter is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePresetParameter2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - preset_parameter: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - index: Option, - bin_step: Option, - base_factor: Option, - filter_period: Option, - decay_period: Option, - reduction_factor: Option, - variable_fee_control: Option, - max_volatility_accumulator: Option, - protocol_share: Option, - base_fee_power_factor: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_reward.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_reward.rs deleted file mode 100644 index 13288af8..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_reward.rs +++ /dev/null @@ -1,739 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeReward { - pub lb_pair: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub token_badge: Option, - - pub admin: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeReward { - pub fn instruction( - &self, - args: InitializeRewardInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - if let Some(token_badge) = self.token_badge { - accounts.push(solana_instruction::AccountMeta::new_readonly( - token_badge, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeRewardInstructionData { - discriminator: [u8; 8], -} - -impl InitializeRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [95, 135, 192, 196, 242, 129, 230, 68], - } - } -} - -impl Default for InitializeRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeRewardInstructionArgs { - pub reward_index: u64, - pub reward_duration: u64, - pub funder: Pubkey, -} - -/// Instruction builder for `InitializeReward`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` reward_vault -/// 2. `[]` reward_mint -/// 3. `[optional]` token_badge -/// 4. `[writable, signer]` admin -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 7. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeRewardBuilder { - lb_pair: Option, - reward_vault: Option, - reward_mint: Option, - token_badge: Option, - admin: Option, - token_program: Option, - system_program: Option, - rent: Option, - event_authority: Option, - program: Option, - reward_index: Option, - reward_duration: Option, - funder: Option, - __remaining_accounts: Vec, -} - -impl InitializeRewardBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge(&mut self, token_badge: Option) -> &mut Self { - self.token_badge = token_badge; - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn reward_duration(&mut self, reward_duration: u64) -> &mut Self { - self.reward_duration = Some(reward_duration); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeReward { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - token_badge: self.token_badge, - admin: self.admin.expect("admin is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeRewardInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - reward_duration: self - .reward_duration - .clone() - .expect("reward_duration is not set"), - funder: self.funder.clone().expect("funder is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_reward` CPI accounts. -pub struct InitializeRewardCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_reward` CPI instruction. -pub struct InitializeRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeRewardInstructionArgs, -} - -impl<'a, 'b> InitializeRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeRewardCpiAccounts<'a, 'b>, - args: InitializeRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - reward_vault: accounts.reward_vault, - reward_mint: accounts.reward_mint, - token_badge: accounts.token_badge, - admin: accounts.admin, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - if let Some(token_badge) = self.token_badge { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *token_badge.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_mint.clone()); - if let Some(token_badge) = self.token_badge { - account_infos.push(token_badge.clone()); - } - account_infos.push(self.admin.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` reward_vault -/// 2. `[]` reward_mint -/// 3. `[optional]` token_badge -/// 4. `[writable, signer]` admin -/// 5. `[]` token_program -/// 6. `[]` system_program -/// 7. `[]` rent -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeRewardCpiBuilderInstruction { - __program: program, - lb_pair: None, - reward_vault: None, - reward_mint: None, - token_badge: None, - admin: None, - token_program: None, - system_program: None, - rent: None, - event_authority: None, - program: None, - reward_index: None, - reward_duration: None, - funder: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn token_badge( - &mut self, - token_badge: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.token_badge = token_badge; - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn reward_duration(&mut self, reward_duration: u64) -> &mut Self { - self.instruction.reward_duration = Some(reward_duration); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: Pubkey) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeRewardInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - reward_duration: self - .instruction - .reward_duration - .clone() - .expect("reward_duration is not set"), - funder: self.instruction.funder.clone().expect("funder is not set"), - }; - let instruction = InitializeRewardCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - token_badge: self.instruction.token_badge, - - admin: self.instruction.admin.expect("admin is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - reward_duration: Option, - funder: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/initialize_token_badge.rs b/crates/meteora-parser/src/generated_sdk/instructions/initialize_token_badge.rs deleted file mode 100644 index a5c2e753..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/initialize_token_badge.rs +++ /dev/null @@ -1,397 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeTokenBadge { - pub token_mint: solana_pubkey::Pubkey, - - pub token_badge: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeTokenBadge { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_badge, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeTokenBadgeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeTokenBadgeInstructionData { - discriminator: [u8; 8], -} - -impl InitializeTokenBadgeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [253, 77, 205, 95, 27, 224, 89, 223], - } - } -} - -impl Default for InitializeTokenBadgeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `InitializeTokenBadge`. -/// -/// ### Accounts: -/// -/// 0. `[]` token_mint -/// 1. `[writable]` token_badge -/// 2. `[writable, signer]` admin -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeTokenBadgeBuilder { - token_mint: Option, - token_badge: Option, - admin: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl InitializeTokenBadgeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn token_badge(&mut self, token_badge: solana_pubkey::Pubkey) -> &mut Self { - self.token_badge = Some(token_badge); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeTokenBadge { - token_mint: self.token_mint.expect("token_mint is not set"), - token_badge: self.token_badge.expect("token_badge is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize_token_badge` CPI accounts. -pub struct InitializeTokenBadgeCpiAccounts<'a, 'b> { - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_token_badge` CPI instruction. -pub struct InitializeTokenBadgeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializeTokenBadgeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeTokenBadgeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - token_mint: accounts.token_mint, - token_badge: accounts.token_badge, - admin: accounts.admin, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_badge.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializeTokenBadgeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.token_badge.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeTokenBadge` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_mint -/// 1. `[writable]` token_badge -/// 2. `[writable, signer]` admin -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeTokenBadgeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeTokenBadgeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeTokenBadgeCpiBuilderInstruction { - __program: program, - token_mint: None, - token_badge: None, - admin: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn token_badge( - &mut self, - token_badge: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge = Some(token_badge); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializeTokenBadgeCpi { - __program: self.instruction.__program, - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - token_badge: self - .instruction - .token_badge - .expect("token_badge is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeTokenBadgeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/migrate_bin_array.rs b/crates/meteora-parser/src/generated_sdk/instructions/migrate_bin_array.rs deleted file mode 100644 index c20c2bfa..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/migrate_bin_array.rs +++ /dev/null @@ -1,277 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MigrateBinArray { - pub lb_pair: solana_pubkey::Pubkey, -} - -impl MigrateBinArray { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lb_pair, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigrateBinArrayInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateBinArrayInstructionData { - discriminator: [u8; 8], -} - -impl MigrateBinArrayInstructionData { - pub fn new() -> Self { - Self { - discriminator: [17, 23, 159, 211, 101, 184, 41, 241], - } - } -} - -impl Default for MigrateBinArrayInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigrateBinArray`. -/// -/// ### Accounts: -/// -/// 0. `[]` lb_pair -#[derive(Clone, Debug, Default)] -pub struct MigrateBinArrayBuilder { - lb_pair: Option, - __remaining_accounts: Vec, -} - -impl MigrateBinArrayBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrateBinArray { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migrate_bin_array` CPI accounts. -pub struct MigrateBinArrayCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migrate_bin_array` CPI instruction. -pub struct MigrateBinArrayCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrateBinArrayCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrateBinArrayCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lb_pair.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigrateBinArrayInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(2 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrateBinArray` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` lb_pair -#[derive(Clone, Debug)] -pub struct MigrateBinArrayCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrateBinArrayCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrateBinArrayCpiBuilderInstruction { - __program: program, - lb_pair: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrateBinArrayCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrateBinArrayCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/migrate_position.rs b/crates/meteora-parser/src/generated_sdk/instructions/migrate_position.rs deleted file mode 100644 index 0a391837..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/migrate_position.rs +++ /dev/null @@ -1,637 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MigratePosition { - pub position_v2: solana_pubkey::Pubkey, - - pub position_v1: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl MigratePosition { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position_v2, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.position_v1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lb_pair, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.owner, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigratePositionInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigratePositionInstructionData { - discriminator: [u8; 8], -} - -impl MigratePositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [15, 132, 59, 50, 199, 6, 251, 46], - } - } -} - -impl Default for MigratePositionInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigratePosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` position_v2 -/// 1. `[writable]` position_v1 -/// 2. `[]` lb_pair -/// 3. `[writable]` bin_array_lower -/// 4. `[writable]` bin_array_upper -/// 5. `[writable, signer]` owner -/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 7. `[writable]` rent_receiver -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct MigratePositionBuilder { - position_v2: Option, - position_v1: Option, - lb_pair: Option, - bin_array_lower: Option, - bin_array_upper: Option, - owner: Option, - system_program: Option, - rent_receiver: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl MigratePositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position_v2(&mut self, position_v2: solana_pubkey::Pubkey) -> &mut Self { - self.position_v2 = Some(position_v2); - self - } - - #[inline(always)] - pub fn position_v1(&mut self, position_v1: solana_pubkey::Pubkey) -> &mut Self { - self.position_v1 = Some(position_v1); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigratePosition { - position_v2: self.position_v2.expect("position_v2 is not set"), - position_v1: self.position_v1.expect("position_v1 is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - owner: self.owner.expect("owner is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migrate_position` CPI accounts. -pub struct MigratePositionCpiAccounts<'a, 'b> { - pub position_v2: &'b solana_account_info::AccountInfo<'a>, - - pub position_v1: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migrate_position` CPI instruction. -pub struct MigratePositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position_v2: &'b solana_account_info::AccountInfo<'a>, - - pub position_v1: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigratePositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigratePositionCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position_v2: accounts.position_v2, - position_v1: accounts.position_v1, - lb_pair: accounts.lb_pair, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - owner: accounts.owner, - system_program: accounts.system_program, - rent_receiver: accounts.rent_receiver, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_v2.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_v1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.owner.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigratePositionInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position_v2.clone()); - account_infos.push(self.position_v1.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent_receiver.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigratePosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` position_v2 -/// 1. `[writable]` position_v1 -/// 2. `[]` lb_pair -/// 3. `[writable]` bin_array_lower -/// 4. `[writable]` bin_array_upper -/// 5. `[writable, signer]` owner -/// 6. `[]` system_program -/// 7. `[writable]` rent_receiver -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct MigratePositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigratePositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigratePositionCpiBuilderInstruction { - __program: program, - position_v2: None, - position_v1: None, - lb_pair: None, - bin_array_lower: None, - bin_array_upper: None, - owner: None, - system_program: None, - rent_receiver: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position_v2( - &mut self, - position_v2: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_v2 = Some(position_v2); - self - } - - #[inline(always)] - pub fn position_v1( - &mut self, - position_v1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_v1 = Some(position_v1); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigratePositionCpi { - __program: self.instruction.__program, - - position_v2: self - .instruction - .position_v2 - .expect("position_v2 is not set"), - - position_v1: self - .instruction - .position_v1 - .expect("position_v1 is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigratePositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position_v2: Option<&'b solana_account_info::AccountInfo<'a>>, - position_v1: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/mod.rs b/crates/meteora-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index 02f01629..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,98 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#add_liquidity; -pub(crate) mod r#add_liquidity2; -pub(crate) mod r#add_liquidity_by_strategy; -pub(crate) mod r#add_liquidity_by_strategy2; -pub(crate) mod r#add_liquidity_by_strategy_one_side; -pub(crate) mod r#add_liquidity_by_weight; -pub(crate) mod r#add_liquidity_one_side; -pub(crate) mod r#add_liquidity_one_side_precise; -pub(crate) mod r#add_liquidity_one_side_precise2; -pub(crate) mod r#claim_fee; -pub(crate) mod r#claim_fee2; -pub(crate) mod r#claim_reward; -pub(crate) mod r#claim_reward2; -pub(crate) mod r#close_claim_protocol_fee_operator; -pub(crate) mod r#close_position; -pub(crate) mod r#close_position2; -pub(crate) mod r#close_position_if_empty; -pub(crate) mod r#close_preset_parameter; -pub(crate) mod r#close_preset_parameter2; -pub(crate) mod r#create_claim_protocol_fee_operator; -pub(crate) mod r#fund_reward; -pub(crate) mod r#go_to_a_bin; -pub(crate) mod r#increase_oracle_length; -pub(crate) mod r#initialize_bin_array; -pub(crate) mod r#initialize_bin_array_bitmap_extension; -pub(crate) mod r#initialize_customizable_permissionless_lb_pair; -pub(crate) mod r#initialize_customizable_permissionless_lb_pair2; -pub(crate) mod r#initialize_lb_pair; -pub(crate) mod r#initialize_lb_pair2; -pub(crate) mod r#initialize_permission_lb_pair; -pub(crate) mod r#initialize_position; -pub(crate) mod r#initialize_position_by_operator; -pub(crate) mod r#initialize_position_pda; -pub(crate) mod r#initialize_preset_parameter; -pub(crate) mod r#initialize_preset_parameter2; -pub(crate) mod r#initialize_reward; -pub(crate) mod r#initialize_token_badge; -pub(crate) mod r#migrate_bin_array; -pub(crate) mod r#migrate_position; -pub(crate) mod r#remove_all_liquidity; -pub(crate) mod r#remove_liquidity; -pub(crate) mod r#remove_liquidity2; -pub(crate) mod r#remove_liquidity_by_range; -pub(crate) mod r#remove_liquidity_by_range2; -pub(crate) mod r#set_activation_point; -pub(crate) mod r#set_pair_status; -pub(crate) mod r#set_pair_status_permissionless; -pub(crate) mod r#set_pre_activation_duration; -pub(crate) mod r#set_pre_activation_swap_address; -pub(crate) mod r#swap; -pub(crate) mod r#swap2; -pub(crate) mod r#swap_exact_out; -pub(crate) mod r#swap_exact_out2; -pub(crate) mod r#swap_with_price_impact; -pub(crate) mod r#swap_with_price_impact2; -pub(crate) mod r#update_base_fee_parameters; -pub(crate) mod r#update_dynamic_fee_parameters; -pub(crate) mod r#update_fees_and_reward2; -pub(crate) mod r#update_fees_and_rewards; -pub(crate) mod r#update_position_operator; -pub(crate) mod r#update_reward_duration; -pub(crate) mod r#update_reward_funder; -pub(crate) mod r#withdraw_ineligible_reward; -pub(crate) mod r#withdraw_protocol_fee; - -pub use self::{ - r#add_liquidity::*, r#add_liquidity2::*, r#add_liquidity_by_strategy::*, - r#add_liquidity_by_strategy2::*, r#add_liquidity_by_strategy_one_side::*, - r#add_liquidity_by_weight::*, r#add_liquidity_one_side::*, r#add_liquidity_one_side_precise::*, - r#add_liquidity_one_side_precise2::*, r#claim_fee::*, r#claim_fee2::*, r#claim_reward::*, - r#claim_reward2::*, r#close_claim_protocol_fee_operator::*, r#close_position::*, - r#close_position2::*, r#close_position_if_empty::*, r#close_preset_parameter::*, - r#close_preset_parameter2::*, r#create_claim_protocol_fee_operator::*, r#fund_reward::*, - r#go_to_a_bin::*, r#increase_oracle_length::*, r#initialize_bin_array::*, - r#initialize_bin_array_bitmap_extension::*, - r#initialize_customizable_permissionless_lb_pair::*, - r#initialize_customizable_permissionless_lb_pair2::*, r#initialize_lb_pair::*, - r#initialize_lb_pair2::*, r#initialize_permission_lb_pair::*, r#initialize_position::*, - r#initialize_position_by_operator::*, r#initialize_position_pda::*, - r#initialize_preset_parameter::*, r#initialize_preset_parameter2::*, r#initialize_reward::*, - r#initialize_token_badge::*, r#migrate_bin_array::*, r#migrate_position::*, - r#remove_all_liquidity::*, r#remove_liquidity::*, r#remove_liquidity2::*, - r#remove_liquidity_by_range::*, r#remove_liquidity_by_range2::*, r#set_activation_point::*, - r#set_pair_status::*, r#set_pair_status_permissionless::*, r#set_pre_activation_duration::*, - r#set_pre_activation_swap_address::*, r#swap::*, r#swap2::*, r#swap_exact_out::*, - r#swap_exact_out2::*, r#swap_with_price_impact::*, r#swap_with_price_impact2::*, - r#update_base_fee_parameters::*, r#update_dynamic_fee_parameters::*, - r#update_fees_and_reward2::*, r#update_fees_and_rewards::*, r#update_position_operator::*, - r#update_reward_duration::*, r#update_reward_funder::*, r#withdraw_ineligible_reward::*, - r#withdraw_protocol_fee::*, -}; diff --git a/crates/meteora-parser/src/generated_sdk/instructions/remove_all_liquidity.rs b/crates/meteora-parser/src/generated_sdk/instructions/remove_all_liquidity.rs deleted file mode 100644 index a53dfe3b..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/remove_all_liquidity.rs +++ /dev/null @@ -1,883 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveAllLiquidity { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl RemoveAllLiquidity { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&RemoveAllLiquidityInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveAllLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl RemoveAllLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [10, 51, 61, 35, 112, 105, 24, 85], - } - } -} - -impl Default for RemoveAllLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `RemoveAllLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct RemoveAllLiquidityBuilder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token_x: Option, - user_token_y: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl RemoveAllLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveAllLiquidity { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `remove_all_liquidity` CPI accounts. -pub struct RemoveAllLiquidityCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_all_liquidity` CPI instruction. -pub struct RemoveAllLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> RemoveAllLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveAllLiquidityCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&RemoveAllLiquidityInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveAllLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct RemoveAllLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveAllLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveAllLiquidityCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token_x: None, - user_token_y: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = RemoveAllLiquidityCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveAllLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity.rs b/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity.rs deleted file mode 100644 index 289eb4c7..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity.rs +++ /dev/null @@ -1,938 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::BinLiquidityReduction; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveLiquidity { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl RemoveLiquidity { - pub fn instruction( - &self, - args: RemoveLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemoveLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RemoveLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl RemoveLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [80, 85, 209, 72, 24, 206, 177, 108], - } - } -} - -impl Default for RemoveLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidityInstructionArgs { - pub bin_liquidity_removal: Vec, -} - -/// Instruction builder for `RemoveLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct RemoveLiquidityBuilder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token_x: Option, - user_token_y: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - bin_liquidity_removal: Option>, - __remaining_accounts: Vec, -} - -impl RemoveLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn bin_liquidity_removal( - &mut self, - bin_liquidity_removal: Vec, - ) -> &mut Self { - self.bin_liquidity_removal = Some(bin_liquidity_removal); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveLiquidity { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = RemoveLiquidityInstructionArgs { - bin_liquidity_removal: self - .bin_liquidity_removal - .clone() - .expect("bin_liquidity_removal is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_liquidity` CPI accounts. -pub struct RemoveLiquidityCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_liquidity` CPI instruction. -pub struct RemoveLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemoveLiquidityInstructionArgs, -} - -impl<'a, 'b> RemoveLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveLiquidityCpiAccounts<'a, 'b>, - args: RemoveLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RemoveLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct RemoveLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveLiquidityCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token_x: None, - user_token_y: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - bin_liquidity_removal: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn bin_liquidity_removal( - &mut self, - bin_liquidity_removal: Vec, - ) -> &mut Self { - self.instruction.bin_liquidity_removal = Some(bin_liquidity_removal); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RemoveLiquidityInstructionArgs { - bin_liquidity_removal: self - .instruction - .bin_liquidity_removal - .clone() - .expect("bin_liquidity_removal is not set"), - }; - let instruction = RemoveLiquidityCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_liquidity_removal: Option>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity2.rs b/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity2.rs deleted file mode 100644 index 592a86d5..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity2.rs +++ /dev/null @@ -1,927 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{BinLiquidityReduction, RemainingAccountsInfo}; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveLiquidity2 { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl RemoveLiquidity2 { - pub fn instruction( - &self, - args: RemoveLiquidity2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemoveLiquidity2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RemoveLiquidity2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidity2InstructionData { - discriminator: [u8; 8], -} - -impl RemoveLiquidity2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [230, 215, 82, 127, 241, 101, 227, 146], - } - } -} - -impl Default for RemoveLiquidity2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidity2InstructionArgs { - pub bin_liquidity_removal: Vec, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `RemoveLiquidity2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[signer]` sender -/// 10. `[]` token_x_program -/// 11. `[]` token_y_program -/// 12. `[]` memo_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct RemoveLiquidity2Builder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token_x: Option, - user_token_y: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - sender: Option, - token_x_program: Option, - token_y_program: Option, - memo_program: Option, - event_authority: Option, - program: Option, - bin_liquidity_removal: Option>, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl RemoveLiquidity2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn bin_liquidity_removal( - &mut self, - bin_liquidity_removal: Vec, - ) -> &mut Self { - self.bin_liquidity_removal = Some(bin_liquidity_removal); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveLiquidity2 { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - sender: self.sender.expect("sender is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = RemoveLiquidity2InstructionArgs { - bin_liquidity_removal: self - .bin_liquidity_removal - .clone() - .expect("bin_liquidity_removal is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_liquidity2` CPI accounts. -pub struct RemoveLiquidity2CpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_liquidity2` CPI instruction. -pub struct RemoveLiquidity2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemoveLiquidity2InstructionArgs, -} - -impl<'a, 'b> RemoveLiquidity2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveLiquidity2CpiAccounts<'a, 'b>, - args: RemoveLiquidity2InstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - sender: accounts.sender, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - memo_program: accounts.memo_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RemoveLiquidity2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveLiquidity2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[signer]` sender -/// 10. `[]` token_x_program -/// 11. `[]` token_y_program -/// 12. `[]` memo_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct RemoveLiquidity2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveLiquidity2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveLiquidity2CpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token_x: None, - user_token_y: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - sender: None, - token_x_program: None, - token_y_program: None, - memo_program: None, - event_authority: None, - program: None, - bin_liquidity_removal: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn bin_liquidity_removal( - &mut self, - bin_liquidity_removal: Vec, - ) -> &mut Self { - self.instruction.bin_liquidity_removal = Some(bin_liquidity_removal); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RemoveLiquidity2InstructionArgs { - bin_liquidity_removal: self - .instruction - .bin_liquidity_removal - .clone() - .expect("bin_liquidity_removal is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = RemoveLiquidity2Cpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveLiquidity2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_liquidity_removal: Option>, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity_by_range.rs b/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity_by_range.rs deleted file mode 100644 index ba4cc2ed..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity_by_range.rs +++ /dev/null @@ -1,974 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveLiquidityByRange { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl RemoveLiquidityByRange { - pub fn instruction( - &self, - args: RemoveLiquidityByRangeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemoveLiquidityByRangeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RemoveLiquidityByRangeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidityByRangeInstructionData { - discriminator: [u8; 8], -} - -impl RemoveLiquidityByRangeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [26, 82, 102, 152, 240, 74, 105, 26], - } - } -} - -impl Default for RemoveLiquidityByRangeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidityByRangeInstructionArgs { - pub from_bin_id: i32, - pub to_bin_id: i32, - pub bps_to_remove: u16, -} - -/// Instruction builder for `RemoveLiquidityByRange`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct RemoveLiquidityByRangeBuilder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token_x: Option, - user_token_y: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - bin_array_lower: Option, - bin_array_upper: Option, - sender: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - from_bin_id: Option, - to_bin_id: Option, - bps_to_remove: Option, - __remaining_accounts: Vec, -} - -impl RemoveLiquidityByRangeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn from_bin_id(&mut self, from_bin_id: i32) -> &mut Self { - self.from_bin_id = Some(from_bin_id); - self - } - - #[inline(always)] - pub fn to_bin_id(&mut self, to_bin_id: i32) -> &mut Self { - self.to_bin_id = Some(to_bin_id); - self - } - - #[inline(always)] - pub fn bps_to_remove(&mut self, bps_to_remove: u16) -> &mut Self { - self.bps_to_remove = Some(bps_to_remove); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveLiquidityByRange { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - sender: self.sender.expect("sender is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = RemoveLiquidityByRangeInstructionArgs { - from_bin_id: self.from_bin_id.clone().expect("from_bin_id is not set"), - to_bin_id: self.to_bin_id.clone().expect("to_bin_id is not set"), - bps_to_remove: self - .bps_to_remove - .clone() - .expect("bps_to_remove is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_liquidity_by_range` CPI accounts. -pub struct RemoveLiquidityByRangeCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_liquidity_by_range` CPI instruction. -pub struct RemoveLiquidityByRangeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemoveLiquidityByRangeInstructionArgs, -} - -impl<'a, 'b> RemoveLiquidityByRangeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveLiquidityByRangeCpiAccounts<'a, 'b>, - args: RemoveLiquidityByRangeInstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - sender: accounts.sender, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RemoveLiquidityByRangeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveLiquidityByRange` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[writable]` bin_array_lower -/// 10. `[writable]` bin_array_upper -/// 11. `[signer]` sender -/// 12. `[]` token_x_program -/// 13. `[]` token_y_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct RemoveLiquidityByRangeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveLiquidityByRangeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveLiquidityByRangeCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token_x: None, - user_token_y: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - bin_array_lower: None, - bin_array_upper: None, - sender: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - from_bin_id: None, - to_bin_id: None, - bps_to_remove: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn from_bin_id(&mut self, from_bin_id: i32) -> &mut Self { - self.instruction.from_bin_id = Some(from_bin_id); - self - } - - #[inline(always)] - pub fn to_bin_id(&mut self, to_bin_id: i32) -> &mut Self { - self.instruction.to_bin_id = Some(to_bin_id); - self - } - - #[inline(always)] - pub fn bps_to_remove(&mut self, bps_to_remove: u16) -> &mut Self { - self.instruction.bps_to_remove = Some(bps_to_remove); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RemoveLiquidityByRangeInstructionArgs { - from_bin_id: self - .instruction - .from_bin_id - .clone() - .expect("from_bin_id is not set"), - to_bin_id: self - .instruction - .to_bin_id - .clone() - .expect("to_bin_id is not set"), - bps_to_remove: self - .instruction - .bps_to_remove - .clone() - .expect("bps_to_remove is not set"), - }; - let instruction = RemoveLiquidityByRangeCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveLiquidityByRangeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - from_bin_id: Option, - to_bin_id: Option, - bps_to_remove: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity_by_range2.rs b/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity_by_range2.rs deleted file mode 100644 index 14c367fd..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/remove_liquidity_by_range2.rs +++ /dev/null @@ -1,965 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveLiquidityByRange2 { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub user_token_x: solana_pubkey::Pubkey, - - pub user_token_y: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub sender: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl RemoveLiquidityByRange2 { - pub fn instruction( - &self, - args: RemoveLiquidityByRange2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemoveLiquidityByRange2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.sender, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RemoveLiquidityByRange2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidityByRange2InstructionData { - discriminator: [u8; 8], -} - -impl RemoveLiquidityByRange2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [204, 2, 195, 145, 53, 145, 145, 205], - } - } -} - -impl Default for RemoveLiquidityByRange2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquidityByRange2InstructionArgs { - pub from_bin_id: i32, - pub to_bin_id: i32, - pub bps_to_remove: u16, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `RemoveLiquidityByRange2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[signer]` sender -/// 10. `[]` token_x_program -/// 11. `[]` token_y_program -/// 12. `[]` memo_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct RemoveLiquidityByRange2Builder { - position: Option, - lb_pair: Option, - bin_array_bitmap_extension: Option, - user_token_x: Option, - user_token_y: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - sender: Option, - token_x_program: Option, - token_y_program: Option, - memo_program: Option, - event_authority: Option, - program: Option, - from_bin_id: Option, - to_bin_id: Option, - bps_to_remove: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl RemoveLiquidityByRange2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn from_bin_id(&mut self, from_bin_id: i32) -> &mut Self { - self.from_bin_id = Some(from_bin_id); - self - } - - #[inline(always)] - pub fn to_bin_id(&mut self, to_bin_id: i32) -> &mut Self { - self.to_bin_id = Some(to_bin_id); - self - } - - #[inline(always)] - pub fn bps_to_remove(&mut self, bps_to_remove: u16) -> &mut Self { - self.bps_to_remove = Some(bps_to_remove); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveLiquidityByRange2 { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - user_token_x: self.user_token_x.expect("user_token_x is not set"), - user_token_y: self.user_token_y.expect("user_token_y is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - sender: self.sender.expect("sender is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = RemoveLiquidityByRange2InstructionArgs { - from_bin_id: self.from_bin_id.clone().expect("from_bin_id is not set"), - to_bin_id: self.to_bin_id.clone().expect("to_bin_id is not set"), - bps_to_remove: self - .bps_to_remove - .clone() - .expect("bps_to_remove is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_liquidity_by_range2` CPI accounts. -pub struct RemoveLiquidityByRange2CpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_liquidity_by_range2` CPI instruction. -pub struct RemoveLiquidityByRange2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemoveLiquidityByRange2InstructionArgs, -} - -impl<'a, 'b> RemoveLiquidityByRange2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveLiquidityByRange2CpiAccounts<'a, 'b>, - args: RemoveLiquidityByRange2InstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - user_token_x: accounts.user_token_x, - user_token_y: accounts.user_token_y, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - sender: accounts.sender, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - memo_program: accounts.memo_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.sender.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RemoveLiquidityByRange2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.user_token_x.clone()); - account_infos.push(self.user_token_y.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveLiquidityByRange2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable, optional]` bin_array_bitmap_extension -/// 3. `[writable]` user_token_x -/// 4. `[writable]` user_token_y -/// 5. `[writable]` reserve_x -/// 6. `[writable]` reserve_y -/// 7. `[]` token_x_mint -/// 8. `[]` token_y_mint -/// 9. `[signer]` sender -/// 10. `[]` token_x_program -/// 11. `[]` token_y_program -/// 12. `[]` memo_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct RemoveLiquidityByRange2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveLiquidityByRange2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveLiquidityByRange2CpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_bitmap_extension: None, - user_token_x: None, - user_token_y: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - sender: None, - token_x_program: None, - token_y_program: None, - memo_program: None, - event_authority: None, - program: None, - from_bin_id: None, - to_bin_id: None, - bps_to_remove: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn user_token_x( - &mut self, - user_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_x = Some(user_token_x); - self - } - - #[inline(always)] - pub fn user_token_y( - &mut self, - user_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_y = Some(user_token_y); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn from_bin_id(&mut self, from_bin_id: i32) -> &mut Self { - self.instruction.from_bin_id = Some(from_bin_id); - self - } - - #[inline(always)] - pub fn to_bin_id(&mut self, to_bin_id: i32) -> &mut Self { - self.instruction.to_bin_id = Some(to_bin_id); - self - } - - #[inline(always)] - pub fn bps_to_remove(&mut self, bps_to_remove: u16) -> &mut Self { - self.instruction.bps_to_remove = Some(bps_to_remove); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RemoveLiquidityByRange2InstructionArgs { - from_bin_id: self - .instruction - .from_bin_id - .clone() - .expect("from_bin_id is not set"), - to_bin_id: self - .instruction - .to_bin_id - .clone() - .expect("to_bin_id is not set"), - bps_to_remove: self - .instruction - .bps_to_remove - .clone() - .expect("bps_to_remove is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = RemoveLiquidityByRange2Cpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - user_token_x: self - .instruction - .user_token_x - .expect("user_token_x is not set"), - - user_token_y: self - .instruction - .user_token_y - .expect("user_token_y is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - sender: self.instruction.sender.expect("sender is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveLiquidityByRange2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - from_bin_id: Option, - to_bin_id: Option, - bps_to_remove: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/set_activation_point.rs b/crates/meteora-parser/src/generated_sdk/instructions/set_activation_point.rs deleted file mode 100644 index f97f7d9b..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/set_activation_point.rs +++ /dev/null @@ -1,351 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetActivationPoint { - pub lb_pair: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, -} - -impl SetActivationPoint { - pub fn instruction( - &self, - args: SetActivationPointInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetActivationPointInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetActivationPointInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetActivationPointInstructionData { - discriminator: [u8; 8], -} - -impl SetActivationPointInstructionData { - pub fn new() -> Self { - Self { - discriminator: [91, 249, 15, 165, 26, 129, 254, 125], - } - } -} - -impl Default for SetActivationPointInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetActivationPointInstructionArgs { - pub activation_point: u64, -} - -/// Instruction builder for `SetActivationPoint`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable, signer]` admin -#[derive(Clone, Debug, Default)] -pub struct SetActivationPointBuilder { - lb_pair: Option, - admin: Option, - activation_point: Option, - __remaining_accounts: Vec, -} - -impl SetActivationPointBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn activation_point(&mut self, activation_point: u64) -> &mut Self { - self.activation_point = Some(activation_point); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetActivationPoint { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - admin: self.admin.expect("admin is not set"), - }; - let args = SetActivationPointInstructionArgs { - activation_point: self - .activation_point - .clone() - .expect("activation_point is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_activation_point` CPI accounts. -pub struct SetActivationPointCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_activation_point` CPI instruction. -pub struct SetActivationPointCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetActivationPointInstructionArgs, -} - -impl<'a, 'b> SetActivationPointCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetActivationPointCpiAccounts<'a, 'b>, - args: SetActivationPointInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - admin: accounts.admin, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetActivationPointInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetActivationPoint` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable, signer]` admin -#[derive(Clone, Debug)] -pub struct SetActivationPointCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetActivationPointCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetActivationPointCpiBuilderInstruction { - __program: program, - lb_pair: None, - admin: None, - activation_point: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn activation_point(&mut self, activation_point: u64) -> &mut Self { - self.instruction.activation_point = Some(activation_point); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetActivationPointInstructionArgs { - activation_point: self - .instruction - .activation_point - .clone() - .expect("activation_point is not set"), - }; - let instruction = SetActivationPointCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetActivationPointCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - activation_point: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/set_pair_status.rs b/crates/meteora-parser/src/generated_sdk/instructions/set_pair_status.rs deleted file mode 100644 index 7a0d437a..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/set_pair_status.rs +++ /dev/null @@ -1,349 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetPairStatus { - pub lb_pair: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, -} - -impl SetPairStatus { - pub fn instruction( - &self, - args: SetPairStatusInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetPairStatusInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetPairStatusInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPairStatusInstructionData { - discriminator: [u8; 8], -} - -impl SetPairStatusInstructionData { - pub fn new() -> Self { - Self { - discriminator: [67, 248, 231, 137, 154, 149, 217, 174], - } - } -} - -impl Default for SetPairStatusInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPairStatusInstructionArgs { - pub status: u8, -} - -/// Instruction builder for `SetPairStatus`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct SetPairStatusBuilder { - lb_pair: Option, - admin: Option, - status: Option, - __remaining_accounts: Vec, -} - -impl SetPairStatusBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn status(&mut self, status: u8) -> &mut Self { - self.status = Some(status); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetPairStatus { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - admin: self.admin.expect("admin is not set"), - }; - let args = SetPairStatusInstructionArgs { - status: self.status.clone().expect("status is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_pair_status` CPI accounts. -pub struct SetPairStatusCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_pair_status` CPI instruction. -pub struct SetPairStatusCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetPairStatusInstructionArgs, -} - -impl<'a, 'b> SetPairStatusCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetPairStatusCpiAccounts<'a, 'b>, - args: SetPairStatusInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - admin: accounts.admin, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetPairStatusInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetPairStatus` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` admin -#[derive(Clone, Debug)] -pub struct SetPairStatusCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetPairStatusCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetPairStatusCpiBuilderInstruction { - __program: program, - lb_pair: None, - admin: None, - status: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn status(&mut self, status: u8) -> &mut Self { - self.instruction.status = Some(status); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetPairStatusInstructionArgs { - status: self.instruction.status.clone().expect("status is not set"), - }; - let instruction = SetPairStatusCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetPairStatusCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - status: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/set_pair_status_permissionless.rs b/crates/meteora-parser/src/generated_sdk/instructions/set_pair_status_permissionless.rs deleted file mode 100644 index f529a3c4..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/set_pair_status_permissionless.rs +++ /dev/null @@ -1,350 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetPairStatusPermissionless { - pub lb_pair: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, -} - -impl SetPairStatusPermissionless { - pub fn instruction( - &self, - args: SetPairStatusPermissionlessInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetPairStatusPermissionlessInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetPairStatusPermissionlessInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPairStatusPermissionlessInstructionData { - discriminator: [u8; 8], -} - -impl SetPairStatusPermissionlessInstructionData { - pub fn new() -> Self { - Self { - discriminator: [78, 59, 152, 211, 70, 183, 46, 208], - } - } -} - -impl Default for SetPairStatusPermissionlessInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPairStatusPermissionlessInstructionArgs { - pub status: u8, -} - -/// Instruction builder for `SetPairStatusPermissionless`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` creator -#[derive(Clone, Debug, Default)] -pub struct SetPairStatusPermissionlessBuilder { - lb_pair: Option, - creator: Option, - status: Option, - __remaining_accounts: Vec, -} - -impl SetPairStatusPermissionlessBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn status(&mut self, status: u8) -> &mut Self { - self.status = Some(status); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetPairStatusPermissionless { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - creator: self.creator.expect("creator is not set"), - }; - let args = SetPairStatusPermissionlessInstructionArgs { - status: self.status.clone().expect("status is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_pair_status_permissionless` CPI accounts. -pub struct SetPairStatusPermissionlessCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_pair_status_permissionless` CPI instruction. -pub struct SetPairStatusPermissionlessCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetPairStatusPermissionlessInstructionArgs, -} - -impl<'a, 'b> SetPairStatusPermissionlessCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetPairStatusPermissionlessCpiAccounts<'a, 'b>, - args: SetPairStatusPermissionlessInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - creator: accounts.creator, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetPairStatusPermissionlessInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.creator.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetPairStatusPermissionless` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` creator -#[derive(Clone, Debug)] -pub struct SetPairStatusPermissionlessCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetPairStatusPermissionlessCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetPairStatusPermissionlessCpiBuilderInstruction { - __program: program, - lb_pair: None, - creator: None, - status: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn status(&mut self, status: u8) -> &mut Self { - self.instruction.status = Some(status); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetPairStatusPermissionlessInstructionArgs { - status: self.instruction.status.clone().expect("status is not set"), - }; - let instruction = SetPairStatusPermissionlessCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetPairStatusPermissionlessCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - status: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/set_pre_activation_duration.rs b/crates/meteora-parser/src/generated_sdk/instructions/set_pre_activation_duration.rs deleted file mode 100644 index be6ed1dc..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/set_pre_activation_duration.rs +++ /dev/null @@ -1,357 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetPreActivationDuration { - pub lb_pair: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, -} - -impl SetPreActivationDuration { - pub fn instruction( - &self, - args: SetPreActivationDurationInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetPreActivationDurationInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetPreActivationDurationInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPreActivationDurationInstructionData { - discriminator: [u8; 8], -} - -impl SetPreActivationDurationInstructionData { - pub fn new() -> Self { - Self { - discriminator: [165, 61, 201, 244, 130, 159, 22, 100], - } - } -} - -impl Default for SetPreActivationDurationInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPreActivationDurationInstructionArgs { - pub pre_activation_duration: u64, -} - -/// Instruction builder for `SetPreActivationDuration`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` creator -#[derive(Clone, Debug, Default)] -pub struct SetPreActivationDurationBuilder { - lb_pair: Option, - creator: Option, - pre_activation_duration: Option, - __remaining_accounts: Vec, -} - -impl SetPreActivationDurationBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn pre_activation_duration(&mut self, pre_activation_duration: u64) -> &mut Self { - self.pre_activation_duration = Some(pre_activation_duration); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetPreActivationDuration { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - creator: self.creator.expect("creator is not set"), - }; - let args = SetPreActivationDurationInstructionArgs { - pre_activation_duration: self - .pre_activation_duration - .clone() - .expect("pre_activation_duration is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_pre_activation_duration` CPI accounts. -pub struct SetPreActivationDurationCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_pre_activation_duration` CPI instruction. -pub struct SetPreActivationDurationCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetPreActivationDurationInstructionArgs, -} - -impl<'a, 'b> SetPreActivationDurationCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetPreActivationDurationCpiAccounts<'a, 'b>, - args: SetPreActivationDurationInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - creator: accounts.creator, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetPreActivationDurationInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.creator.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetPreActivationDuration` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` creator -#[derive(Clone, Debug)] -pub struct SetPreActivationDurationCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetPreActivationDurationCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetPreActivationDurationCpiBuilderInstruction { - __program: program, - lb_pair: None, - creator: None, - pre_activation_duration: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn pre_activation_duration(&mut self, pre_activation_duration: u64) -> &mut Self { - self.instruction.pre_activation_duration = Some(pre_activation_duration); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetPreActivationDurationInstructionArgs { - pre_activation_duration: self - .instruction - .pre_activation_duration - .clone() - .expect("pre_activation_duration is not set"), - }; - let instruction = SetPreActivationDurationCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetPreActivationDurationCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - pre_activation_duration: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/set_pre_activation_swap_address.rs b/crates/meteora-parser/src/generated_sdk/instructions/set_pre_activation_swap_address.rs deleted file mode 100644 index 99214ae7..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/set_pre_activation_swap_address.rs +++ /dev/null @@ -1,364 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct SetPreActivationSwapAddress { - pub lb_pair: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, -} - -impl SetPreActivationSwapAddress { - pub fn instruction( - &self, - args: SetPreActivationSwapAddressInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetPreActivationSwapAddressInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetPreActivationSwapAddressInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPreActivationSwapAddressInstructionData { - discriminator: [u8; 8], -} - -impl SetPreActivationSwapAddressInstructionData { - pub fn new() -> Self { - Self { - discriminator: [57, 139, 47, 123, 216, 80, 223, 10], - } - } -} - -impl Default for SetPreActivationSwapAddressInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPreActivationSwapAddressInstructionArgs { - pub pre_activation_swap_address: Pubkey, -} - -/// Instruction builder for `SetPreActivationSwapAddress`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` creator -#[derive(Clone, Debug, Default)] -pub struct SetPreActivationSwapAddressBuilder { - lb_pair: Option, - creator: Option, - pre_activation_swap_address: Option, - __remaining_accounts: Vec, -} - -impl SetPreActivationSwapAddressBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn pre_activation_swap_address( - &mut self, - pre_activation_swap_address: Pubkey, - ) -> &mut Self { - self.pre_activation_swap_address = Some(pre_activation_swap_address); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetPreActivationSwapAddress { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - creator: self.creator.expect("creator is not set"), - }; - let args = SetPreActivationSwapAddressInstructionArgs { - pre_activation_swap_address: self - .pre_activation_swap_address - .clone() - .expect("pre_activation_swap_address is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_pre_activation_swap_address` CPI accounts. -pub struct SetPreActivationSwapAddressCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_pre_activation_swap_address` CPI instruction. -pub struct SetPreActivationSwapAddressCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetPreActivationSwapAddressInstructionArgs, -} - -impl<'a, 'b> SetPreActivationSwapAddressCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetPreActivationSwapAddressCpiAccounts<'a, 'b>, - args: SetPreActivationSwapAddressInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - creator: accounts.creator, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetPreActivationSwapAddressInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.creator.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetPreActivationSwapAddress` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` creator -#[derive(Clone, Debug)] -pub struct SetPreActivationSwapAddressCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetPreActivationSwapAddressCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetPreActivationSwapAddressCpiBuilderInstruction { - __program: program, - lb_pair: None, - creator: None, - pre_activation_swap_address: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn pre_activation_swap_address( - &mut self, - pre_activation_swap_address: Pubkey, - ) -> &mut Self { - self.instruction.pre_activation_swap_address = Some(pre_activation_swap_address); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetPreActivationSwapAddressInstructionArgs { - pre_activation_swap_address: self - .instruction - .pre_activation_swap_address - .clone() - .expect("pre_activation_swap_address is not set"), - }; - let instruction = SetPreActivationSwapAddressCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetPreActivationSwapAddressCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - pre_activation_swap_address: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/swap.rs b/crates/meteora-parser/src/generated_sdk/instructions/swap.rs deleted file mode 100644 index de8274ae..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/swap.rs +++ /dev/null @@ -1,918 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Swap { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub user_token_in: solana_pubkey::Pubkey, - - pub user_token_out: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub host_fee_in: Option, - - pub user: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Swap { - pub fn instruction(&self, args: SwapInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_in, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_out, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new(host_fee_in, false)); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionData { - discriminator: [u8; 8], -} - -impl SwapInstructionData { - pub fn new() -> Self { - Self { - discriminator: [248, 198, 158, 145, 225, 117, 135, 200], - } - } -} - -impl Default for SwapInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionArgs { - pub amount_in: u64, - pub min_amount_out: u64, -} - -/// Instruction builder for `Swap`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SwapBuilder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - reserve_x: Option, - reserve_y: Option, - user_token_in: Option, - user_token_out: Option, - token_x_mint: Option, - token_y_mint: Option, - oracle: Option, - host_fee_in: Option, - user: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - amount_in: Option, - min_amount_out: Option, - __remaining_accounts: Vec, -} - -impl SwapBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in(&mut self, user_token_in: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out(&mut self, user_token_out: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in(&mut self, host_fee_in: Option) -> &mut Self { - self.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn min_amount_out(&mut self, min_amount_out: u64) -> &mut Self { - self.min_amount_out = Some(min_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Swap { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - user_token_in: self.user_token_in.expect("user_token_in is not set"), - user_token_out: self.user_token_out.expect("user_token_out is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - oracle: self.oracle.expect("oracle is not set"), - host_fee_in: self.host_fee_in, - user: self.user.expect("user is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SwapInstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - min_amount_out: self - .min_amount_out - .clone() - .expect("min_amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap` CPI accounts. -pub struct SwapCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap` CPI instruction. -pub struct SwapCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapInstructionArgs, -} - -impl<'a, 'b> SwapCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapCpiAccounts<'a, 'b>, - args: SwapInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - user_token_in: accounts.user_token_in, - user_token_out: accounts.user_token_out, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - oracle: accounts.oracle, - host_fee_in: accounts.host_fee_in, - user: accounts.user, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_in.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_out.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new( - *host_fee_in.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.user_token_in.clone()); - account_infos.push(self.user_token_out.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.oracle.clone()); - if let Some(host_fee_in) = self.host_fee_in { - account_infos.push(host_fee_in.clone()); - } - account_infos.push(self.user.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Swap` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct SwapCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapCpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - reserve_x: None, - reserve_y: None, - user_token_in: None, - user_token_out: None, - token_x_mint: None, - token_y_mint: None, - oracle: None, - host_fee_in: None, - user: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - amount_in: None, - min_amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in( - &mut self, - user_token_in: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out( - &mut self, - user_token_out: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in( - &mut self, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn min_amount_out(&mut self, min_amount_out: u64) -> &mut Self { - self.instruction.min_amount_out = Some(min_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapInstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - min_amount_out: self - .instruction - .min_amount_out - .clone() - .expect("min_amount_out is not set"), - }; - let instruction = SwapCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - user_token_in: self - .instruction - .user_token_in - .expect("user_token_in is not set"), - - user_token_out: self - .instruction - .user_token_out - .expect("user_token_out is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - host_fee_in: self.instruction.host_fee_in, - - user: self.instruction.user.expect("user is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_out: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - min_amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/swap2.rs b/crates/meteora-parser/src/generated_sdk/instructions/swap2.rs deleted file mode 100644 index 5e80119d..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/swap2.rs +++ /dev/null @@ -1,993 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct Swap2 { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub user_token_in: solana_pubkey::Pubkey, - - pub user_token_out: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub host_fee_in: Option, - - pub user: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Swap2 { - pub fn instruction(&self, args: Swap2InstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: Swap2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_in, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_out, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new(host_fee_in, false)); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&Swap2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Swap2InstructionData { - discriminator: [u8; 8], -} - -impl Swap2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [65, 75, 63, 76, 235, 91, 91, 136], - } - } -} - -impl Default for Swap2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Swap2InstructionArgs { - pub amount_in: u64, - pub min_amount_out: u64, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `Swap2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` memo_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct Swap2Builder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - reserve_x: Option, - reserve_y: Option, - user_token_in: Option, - user_token_out: Option, - token_x_mint: Option, - token_y_mint: Option, - oracle: Option, - host_fee_in: Option, - user: Option, - token_x_program: Option, - token_y_program: Option, - memo_program: Option, - event_authority: Option, - program: Option, - amount_in: Option, - min_amount_out: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl Swap2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in(&mut self, user_token_in: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out(&mut self, user_token_out: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in(&mut self, host_fee_in: Option) -> &mut Self { - self.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn min_amount_out(&mut self, min_amount_out: u64) -> &mut Self { - self.min_amount_out = Some(min_amount_out); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Swap2 { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - user_token_in: self.user_token_in.expect("user_token_in is not set"), - user_token_out: self.user_token_out.expect("user_token_out is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - oracle: self.oracle.expect("oracle is not set"), - host_fee_in: self.host_fee_in, - user: self.user.expect("user is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = Swap2InstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - min_amount_out: self - .min_amount_out - .clone() - .expect("min_amount_out is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap2` CPI accounts. -pub struct Swap2CpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap2` CPI instruction. -pub struct Swap2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: Swap2InstructionArgs, -} - -impl<'a, 'b> Swap2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: Swap2CpiAccounts<'a, 'b>, - args: Swap2InstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - user_token_in: accounts.user_token_in, - user_token_out: accounts.user_token_out, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - oracle: accounts.oracle, - host_fee_in: accounts.host_fee_in, - user: accounts.user, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - memo_program: accounts.memo_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_in.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_out.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new( - *host_fee_in.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&Swap2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.user_token_in.clone()); - account_infos.push(self.user_token_out.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.oracle.clone()); - if let Some(host_fee_in) = self.host_fee_in { - account_infos.push(host_fee_in.clone()); - } - account_infos.push(self.user.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Swap2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` memo_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct Swap2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> Swap2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(Swap2CpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - reserve_x: None, - reserve_y: None, - user_token_in: None, - user_token_out: None, - token_x_mint: None, - token_y_mint: None, - oracle: None, - host_fee_in: None, - user: None, - token_x_program: None, - token_y_program: None, - memo_program: None, - event_authority: None, - program: None, - amount_in: None, - min_amount_out: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in( - &mut self, - user_token_in: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out( - &mut self, - user_token_out: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in( - &mut self, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn min_amount_out(&mut self, min_amount_out: u64) -> &mut Self { - self.instruction.min_amount_out = Some(min_amount_out); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = Swap2InstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - min_amount_out: self - .instruction - .min_amount_out - .clone() - .expect("min_amount_out is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = Swap2Cpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - user_token_in: self - .instruction - .user_token_in - .expect("user_token_in is not set"), - - user_token_out: self - .instruction - .user_token_out - .expect("user_token_out is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - host_fee_in: self.instruction.host_fee_in, - - user: self.instruction.user.expect("user is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct Swap2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_out: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - min_amount_out: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/swap_exact_out.rs b/crates/meteora-parser/src/generated_sdk/instructions/swap_exact_out.rs deleted file mode 100644 index 62ed230c..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/swap_exact_out.rs +++ /dev/null @@ -1,921 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SwapExactOut { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub user_token_in: solana_pubkey::Pubkey, - - pub user_token_out: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub host_fee_in: Option, - - pub user: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SwapExactOut { - pub fn instruction( - &self, - args: SwapExactOutInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapExactOutInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_in, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_out, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new(host_fee_in, false)); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapExactOutInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapExactOutInstructionData { - discriminator: [u8; 8], -} - -impl SwapExactOutInstructionData { - pub fn new() -> Self { - Self { - discriminator: [250, 73, 101, 33, 38, 207, 75, 184], - } - } -} - -impl Default for SwapExactOutInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapExactOutInstructionArgs { - pub max_in_amount: u64, - pub out_amount: u64, -} - -/// Instruction builder for `SwapExactOut`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SwapExactOutBuilder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - reserve_x: Option, - reserve_y: Option, - user_token_in: Option, - user_token_out: Option, - token_x_mint: Option, - token_y_mint: Option, - oracle: Option, - host_fee_in: Option, - user: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - max_in_amount: Option, - out_amount: Option, - __remaining_accounts: Vec, -} - -impl SwapExactOutBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in(&mut self, user_token_in: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out(&mut self, user_token_out: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in(&mut self, host_fee_in: Option) -> &mut Self { - self.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn max_in_amount(&mut self, max_in_amount: u64) -> &mut Self { - self.max_in_amount = Some(max_in_amount); - self - } - - #[inline(always)] - pub fn out_amount(&mut self, out_amount: u64) -> &mut Self { - self.out_amount = Some(out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapExactOut { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - user_token_in: self.user_token_in.expect("user_token_in is not set"), - user_token_out: self.user_token_out.expect("user_token_out is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - oracle: self.oracle.expect("oracle is not set"), - host_fee_in: self.host_fee_in, - user: self.user.expect("user is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SwapExactOutInstructionArgs { - max_in_amount: self - .max_in_amount - .clone() - .expect("max_in_amount is not set"), - out_amount: self.out_amount.clone().expect("out_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_exact_out` CPI accounts. -pub struct SwapExactOutCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_exact_out` CPI instruction. -pub struct SwapExactOutCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapExactOutInstructionArgs, -} - -impl<'a, 'b> SwapExactOutCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapExactOutCpiAccounts<'a, 'b>, - args: SwapExactOutInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - user_token_in: accounts.user_token_in, - user_token_out: accounts.user_token_out, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - oracle: accounts.oracle, - host_fee_in: accounts.host_fee_in, - user: accounts.user, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_in.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_out.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new( - *host_fee_in.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapExactOutInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.user_token_in.clone()); - account_infos.push(self.user_token_out.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.oracle.clone()); - if let Some(host_fee_in) = self.host_fee_in { - account_infos.push(host_fee_in.clone()); - } - account_infos.push(self.user.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapExactOut` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct SwapExactOutCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapExactOutCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapExactOutCpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - reserve_x: None, - reserve_y: None, - user_token_in: None, - user_token_out: None, - token_x_mint: None, - token_y_mint: None, - oracle: None, - host_fee_in: None, - user: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - max_in_amount: None, - out_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in( - &mut self, - user_token_in: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out( - &mut self, - user_token_out: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in( - &mut self, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn max_in_amount(&mut self, max_in_amount: u64) -> &mut Self { - self.instruction.max_in_amount = Some(max_in_amount); - self - } - - #[inline(always)] - pub fn out_amount(&mut self, out_amount: u64) -> &mut Self { - self.instruction.out_amount = Some(out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapExactOutInstructionArgs { - max_in_amount: self - .instruction - .max_in_amount - .clone() - .expect("max_in_amount is not set"), - out_amount: self - .instruction - .out_amount - .clone() - .expect("out_amount is not set"), - }; - let instruction = SwapExactOutCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - user_token_in: self - .instruction - .user_token_in - .expect("user_token_in is not set"), - - user_token_out: self - .instruction - .user_token_out - .expect("user_token_out is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - host_fee_in: self.instruction.host_fee_in, - - user: self.instruction.user.expect("user is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapExactOutCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_out: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - max_in_amount: Option, - out_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/swap_exact_out2.rs b/crates/meteora-parser/src/generated_sdk/instructions/swap_exact_out2.rs deleted file mode 100644 index 0dffcd7a..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/swap_exact_out2.rs +++ /dev/null @@ -1,996 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct SwapExactOut2 { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub user_token_in: solana_pubkey::Pubkey, - - pub user_token_out: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub host_fee_in: Option, - - pub user: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SwapExactOut2 { - pub fn instruction( - &self, - args: SwapExactOut2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapExactOut2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_in, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_out, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new(host_fee_in, false)); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapExactOut2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapExactOut2InstructionData { - discriminator: [u8; 8], -} - -impl SwapExactOut2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [43, 215, 247, 132, 137, 60, 243, 81], - } - } -} - -impl Default for SwapExactOut2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapExactOut2InstructionArgs { - pub max_in_amount: u64, - pub out_amount: u64, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `SwapExactOut2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` memo_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SwapExactOut2Builder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - reserve_x: Option, - reserve_y: Option, - user_token_in: Option, - user_token_out: Option, - token_x_mint: Option, - token_y_mint: Option, - oracle: Option, - host_fee_in: Option, - user: Option, - token_x_program: Option, - token_y_program: Option, - memo_program: Option, - event_authority: Option, - program: Option, - max_in_amount: Option, - out_amount: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl SwapExactOut2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in(&mut self, user_token_in: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out(&mut self, user_token_out: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in(&mut self, host_fee_in: Option) -> &mut Self { - self.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn max_in_amount(&mut self, max_in_amount: u64) -> &mut Self { - self.max_in_amount = Some(max_in_amount); - self - } - - #[inline(always)] - pub fn out_amount(&mut self, out_amount: u64) -> &mut Self { - self.out_amount = Some(out_amount); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapExactOut2 { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - user_token_in: self.user_token_in.expect("user_token_in is not set"), - user_token_out: self.user_token_out.expect("user_token_out is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - oracle: self.oracle.expect("oracle is not set"), - host_fee_in: self.host_fee_in, - user: self.user.expect("user is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SwapExactOut2InstructionArgs { - max_in_amount: self - .max_in_amount - .clone() - .expect("max_in_amount is not set"), - out_amount: self.out_amount.clone().expect("out_amount is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_exact_out2` CPI accounts. -pub struct SwapExactOut2CpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_exact_out2` CPI instruction. -pub struct SwapExactOut2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapExactOut2InstructionArgs, -} - -impl<'a, 'b> SwapExactOut2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapExactOut2CpiAccounts<'a, 'b>, - args: SwapExactOut2InstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - user_token_in: accounts.user_token_in, - user_token_out: accounts.user_token_out, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - oracle: accounts.oracle, - host_fee_in: accounts.host_fee_in, - user: accounts.user, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - memo_program: accounts.memo_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_in.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_out.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new( - *host_fee_in.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapExactOut2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.user_token_in.clone()); - account_infos.push(self.user_token_out.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.oracle.clone()); - if let Some(host_fee_in) = self.host_fee_in { - account_infos.push(host_fee_in.clone()); - } - account_infos.push(self.user.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapExactOut2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` memo_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct SwapExactOut2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapExactOut2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapExactOut2CpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - reserve_x: None, - reserve_y: None, - user_token_in: None, - user_token_out: None, - token_x_mint: None, - token_y_mint: None, - oracle: None, - host_fee_in: None, - user: None, - token_x_program: None, - token_y_program: None, - memo_program: None, - event_authority: None, - program: None, - max_in_amount: None, - out_amount: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in( - &mut self, - user_token_in: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out( - &mut self, - user_token_out: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in( - &mut self, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn max_in_amount(&mut self, max_in_amount: u64) -> &mut Self { - self.instruction.max_in_amount = Some(max_in_amount); - self - } - - #[inline(always)] - pub fn out_amount(&mut self, out_amount: u64) -> &mut Self { - self.instruction.out_amount = Some(out_amount); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapExactOut2InstructionArgs { - max_in_amount: self - .instruction - .max_in_amount - .clone() - .expect("max_in_amount is not set"), - out_amount: self - .instruction - .out_amount - .clone() - .expect("out_amount is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = SwapExactOut2Cpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - user_token_in: self - .instruction - .user_token_in - .expect("user_token_in is not set"), - - user_token_out: self - .instruction - .user_token_out - .expect("user_token_out is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - host_fee_in: self.instruction.host_fee_in, - - user: self.instruction.user.expect("user is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapExactOut2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_out: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - max_in_amount: Option, - out_amount: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/swap_with_price_impact.rs b/crates/meteora-parser/src/generated_sdk/instructions/swap_with_price_impact.rs deleted file mode 100644 index 80466146..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/swap_with_price_impact.rs +++ /dev/null @@ -1,941 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SwapWithPriceImpact { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub user_token_in: solana_pubkey::Pubkey, - - pub user_token_out: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub host_fee_in: Option, - - pub user: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SwapWithPriceImpact { - pub fn instruction( - &self, - args: SwapWithPriceImpactInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapWithPriceImpactInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_in, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_out, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new(host_fee_in, false)); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapWithPriceImpactInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapWithPriceImpactInstructionData { - discriminator: [u8; 8], -} - -impl SwapWithPriceImpactInstructionData { - pub fn new() -> Self { - Self { - discriminator: [56, 173, 230, 208, 173, 228, 156, 205], - } - } -} - -impl Default for SwapWithPriceImpactInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapWithPriceImpactInstructionArgs { - pub amount_in: u64, - pub active_id: Option, - pub max_price_impact_bps: u16, -} - -/// Instruction builder for `SwapWithPriceImpact`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SwapWithPriceImpactBuilder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - reserve_x: Option, - reserve_y: Option, - user_token_in: Option, - user_token_out: Option, - token_x_mint: Option, - token_y_mint: Option, - oracle: Option, - host_fee_in: Option, - user: Option, - token_x_program: Option, - token_y_program: Option, - event_authority: Option, - program: Option, - amount_in: Option, - active_id: Option, - max_price_impact_bps: Option, - __remaining_accounts: Vec, -} - -impl SwapWithPriceImpactBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in(&mut self, user_token_in: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out(&mut self, user_token_out: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in(&mut self, host_fee_in: Option) -> &mut Self { - self.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn max_price_impact_bps(&mut self, max_price_impact_bps: u16) -> &mut Self { - self.max_price_impact_bps = Some(max_price_impact_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapWithPriceImpact { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - user_token_in: self.user_token_in.expect("user_token_in is not set"), - user_token_out: self.user_token_out.expect("user_token_out is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - oracle: self.oracle.expect("oracle is not set"), - host_fee_in: self.host_fee_in, - user: self.user.expect("user is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SwapWithPriceImpactInstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - active_id: self.active_id.clone(), - max_price_impact_bps: self - .max_price_impact_bps - .clone() - .expect("max_price_impact_bps is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_with_price_impact` CPI accounts. -pub struct SwapWithPriceImpactCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_with_price_impact` CPI instruction. -pub struct SwapWithPriceImpactCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapWithPriceImpactInstructionArgs, -} - -impl<'a, 'b> SwapWithPriceImpactCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapWithPriceImpactCpiAccounts<'a, 'b>, - args: SwapWithPriceImpactInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - user_token_in: accounts.user_token_in, - user_token_out: accounts.user_token_out, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - oracle: accounts.oracle, - host_fee_in: accounts.host_fee_in, - user: accounts.user, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_in.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_out.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new( - *host_fee_in.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapWithPriceImpactInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.user_token_in.clone()); - account_infos.push(self.user_token_out.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.oracle.clone()); - if let Some(host_fee_in) = self.host_fee_in { - account_infos.push(host_fee_in.clone()); - } - account_infos.push(self.user.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapWithPriceImpact` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct SwapWithPriceImpactCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapWithPriceImpactCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapWithPriceImpactCpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - reserve_x: None, - reserve_y: None, - user_token_in: None, - user_token_out: None, - token_x_mint: None, - token_y_mint: None, - oracle: None, - host_fee_in: None, - user: None, - token_x_program: None, - token_y_program: None, - event_authority: None, - program: None, - amount_in: None, - active_id: None, - max_price_impact_bps: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in( - &mut self, - user_token_in: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out( - &mut self, - user_token_out: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in( - &mut self, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.instruction.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn max_price_impact_bps(&mut self, max_price_impact_bps: u16) -> &mut Self { - self.instruction.max_price_impact_bps = Some(max_price_impact_bps); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapWithPriceImpactInstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - active_id: self.instruction.active_id.clone(), - max_price_impact_bps: self - .instruction - .max_price_impact_bps - .clone() - .expect("max_price_impact_bps is not set"), - }; - let instruction = SwapWithPriceImpactCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - user_token_in: self - .instruction - .user_token_in - .expect("user_token_in is not set"), - - user_token_out: self - .instruction - .user_token_out - .expect("user_token_out is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - host_fee_in: self.instruction.host_fee_in, - - user: self.instruction.user.expect("user is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapWithPriceImpactCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_out: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - active_id: Option, - max_price_impact_bps: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/swap_with_price_impact2.rs b/crates/meteora-parser/src/generated_sdk/instructions/swap_with_price_impact2.rs deleted file mode 100644 index 05d5c74f..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/swap_with_price_impact2.rs +++ /dev/null @@ -1,1016 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct SwapWithPriceImpact2 { - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_bitmap_extension: Option, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub user_token_in: solana_pubkey::Pubkey, - - pub user_token_out: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub host_fee_in: Option, - - pub user: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SwapWithPriceImpact2 { - pub fn instruction( - &self, - args: SwapWithPriceImpact2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapWithPriceImpact2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - bin_array_bitmap_extension, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_in, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_out, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new(host_fee_in, false)); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapWithPriceImpact2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapWithPriceImpact2InstructionData { - discriminator: [u8; 8], -} - -impl SwapWithPriceImpact2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [74, 98, 192, 214, 177, 51, 75, 51], - } - } -} - -impl Default for SwapWithPriceImpact2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapWithPriceImpact2InstructionArgs { - pub amount_in: u64, - pub active_id: Option, - pub max_price_impact_bps: u16, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `SwapWithPriceImpact2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` memo_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SwapWithPriceImpact2Builder { - lb_pair: Option, - bin_array_bitmap_extension: Option, - reserve_x: Option, - reserve_y: Option, - user_token_in: Option, - user_token_out: Option, - token_x_mint: Option, - token_y_mint: Option, - oracle: Option, - host_fee_in: Option, - user: Option, - token_x_program: Option, - token_y_program: Option, - memo_program: Option, - event_authority: Option, - program: Option, - amount_in: Option, - active_id: Option, - max_price_impact_bps: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl SwapWithPriceImpact2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option, - ) -> &mut Self { - self.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in(&mut self, user_token_in: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out(&mut self, user_token_out: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in(&mut self, host_fee_in: Option) -> &mut Self { - self.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn max_price_impact_bps(&mut self, max_price_impact_bps: u16) -> &mut Self { - self.max_price_impact_bps = Some(max_price_impact_bps); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapWithPriceImpact2 { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_bitmap_extension: self.bin_array_bitmap_extension, - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - user_token_in: self.user_token_in.expect("user_token_in is not set"), - user_token_out: self.user_token_out.expect("user_token_out is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - oracle: self.oracle.expect("oracle is not set"), - host_fee_in: self.host_fee_in, - user: self.user.expect("user is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SwapWithPriceImpact2InstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - active_id: self.active_id.clone(), - max_price_impact_bps: self - .max_price_impact_bps - .clone() - .expect("max_price_impact_bps is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_with_price_impact2` CPI accounts. -pub struct SwapWithPriceImpact2CpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_with_price_impact2` CPI instruction. -pub struct SwapWithPriceImpact2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_in: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_out: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapWithPriceImpact2InstructionArgs, -} - -impl<'a, 'b> SwapWithPriceImpact2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapWithPriceImpact2CpiAccounts<'a, 'b>, - args: SwapWithPriceImpact2InstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - bin_array_bitmap_extension: accounts.bin_array_bitmap_extension, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - user_token_in: accounts.user_token_in, - user_token_out: accounts.user_token_out, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - oracle: accounts.oracle, - host_fee_in: accounts.host_fee_in, - user: accounts.user, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - memo_program: accounts.memo_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - accounts.push(solana_instruction::AccountMeta::new_readonly( - *bin_array_bitmap_extension.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_in.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_out.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - if let Some(host_fee_in) = self.host_fee_in { - accounts.push(solana_instruction::AccountMeta::new( - *host_fee_in.key, - false, - )); - } else { - accounts.push(solana_instruction::AccountMeta::new_readonly( - crate::LB_CLMM_ID, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapWithPriceImpact2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - if let Some(bin_array_bitmap_extension) = self.bin_array_bitmap_extension { - account_infos.push(bin_array_bitmap_extension.clone()); - } - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.user_token_in.clone()); - account_infos.push(self.user_token_out.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.oracle.clone()); - if let Some(host_fee_in) = self.host_fee_in { - account_infos.push(host_fee_in.clone()); - } - account_infos.push(self.user.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapWithPriceImpact2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[optional]` bin_array_bitmap_extension -/// 2. `[writable]` reserve_x -/// 3. `[writable]` reserve_y -/// 4. `[writable]` user_token_in -/// 5. `[writable]` user_token_out -/// 6. `[]` token_x_mint -/// 7. `[]` token_y_mint -/// 8. `[writable]` oracle -/// 9. `[writable, optional]` host_fee_in -/// 10. `[signer]` user -/// 11. `[]` token_x_program -/// 12. `[]` token_y_program -/// 13. `[]` memo_program -/// 14. `[]` event_authority -/// 15. `[]` program -#[derive(Clone, Debug)] -pub struct SwapWithPriceImpact2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapWithPriceImpact2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapWithPriceImpact2CpiBuilderInstruction { - __program: program, - lb_pair: None, - bin_array_bitmap_extension: None, - reserve_x: None, - reserve_y: None, - user_token_in: None, - user_token_out: None, - token_x_mint: None, - token_y_mint: None, - oracle: None, - host_fee_in: None, - user: None, - token_x_program: None, - token_y_program: None, - memo_program: None, - event_authority: None, - program: None, - amount_in: None, - active_id: None, - max_price_impact_bps: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn bin_array_bitmap_extension( - &mut self, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.bin_array_bitmap_extension = bin_array_bitmap_extension; - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn user_token_in( - &mut self, - user_token_in: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_in = Some(user_token_in); - self - } - - #[inline(always)] - pub fn user_token_out( - &mut self, - user_token_out: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_out = Some(user_token_out); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn host_fee_in( - &mut self, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.host_fee_in = host_fee_in; - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn active_id(&mut self, active_id: i32) -> &mut Self { - self.instruction.active_id = Some(active_id); - self - } - - #[inline(always)] - pub fn max_price_impact_bps(&mut self, max_price_impact_bps: u16) -> &mut Self { - self.instruction.max_price_impact_bps = Some(max_price_impact_bps); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapWithPriceImpact2InstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - active_id: self.instruction.active_id.clone(), - max_price_impact_bps: self - .instruction - .max_price_impact_bps - .clone() - .expect("max_price_impact_bps is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = SwapWithPriceImpact2Cpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_bitmap_extension: self.instruction.bin_array_bitmap_extension, - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - user_token_in: self - .instruction - .user_token_in - .expect("user_token_in is not set"), - - user_token_out: self - .instruction - .user_token_out - .expect("user_token_out is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - host_fee_in: self.instruction.host_fee_in, - - user: self.instruction.user.expect("user is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapWithPriceImpact2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_bitmap_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_out: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - host_fee_in: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - active_id: Option, - max_price_impact_bps: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/update_base_fee_parameters.rs b/crates/meteora-parser/src/generated_sdk/instructions/update_base_fee_parameters.rs deleted file mode 100644 index 4c2b34fc..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/update_base_fee_parameters.rs +++ /dev/null @@ -1,481 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateBaseFeeParameters { - pub lb_pair: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl UpdateBaseFeeParameters { - pub fn instruction( - &self, - args: UpdateBaseFeeParametersInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateBaseFeeParametersInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateBaseFeeParametersInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateBaseFeeParametersInstructionData { - discriminator: [u8; 8], -} - -impl UpdateBaseFeeParametersInstructionData { - pub fn new() -> Self { - Self { - discriminator: [75, 168, 223, 161, 16, 195, 3, 47], - } - } -} - -impl Default for UpdateBaseFeeParametersInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateBaseFeeParametersInstructionArgs { - pub protocol_share: u16, - pub base_factor: u16, - pub base_fee_power_factor: u8, -} - -/// Instruction builder for `UpdateBaseFeeParameters`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` admin -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug, Default)] -pub struct UpdateBaseFeeParametersBuilder { - lb_pair: Option, - admin: Option, - event_authority: Option, - program: Option, - protocol_share: Option, - base_factor: Option, - base_fee_power_factor: Option, - __remaining_accounts: Vec, -} - -impl UpdateBaseFeeParametersBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn protocol_share(&mut self, protocol_share: u16) -> &mut Self { - self.protocol_share = Some(protocol_share); - self - } - - #[inline(always)] - pub fn base_factor(&mut self, base_factor: u16) -> &mut Self { - self.base_factor = Some(base_factor); - self - } - - #[inline(always)] - pub fn base_fee_power_factor(&mut self, base_fee_power_factor: u8) -> &mut Self { - self.base_fee_power_factor = Some(base_fee_power_factor); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateBaseFeeParameters { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - admin: self.admin.expect("admin is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = UpdateBaseFeeParametersInstructionArgs { - protocol_share: self - .protocol_share - .clone() - .expect("protocol_share is not set"), - base_factor: self.base_factor.clone().expect("base_factor is not set"), - base_fee_power_factor: self - .base_fee_power_factor - .clone() - .expect("base_fee_power_factor is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_base_fee_parameters` CPI accounts. -pub struct UpdateBaseFeeParametersCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_base_fee_parameters` CPI instruction. -pub struct UpdateBaseFeeParametersCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateBaseFeeParametersInstructionArgs, -} - -impl<'a, 'b> UpdateBaseFeeParametersCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateBaseFeeParametersCpiAccounts<'a, 'b>, - args: UpdateBaseFeeParametersInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - admin: accounts.admin, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateBaseFeeParametersInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateBaseFeeParameters` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` admin -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug)] -pub struct UpdateBaseFeeParametersCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateBaseFeeParametersCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateBaseFeeParametersCpiBuilderInstruction { - __program: program, - lb_pair: None, - admin: None, - event_authority: None, - program: None, - protocol_share: None, - base_factor: None, - base_fee_power_factor: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn protocol_share(&mut self, protocol_share: u16) -> &mut Self { - self.instruction.protocol_share = Some(protocol_share); - self - } - - #[inline(always)] - pub fn base_factor(&mut self, base_factor: u16) -> &mut Self { - self.instruction.base_factor = Some(base_factor); - self - } - - #[inline(always)] - pub fn base_fee_power_factor(&mut self, base_fee_power_factor: u8) -> &mut Self { - self.instruction.base_fee_power_factor = Some(base_fee_power_factor); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateBaseFeeParametersInstructionArgs { - protocol_share: self - .instruction - .protocol_share - .clone() - .expect("protocol_share is not set"), - base_factor: self - .instruction - .base_factor - .clone() - .expect("base_factor is not set"), - base_fee_power_factor: self - .instruction - .base_fee_power_factor - .clone() - .expect("base_fee_power_factor is not set"), - }; - let instruction = UpdateBaseFeeParametersCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateBaseFeeParametersCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_share: Option, - base_factor: Option, - base_fee_power_factor: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/update_dynamic_fee_parameters.rs b/crates/meteora-parser/src/generated_sdk/instructions/update_dynamic_fee_parameters.rs deleted file mode 100644 index a164c5ed..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/update_dynamic_fee_parameters.rs +++ /dev/null @@ -1,531 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateDynamicFeeParameters { - pub lb_pair: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl UpdateDynamicFeeParameters { - pub fn instruction( - &self, - args: UpdateDynamicFeeParametersInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateDynamicFeeParametersInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateDynamicFeeParametersInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateDynamicFeeParametersInstructionData { - discriminator: [u8; 8], -} - -impl UpdateDynamicFeeParametersInstructionData { - pub fn new() -> Self { - Self { - discriminator: [92, 161, 46, 246, 255, 189, 22, 22], - } - } -} - -impl Default for UpdateDynamicFeeParametersInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateDynamicFeeParametersInstructionArgs { - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub variable_fee_control: u32, - pub max_volatility_accumulator: u32, -} - -/// Instruction builder for `UpdateDynamicFeeParameters`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` admin -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug, Default)] -pub struct UpdateDynamicFeeParametersBuilder { - lb_pair: Option, - admin: Option, - event_authority: Option, - program: Option, - filter_period: Option, - decay_period: Option, - reduction_factor: Option, - variable_fee_control: Option, - max_volatility_accumulator: Option, - __remaining_accounts: Vec, -} - -impl UpdateDynamicFeeParametersBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn filter_period(&mut self, filter_period: u16) -> &mut Self { - self.filter_period = Some(filter_period); - self - } - - #[inline(always)] - pub fn decay_period(&mut self, decay_period: u16) -> &mut Self { - self.decay_period = Some(decay_period); - self - } - - #[inline(always)] - pub fn reduction_factor(&mut self, reduction_factor: u16) -> &mut Self { - self.reduction_factor = Some(reduction_factor); - self - } - - #[inline(always)] - pub fn variable_fee_control(&mut self, variable_fee_control: u32) -> &mut Self { - self.variable_fee_control = Some(variable_fee_control); - self - } - - #[inline(always)] - pub fn max_volatility_accumulator(&mut self, max_volatility_accumulator: u32) -> &mut Self { - self.max_volatility_accumulator = Some(max_volatility_accumulator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateDynamicFeeParameters { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - admin: self.admin.expect("admin is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = UpdateDynamicFeeParametersInstructionArgs { - filter_period: self - .filter_period - .clone() - .expect("filter_period is not set"), - decay_period: self.decay_period.clone().expect("decay_period is not set"), - reduction_factor: self - .reduction_factor - .clone() - .expect("reduction_factor is not set"), - variable_fee_control: self - .variable_fee_control - .clone() - .expect("variable_fee_control is not set"), - max_volatility_accumulator: self - .max_volatility_accumulator - .clone() - .expect("max_volatility_accumulator is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_dynamic_fee_parameters` CPI accounts. -pub struct UpdateDynamicFeeParametersCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_dynamic_fee_parameters` CPI instruction. -pub struct UpdateDynamicFeeParametersCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateDynamicFeeParametersInstructionArgs, -} - -impl<'a, 'b> UpdateDynamicFeeParametersCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateDynamicFeeParametersCpiAccounts<'a, 'b>, - args: UpdateDynamicFeeParametersInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - admin: accounts.admin, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateDynamicFeeParametersInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateDynamicFeeParameters` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` admin -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug)] -pub struct UpdateDynamicFeeParametersCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateDynamicFeeParametersCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateDynamicFeeParametersCpiBuilderInstruction { - __program: program, - lb_pair: None, - admin: None, - event_authority: None, - program: None, - filter_period: None, - decay_period: None, - reduction_factor: None, - variable_fee_control: None, - max_volatility_accumulator: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn filter_period(&mut self, filter_period: u16) -> &mut Self { - self.instruction.filter_period = Some(filter_period); - self - } - - #[inline(always)] - pub fn decay_period(&mut self, decay_period: u16) -> &mut Self { - self.instruction.decay_period = Some(decay_period); - self - } - - #[inline(always)] - pub fn reduction_factor(&mut self, reduction_factor: u16) -> &mut Self { - self.instruction.reduction_factor = Some(reduction_factor); - self - } - - #[inline(always)] - pub fn variable_fee_control(&mut self, variable_fee_control: u32) -> &mut Self { - self.instruction.variable_fee_control = Some(variable_fee_control); - self - } - - #[inline(always)] - pub fn max_volatility_accumulator(&mut self, max_volatility_accumulator: u32) -> &mut Self { - self.instruction.max_volatility_accumulator = Some(max_volatility_accumulator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateDynamicFeeParametersInstructionArgs { - filter_period: self - .instruction - .filter_period - .clone() - .expect("filter_period is not set"), - decay_period: self - .instruction - .decay_period - .clone() - .expect("decay_period is not set"), - reduction_factor: self - .instruction - .reduction_factor - .clone() - .expect("reduction_factor is not set"), - variable_fee_control: self - .instruction - .variable_fee_control - .clone() - .expect("variable_fee_control is not set"), - max_volatility_accumulator: self - .instruction - .max_volatility_accumulator - .clone() - .expect("max_volatility_accumulator is not set"), - }; - let instruction = UpdateDynamicFeeParametersCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateDynamicFeeParametersCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - filter_period: Option, - decay_period: Option, - reduction_factor: Option, - variable_fee_control: Option, - max_volatility_accumulator: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/update_fees_and_reward2.rs b/crates/meteora-parser/src/generated_sdk/instructions/update_fees_and_reward2.rs deleted file mode 100644 index b0b09b72..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/update_fees_and_reward2.rs +++ /dev/null @@ -1,408 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateFeesAndReward2 { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, -} - -impl UpdateFeesAndReward2 { - pub fn instruction( - &self, - args: UpdateFeesAndReward2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateFeesAndReward2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateFeesAndReward2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateFeesAndReward2InstructionData { - discriminator: [u8; 8], -} - -impl UpdateFeesAndReward2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [32, 142, 184, 154, 103, 65, 184, 88], - } - } -} - -impl Default for UpdateFeesAndReward2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateFeesAndReward2InstructionArgs { - pub min_bin_id: i32, - pub max_bin_id: i32, -} - -/// Instruction builder for `UpdateFeesAndReward2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[signer]` owner -#[derive(Clone, Debug, Default)] -pub struct UpdateFeesAndReward2Builder { - position: Option, - lb_pair: Option, - owner: Option, - min_bin_id: Option, - max_bin_id: Option, - __remaining_accounts: Vec, -} - -impl UpdateFeesAndReward2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn min_bin_id(&mut self, min_bin_id: i32) -> &mut Self { - self.min_bin_id = Some(min_bin_id); - self - } - - #[inline(always)] - pub fn max_bin_id(&mut self, max_bin_id: i32) -> &mut Self { - self.max_bin_id = Some(max_bin_id); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateFeesAndReward2 { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - owner: self.owner.expect("owner is not set"), - }; - let args = UpdateFeesAndReward2InstructionArgs { - min_bin_id: self.min_bin_id.clone().expect("min_bin_id is not set"), - max_bin_id: self.max_bin_id.clone().expect("max_bin_id is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_fees_and_reward2` CPI accounts. -pub struct UpdateFeesAndReward2CpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_fees_and_reward2` CPI instruction. -pub struct UpdateFeesAndReward2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateFeesAndReward2InstructionArgs, -} - -impl<'a, 'b> UpdateFeesAndReward2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateFeesAndReward2CpiAccounts<'a, 'b>, - args: UpdateFeesAndReward2InstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - owner: accounts.owner, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateFeesAndReward2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.owner.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateFeesAndReward2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[signer]` owner -#[derive(Clone, Debug)] -pub struct UpdateFeesAndReward2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateFeesAndReward2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateFeesAndReward2CpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - owner: None, - min_bin_id: None, - max_bin_id: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn min_bin_id(&mut self, min_bin_id: i32) -> &mut Self { - self.instruction.min_bin_id = Some(min_bin_id); - self - } - - #[inline(always)] - pub fn max_bin_id(&mut self, max_bin_id: i32) -> &mut Self { - self.instruction.max_bin_id = Some(max_bin_id); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateFeesAndReward2InstructionArgs { - min_bin_id: self - .instruction - .min_bin_id - .clone() - .expect("min_bin_id is not set"), - max_bin_id: self - .instruction - .max_bin_id - .clone() - .expect("max_bin_id is not set"), - }; - let instruction = UpdateFeesAndReward2Cpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateFeesAndReward2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - min_bin_id: Option, - max_bin_id: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/update_fees_and_rewards.rs b/crates/meteora-parser/src/generated_sdk/instructions/update_fees_and_rewards.rs deleted file mode 100644 index dfcc853d..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/update_fees_and_rewards.rs +++ /dev/null @@ -1,426 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateFeesAndRewards { - pub position: solana_pubkey::Pubkey, - - pub lb_pair: solana_pubkey::Pubkey, - - pub bin_array_lower: solana_pubkey::Pubkey, - - pub bin_array_upper: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, -} - -impl UpdateFeesAndRewards { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bin_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&UpdateFeesAndRewardsInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateFeesAndRewardsInstructionData { - discriminator: [u8; 8], -} - -impl UpdateFeesAndRewardsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [154, 230, 250, 13, 236, 209, 75, 223], - } - } -} - -impl Default for UpdateFeesAndRewardsInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `UpdateFeesAndRewards`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable]` bin_array_lower -/// 3. `[writable]` bin_array_upper -/// 4. `[signer]` owner -#[derive(Clone, Debug, Default)] -pub struct UpdateFeesAndRewardsBuilder { - position: Option, - lb_pair: Option, - bin_array_lower: Option, - bin_array_upper: Option, - owner: Option, - __remaining_accounts: Vec, -} - -impl UpdateFeesAndRewardsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateFeesAndRewards { - position: self.position.expect("position is not set"), - lb_pair: self.lb_pair.expect("lb_pair is not set"), - bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"), - bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"), - owner: self.owner.expect("owner is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `update_fees_and_rewards` CPI accounts. -pub struct UpdateFeesAndRewardsCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_fees_and_rewards` CPI instruction. -pub struct UpdateFeesAndRewardsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> UpdateFeesAndRewardsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateFeesAndRewardsCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position: accounts.position, - lb_pair: accounts.lb_pair, - bin_array_lower: accounts.bin_array_lower, - bin_array_upper: accounts.bin_array_upper, - owner: accounts.owner, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&UpdateFeesAndRewardsInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.bin_array_lower.clone()); - account_infos.push(self.bin_array_upper.clone()); - account_infos.push(self.owner.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateFeesAndRewards` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[writable]` lb_pair -/// 2. `[writable]` bin_array_lower -/// 3. `[writable]` bin_array_upper -/// 4. `[signer]` owner -#[derive(Clone, Debug)] -pub struct UpdateFeesAndRewardsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateFeesAndRewardsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateFeesAndRewardsCpiBuilderInstruction { - __program: program, - position: None, - lb_pair: None, - bin_array_lower: None, - bin_array_upper: None, - owner: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn bin_array_lower( - &mut self, - bin_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_lower = Some(bin_array_lower); - self - } - - #[inline(always)] - pub fn bin_array_upper( - &mut self, - bin_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bin_array_upper = Some(bin_array_upper); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = UpdateFeesAndRewardsCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - bin_array_lower: self - .instruction - .bin_array_lower - .expect("bin_array_lower is not set"), - - bin_array_upper: self - .instruction - .bin_array_upper - .expect("bin_array_upper is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateFeesAndRewardsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/update_position_operator.rs b/crates/meteora-parser/src/generated_sdk/instructions/update_position_operator.rs deleted file mode 100644 index f0cac6e5..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/update_position_operator.rs +++ /dev/null @@ -1,432 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct UpdatePositionOperator { - pub position: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl UpdatePositionOperator { - pub fn instruction( - &self, - args: UpdatePositionOperatorInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdatePositionOperatorInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdatePositionOperatorInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePositionOperatorInstructionData { - discriminator: [u8; 8], -} - -impl UpdatePositionOperatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [202, 184, 103, 143, 180, 191, 116, 217], - } - } -} - -impl Default for UpdatePositionOperatorInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePositionOperatorInstructionArgs { - pub operator: Pubkey, -} - -/// Instruction builder for `UpdatePositionOperator`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[signer]` owner -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug, Default)] -pub struct UpdatePositionOperatorBuilder { - position: Option, - owner: Option, - event_authority: Option, - program: Option, - operator: Option, - __remaining_accounts: Vec, -} - -impl UpdatePositionOperatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdatePositionOperator { - position: self.position.expect("position is not set"), - owner: self.owner.expect("owner is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = UpdatePositionOperatorInstructionArgs { - operator: self.operator.clone().expect("operator is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_position_operator` CPI accounts. -pub struct UpdatePositionOperatorCpiAccounts<'a, 'b> { - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_position_operator` CPI instruction. -pub struct UpdatePositionOperatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdatePositionOperatorInstructionArgs, -} - -impl<'a, 'b> UpdatePositionOperatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdatePositionOperatorCpiAccounts<'a, 'b>, - args: UpdatePositionOperatorInstructionArgs, - ) -> Self { - Self { - __program: program, - position: accounts.position, - owner: accounts.owner, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdatePositionOperatorInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdatePositionOperator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position -/// 1. `[signer]` owner -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug)] -pub struct UpdatePositionOperatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdatePositionOperatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdatePositionOperatorCpiBuilderInstruction { - __program: program, - position: None, - owner: None, - event_authority: None, - program: None, - operator: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: Pubkey) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdatePositionOperatorInstructionArgs { - operator: self - .instruction - .operator - .clone() - .expect("operator is not set"), - }; - let instruction = UpdatePositionOperatorCpi { - __program: self.instruction.__program, - - position: self.instruction.position.expect("position is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdatePositionOperatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/update_reward_duration.rs b/crates/meteora-parser/src/generated_sdk/instructions/update_reward_duration.rs deleted file mode 100644 index 6e36bfd7..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/update_reward_duration.rs +++ /dev/null @@ -1,486 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateRewardDuration { - pub lb_pair: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub bin_array: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl UpdateRewardDuration { - pub fn instruction( - &self, - args: UpdateRewardDurationInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateRewardDurationInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.bin_array, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateRewardDurationInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateRewardDurationInstructionData { - discriminator: [u8; 8], -} - -impl UpdateRewardDurationInstructionData { - pub fn new() -> Self { - Self { - discriminator: [138, 174, 196, 169, 213, 235, 254, 107], - } - } -} - -impl Default for UpdateRewardDurationInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateRewardDurationInstructionArgs { - pub reward_index: u64, - pub new_duration: u64, -} - -/// Instruction builder for `UpdateRewardDuration`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` admin -/// 2. `[writable]` bin_array -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct UpdateRewardDurationBuilder { - lb_pair: Option, - admin: Option, - bin_array: Option, - event_authority: Option, - program: Option, - reward_index: Option, - new_duration: Option, - __remaining_accounts: Vec, -} - -impl UpdateRewardDurationBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn bin_array(&mut self, bin_array: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array = Some(bin_array); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn new_duration(&mut self, new_duration: u64) -> &mut Self { - self.new_duration = Some(new_duration); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateRewardDuration { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - admin: self.admin.expect("admin is not set"), - bin_array: self.bin_array.expect("bin_array is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = UpdateRewardDurationInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - new_duration: self.new_duration.clone().expect("new_duration is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_reward_duration` CPI accounts. -pub struct UpdateRewardDurationCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_reward_duration` CPI instruction. -pub struct UpdateRewardDurationCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateRewardDurationInstructionArgs, -} - -impl<'a, 'b> UpdateRewardDurationCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateRewardDurationCpiAccounts<'a, 'b>, - args: UpdateRewardDurationInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - admin: accounts.admin, - bin_array: accounts.bin_array, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateRewardDurationInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.bin_array.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateRewardDuration` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` admin -/// 2. `[writable]` bin_array -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct UpdateRewardDurationCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateRewardDurationCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateRewardDurationCpiBuilderInstruction { - __program: program, - lb_pair: None, - admin: None, - bin_array: None, - event_authority: None, - program: None, - reward_index: None, - new_duration: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn bin_array(&mut self, bin_array: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.bin_array = Some(bin_array); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn new_duration(&mut self, new_duration: u64) -> &mut Self { - self.instruction.new_duration = Some(new_duration); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateRewardDurationInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - new_duration: self - .instruction - .new_duration - .clone() - .expect("new_duration is not set"), - }; - let instruction = UpdateRewardDurationCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - bin_array: self.instruction.bin_array.expect("bin_array is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateRewardDurationCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - new_duration: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/update_reward_funder.rs b/crates/meteora-parser/src/generated_sdk/instructions/update_reward_funder.rs deleted file mode 100644 index 5a305875..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/update_reward_funder.rs +++ /dev/null @@ -1,454 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateRewardFunder { - pub lb_pair: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl UpdateRewardFunder { - pub fn instruction( - &self, - args: UpdateRewardFunderInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateRewardFunderInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateRewardFunderInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateRewardFunderInstructionData { - discriminator: [u8; 8], -} - -impl UpdateRewardFunderInstructionData { - pub fn new() -> Self { - Self { - discriminator: [211, 28, 48, 32, 215, 160, 35, 23], - } - } -} - -impl Default for UpdateRewardFunderInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateRewardFunderInstructionArgs { - pub reward_index: u64, - pub new_funder: Pubkey, -} - -/// Instruction builder for `UpdateRewardFunder`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` admin -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug, Default)] -pub struct UpdateRewardFunderBuilder { - lb_pair: Option, - admin: Option, - event_authority: Option, - program: Option, - reward_index: Option, - new_funder: Option, - __remaining_accounts: Vec, -} - -impl UpdateRewardFunderBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn new_funder(&mut self, new_funder: Pubkey) -> &mut Self { - self.new_funder = Some(new_funder); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateRewardFunder { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - admin: self.admin.expect("admin is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = UpdateRewardFunderInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - new_funder: self.new_funder.clone().expect("new_funder is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_reward_funder` CPI accounts. -pub struct UpdateRewardFunderCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_reward_funder` CPI instruction. -pub struct UpdateRewardFunderCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateRewardFunderInstructionArgs, -} - -impl<'a, 'b> UpdateRewardFunderCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateRewardFunderCpiAccounts<'a, 'b>, - args: UpdateRewardFunderInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - admin: accounts.admin, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateRewardFunderInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateRewardFunder` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[signer]` admin -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug)] -pub struct UpdateRewardFunderCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateRewardFunderCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateRewardFunderCpiBuilderInstruction { - __program: program, - lb_pair: None, - admin: None, - event_authority: None, - program: None, - reward_index: None, - new_funder: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn new_funder(&mut self, new_funder: Pubkey) -> &mut Self { - self.instruction.new_funder = Some(new_funder); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateRewardFunderInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - new_funder: self - .instruction - .new_funder - .clone() - .expect("new_funder is not set"), - }; - let instruction = UpdateRewardFunderCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateRewardFunderCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - new_funder: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/withdraw_ineligible_reward.rs b/crates/meteora-parser/src/generated_sdk/instructions/withdraw_ineligible_reward.rs deleted file mode 100644 index cc2b3a43..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/withdraw_ineligible_reward.rs +++ /dev/null @@ -1,716 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct WithdrawIneligibleReward { - pub lb_pair: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub funder_token_account: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub bin_array: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl WithdrawIneligibleReward { - pub fn instruction( - &self, - args: WithdrawIneligibleRewardInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: WithdrawIneligibleRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.funder_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.funder, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.bin_array, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawIneligibleRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawIneligibleRewardInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawIneligibleRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [148, 206, 42, 195, 247, 49, 103, 8], - } - } -} - -impl Default for WithdrawIneligibleRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawIneligibleRewardInstructionArgs { - pub reward_index: u64, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `WithdrawIneligibleReward`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` reward_vault -/// 2. `[]` reward_mint -/// 3. `[writable]` funder_token_account -/// 4. `[signer]` funder -/// 5. `[writable]` bin_array -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[]` memo_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug, Default)] -pub struct WithdrawIneligibleRewardBuilder { - lb_pair: Option, - reward_vault: Option, - reward_mint: Option, - funder_token_account: Option, - funder: Option, - bin_array: Option, - token_program: Option, - memo_program: Option, - event_authority: Option, - program: Option, - reward_index: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl WithdrawIneligibleRewardBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn bin_array(&mut self, bin_array: solana_pubkey::Pubkey) -> &mut Self { - self.bin_array = Some(bin_array); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = WithdrawIneligibleReward { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - funder_token_account: self - .funder_token_account - .expect("funder_token_account is not set"), - funder: self.funder.expect("funder is not set"), - bin_array: self.bin_array.expect("bin_array is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - memo_program: self.memo_program.expect("memo_program is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = WithdrawIneligibleRewardInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw_ineligible_reward` CPI accounts. -pub struct WithdrawIneligibleRewardCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw_ineligible_reward` CPI instruction. -pub struct WithdrawIneligibleRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub bin_array: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: WithdrawIneligibleRewardInstructionArgs, -} - -impl<'a, 'b> WithdrawIneligibleRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawIneligibleRewardCpiAccounts<'a, 'b>, - args: WithdrawIneligibleRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - reward_vault: accounts.reward_vault, - reward_mint: accounts.reward_mint, - funder_token_account: accounts.funder_token_account, - funder: accounts.funder, - bin_array: accounts.bin_array, - token_program: accounts.token_program, - memo_program: accounts.memo_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.funder_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.funder.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bin_array.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&WithdrawIneligibleRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.funder_token_account.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.bin_array.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `WithdrawIneligibleReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` reward_vault -/// 2. `[]` reward_mint -/// 3. `[writable]` funder_token_account -/// 4. `[signer]` funder -/// 5. `[writable]` bin_array -/// 6. `[]` token_program -/// 7. `[]` memo_program -/// 8. `[]` event_authority -/// 9. `[]` program -#[derive(Clone, Debug)] -pub struct WithdrawIneligibleRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawIneligibleRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawIneligibleRewardCpiBuilderInstruction { - __program: program, - lb_pair: None, - reward_vault: None, - reward_mint: None, - funder_token_account: None, - funder: None, - bin_array: None, - token_program: None, - memo_program: None, - event_authority: None, - program: None, - reward_index: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn bin_array(&mut self, bin_array: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.bin_array = Some(bin_array); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u64) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = WithdrawIneligibleRewardInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = WithdrawIneligibleRewardCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - funder_token_account: self - .instruction - .funder_token_account - .expect("funder_token_account is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - bin_array: self.instruction.bin_array.expect("bin_array is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawIneligibleRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - funder_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - bin_array: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/instructions/withdraw_protocol_fee.rs b/crates/meteora-parser/src/generated_sdk/instructions/withdraw_protocol_fee.rs deleted file mode 100644 index 991ea6a3..00000000 --- a/crates/meteora-parser/src/generated_sdk/instructions/withdraw_protocol_fee.rs +++ /dev/null @@ -1,815 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct WithdrawProtocolFee { - pub lb_pair: solana_pubkey::Pubkey, - - pub reserve_x: solana_pubkey::Pubkey, - - pub reserve_y: solana_pubkey::Pubkey, - - pub token_x_mint: solana_pubkey::Pubkey, - - pub token_y_mint: solana_pubkey::Pubkey, - - pub receiver_token_x: solana_pubkey::Pubkey, - - pub receiver_token_y: solana_pubkey::Pubkey, - - pub claim_fee_operator: solana_pubkey::Pubkey, - /// operator - pub operator: solana_pubkey::Pubkey, - - pub token_x_program: solana_pubkey::Pubkey, - - pub token_y_program: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, -} - -impl WithdrawProtocolFee { - pub fn instruction( - &self, - args: WithdrawProtocolFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: WithdrawProtocolFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.lb_pair, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_x, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve_y, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.receiver_token_x, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.receiver_token_y, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.claim_fee_operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_x_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_y_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawProtocolFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawProtocolFeeInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawProtocolFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [158, 201, 158, 189, 33, 93, 162, 103], - } - } -} - -impl Default for WithdrawProtocolFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawProtocolFeeInstructionArgs { - pub amount_x: u64, - pub amount_y: u64, - pub remaining_accounts_info: RemainingAccountsInfo, -} - -/// Instruction builder for `WithdrawProtocolFee`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` reserve_x -/// 2. `[writable]` reserve_y -/// 3. `[]` token_x_mint -/// 4. `[]` token_y_mint -/// 5. `[writable]` receiver_token_x -/// 6. `[writable]` receiver_token_y -/// 7. `[]` claim_fee_operator -/// 8. `[signer]` operator -/// 9. `[]` token_x_program -/// 10. `[]` token_y_program -/// 11. `[]` memo_program -#[derive(Clone, Debug, Default)] -pub struct WithdrawProtocolFeeBuilder { - lb_pair: Option, - reserve_x: Option, - reserve_y: Option, - token_x_mint: Option, - token_y_mint: Option, - receiver_token_x: Option, - receiver_token_y: Option, - claim_fee_operator: Option, - operator: Option, - token_x_program: Option, - token_y_program: Option, - memo_program: Option, - amount_x: Option, - amount_y: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl WithdrawProtocolFeeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self { - self.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self { - self.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn receiver_token_x(&mut self, receiver_token_x: solana_pubkey::Pubkey) -> &mut Self { - self.receiver_token_x = Some(receiver_token_x); - self - } - - #[inline(always)] - pub fn receiver_token_y(&mut self, receiver_token_y: solana_pubkey::Pubkey) -> &mut Self { - self.receiver_token_y = Some(receiver_token_y); - self - } - - #[inline(always)] - pub fn claim_fee_operator(&mut self, claim_fee_operator: solana_pubkey::Pubkey) -> &mut Self { - self.claim_fee_operator = Some(claim_fee_operator); - self - } - - /// operator - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn token_x_program(&mut self, token_x_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program(&mut self, token_y_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn amount_x(&mut self, amount_x: u64) -> &mut Self { - self.amount_x = Some(amount_x); - self - } - - #[inline(always)] - pub fn amount_y(&mut self, amount_y: u64) -> &mut Self { - self.amount_y = Some(amount_y); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = WithdrawProtocolFee { - lb_pair: self.lb_pair.expect("lb_pair is not set"), - reserve_x: self.reserve_x.expect("reserve_x is not set"), - reserve_y: self.reserve_y.expect("reserve_y is not set"), - token_x_mint: self.token_x_mint.expect("token_x_mint is not set"), - token_y_mint: self.token_y_mint.expect("token_y_mint is not set"), - receiver_token_x: self.receiver_token_x.expect("receiver_token_x is not set"), - receiver_token_y: self.receiver_token_y.expect("receiver_token_y is not set"), - claim_fee_operator: self - .claim_fee_operator - .expect("claim_fee_operator is not set"), - operator: self.operator.expect("operator is not set"), - token_x_program: self.token_x_program.expect("token_x_program is not set"), - token_y_program: self.token_y_program.expect("token_y_program is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - }; - let args = WithdrawProtocolFeeInstructionArgs { - amount_x: self.amount_x.clone().expect("amount_x is not set"), - amount_y: self.amount_y.clone().expect("amount_y is not set"), - remaining_accounts_info: self - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw_protocol_fee` CPI accounts. -pub struct WithdrawProtocolFeeCpiAccounts<'a, 'b> { - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub receiver_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub receiver_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - /// operator - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw_protocol_fee` CPI instruction. -pub struct WithdrawProtocolFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub lb_pair: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_x: &'b solana_account_info::AccountInfo<'a>, - - pub reserve_y: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_mint: &'b solana_account_info::AccountInfo<'a>, - - pub receiver_token_x: &'b solana_account_info::AccountInfo<'a>, - - pub receiver_token_y: &'b solana_account_info::AccountInfo<'a>, - - pub claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - /// operator - pub operator: &'b solana_account_info::AccountInfo<'a>, - - pub token_x_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_y_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: WithdrawProtocolFeeInstructionArgs, -} - -impl<'a, 'b> WithdrawProtocolFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawProtocolFeeCpiAccounts<'a, 'b>, - args: WithdrawProtocolFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - lb_pair: accounts.lb_pair, - reserve_x: accounts.reserve_x, - reserve_y: accounts.reserve_y, - token_x_mint: accounts.token_x_mint, - token_y_mint: accounts.token_y_mint, - receiver_token_x: accounts.receiver_token_x, - receiver_token_y: accounts.receiver_token_y, - claim_fee_operator: accounts.claim_fee_operator, - operator: accounts.operator, - token_x_program: accounts.token_x_program, - token_y_program: accounts.token_y_program, - memo_program: accounts.memo_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.lb_pair.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.receiver_token_x.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.receiver_token_y.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.claim_fee_operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_x_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_y_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&WithdrawProtocolFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::LB_CLMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.lb_pair.clone()); - account_infos.push(self.reserve_x.clone()); - account_infos.push(self.reserve_y.clone()); - account_infos.push(self.token_x_mint.clone()); - account_infos.push(self.token_y_mint.clone()); - account_infos.push(self.receiver_token_x.clone()); - account_infos.push(self.receiver_token_y.clone()); - account_infos.push(self.claim_fee_operator.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.token_x_program.clone()); - account_infos.push(self.token_y_program.clone()); - account_infos.push(self.memo_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `WithdrawProtocolFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` lb_pair -/// 1. `[writable]` reserve_x -/// 2. `[writable]` reserve_y -/// 3. `[]` token_x_mint -/// 4. `[]` token_y_mint -/// 5. `[writable]` receiver_token_x -/// 6. `[writable]` receiver_token_y -/// 7. `[]` claim_fee_operator -/// 8. `[signer]` operator -/// 9. `[]` token_x_program -/// 10. `[]` token_y_program -/// 11. `[]` memo_program -#[derive(Clone, Debug)] -pub struct WithdrawProtocolFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawProtocolFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawProtocolFeeCpiBuilderInstruction { - __program: program, - lb_pair: None, - reserve_x: None, - reserve_y: None, - token_x_mint: None, - token_y_mint: None, - receiver_token_x: None, - receiver_token_y: None, - claim_fee_operator: None, - operator: None, - token_x_program: None, - token_y_program: None, - memo_program: None, - amount_x: None, - amount_y: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lb_pair = Some(lb_pair); - self - } - - #[inline(always)] - pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_x = Some(reserve_x); - self - } - - #[inline(always)] - pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve_y = Some(reserve_y); - self - } - - #[inline(always)] - pub fn token_x_mint( - &mut self, - token_x_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_mint = Some(token_x_mint); - self - } - - #[inline(always)] - pub fn token_y_mint( - &mut self, - token_y_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_mint = Some(token_y_mint); - self - } - - #[inline(always)] - pub fn receiver_token_x( - &mut self, - receiver_token_x: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.receiver_token_x = Some(receiver_token_x); - self - } - - #[inline(always)] - pub fn receiver_token_y( - &mut self, - receiver_token_y: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.receiver_token_y = Some(receiver_token_y); - self - } - - #[inline(always)] - pub fn claim_fee_operator( - &mut self, - claim_fee_operator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.claim_fee_operator = Some(claim_fee_operator); - self - } - - /// operator - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn token_x_program( - &mut self, - token_x_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_x_program = Some(token_x_program); - self - } - - #[inline(always)] - pub fn token_y_program( - &mut self, - token_y_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_y_program = Some(token_y_program); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn amount_x(&mut self, amount_x: u64) -> &mut Self { - self.instruction.amount_x = Some(amount_x); - self - } - - #[inline(always)] - pub fn amount_y(&mut self, amount_y: u64) -> &mut Self { - self.instruction.amount_y = Some(amount_y); - self - } - - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = WithdrawProtocolFeeInstructionArgs { - amount_x: self - .instruction - .amount_x - .clone() - .expect("amount_x is not set"), - amount_y: self - .instruction - .amount_y - .clone() - .expect("amount_y is not set"), - remaining_accounts_info: self - .instruction - .remaining_accounts_info - .clone() - .expect("remaining_accounts_info is not set"), - }; - let instruction = WithdrawProtocolFeeCpi { - __program: self.instruction.__program, - - lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"), - - reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"), - - reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"), - - token_x_mint: self - .instruction - .token_x_mint - .expect("token_x_mint is not set"), - - token_y_mint: self - .instruction - .token_y_mint - .expect("token_y_mint is not set"), - - receiver_token_x: self - .instruction - .receiver_token_x - .expect("receiver_token_x is not set"), - - receiver_token_y: self - .instruction - .receiver_token_y - .expect("receiver_token_y is not set"), - - claim_fee_operator: self - .instruction - .claim_fee_operator - .expect("claim_fee_operator is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - token_x_program: self - .instruction - .token_x_program - .expect("token_x_program is not set"), - - token_y_program: self - .instruction - .token_y_program - .expect("token_y_program is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawProtocolFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - receiver_token_x: Option<&'b solana_account_info::AccountInfo<'a>>, - receiver_token_y: Option<&'b solana_account_info::AccountInfo<'a>>, - claim_fee_operator: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - token_x_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_y_program: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_x: Option, - amount_y: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-parser/src/generated_sdk/mod.rs b/crates/meteora-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/meteora-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/meteora-parser/src/generated_sdk/programs.rs b/crates/meteora-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 7340119b..00000000 --- a/crates/meteora-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `lb_clmm` program ID. -pub const LB_CLMM_ID: Pubkey = pubkey!("LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"); diff --git a/crates/meteora-parser/src/generated_sdk/shared.rs b/crates/meteora-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/meteora-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/meteora-parser/src/generated_sdk/types/accounts_type.rs b/crates/meteora-parser/src/generated_sdk/types/accounts_type.rs deleted file mode 100644 index 66090596..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/accounts_type.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum AccountsType { - TransferHookX, - TransferHookY, - TransferHookReward, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/activation_type.rs b/crates/meteora-parser/src/generated_sdk/types/activation_type.rs deleted file mode 100644 index 88b13245..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/activation_type.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Type of the activation -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum ActivationType { - Slot, - Timestamp, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/bin.rs b/crates/meteora-parser/src/generated_sdk/types/bin.rs deleted file mode 100644 index b000fc0a..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/bin.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Bin { - /// Amount of token X in the bin. This already excluded protocol fees. - pub amount_x: u64, - /// Amount of token Y in the bin. This already excluded protocol fees. - pub amount_y: u64, - /// Bin price - pub price: u128, - /// Liquidities of the bin. This is the same as LP mint supply. q-number - pub liquidity_supply: u128, - /// reward_a_per_token_stored - pub reward_per_token_stored: [u128; 2], - /// Swap fee amount of token X per liquidity deposited. - pub fee_amount_x_per_token_stored: u128, - /// Swap fee amount of token Y per liquidity deposited. - pub fee_amount_y_per_token_stored: u128, - /// Total token X swap into the bin. Only used for tracking purpose. - pub amount_x_in: u128, - /// Total token Y swap into he bin. Only used for tracking purpose. - pub amount_y_in: u128, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/bin_liquidity_distribution.rs b/crates/meteora-parser/src/generated_sdk/types/bin_liquidity_distribution.rs deleted file mode 100644 index 4d32646d..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/bin_liquidity_distribution.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BinLiquidityDistribution { - /// Define the bin ID wish to deposit to. - pub bin_id: i32, - /// DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin. - pub distribution_x: u16, - /// DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin. - pub distribution_y: u16, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/bin_liquidity_distribution_by_weight.rs b/crates/meteora-parser/src/generated_sdk/types/bin_liquidity_distribution_by_weight.rs deleted file mode 100644 index fa8e6c06..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/bin_liquidity_distribution_by_weight.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BinLiquidityDistributionByWeight { - /// Define the bin ID wish to deposit to. - pub bin_id: i32, - /// weight of liquidity distributed for this bin id - pub weight: u16, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/bin_liquidity_reduction.rs b/crates/meteora-parser/src/generated_sdk/types/bin_liquidity_reduction.rs deleted file mode 100644 index 5d16aff8..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/bin_liquidity_reduction.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BinLiquidityReduction { - pub bin_id: i32, - pub bps_to_remove: u16, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/compressed_bin_deposit_amount.rs b/crates/meteora-parser/src/generated_sdk/types/compressed_bin_deposit_amount.rs deleted file mode 100644 index 7e933f49..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/compressed_bin_deposit_amount.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CompressedBinDepositAmount { - pub bin_id: i32, - pub amount: u32, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/compressed_bin_deposit_amount2.rs b/crates/meteora-parser/src/generated_sdk/types/compressed_bin_deposit_amount2.rs deleted file mode 100644 index 47e870f9..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/compressed_bin_deposit_amount2.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CompressedBinDepositAmount2 { - pub bin_id: i32, - pub amount: u32, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/customizable_params.rs b/crates/meteora-parser/src/generated_sdk/types/customizable_params.rs deleted file mode 100644 index d96b8d82..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/customizable_params.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CustomizableParams { - /// Pool price - pub active_id: i32, - /// Bin step - pub bin_step: u16, - /// Base factor - pub base_factor: u16, - /// Activation type. 0 = Slot, 1 = Time. Check ActivationType enum - pub activation_type: u8, - /// Whether the pool has an alpha vault - pub has_alpha_vault: bool, - /// Decide when does the pool start trade. None = Now - pub activation_point: Option, - /// Pool creator have permission to enable/disable pool with restricted program validation. Only applicable for customizable permissionless pool. - pub creator_pool_on_off_control: bool, - /// Base fee power factor - pub base_fee_power_factor: u8, - /// Padding, for future use - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 62], -} diff --git a/crates/meteora-parser/src/generated_sdk/types/fee_info.rs b/crates/meteora-parser/src/generated_sdk/types/fee_info.rs deleted file mode 100644 index 42d7d9e6..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/fee_info.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FeeInfo { - pub fee_x_per_token_complete: u128, - pub fee_y_per_token_complete: u128, - pub fee_x_pending: u64, - pub fee_y_pending: u64, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/layout_version.rs b/crates/meteora-parser/src/generated_sdk/types/layout_version.rs deleted file mode 100644 index d934bc77..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/layout_version.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Layout version -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum LayoutVersion { - V0, - V1, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/liquidity_parameter.rs b/crates/meteora-parser/src/generated_sdk/types/liquidity_parameter.rs deleted file mode 100644 index b4261557..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/liquidity_parameter.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::BinLiquidityDistribution; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LiquidityParameter { - /// Amount of X token to deposit - pub amount_x: u64, - /// Amount of Y token to deposit - pub amount_y: u64, - /// Liquidity distribution to each bins - pub bin_liquidity_dist: Vec, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/liquidity_parameter_by_strategy.rs b/crates/meteora-parser/src/generated_sdk/types/liquidity_parameter_by_strategy.rs deleted file mode 100644 index 907117e1..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/liquidity_parameter_by_strategy.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::StrategyParameters; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LiquidityParameterByStrategy { - /// Amount of X token to deposit - pub amount_x: u64, - /// Amount of Y token to deposit - pub amount_y: u64, - /// Active bin that integrator observe off-chain - pub active_id: i32, - /// max active bin slippage allowed - pub max_active_bin_slippage: i32, - /// strategy parameters - pub strategy_parameters: StrategyParameters, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/mod.rs b/crates/meteora-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index f13966f6..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#accounts_type; -pub(crate) mod r#activation_type; -pub(crate) mod r#bin; -pub(crate) mod r#bin_liquidity_distribution; -pub(crate) mod r#bin_liquidity_distribution_by_weight; -pub(crate) mod r#bin_liquidity_reduction; -pub(crate) mod r#compressed_bin_deposit_amount; -pub(crate) mod r#compressed_bin_deposit_amount2; -pub(crate) mod r#customizable_params; -pub(crate) mod r#fee_info; -pub(crate) mod r#layout_version; -pub(crate) mod r#liquidity_parameter; -pub(crate) mod r#liquidity_parameter_by_strategy; -pub(crate) mod r#observation; -pub(crate) mod r#pair_status; -pub(crate) mod r#pair_type; -pub(crate) mod r#protocol_fee; -pub(crate) mod r#remaining_accounts_info; -pub(crate) mod r#remaining_accounts_slice; -pub(crate) mod r#reward_info; -pub(crate) mod r#rounding; -pub(crate) mod r#static_parameters; -pub(crate) mod r#strategy_parameters; -pub(crate) mod r#strategy_type; -pub(crate) mod r#token_program_flags; -pub(crate) mod r#user_reward_info; -pub(crate) mod r#variable_parameters; - -pub use self::{ - r#accounts_type::*, r#activation_type::*, r#bin::*, r#bin_liquidity_distribution::*, - r#bin_liquidity_distribution_by_weight::*, r#bin_liquidity_reduction::*, - r#compressed_bin_deposit_amount::*, r#compressed_bin_deposit_amount2::*, - r#customizable_params::*, r#fee_info::*, r#layout_version::*, r#liquidity_parameter::*, - r#liquidity_parameter_by_strategy::*, r#observation::*, r#pair_status::*, r#pair_type::*, - r#protocol_fee::*, r#remaining_accounts_info::*, r#remaining_accounts_slice::*, - r#reward_info::*, r#rounding::*, r#static_parameters::*, r#strategy_parameters::*, - r#strategy_type::*, r#token_program_flags::*, r#user_reward_info::*, r#variable_parameters::*, -}; diff --git a/crates/meteora-parser/src/generated_sdk/types/observation.rs b/crates/meteora-parser/src/generated_sdk/types/observation.rs deleted file mode 100644 index fadfc36a..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/observation.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Observation { - /// Cumulative active bin ID - pub cumulative_active_bin_id: i128, - /// Observation sample created timestamp - pub created_at: i64, - /// Observation sample last updated timestamp - pub last_updated_at: i64, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/pair_status.rs b/crates/meteora-parser/src/generated_sdk/types/pair_status.rs deleted file mode 100644 index b419fd9e..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/pair_status.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Pair status. 0 = Enabled, 1 = Disabled. Putting 0 as enabled for backward compatibility. -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum PairStatus { - Enabled, - Disabled, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/pair_type.rs b/crates/meteora-parser/src/generated_sdk/types/pair_type.rs deleted file mode 100644 index 641aefc9..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/pair_type.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Type of the Pair. 0 = Permissionless, 1 = Permission, 2 = CustomizablePermissionless. Putting 0 as permissionless for backward compatibility. -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum PairType { - Permissionless, - Permission, - CustomizablePermissionless, - PermissionlessV2, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/protocol_fee.rs b/crates/meteora-parser/src/generated_sdk/types/protocol_fee.rs deleted file mode 100644 index b7027872..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/protocol_fee.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ProtocolFee { - pub amount_x: u64, - pub amount_y: u64, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/remaining_accounts_info.rs b/crates/meteora-parser/src/generated_sdk/types/remaining_accounts_info.rs deleted file mode 100644 index d8a464a1..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/remaining_accounts_info.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsSlice; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemainingAccountsInfo { - pub slices: Vec, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/remaining_accounts_slice.rs b/crates/meteora-parser/src/generated_sdk/types/remaining_accounts_slice.rs deleted file mode 100644 index b96d81aa..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/remaining_accounts_slice.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::AccountsType; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemainingAccountsSlice { - pub accounts_type: AccountsType, - pub length: u8, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/reward_info.rs b/crates/meteora-parser/src/generated_sdk/types/reward_info.rs deleted file mode 100644 index 2e775a42..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/reward_info.rs +++ /dev/null @@ -1,43 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Stores the state relevant for tracking liquidity mining rewards -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RewardInfo { - /// Reward token mint. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - /// Reward vault token account. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vault: Pubkey, - /// Authority account that allows to fund rewards - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub funder: Pubkey, - /// TODO check whether we need to store it in pool - pub reward_duration: u64, - /// TODO check whether we need to store it in pool - pub reward_duration_end: u64, - /// TODO check whether we need to store it in pool - pub reward_rate: u128, - /// The last time reward states were updated. - pub last_update_time: u64, - /// Accumulated seconds where when farm distribute rewards, but the bin is empty. The reward will be accumulated for next reward time window. - pub cumulative_seconds_with_empty_liquidity_reward: u64, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/rounding.rs b/crates/meteora-parser/src/generated_sdk/types/rounding.rs deleted file mode 100644 index 97f6c4a4..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/rounding.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum Rounding { - Up, - Down, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/static_parameters.rs b/crates/meteora-parser/src/generated_sdk/types/static_parameters.rs deleted file mode 100644 index aab9d84d..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/static_parameters.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Parameter that set by the protocol -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct StaticParameters { - /// Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor - pub base_factor: u16, - /// Filter period determine high frequency trading time window. - pub filter_period: u16, - /// Decay period determine when the volatile fee start decay / decrease. - pub decay_period: u16, - /// Reduction factor controls the volatile fee rate decrement rate. - pub reduction_factor: u16, - /// Used to scale the variable fee component depending on the dynamic of the market - pub variable_fee_control: u32, - /// Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate. - pub max_volatility_accumulator: u32, - /// Min bin id supported by the pool based on the configured bin step. - pub min_bin_id: i32, - /// Max bin id supported by the pool based on the configured bin step. - pub max_bin_id: i32, - /// Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee - pub protocol_share: u16, - /// Base fee power factor - pub base_fee_power_factor: u8, - /// Padding for bytemuck safe alignment - pub padding: [u8; 5], -} diff --git a/crates/meteora-parser/src/generated_sdk/types/strategy_parameters.rs b/crates/meteora-parser/src/generated_sdk/types/strategy_parameters.rs deleted file mode 100644 index 1b84fdac..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/strategy_parameters.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::StrategyType; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct StrategyParameters { - /// min bin id - pub min_bin_id: i32, - /// max bin id - pub max_bin_id: i32, - /// strategy type - pub strategy_type: StrategyType, - /// parameters - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub parameteres: [u8; 64], -} diff --git a/crates/meteora-parser/src/generated_sdk/types/strategy_type.rs b/crates/meteora-parser/src/generated_sdk/types/strategy_type.rs deleted file mode 100644 index 7fcfd5ca..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/strategy_type.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum StrategyType { - SpotOneSide, - CurveOneSide, - BidAskOneSide, - SpotBalanced, - CurveBalanced, - BidAskBalanced, - SpotImBalanced, - CurveImBalanced, - BidAskImBalanced, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/token_program_flags.rs b/crates/meteora-parser/src/generated_sdk/types/token_program_flags.rs deleted file mode 100644 index 633df2b0..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/token_program_flags.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TokenProgramFlags { - TokenProgram, - TokenProgram2022, -} diff --git a/crates/meteora-parser/src/generated_sdk/types/user_reward_info.rs b/crates/meteora-parser/src/generated_sdk/types/user_reward_info.rs deleted file mode 100644 index 0bdb2d87..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/user_reward_info.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UserRewardInfo { - pub reward_per_token_completes: [u128; 2], - pub reward_pendings: [u64; 2], -} diff --git a/crates/meteora-parser/src/generated_sdk/types/variable_parameters.rs b/crates/meteora-parser/src/generated_sdk/types/variable_parameters.rs deleted file mode 100644 index 556265c1..00000000 --- a/crates/meteora-parser/src/generated_sdk/types/variable_parameters.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Parameters that changes based on dynamic of the market -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct VariableParameters { - /// 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 - pub volatility_accumulator: u32, - /// Volatility reference is decayed volatility accumulator. It is always <= volatility_accumulator - pub volatility_reference: u32, - /// Active bin id of last swap. - pub index_reference: i32, - /// Padding for bytemuck safe alignment - pub padding: [u8; 4], - /// Last timestamp the variable parameters was updated - pub last_update_timestamp: i64, - /// Padding for bytemuck safe alignment - pub padding1: [u8; 8], -} diff --git a/crates/meteora-parser/src/lib.rs b/crates/meteora-parser/src/lib.rs deleted file mode 100644 index 30b8d32b..00000000 --- a/crates/meteora-parser/src/lib.rs +++ /dev/null @@ -1,19 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -mod custom_impl; - -pub const ID: Pubkey = LB_CLMM_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.meteora"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/meteora-pools-parser/Cargo.toml b/crates/meteora-pools-parser/Cargo.toml deleted file mode 100644 index 49d33252..00000000 --- a/crates/meteora-pools-parser/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "yellowstone-vixen-meteora-pools-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Meteora Pools program" -license.workspace = true -repository.workspace = true -authors.workspace = true - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info.workspace = true -solana-cpi.workspace = true -solana-decode-error.workspace = true -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction.workspace = true -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true \ No newline at end of file diff --git a/crates/meteora-pools-parser/build.rs b/crates/meteora-pools-parser/build.rs deleted file mode 100644 index f6f10853..00000000 --- a/crates/meteora-pools-parser/build.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/meteora_pools.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/meteora-pools-parser/idl.json b/crates/meteora-pools-parser/idl.json deleted file mode 100644 index 553c3c14..00000000 --- a/crates/meteora-pools-parser/idl.json +++ /dev/null @@ -1,3316 +0,0 @@ -{ - "version": "0.5.2", - "name": "amm", - "docs": ["Program for AMM"], - "instructions": [ - { - "name": "initializePermissionedPool", - "docs": ["Initialize a new permissioned pool."], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": true, - "docs": ["Pool account (arbitrary address)"] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "tokenAMint", - "isMut": false, - "isSigner": false, - "docs": ["Token A mint of the pool. Eg: USDT"] - }, - { - "name": "tokenBMint", - "isMut": false, - "isSigner": false, - "docs": ["Token B mint of the pool. Eg: USDC"] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault A"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault B"] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "adminTokenA", - "isMut": true, - "isSigner": false, - "docs": [ - "Admin token account for pool token A mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { - "name": "adminTokenB", - "isMut": true, - "isSigner": false, - "docs": [ - "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { - "name": "adminPoolLp", - "isMut": true, - "isSigner": false, - "docs": [ - "Admin pool LP token account. Used to receive LP during first deposit (initialize pool)", - "Admin pool LP token account. Used to receive LP during first deposit (initialize pool)" - ] - }, - { - "name": "protocolTokenAFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token A. Used to receive trading fee." - ] - }, - { - "name": "protocolTokenBFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token B. Used to receive trading fee." - ] - }, - { - "name": "admin", - "isMut": true, - "isSigner": true, - "docs": [ - "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." - ] - }, - { "name": "feeOwner", "isMut": false, "isSigner": false }, - { - "name": "rent", - "isMut": false, - "isSigner": false, - "docs": ["Rent account."] - }, - { "name": "mintMetadata", "isMut": true, "isSigner": false }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. The pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Associated token program."] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false, - "docs": ["System program."] - } - ], - "args": [ - { "name": "curveType", "type": { "defined": "CurveType" } } - ] - }, - { - "name": "initializePermissionlessPool", - "docs": ["Initialize a new permissionless pool."], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA address)"] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "tokenAMint", - "isMut": false, - "isSigner": false, - "docs": ["Token A mint of the pool. Eg: USDT"] - }, - { - "name": "tokenBMint", - "isMut": false, - "isSigner": false, - "docs": ["Token B mint of the pool. Eg: USDC"] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault A"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault B"] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "payerTokenA", - "isMut": true, - "isSigner": false, - "docs": [ - "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { - "name": "payerTokenB", - "isMut": true, - "isSigner": false, - "docs": [ - "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { "name": "payerPoolLp", "isMut": true, "isSigner": false }, - { - "name": "protocolTokenAFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token A. Used to receive trading fee." - ] - }, - { - "name": "protocolTokenBFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token B. Used to receive trading fee." - ] - }, - { - "name": "payer", - "isMut": true, - "isSigner": true, - "docs": [ - "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." - ] - }, - { "name": "feeOwner", "isMut": false, "isSigner": false }, - { - "name": "rent", - "isMut": false, - "isSigner": false, - "docs": ["Rent account."] - }, - { "name": "mintMetadata", "isMut": true, "isSigner": false }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. The pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Associated token program."] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false, - "docs": ["System program."] - } - ], - "args": [ - { "name": "curveType", "type": { "defined": "CurveType" } }, - { "name": "tokenAAmount", "type": "u64" }, - { "name": "tokenBAmount", "type": "u64" } - ] - }, - { - "name": "initializePermissionlessPoolWithFeeTier", - "docs": [ - "Initialize a new permissionless pool with customized fee tier" - ], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA address)"] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "tokenAMint", - "isMut": false, - "isSigner": false, - "docs": ["Token A mint of the pool. Eg: USDT"] - }, - { - "name": "tokenBMint", - "isMut": false, - "isSigner": false, - "docs": ["Token B mint of the pool. Eg: USDC"] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault A"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault B"] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "payerTokenA", - "isMut": true, - "isSigner": false, - "docs": [ - "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { - "name": "payerTokenB", - "isMut": true, - "isSigner": false, - "docs": [ - "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { "name": "payerPoolLp", "isMut": true, "isSigner": false }, - { - "name": "protocolTokenAFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token A. Used to receive trading fee." - ] - }, - { - "name": "protocolTokenBFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token B. Used to receive trading fee." - ] - }, - { - "name": "payer", - "isMut": true, - "isSigner": true, - "docs": [ - "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." - ] - }, - { "name": "feeOwner", "isMut": false, "isSigner": false }, - { - "name": "rent", - "isMut": false, - "isSigner": false, - "docs": ["Rent account."] - }, - { "name": "mintMetadata", "isMut": true, "isSigner": false }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. The pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Associated token program."] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false, - "docs": ["System program."] - } - ], - "args": [ - { "name": "curveType", "type": { "defined": "CurveType" } }, - { "name": "tradeFeeBps", "type": "u64" }, - { "name": "tokenAAmount", "type": "u64" }, - { "name": "tokenBAmount", "type": "u64" } - ] - }, - { - "name": "enableOrDisablePool", - "docs": [ - "Enable or disable a pool. A disabled pool allow only remove balanced liquidity operation." - ], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "admin", - "isMut": false, - "isSigner": true, - "docs": ["Admin account. Must be owner of the pool."] - } - ], - "args": [{ "name": "enable", "type": "bool" }] - }, - { - "name": "swap", - "docs": [ - "Swap token A to B, or vice versa. An amount of trading fee will be charged for liquidity provider, and the admin of the pool." - ], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "userSourceToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token account. Token from this account will be transfer into the vault by the pool in exchange for another token of the pool." - ] - }, - { - "name": "userDestinationToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token account. The exchanged token will be transfer into this account from the pool." - ] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["Lp token mint of vault a"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["Lp token mint of vault b"] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "protocolTokenFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account. Used to receive trading fee. It's mint field must matched with user_source_token mint field." - ] - }, - { - "name": "user", - "isMut": false, - "isSigner": true, - "docs": [ - "User account. Must be owner of user_source_token." - ] - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. the pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - } - ], - "args": [ - { "name": "inAmount", "type": "u64" }, - { "name": "minimumOutAmount", "type": "u64" } - ] - }, - { - "name": "removeLiquiditySingleSide", - "docs": [ - "Withdraw only single token from the pool. Only supported by pool with stable swap curve." - ], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "userPoolLp", - "isMut": true, - "isSigner": false, - "docs": [ - "User pool lp token account. LP will be burned from this account upon success liquidity removal." - ] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault A"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault B"] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "userDestinationToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token account to receive token upon success liquidity removal." - ] - }, - { - "name": "user", - "isMut": false, - "isSigner": true, - "docs": [ - "User account. Must be owner of the user_pool_lp account." - ] - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. The pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - } - ], - "args": [ - { "name": "poolTokenAmount", "type": "u64" }, - { "name": "minimumOutAmount", "type": "u64" } - ] - }, - { - "name": "addImbalanceLiquidity", - "docs": [ - "Deposit tokens to the pool in an imbalance ratio. Only supported by pool with stable swap curve." - ], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "userPoolLp", - "isMut": true, - "isSigner": false, - "docs": [ - "user pool lp token account. lp will be burned from this account upon success liquidity removal." - ] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault a"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault b"] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "userAToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." - ] - }, - { - "name": "userBToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." - ] - }, - { - "name": "user", - "isMut": false, - "isSigner": true, - "docs": [ - "User account. Must be owner of user_a_token, and user_b_token." - ] - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. the pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - } - ], - "args": [ - { "name": "minimumPoolTokenAmount", "type": "u64" }, - { "name": "tokenAAmount", "type": "u64" }, - { "name": "tokenBAmount", "type": "u64" } - ] - }, - { - "name": "removeBalanceLiquidity", - "docs": [ - "Withdraw tokens from the pool in a balanced ratio. User will still able to withdraw from pool even the pool is disabled. This allow user to exit their liquidity when there's some unforeseen event happen." - ], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "userPoolLp", - "isMut": true, - "isSigner": false, - "docs": [ - "user pool lp token account. lp will be burned from this account upon success liquidity removal." - ] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault a"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault b"] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "userAToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." - ] - }, - { - "name": "userBToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." - ] - }, - { - "name": "user", - "isMut": false, - "isSigner": true, - "docs": [ - "User account. Must be owner of user_a_token, and user_b_token." - ] - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. the pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - } - ], - "args": [ - { "name": "poolTokenAmount", "type": "u64" }, - { "name": "minimumATokenOut", "type": "u64" }, - { "name": "minimumBTokenOut", "type": "u64" } - ] - }, - { - "name": "addBalanceLiquidity", - "docs": ["Deposit tokens to the pool in a balanced ratio."], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "userPoolLp", - "isMut": true, - "isSigner": false, - "docs": [ - "user pool lp token account. lp will be burned from this account upon success liquidity removal." - ] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault a"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault b"] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "userAToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." - ] - }, - { - "name": "userBToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." - ] - }, - { - "name": "user", - "isMut": false, - "isSigner": true, - "docs": [ - "User account. Must be owner of user_a_token, and user_b_token." - ] - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. the pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - } - ], - "args": [ - { "name": "poolTokenAmount", "type": "u64" }, - { "name": "maximumTokenAAmount", "type": "u64" }, - { "name": "maximumTokenBAmount", "type": "u64" } - ] - }, - { - "name": "setPoolFees", - "docs": [ - "Update trading fee charged for liquidity provider, and admin." - ], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "feeOperator", - "isMut": false, - "isSigner": true, - "docs": ["Fee operator account"] - } - ], - "args": [ - { "name": "fees", "type": { "defined": "PoolFees" } }, - { "name": "newPartnerFeeNumerator", "type": "u64" } - ] - }, - { - "name": "overrideCurveParam", - "docs": [ - "Update swap curve parameters. This function do not allow update of curve type. For example: stable swap curve to constant product curve. Only supported by pool with stable swap curve.", - "Only amp is allowed to be override. The other attributes of stable swap curve will be ignored." - ], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "admin", - "isMut": false, - "isSigner": true, - "docs": ["Admin account."] - } - ], - "args": [ - { "name": "curveType", "type": { "defined": "CurveType" } } - ] - }, - { - "name": "getPoolInfo", - "docs": ["Get the general information of the pool."], - "accounts": [ - { - "name": "pool", - "isMut": false, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "lpMint", - "isMut": false, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "aVaultLp", - "isMut": false, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": false, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "aVault", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aVaultLpMint", - "isMut": false, - "isSigner": false, - "docs": ["LP token mint of vault a"] - }, - { - "name": "bVaultLpMint", - "isMut": false, - "isSigner": false, - "docs": ["LP token mint of vault b"] - } - ], - "args": [] - }, - { - "name": "bootstrapLiquidity", - "docs": ["Bootstrap the pool when liquidity is depleted."], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "userPoolLp", - "isMut": true, - "isSigner": false, - "docs": [ - "user pool lp token account. lp will be burned from this account upon success liquidity removal." - ] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault a"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault b"] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "userAToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." - ] - }, - { - "name": "userBToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." - ] - }, - { - "name": "user", - "isMut": false, - "isSigner": true, - "docs": [ - "User account. Must be owner of user_a_token, and user_b_token." - ] - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. the pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - } - ], - "args": [ - { "name": "tokenAAmount", "type": "u64" }, - { "name": "tokenBAmount", "type": "u64" } - ] - }, - { - "name": "createMintMetadata", - "docs": ["Create mint metadata account for old pools"], - "accounts": [ - { - "name": "pool", - "isMut": false, - "isSigner": false, - "docs": ["Pool account"] - }, - { - "name": "lpMint", - "isMut": false, - "isSigner": false, - "docs": ["LP mint account of the pool"] - }, - { - "name": "aVaultLp", - "isMut": false, - "isSigner": false, - "docs": ["Vault A LP account of the pool"] - }, - { "name": "mintMetadata", "isMut": true, "isSigner": false }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false, - "docs": ["System program."] - }, - { - "name": "payer", - "isMut": true, - "isSigner": true, - "docs": ["Payer"] - } - ], - "args": [] - }, - { - "name": "createLockEscrow", - "docs": ["Create lock account"], - "accounts": [ - { - "name": "pool", - "isMut": false, - "isSigner": false, - "docs": ["Pool account"] - }, - { - "name": "lockEscrow", - "isMut": true, - "isSigner": false, - "docs": ["Lock account"] - }, - { "name": "owner", "isMut": false, "isSigner": false }, - { - "name": "lpMint", - "isMut": false, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "payer", - "isMut": true, - "isSigner": true, - "docs": ["Payer account"] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false, - "docs": ["System program."] - } - ], - "args": [] - }, - { - "name": "lock", - "docs": ["Lock Lp token"], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account"] - }, - { - "name": "lpMint", - "isMut": false, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "lockEscrow", - "isMut": true, - "isSigner": false, - "docs": ["Lock account"] - }, - { - "name": "owner", - "isMut": true, - "isSigner": true, - "docs": ["Can be anyone"] - }, - { - "name": "sourceTokens", - "isMut": true, - "isSigner": false, - "docs": ["owner lp token account"] - }, - { - "name": "escrowVault", - "isMut": true, - "isSigner": false, - "docs": ["Escrow vault"] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - }, - { - "name": "aVault", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aVaultLp", - "isMut": false, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": false, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "aVaultLpMint", - "isMut": false, - "isSigner": false, - "docs": ["LP token mint of vault a"] - }, - { - "name": "bVaultLpMint", - "isMut": false, - "isSigner": false, - "docs": ["LP token mint of vault b"] - } - ], - "args": [{ "name": "maxAmount", "type": "u64" }] - }, - { - "name": "claimFee", - "docs": ["Claim fee"], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account"] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "lockEscrow", - "isMut": true, - "isSigner": false, - "docs": ["Lock account"] - }, - { - "name": "owner", - "isMut": true, - "isSigner": true, - "docs": ["Owner of lock account"] - }, - { - "name": "sourceTokens", - "isMut": true, - "isSigner": false, - "docs": ["owner lp token account"] - }, - { - "name": "escrowVault", - "isMut": true, - "isSigner": false, - "docs": ["Escrow vault"] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault a"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault b"] - }, - { - "name": "userAToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." - ] - }, - { - "name": "userBToken", - "isMut": true, - "isSigner": false, - "docs": [ - "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." - ] - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. the pool will deposit/withdraw liquidity from the vault." - ] - } - ], - "args": [{ "name": "maxAmount", "type": "u64" }] - }, - { - "name": "createConfig", - "docs": ["Create config"], - "accounts": [ - { "name": "config", "isMut": true, "isSigner": false }, - { "name": "admin", "isMut": true, "isSigner": true }, - { "name": "systemProgram", "isMut": false, "isSigner": false } - ], - "args": [ - { - "name": "configParameters", - "type": { "defined": "ConfigParameters" } - } - ] - }, - { - "name": "closeConfig", - "docs": ["Close config"], - "accounts": [ - { "name": "config", "isMut": true, "isSigner": false }, - { "name": "admin", "isMut": true, "isSigner": true }, - { "name": "rentReceiver", "isMut": true, "isSigner": false } - ], - "args": [] - }, - { - "name": "initializePermissionlessConstantProductPoolWithConfig", - "docs": ["Initialize permissionless pool with config"], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA address)"] - }, - { "name": "config", "isMut": false, "isSigner": false }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "tokenAMint", - "isMut": false, - "isSigner": false, - "docs": ["Token A mint of the pool. Eg: USDT"] - }, - { - "name": "tokenBMint", - "isMut": false, - "isSigner": false, - "docs": ["Token B mint of the pool. Eg: USDC"] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault A"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault B"] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "payerTokenA", - "isMut": true, - "isSigner": false, - "docs": [ - "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { - "name": "payerTokenB", - "isMut": true, - "isSigner": false, - "docs": [ - "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { "name": "payerPoolLp", "isMut": true, "isSigner": false }, - { - "name": "protocolTokenAFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token A. Used to receive trading fee." - ] - }, - { - "name": "protocolTokenBFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token B. Used to receive trading fee." - ] - }, - { - "name": "payer", - "isMut": true, - "isSigner": true, - "docs": [ - "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." - ] - }, - { - "name": "rent", - "isMut": false, - "isSigner": false, - "docs": ["Rent account."] - }, - { "name": "mintMetadata", "isMut": true, "isSigner": false }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. The pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Associated token program."] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false, - "docs": ["System program."] - } - ], - "args": [ - { "name": "tokenAAmount", "type": "u64" }, - { "name": "tokenBAmount", "type": "u64" } - ] - }, - { - "name": "initializePermissionlessConstantProductPoolWithConfig2", - "docs": ["Initialize permissionless pool with config 2"], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA address)"] - }, - { "name": "config", "isMut": false, "isSigner": false }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "tokenAMint", - "isMut": false, - "isSigner": false, - "docs": ["Token A mint of the pool. Eg: USDT"] - }, - { - "name": "tokenBMint", - "isMut": false, - "isSigner": false, - "docs": ["Token B mint of the pool. Eg: USDC"] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault A"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault B"] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "payerTokenA", - "isMut": true, - "isSigner": false, - "docs": [ - "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { - "name": "payerTokenB", - "isMut": true, - "isSigner": false, - "docs": [ - "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { "name": "payerPoolLp", "isMut": true, "isSigner": false }, - { - "name": "protocolTokenAFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token A. Used to receive trading fee." - ] - }, - { - "name": "protocolTokenBFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token B. Used to receive trading fee." - ] - }, - { - "name": "payer", - "isMut": true, - "isSigner": true, - "docs": [ - "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." - ] - }, - { - "name": "rent", - "isMut": false, - "isSigner": false, - "docs": ["Rent account."] - }, - { "name": "mintMetadata", "isMut": true, "isSigner": false }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. The pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Associated token program."] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false, - "docs": ["System program."] - } - ], - "args": [ - { "name": "tokenAAmount", "type": "u64" }, - { "name": "tokenBAmount", "type": "u64" }, - { "name": "activationPoint", "type": { "option": "u64" } } - ] - }, - { - "name": "initializeCustomizablePermissionlessConstantProductPool", - "docs": ["Initialize permissionless pool with customizable params"], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA address)"] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of the pool"] - }, - { - "name": "tokenAMint", - "isMut": false, - "isSigner": false, - "docs": ["Token A mint of the pool. Eg: USDT"] - }, - { - "name": "tokenBMint", - "isMut": false, - "isSigner": false, - "docs": ["Token B mint of the pool. Eg: USDC"] - }, - { - "name": "aVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "bVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." - ] - }, - { - "name": "aTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault A"] - }, - { - "name": "bTokenVault", - "isMut": true, - "isSigner": false, - "docs": ["Token vault account of vault B"] - }, - { - "name": "aVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault A"] - }, - { - "name": "bVaultLpMint", - "isMut": true, - "isSigner": false, - "docs": ["LP token mint of vault B"] - }, - { - "name": "aVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "bVaultLp", - "isMut": true, - "isSigner": false, - "docs": [ - "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." - ] - }, - { - "name": "payerTokenA", - "isMut": true, - "isSigner": false, - "docs": [ - "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { - "name": "payerTokenB", - "isMut": true, - "isSigner": false, - "docs": [ - "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." - ] - }, - { "name": "payerPoolLp", "isMut": true, "isSigner": false }, - { - "name": "protocolTokenAFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token A. Used to receive trading fee." - ] - }, - { - "name": "protocolTokenBFee", - "isMut": true, - "isSigner": false, - "docs": [ - "Protocol fee token account for token B. Used to receive trading fee." - ] - }, - { - "name": "payer", - "isMut": true, - "isSigner": true, - "docs": [ - "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." - ] - }, - { - "name": "rent", - "isMut": false, - "isSigner": false, - "docs": ["Rent account."] - }, - { "name": "mintMetadata", "isMut": true, "isSigner": false }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "vaultProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Vault program. The pool will deposit/withdraw liquidity from the vault." - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Token program."] - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false, - "docs": ["Associated token program."] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false, - "docs": ["System program."] - } - ], - "args": [ - { "name": "tokenAAmount", "type": "u64" }, - { "name": "tokenBAmount", "type": "u64" }, - { - "name": "params", - "type": { "defined": "CustomizableParams" } - } - ] - }, - { - "name": "updateActivationPoint", - "docs": ["Update activation slot"], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { - "name": "admin", - "isMut": false, - "isSigner": true, - "docs": ["Admin account."] - } - ], - "args": [{ "name": "newActivationPoint", "type": "u64" }] - }, - { - "name": "withdrawProtocolFees", - "docs": ["Withdraw protocol fee"], - "accounts": [ - { - "name": "pool", - "isMut": false, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { "name": "aVaultLp", "isMut": false, "isSigner": false }, - { - "name": "protocolTokenAFee", - "isMut": true, - "isSigner": false - }, - { - "name": "protocolTokenBFee", - "isMut": true, - "isSigner": false - }, - { "name": "treasuryTokenA", "isMut": true, "isSigner": false }, - { "name": "treasuryTokenB", "isMut": true, "isSigner": false }, - { "name": "tokenProgram", "isMut": false, "isSigner": false } - ], - "args": [] - }, - { - "name": "setWhitelistedVault", - "docs": ["Set whitelisted vault"], - "accounts": [ - { "name": "pool", "isMut": true, "isSigner": false }, - { "name": "admin", "isMut": false, "isSigner": true } - ], - "args": [{ "name": "whitelistedVault", "type": "publicKey" }] - }, - { - "name": "partnerClaimFee", - "docs": ["Partner claim fee"], - "accounts": [ - { - "name": "pool", - "isMut": true, - "isSigner": false, - "docs": ["Pool account (PDA)"] - }, - { "name": "aVaultLp", "isMut": false, "isSigner": false }, - { - "name": "protocolTokenAFee", - "isMut": true, - "isSigner": false - }, - { - "name": "protocolTokenBFee", - "isMut": true, - "isSigner": false - }, - { "name": "partnerTokenA", "isMut": true, "isSigner": false }, - { "name": "partnerTokenB", "isMut": true, "isSigner": false }, - { "name": "tokenProgram", "isMut": false, "isSigner": false }, - { "name": "partnerAuthority", "isMut": false, "isSigner": true } - ], - "args": [ - { "name": "maxAmountA", "type": "u64" }, - { "name": "maxAmountB", "type": "u64" } - ] - } - ], - "accounts": [ - { - "name": "Config", - "type": { - "kind": "struct", - "fields": [ - { "name": "poolFees", "type": { "defined": "PoolFees" } }, - { "name": "activationDuration", "type": "u64" }, - { "name": "vaultConfigKey", "type": "publicKey" }, - { - "name": "poolCreatorAuthority", - "docs": [ - "Only pool_creator_authority can use the current config to initialize new pool. When it's Pubkey::default, it's a public config." - ], - "type": "publicKey" - }, - { - "name": "activationType", - "docs": ["Activation type"], - "type": "u8" - }, - { "name": "partnerFeeNumerator", "type": "u64" }, - { "name": "padding", "type": { "array": ["u8", 219] } } - ] - } - }, - { - "name": "LockEscrow", - "docs": ["State of lock escrow account"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "docs": ["Pool address"], - "type": "publicKey" - }, - { - "name": "owner", - "docs": ["Owner address"], - "type": "publicKey" - }, - { - "name": "escrowVault", - "docs": ["Vault address, store the lock user lock"], - "type": "publicKey" - }, - { - "name": "bump", - "docs": ["bump, used to sign"], - "type": "u8" - }, - { - "name": "totalLockedAmount", - "docs": ["Total locked amount"], - "type": "u64" - }, - { - "name": "lpPerToken", - "docs": ["Lp per token, virtual price of lp token"], - "type": "u128" - }, - { - "name": "unclaimedFeePending", - "docs": ["Unclaimed fee pending"], - "type": "u64" - }, - { - "name": "aFee", - "docs": ["Total a fee claimed so far"], - "type": "u64" - }, - { - "name": "bFee", - "docs": ["Total b fee claimed so far"], - "type": "u64" - } - ] - } - }, - { - "name": "Pool", - "docs": ["State of pool account"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "lpMint", - "docs": ["LP token mint of the pool"], - "type": "publicKey" - }, - { - "name": "tokenAMint", - "docs": ["Token A mint of the pool. Eg: USDT"], - "type": "publicKey" - }, - { - "name": "tokenBMint", - "docs": ["Token B mint of the pool. Eg: USDC"], - "type": "publicKey" - }, - { - "name": "aVault", - "docs": [ - "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." - ], - "type": "publicKey" - }, - { - "name": "bVault", - "docs": [ - "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." - ], - "type": "publicKey" - }, - { - "name": "aVaultLp", - "docs": [ - "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ], - "type": "publicKey" - }, - { - "name": "bVaultLp", - "docs": [ - "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." - ], - "type": "publicKey" - }, - { - "name": "aVaultLpBump", - "docs": [ - "\"A\" vault lp bump. Used to create signer seeds." - ], - "type": "u8" - }, - { - "name": "enabled", - "docs": [ - "Flag to determine whether the pool is enabled, or disabled." - ], - "type": "bool" - }, - { - "name": "protocolTokenAFee", - "docs": [ - "Protocol fee token account for token A. Used to receive trading fee." - ], - "type": "publicKey" - }, - { - "name": "protocolTokenBFee", - "docs": [ - "Protocol fee token account for token B. Used to receive trading fee." - ], - "type": "publicKey" - }, - { - "name": "feeLastUpdatedAt", - "docs": ["Fee last updated timestamp"], - "type": "u64" - }, - { "name": "padding0", "type": { "array": ["u8", 24] } }, - { - "name": "fees", - "docs": ["Store the fee charges setting."], - "type": { "defined": "PoolFees" } - }, - { - "name": "poolType", - "docs": ["Pool type"], - "type": { "defined": "PoolType" } - }, - { - "name": "stake", - "docs": ["Stake pubkey of SPL stake pool"], - "type": "publicKey" - }, - { - "name": "totalLockedLp", - "docs": ["Total locked lp token"], - "type": "u64" - }, - { - "name": "bootstrapping", - "docs": ["bootstrapping config"], - "type": { "defined": "Bootstrapping" } - }, - { - "name": "partnerInfo", - "type": { "defined": "PartnerInfo" } - }, - { - "name": "padding", - "docs": ["Padding for future pool field"], - "type": { "defined": "Padding" } - }, - { - "name": "curveType", - "docs": [ - "The type of the swap curve supported by the pool." - ], - "type": { "defined": "CurveType" } - } - ] - } - } - ], - "types": [ - { - "name": "TokenMultiplier", - "docs": [ - "Multiplier for the pool token. Used to normalized token with different decimal into the same precision." - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenAMultiplier", - "docs": ["Multiplier for token A of the pool."], - "type": "u64" - }, - { - "name": "tokenBMultiplier", - "docs": ["Multiplier for token B of the pool."], - "type": "u64" - }, - { - "name": "precisionFactor", - "docs": [ - "Record the highest token decimal in the pool. For example, Token A is 6 decimal, token B is 9 decimal. This will save value of 9." - ], - "type": "u8" - } - ] - } - }, - { - "name": "PoolFees", - "docs": ["Information regarding fee charges"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "tradeFeeNumerator", - "docs": [ - "Trade fees are extra token amounts that are held inside the token", - "accounts during a trade, making the value of liquidity tokens rise.", - "Trade fee numerator" - ], - "type": "u64" - }, - { - "name": "tradeFeeDenominator", - "docs": ["Trade fee denominator"], - "type": "u64" - }, - { - "name": "protocolTradeFeeNumerator", - "docs": [ - "Protocol trading fees are extra token amounts that are held inside the token", - "accounts during a trade, with the equivalent in pool tokens minted to", - "the protocol of the program.", - "Protocol trade fee numerator" - ], - "type": "u64" - }, - { - "name": "protocolTradeFeeDenominator", - "docs": ["Protocol trade fee denominator"], - "type": "u64" - } - ] - } - }, - { - "name": "Depeg", - "docs": ["Contains information for depeg pool"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "baseVirtualPrice", - "docs": [ - "The virtual price of staking / interest bearing token" - ], - "type": "u64" - }, - { - "name": "baseCacheUpdated", - "docs": ["The last time base_virtual_price is updated"], - "type": "u64" - }, - { - "name": "depegType", - "docs": ["Type of the depeg pool"], - "type": { "defined": "DepegType" } - } - ] - } - }, - { - "name": "ConfigParameters", - "type": { - "kind": "struct", - "fields": [ - { "name": "tradeFeeNumerator", "type": "u64" }, - { "name": "protocolTradeFeeNumerator", "type": "u64" }, - { "name": "activationDuration", "type": "u64" }, - { "name": "vaultConfigKey", "type": "publicKey" }, - { "name": "poolCreatorAuthority", "type": "publicKey" }, - { "name": "activationType", "type": "u8" }, - { "name": "index", "type": "u64" }, - { "name": "partnerFeeNumerator", "type": "u64" } - ] - } - }, - { - "name": "CustomizableParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tradeFeeNumerator", - "docs": ["Trading fee."], - "type": "u32" - }, - { - "name": "activationPoint", - "docs": ["The pool start trading."], - "type": { "option": "u64" } - }, - { - "name": "hasAlphaVault", - "docs": ["Whether the pool support alpha vault"], - "type": "bool" - }, - { - "name": "activationType", - "docs": ["Activation type"], - "type": "u8" - }, - { - "name": "padding", - "docs": ["Padding"], - "type": { "array": ["u8", 90] } - } - ] - } - }, - { - "name": "Padding", - "docs": ["Padding for future pool fields"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "padding0", - "docs": ["Padding 0"], - "type": { "array": ["u8", 6] } - }, - { - "name": "padding1", - "docs": ["Padding 1"], - "type": { "array": ["u64", 21] } - }, - { - "name": "padding2", - "docs": ["Padding 2"], - "type": { "array": ["u64", 21] } - } - ] - } - }, - { - "name": "PartnerInfo", - "type": { - "kind": "struct", - "fields": [ - { "name": "feeNumerator", "type": "u64" }, - { "name": "partnerAuthority", "type": "publicKey" }, - { "name": "pendingFeeA", "type": "u64" }, - { "name": "pendingFeeB", "type": "u64" } - ] - } - }, - { - "name": "Bootstrapping", - "type": { - "kind": "struct", - "fields": [ - { - "name": "activationPoint", - "docs": ["Activation point, can be slot or timestamp"], - "type": "u64" - }, - { - "name": "whitelistedVault", - "docs": [ - "Whitelisted vault to be able to buy pool before activation_point" - ], - "type": "publicKey" - }, - { - "name": "poolCreator", - "docs": [ - "Need to store pool creator in lauch pool, so they can modify liquidity before activation_point" - ], - "type": "publicKey" - }, - { - "name": "activationType", - "docs": [ - "Activation type, 0 means by slot, 1 means by timestamp" - ], - "type": "u8" - } - ] - } - }, - { - "name": "ActivationType", - "docs": ["Type of the activation"], - "type": { - "kind": "enum", - "variants": [{ "name": "Slot" }, { "name": "Timestamp" }] - } - }, - { - "name": "RoundDirection", - "docs": ["Rounding direction"], - "type": { - "kind": "enum", - "variants": [{ "name": "Floor" }, { "name": "Ceiling" }] - } - }, - { - "name": "TradeDirection", - "docs": ["Trade (swap) direction"], - "type": { - "kind": "enum", - "variants": [{ "name": "AtoB" }, { "name": "BtoA" }] - } - }, - { - "name": "NewCurveType", - "docs": ["Type of the swap curve"], - "type": { - "kind": "enum", - "variants": [ - { "name": "ConstantProduct" }, - { - "name": "Stable", - "fields": [ - { - "name": "amp", - "docs": ["Amplification coefficient"], - "type": "u64" - }, - { - "name": "token_multiplier", - "docs": [ - "Multiplier for the pool token. Used to normalized token with different decimal into the same precision." - ], - "type": { "defined": "TokenMultiplier" } - }, - { - "name": "depeg", - "docs": [ - "Depeg pool information. Contains functions to allow token amount to be repeg using stake / interest bearing token virtual price" - ], - "type": { "defined": "Depeg" } - }, - { - "name": "last_amp_updated_timestamp", - "docs": [ - "The last amp updated timestamp. Used to prevent update_curve_info called infinitely many times within a short period" - ], - "type": "u64" - } - ] - }, - { - "name": "NewCurve", - "fields": [ - { "name": "field_one", "type": "u64" }, - { "name": "field_two", "type": "u64" } - ] - } - ] - } - }, - { - "name": "CurveType", - "docs": ["Type of the swap curve"], - "type": { - "kind": "enum", - "variants": [ - { "name": "ConstantProduct" }, - { - "name": "Stable", - "fields": [ - { - "name": "amp", - "docs": ["Amplification coefficient"], - "type": "u64" - }, - { - "name": "token_multiplier", - "docs": [ - "Multiplier for the pool token. Used to normalized token with different decimal into the same precision." - ], - "type": { "defined": "TokenMultiplier" } - }, - { - "name": "depeg", - "docs": [ - "Depeg pool information. Contains functions to allow token amount to be repeg using stake / interest bearing token virtual price" - ], - "type": { "defined": "Depeg" } - }, - { - "name": "last_amp_updated_timestamp", - "docs": [ - "The last amp updated timestamp. Used to prevent update_curve_info called infinitely many times within a short period" - ], - "type": "u64" - } - ] - } - ] - } - }, - { - "name": "DepegType", - "docs": ["Type of depeg pool"], - "type": { - "kind": "enum", - "variants": [ - { "name": "None" }, - { "name": "Marinade" }, - { "name": "Lido" }, - { "name": "SplStake" } - ] - } - }, - { - "name": "Rounding", - "docs": ["Round up, down"], - "type": { - "kind": "enum", - "variants": [{ "name": "Up" }, { "name": "Down" }] - } - }, - { - "name": "PoolType", - "docs": ["Pool type"], - "type": { - "kind": "enum", - "variants": [ - { "name": "Permissioned" }, - { "name": "Permissionless" } - ] - } - } - ], - "events": [ - { - "name": "AddLiquidity", - "fields": [ - { "name": "lpMintAmount", "type": "u64", "index": false }, - { "name": "tokenAAmount", "type": "u64", "index": false }, - { "name": "tokenBAmount", "type": "u64", "index": false } - ] - }, - { - "name": "RemoveLiquidity", - "fields": [ - { "name": "lpUnmintAmount", "type": "u64", "index": false }, - { "name": "tokenAOutAmount", "type": "u64", "index": false }, - { "name": "tokenBOutAmount", "type": "u64", "index": false } - ] - }, - { - "name": "BootstrapLiquidity", - "fields": [ - { "name": "lpMintAmount", "type": "u64", "index": false }, - { "name": "tokenAAmount", "type": "u64", "index": false }, - { "name": "tokenBAmount", "type": "u64", "index": false }, - { "name": "pool", "type": "publicKey", "index": false } - ] - }, - { - "name": "Swap", - "fields": [ - { "name": "inAmount", "type": "u64", "index": false }, - { "name": "outAmount", "type": "u64", "index": false }, - { "name": "tradeFee", "type": "u64", "index": false }, - { "name": "protocolFee", "type": "u64", "index": false }, - { "name": "hostFee", "type": "u64", "index": false } - ] - }, - { - "name": "SetPoolFees", - "fields": [ - { "name": "tradeFeeNumerator", "type": "u64", "index": false }, - { - "name": "tradeFeeDenominator", - "type": "u64", - "index": false - }, - { - "name": "protocolTradeFeeNumerator", - "type": "u64", - "index": false - }, - { - "name": "protocolTradeFeeDenominator", - "type": "u64", - "index": false - }, - { "name": "pool", "type": "publicKey", "index": false } - ] - }, - { - "name": "PoolInfo", - "fields": [ - { "name": "tokenAAmount", "type": "u64", "index": false }, - { "name": "tokenBAmount", "type": "u64", "index": false }, - { "name": "virtualPrice", "type": "f64", "index": false }, - { "name": "currentTimestamp", "type": "u64", "index": false } - ] - }, - { - "name": "TransferAdmin", - "fields": [ - { "name": "admin", "type": "publicKey", "index": false }, - { "name": "newAdmin", "type": "publicKey", "index": false }, - { "name": "pool", "type": "publicKey", "index": false } - ] - }, - { - "name": "OverrideCurveParam", - "fields": [ - { "name": "newAmp", "type": "u64", "index": false }, - { "name": "updatedTimestamp", "type": "u64", "index": false }, - { "name": "pool", "type": "publicKey", "index": false } - ] - }, - { - "name": "PoolCreated", - "fields": [ - { "name": "lpMint", "type": "publicKey", "index": false }, - { "name": "tokenAMint", "type": "publicKey", "index": false }, - { "name": "tokenBMint", "type": "publicKey", "index": false }, - { - "name": "poolType", - "type": { "defined": "PoolType" }, - "index": false - }, - { "name": "pool", "type": "publicKey", "index": false } - ] - }, - { - "name": "PoolEnabled", - "fields": [ - { "name": "pool", "type": "publicKey", "index": false }, - { "name": "enabled", "type": "bool", "index": false } - ] - }, - { - "name": "MigrateFeeAccount", - "fields": [ - { "name": "pool", "type": "publicKey", "index": false }, - { - "name": "newAdminTokenAFee", - "type": "publicKey", - "index": false - }, - { - "name": "newAdminTokenBFee", - "type": "publicKey", - "index": false - }, - { "name": "tokenAAmount", "type": "u64", "index": false }, - { "name": "tokenBAmount", "type": "u64", "index": false } - ] - }, - { - "name": "CreateLockEscrow", - "fields": [ - { "name": "pool", "type": "publicKey", "index": false }, - { "name": "owner", "type": "publicKey", "index": false } - ] - }, - { - "name": "Lock", - "fields": [ - { "name": "pool", "type": "publicKey", "index": false }, - { "name": "owner", "type": "publicKey", "index": false }, - { "name": "amount", "type": "u64", "index": false } - ] - }, - { - "name": "ClaimFee", - "fields": [ - { "name": "pool", "type": "publicKey", "index": false }, - { "name": "owner", "type": "publicKey", "index": false }, - { "name": "amount", "type": "u64", "index": false }, - { "name": "aFee", "type": "u64", "index": false }, - { "name": "bFee", "type": "u64", "index": false } - ] - }, - { - "name": "CreateConfig", - "fields": [ - { "name": "tradeFeeNumerator", "type": "u64", "index": false }, - { - "name": "protocolTradeFeeNumerator", - "type": "u64", - "index": false - }, - { "name": "config", "type": "publicKey", "index": false } - ] - }, - { - "name": "CloseConfig", - "fields": [ - { "name": "config", "type": "publicKey", "index": false } - ] - }, - { - "name": "WithdrawProtocolFees", - "fields": [ - { "name": "pool", "type": "publicKey", "index": false }, - { "name": "protocolAFee", "type": "u64", "index": false }, - { "name": "protocolBFee", "type": "u64", "index": false }, - { - "name": "protocolAFeeOwner", - "type": "publicKey", - "index": false - }, - { - "name": "protocolBFeeOwner", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "PartnerClaimFees", - "fields": [ - { "name": "pool", "type": "publicKey", "index": false }, - { "name": "feeA", "type": "u64", "index": false }, - { "name": "feeB", "type": "u64", "index": false }, - { "name": "partner", "type": "publicKey", "index": false } - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "MathOverflow", - "msg": "Math operation overflow" - }, - { "code": 6001, "name": "InvalidFee", "msg": "Invalid fee setup" }, - { - "code": 6002, - "name": "InvalidInvariant", - "msg": "Invalid invariant d" - }, - { - "code": 6003, - "name": "FeeCalculationFailure", - "msg": "Fee calculation failure" - }, - { - "code": 6004, - "name": "ExceededSlippage", - "msg": "Exceeded slippage tolerance" - }, - { - "code": 6005, - "name": "InvalidCalculation", - "msg": "Invalid curve calculation" - }, - { - "code": 6006, - "name": "ZeroTradingTokens", - "msg": "Given pool token amount results in zero trading tokens" - }, - { - "code": 6007, - "name": "ConversionError", - "msg": "Math conversion overflow" - }, - { - "code": 6008, - "name": "FaultyLpMint", - "msg": "LP mint authority must be 'A' vault lp, without freeze authority, and 0 supply" - }, - { - "code": 6009, - "name": "MismatchedTokenMint", - "msg": "Token mint mismatched" - }, - { - "code": 6010, - "name": "MismatchedLpMint", - "msg": "LP mint mismatched" - }, - { - "code": 6011, - "name": "MismatchedOwner", - "msg": "Invalid lp token owner" - }, - { - "code": 6012, - "name": "InvalidVaultAccount", - "msg": "Invalid vault account" - }, - { - "code": 6013, - "name": "InvalidVaultLpAccount", - "msg": "Invalid vault lp account" - }, - { - "code": 6014, - "name": "InvalidPoolLpMintAccount", - "msg": "Invalid pool lp mint account" - }, - { "code": 6015, "name": "PoolDisabled", "msg": "Pool disabled" }, - { - "code": 6016, - "name": "InvalidAdminAccount", - "msg": "Invalid admin account" - }, - { - "code": 6017, - "name": "InvalidProtocolFeeAccount", - "msg": "Invalid protocol fee account" - }, - { - "code": 6018, - "name": "SameAdminAccount", - "msg": "Same admin account" - }, - { - "code": 6019, - "name": "IdenticalSourceDestination", - "msg": "Identical user source and destination token account" - }, - { - "code": 6020, - "name": "ApyCalculationError", - "msg": "Apy calculation error" - }, - { - "code": 6021, - "name": "InsufficientSnapshot", - "msg": "Insufficient virtual price snapshot" - }, - { - "code": 6022, - "name": "NonUpdatableCurve", - "msg": "Current curve is non-updatable" - }, - { - "code": 6023, - "name": "MisMatchedCurve", - "msg": "New curve is mismatched with old curve" - }, - { - "code": 6024, - "name": "InvalidAmplification", - "msg": "Amplification is invalid" - }, - { - "code": 6025, - "name": "UnsupportedOperation", - "msg": "Operation is not supported" - }, - { - "code": 6026, - "name": "ExceedMaxAChanges", - "msg": "Exceed max amplification changes" - }, - { - "code": 6027, - "name": "InvalidRemainingAccountsLen", - "msg": "Invalid remaining accounts length" - }, - { - "code": 6028, - "name": "InvalidRemainingAccounts", - "msg": "Invalid remaining account" - }, - { - "code": 6029, - "name": "MismatchedDepegMint", - "msg": "Token mint B doesn't matches depeg type token mint" - }, - { - "code": 6030, - "name": "InvalidApyAccount", - "msg": "Invalid APY account" - }, - { - "code": 6031, - "name": "InvalidTokenMultiplier", - "msg": "Invalid token multiplier" - }, - { - "code": 6032, - "name": "InvalidDepegInformation", - "msg": "Invalid depeg information" - }, - { - "code": 6033, - "name": "UpdateTimeConstraint", - "msg": "Update time constraint violated" - }, - { - "code": 6034, - "name": "ExceedMaxFeeBps", - "msg": "Exceeded max fee bps" - }, - { "code": 6035, "name": "InvalidAdmin", "msg": "Invalid admin" }, - { - "code": 6036, - "name": "PoolIsNotPermissioned", - "msg": "Pool is not permissioned" - }, - { - "code": 6037, - "name": "InvalidDepositAmount", - "msg": "Invalid deposit amount" - }, - { "code": 6038, "name": "InvalidFeeOwner", "msg": "Invalid fee owner" }, - { - "code": 6039, - "name": "NonDepletedPool", - "msg": "Pool is not depleted" - }, - { - "code": 6040, - "name": "AmountNotPeg", - "msg": "Token amount is not 1:1" - }, - { "code": 6041, "name": "AmountIsZero", "msg": "Amount is zero" }, - { "code": 6042, "name": "TypeCastFailed", "msg": "Type cast error" }, - { - "code": 6043, - "name": "AmountIsNotEnough", - "msg": "Amount is not enough" - }, - { - "code": 6044, - "name": "InvalidActivationDuration", - "msg": "Invalid activation duration" - }, - { - "code": 6045, - "name": "PoolIsNotLaunchPool", - "msg": "Pool is not launch pool" - }, - { - "code": 6046, - "name": "UnableToModifyActivationPoint", - "msg": "Unable to modify activation point" - }, - { - "code": 6047, - "name": "InvalidAuthorityToCreateThePool", - "msg": "Invalid authority to create the pool" - }, - { - "code": 6048, - "name": "InvalidActivationType", - "msg": "Invalid activation type" - }, - { - "code": 6049, - "name": "InvalidActivationPoint", - "msg": "Invalid activation point" - }, - { - "code": 6050, - "name": "PreActivationSwapStarted", - "msg": "Pre activation swap window started" - }, - { "code": 6051, "name": "InvalidPoolType", "msg": "Invalid pool type" }, - { - "code": 6052, - "name": "InvalidQuoteMint", - "msg": "Quote token must be SOL,USDC" - } - ] -} diff --git a/crates/meteora-pools-parser/proto/meteora_pools.proto b/crates/meteora-pools-parser/proto/meteora_pools.proto deleted file mode 100644 index a69f1949..00000000 --- a/crates/meteora-pools-parser/proto/meteora_pools.proto +++ /dev/null @@ -1,862 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.meteora_pools; - -message NewCurveTypeConstantProduct { } - -message NewCurveTypeStable { - uint64 amp = 1; - TokenMultiplier token_multiplier = 2; - Depeg depeg = 3; - uint64 last_amp_updated_timestamp = 4; -} - -message NewCurveTypeNewCurve { - uint64 field_one = 1; - uint64 field_two = 2; -} - -message CurveTypeConstantProduct { } - -message CurveTypeStable { - uint64 amp = 1; - TokenMultiplier token_multiplier = 2; - Depeg depeg = 3; - uint64 last_amp_updated_timestamp = 4; -} - -message InitializePermissionedPoolIx { - InitializePermissionedPoolIxAccounts accounts = 1; - InitializePermissionedPoolIxData data = 2; -} - -message InitializePermissionlessPoolIx { - InitializePermissionlessPoolIxAccounts accounts = 1; - InitializePermissionlessPoolIxData data = 2; -} - -message InitializePermissionlessPoolWithFeeTierIx { - InitializePermissionlessPoolWithFeeTierIxAccounts accounts = 1; - InitializePermissionlessPoolWithFeeTierIxData data = 2; -} - -message EnableOrDisablePoolIx { - EnableOrDisablePoolIxAccounts accounts = 1; - EnableOrDisablePoolIxData data = 2; -} - -message SwapIx { - SwapIxAccounts accounts = 1; - SwapIxData data = 2; -} - -message RemoveLiquiditySingleSideIx { - RemoveLiquiditySingleSideIxAccounts accounts = 1; - RemoveLiquiditySingleSideIxData data = 2; -} - -message AddImbalanceLiquidityIx { - AddImbalanceLiquidityIxAccounts accounts = 1; - AddImbalanceLiquidityIxData data = 2; -} - -message RemoveBalanceLiquidityIx { - RemoveBalanceLiquidityIxAccounts accounts = 1; - RemoveBalanceLiquidityIxData data = 2; -} - -message AddBalanceLiquidityIx { - AddBalanceLiquidityIxAccounts accounts = 1; - AddBalanceLiquidityIxData data = 2; -} - -message SetPoolFeesIx { - SetPoolFeesIxAccounts accounts = 1; - SetPoolFeesIxData data = 2; -} - -message OverrideCurveParamIx { - OverrideCurveParamIxAccounts accounts = 1; - OverrideCurveParamIxData data = 2; -} - -message GetPoolInfoIx { - GetPoolInfoIxAccounts accounts = 1; -} - -message BootstrapLiquidityIx { - BootstrapLiquidityIxAccounts accounts = 1; - BootstrapLiquidityIxData data = 2; -} - -message CreateMintMetadataIx { - CreateMintMetadataIxAccounts accounts = 1; -} - -message CreateLockEscrowIx { - CreateLockEscrowIxAccounts accounts = 1; -} - -message LockIx { - LockIxAccounts accounts = 1; - LockIxData data = 2; -} - -message ClaimFeeIx { - ClaimFeeIxAccounts accounts = 1; - ClaimFeeIxData data = 2; -} - -message CreateConfigIx { - CreateConfigIxAccounts accounts = 1; - CreateConfigIxData data = 2; -} - -message CloseConfigIx { - CloseConfigIxAccounts accounts = 1; -} - -message InitializePermissionlessConstantProductPoolWithConfigIx { - InitializePermissionlessConstantProductPoolWithConfigIxAccounts accounts = 1; - InitializePermissionlessConstantProductPoolWithConfigIxData data = 2; -} - -message InitializePermissionlessConstantProductPoolWithConfig2Ix { - InitializePermissionlessConstantProductPoolWithConfig2IxAccounts accounts = 1; - InitializePermissionlessConstantProductPoolWithConfig2IxData data = 2; -} - -message InitializeCustomizablePermissionlessConstantProductPoolIx { - InitializeCustomizablePermissionlessConstantProductPoolIxAccounts accounts = 1; - InitializeCustomizablePermissionlessConstantProductPoolIxData data = 2; -} - -message UpdateActivationPointIx { - UpdateActivationPointIxAccounts accounts = 1; - UpdateActivationPointIxData data = 2; -} - -message WithdrawProtocolFeesIx { - WithdrawProtocolFeesIxAccounts accounts = 1; -} - -message SetWhitelistedVaultIx { - SetWhitelistedVaultIxAccounts accounts = 1; - SetWhitelistedVaultIxData data = 2; -} - -message PartnerClaimFeeIx { - PartnerClaimFeeIxAccounts accounts = 1; - PartnerClaimFeeIxData data = 2; -} - - -message TokenMultiplier { - uint64 token_a_multiplier = 1; - uint64 token_b_multiplier = 2; - uint32 precision_factor = 3; -} - -message PoolFees { - uint64 trade_fee_numerator = 1; - uint64 trade_fee_denominator = 2; - uint64 protocol_trade_fee_numerator = 3; - uint64 protocol_trade_fee_denominator = 4; -} - -message Depeg { - uint64 base_virtual_price = 1; - uint64 base_cache_updated = 2; - DepegType depeg_type = 3; -} - -message Padding { - repeated uint32 padding0 = 1; - repeated uint64 padding1 = 2; - repeated uint64 padding2 = 3; -} - -message PartnerInfo { - uint64 fee_numerator = 1; - string partner_authority = 2; - uint64 pending_fee_a = 3; - uint64 pending_fee_b = 4; -} - -message Bootstrapping { - uint64 activation_point = 1; - string whitelisted_vault = 2; - string pool_creator = 3; - uint32 activation_type = 4; -} - -enum ActivationType { - ActivationTypeSlot = 0; - ActivationTypeTimestamp = 1; -} - -enum RoundDirection { - RoundDirectionFloor = 0; - RoundDirectionCeiling = 1; -} - -enum TradeDirection { - TradeDirectionAtoB = 0; - TradeDirectionBtoA = 1; -} - -message NewCurveType { - oneof variant{ - NewCurveTypeConstantProduct constant_product = 1; - NewCurveTypeStable stable = 2; - NewCurveTypeNewCurve new_curve = 3; - } -} - -message CurveType { - oneof variant{ - CurveTypeConstantProduct constant_product = 1; - CurveTypeStable stable = 2; - } -} - -enum DepegType { - DepegTypeNone = 0; - DepegTypeMarinade = 1; - DepegTypeLido = 2; - DepegTypeSplStake = 3; -} - -enum Rounding { - RoundingUp = 0; - RoundingDown = 1; -} - -enum PoolType { - PoolTypePermissioned = 0; - PoolTypePermissionless = 1; -} - - -message Config { - PoolFees pool_fees = 1; - uint64 activation_duration = 2; - string vault_config_key = 3; - string pool_creator_authority = 4; - uint32 activation_type = 5; - uint64 partner_fee_numerator = 6; - repeated uint32 padding = 7; -} - -message LockEscrow { - string pool = 1; - string owner = 2; - string escrow_vault = 3; - uint32 bump = 4; - uint64 total_locked_amount = 5; - string lp_per_token = 6; - uint64 unclaimed_fee_pending = 7; - uint64 a_fee = 8; - uint64 b_fee = 9; -} - -message Pool { - string lp_mint = 1; - string token_a_mint = 2; - string token_b_mint = 3; - string a_vault = 4; - string b_vault = 5; - string a_vault_lp = 6; - string b_vault_lp = 7; - uint32 a_vault_lp_bump = 8; - bool enabled = 9; - string protocol_token_a_fee = 10; - string protocol_token_b_fee = 11; - uint64 fee_last_updated_at = 12; - repeated uint32 padding0 = 13; - PoolFees fees = 14; - PoolType pool_type = 15; - string stake = 16; - uint64 total_locked_lp = 17; - Bootstrapping bootstrapping = 18; - PartnerInfo partner_info = 19; - Padding padding = 20; - CurveType curve_type = 21; -} - - -message InitializePermissionedPoolIxAccounts { - string pool = 1; - string lp_mint = 2; - string token_a_mint = 3; - string token_b_mint = 4; - string a_vault = 5; - string b_vault = 6; - string a_vault_lp_mint = 7; - string b_vault_lp_mint = 8; - string a_vault_lp = 9; - string b_vault_lp = 10; - string admin_token_a = 11; - string admin_token_b = 12; - string admin_pool_lp = 13; - string protocol_token_a_fee = 14; - string protocol_token_b_fee = 15; - string admin = 16; - string fee_owner = 17; - string rent = 18; - string mint_metadata = 19; - string metadata_program = 20; - string vault_program = 21; - string token_program = 22; - string associated_token_program = 23; - string system_program = 24; -} - -message InitializePermissionedPoolIxData { - CurveType curve_type = 1; -} - -message InitializePermissionlessPoolIxAccounts { - string pool = 1; - string lp_mint = 2; - string token_a_mint = 3; - string token_b_mint = 4; - string a_vault = 5; - string b_vault = 6; - string a_token_vault = 7; - string b_token_vault = 8; - string a_vault_lp_mint = 9; - string b_vault_lp_mint = 10; - string a_vault_lp = 11; - string b_vault_lp = 12; - string payer_token_a = 13; - string payer_token_b = 14; - string payer_pool_lp = 15; - string protocol_token_a_fee = 16; - string protocol_token_b_fee = 17; - string payer = 18; - string fee_owner = 19; - string rent = 20; - string mint_metadata = 21; - string metadata_program = 22; - string vault_program = 23; - string token_program = 24; - string associated_token_program = 25; - string system_program = 26; -} - -message InitializePermissionlessPoolIxData { - CurveType curve_type = 1; - uint64 token_a_amount = 2; - uint64 token_b_amount = 3; -} - -message InitializePermissionlessPoolWithFeeTierIxAccounts { - string pool = 1; - string lp_mint = 2; - string token_a_mint = 3; - string token_b_mint = 4; - string a_vault = 5; - string b_vault = 6; - string a_token_vault = 7; - string b_token_vault = 8; - string a_vault_lp_mint = 9; - string b_vault_lp_mint = 10; - string a_vault_lp = 11; - string b_vault_lp = 12; - string payer_token_a = 13; - string payer_token_b = 14; - string payer_pool_lp = 15; - string protocol_token_a_fee = 16; - string protocol_token_b_fee = 17; - string payer = 18; - string fee_owner = 19; - string rent = 20; - string mint_metadata = 21; - string metadata_program = 22; - string vault_program = 23; - string token_program = 24; - string associated_token_program = 25; - string system_program = 26; -} - -message InitializePermissionlessPoolWithFeeTierIxData { - CurveType curve_type = 1; - uint64 trade_fee_bps = 2; - uint64 token_a_amount = 3; - uint64 token_b_amount = 4; -} - -message EnableOrDisablePoolIxAccounts { - string pool = 1; - string admin = 2; -} - -message EnableOrDisablePoolIxData { - bool enable = 1; -} - -message SwapIxAccounts { - string pool = 1; - string user_source_token = 2; - string user_destination_token = 3; - string a_vault = 4; - string b_vault = 5; - string a_token_vault = 6; - string b_token_vault = 7; - string a_vault_lp_mint = 8; - string b_vault_lp_mint = 9; - string a_vault_lp = 10; - string b_vault_lp = 11; - string protocol_token_fee = 12; - string user = 13; - string vault_program = 14; - string token_program = 15; -} - -message SwapIxData { - uint64 in_amount = 1; - uint64 minimum_out_amount = 2; -} - -message RemoveLiquiditySingleSideIxAccounts { - string pool = 1; - string lp_mint = 2; - string user_pool_lp = 3; - string a_vault_lp = 4; - string b_vault_lp = 5; - string a_vault = 6; - string b_vault = 7; - string a_vault_lp_mint = 8; - string b_vault_lp_mint = 9; - string a_token_vault = 10; - string b_token_vault = 11; - string user_destination_token = 12; - string user = 13; - string vault_program = 14; - string token_program = 15; -} - -message RemoveLiquiditySingleSideIxData { - uint64 pool_token_amount = 1; - uint64 minimum_out_amount = 2; -} - -message AddImbalanceLiquidityIxAccounts { - string pool = 1; - string lp_mint = 2; - string user_pool_lp = 3; - string a_vault_lp = 4; - string b_vault_lp = 5; - string a_vault = 6; - string b_vault = 7; - string a_vault_lp_mint = 8; - string b_vault_lp_mint = 9; - string a_token_vault = 10; - string b_token_vault = 11; - string user_a_token = 12; - string user_b_token = 13; - string user = 14; - string vault_program = 15; - string token_program = 16; -} - -message AddImbalanceLiquidityIxData { - uint64 minimum_pool_token_amount = 1; - uint64 token_a_amount = 2; - uint64 token_b_amount = 3; -} - -message RemoveBalanceLiquidityIxAccounts { - string pool = 1; - string lp_mint = 2; - string user_pool_lp = 3; - string a_vault_lp = 4; - string b_vault_lp = 5; - string a_vault = 6; - string b_vault = 7; - string a_vault_lp_mint = 8; - string b_vault_lp_mint = 9; - string a_token_vault = 10; - string b_token_vault = 11; - string user_a_token = 12; - string user_b_token = 13; - string user = 14; - string vault_program = 15; - string token_program = 16; -} - -message RemoveBalanceLiquidityIxData { - uint64 pool_token_amount = 1; - uint64 minimum_a_token_out = 2; - uint64 minimum_b_token_out = 3; -} - -message AddBalanceLiquidityIxAccounts { - string pool = 1; - string lp_mint = 2; - string user_pool_lp = 3; - string a_vault_lp = 4; - string b_vault_lp = 5; - string a_vault = 6; - string b_vault = 7; - string a_vault_lp_mint = 8; - string b_vault_lp_mint = 9; - string a_token_vault = 10; - string b_token_vault = 11; - string user_a_token = 12; - string user_b_token = 13; - string user = 14; - string vault_program = 15; - string token_program = 16; -} - -message AddBalanceLiquidityIxData { - uint64 pool_token_amount = 1; - uint64 maximum_token_a_amount = 2; - uint64 maximum_token_b_amount = 3; -} - -message SetPoolFeesIxAccounts { - string pool = 1; - string fee_operator = 2; -} - -message SetPoolFeesIxData { - PoolFees fees = 1; - uint64 new_partner_fee_numerator = 2; -} - -message OverrideCurveParamIxAccounts { - string pool = 1; - string admin = 2; -} - -message OverrideCurveParamIxData { - CurveType curve_type = 1; -} - -message GetPoolInfoIxAccounts { - string pool = 1; - string lp_mint = 2; - string a_vault_lp = 3; - string b_vault_lp = 4; - string a_vault = 5; - string b_vault = 6; - string a_vault_lp_mint = 7; - string b_vault_lp_mint = 8; -} - - -message BootstrapLiquidityIxAccounts { - string pool = 1; - string lp_mint = 2; - string user_pool_lp = 3; - string a_vault_lp = 4; - string b_vault_lp = 5; - string a_vault = 6; - string b_vault = 7; - string a_vault_lp_mint = 8; - string b_vault_lp_mint = 9; - string a_token_vault = 10; - string b_token_vault = 11; - string user_a_token = 12; - string user_b_token = 13; - string user = 14; - string vault_program = 15; - string token_program = 16; -} - -message BootstrapLiquidityIxData { - uint64 token_a_amount = 1; - uint64 token_b_amount = 2; -} - -message CreateMintMetadataIxAccounts { - string pool = 1; - string lp_mint = 2; - string a_vault_lp = 3; - string mint_metadata = 4; - string metadata_program = 5; - string system_program = 6; - string payer = 7; -} - - -message CreateLockEscrowIxAccounts { - string pool = 1; - string lock_escrow = 2; - string owner = 3; - string lp_mint = 4; - string payer = 5; - string system_program = 6; -} - - -message LockIxAccounts { - string pool = 1; - string lp_mint = 2; - string lock_escrow = 3; - string owner = 4; - string source_tokens = 5; - string escrow_vault = 6; - string token_program = 7; - string a_vault = 8; - string b_vault = 9; - string a_vault_lp = 10; - string b_vault_lp = 11; - string a_vault_lp_mint = 12; - string b_vault_lp_mint = 13; -} - -message LockIxData { - uint64 max_amount = 1; -} - -message ClaimFeeIxAccounts { - string pool = 1; - string lp_mint = 2; - string lock_escrow = 3; - string owner = 4; - string source_tokens = 5; - string escrow_vault = 6; - string token_program = 7; - string a_token_vault = 8; - string b_token_vault = 9; - string a_vault = 10; - string b_vault = 11; - string a_vault_lp = 12; - string b_vault_lp = 13; - string a_vault_lp_mint = 14; - string b_vault_lp_mint = 15; - string user_a_token = 16; - string user_b_token = 17; - string vault_program = 18; -} - -message ClaimFeeIxData { - uint64 max_amount = 1; -} - -message CreateConfigIxAccounts { - string config = 1; - string admin = 2; - string system_program = 3; -} - -message CreateConfigIxData { - uint64 trade_fee_numerator = 1; - uint64 protocol_trade_fee_numerator = 2; - uint64 activation_duration = 3; - string vault_config_key = 4; - string pool_creator_authority = 5; - uint32 activation_type = 6; - uint64 index = 7; - uint64 partner_fee_numerator = 8; -} - -message CloseConfigIxAccounts { - string config = 1; - string admin = 2; - string rent_receiver = 3; -} - - -message InitializePermissionlessConstantProductPoolWithConfigIxAccounts { - string pool = 1; - string config = 2; - string lp_mint = 3; - string token_a_mint = 4; - string token_b_mint = 5; - string a_vault = 6; - string b_vault = 7; - string a_token_vault = 8; - string b_token_vault = 9; - string a_vault_lp_mint = 10; - string b_vault_lp_mint = 11; - string a_vault_lp = 12; - string b_vault_lp = 13; - string payer_token_a = 14; - string payer_token_b = 15; - string payer_pool_lp = 16; - string protocol_token_a_fee = 17; - string protocol_token_b_fee = 18; - string payer = 19; - string rent = 20; - string mint_metadata = 21; - string metadata_program = 22; - string vault_program = 23; - string token_program = 24; - string associated_token_program = 25; - string system_program = 26; -} - -message InitializePermissionlessConstantProductPoolWithConfigIxData { - uint64 token_a_amount = 1; - uint64 token_b_amount = 2; -} - -message InitializePermissionlessConstantProductPoolWithConfig2IxAccounts { - string pool = 1; - string config = 2; - string lp_mint = 3; - string token_a_mint = 4; - string token_b_mint = 5; - string a_vault = 6; - string b_vault = 7; - string a_token_vault = 8; - string b_token_vault = 9; - string a_vault_lp_mint = 10; - string b_vault_lp_mint = 11; - string a_vault_lp = 12; - string b_vault_lp = 13; - string payer_token_a = 14; - string payer_token_b = 15; - string payer_pool_lp = 16; - string protocol_token_a_fee = 17; - string protocol_token_b_fee = 18; - string payer = 19; - string rent = 20; - string mint_metadata = 21; - string metadata_program = 22; - string vault_program = 23; - string token_program = 24; - string associated_token_program = 25; - string system_program = 26; -} - -message InitializePermissionlessConstantProductPoolWithConfig2IxData { - uint64 token_a_amount = 1; - uint64 token_b_amount = 2; - optional uint64 activation_point = 3; -} - -message InitializeCustomizablePermissionlessConstantProductPoolIxAccounts { - string pool = 1; - string lp_mint = 2; - string token_a_mint = 3; - string token_b_mint = 4; - string a_vault = 5; - string b_vault = 6; - string a_token_vault = 7; - string b_token_vault = 8; - string a_vault_lp_mint = 9; - string b_vault_lp_mint = 10; - string a_vault_lp = 11; - string b_vault_lp = 12; - string payer_token_a = 13; - string payer_token_b = 14; - string payer_pool_lp = 15; - string protocol_token_a_fee = 16; - string protocol_token_b_fee = 17; - string payer = 18; - string rent = 19; - string mint_metadata = 20; - string metadata_program = 21; - string vault_program = 22; - string token_program = 23; - string associated_token_program = 24; - string system_program = 25; -} - -message InitializeCustomizablePermissionlessConstantProductPoolIxData { - uint64 token_a_amount = 1; - uint64 token_b_amount = 2; - uint32 trade_fee_numerator = 3; - optional uint64 activation_point = 4; - bool has_alpha_vault = 5; - uint32 activation_type = 6; - repeated uint32 padding = 7; -} - -message UpdateActivationPointIxAccounts { - string pool = 1; - string admin = 2; -} - -message UpdateActivationPointIxData { - uint64 new_activation_point = 1; -} - -message WithdrawProtocolFeesIxAccounts { - string pool = 1; - string a_vault_lp = 2; - string protocol_token_a_fee = 3; - string protocol_token_b_fee = 4; - string treasury_token_a = 5; - string treasury_token_b = 6; - string token_program = 7; -} - - -message SetWhitelistedVaultIxAccounts { - string pool = 1; - string admin = 2; -} - -message SetWhitelistedVaultIxData { - string whitelisted_vault = 1; -} - -message PartnerClaimFeeIxAccounts { - string pool = 1; - string a_vault_lp = 2; - string protocol_token_a_fee = 3; - string protocol_token_b_fee = 4; - string partner_token_a = 5; - string partner_token_b = 6; - string token_program = 7; - string partner_authority = 8; -} - -message PartnerClaimFeeIxData { - uint64 max_amount_a = 1; - uint64 max_amount_b = 2; -} - - -message ProgramState { - oneof state_oneof { - Config config = 1; - LockEscrow lock_escrow = 2; - Pool pool = 3; - } -} - -message ProgramIxs { - oneof ix_oneof { - InitializePermissionedPoolIx initialize_permissioned_pool = 1; - InitializePermissionlessPoolIx initialize_permissionless_pool = 2; - InitializePermissionlessPoolWithFeeTierIx initialize_permissionless_pool_with_fee_tier = 3; - EnableOrDisablePoolIx enable_or_disable_pool = 4; - SwapIx swap = 5; - RemoveLiquiditySingleSideIx remove_liquidity_single_side = 6; - AddImbalanceLiquidityIx add_imbalance_liquidity = 7; - RemoveBalanceLiquidityIx remove_balance_liquidity = 8; - AddBalanceLiquidityIx add_balance_liquidity = 9; - SetPoolFeesIx set_pool_fees = 10; - OverrideCurveParamIx override_curve_param = 11; - GetPoolInfoIx get_pool_info = 12; - BootstrapLiquidityIx bootstrap_liquidity = 13; - CreateMintMetadataIx create_mint_metadata = 14; - CreateLockEscrowIx create_lock_escrow = 15; - LockIx lock = 16; - ClaimFeeIx claim_fee = 17; - CreateConfigIx create_config = 18; - CloseConfigIx close_config = 19; - InitializePermissionlessConstantProductPoolWithConfigIx initialize_permissionless_constant_product_pool_with_config = 20; - InitializePermissionlessConstantProductPoolWithConfig2Ix initialize_permissionless_constant_product_pool_with_config2 = 21; - InitializeCustomizablePermissionlessConstantProductPoolIx initialize_customizable_permissionless_constant_product_pool = 22; - UpdateActivationPointIx update_activation_point = 23; - WithdrawProtocolFeesIx withdraw_protocol_fees = 24; - SetWhitelistedVaultIx set_whitelisted_vault = 25; - PartnerClaimFeeIx partner_claim_fee = 26; - } -} - diff --git a/crates/meteora-pools-parser/src/generated_parser/accounts_parser.rs b/crates/meteora-pools-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index 5c924ec0..00000000 --- a/crates/meteora-pools-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,204 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{Config, LockEscrow, Pool}, - deserialize_checked, ID, -}; - -/// Amm Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum AmmProgramState { - Config(Config), - LockEscrow(LockEscrow), - Pool(Pool), -} - -impl AmmProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [155, 12, 170, 224, 30, 250, 204, 130] => Ok(AmmProgramState::Config( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [190, 106, 121, 6, 200, 182, 21, 75] => Ok(AmmProgramState::LockEscrow( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [241, 154, 109, 4, 17, 177, 109, 188] => Ok(AmmProgramState::Pool( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = AmmProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "amm::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = AmmProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, AmmProgramState, Config}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for Config { - fn into_proto(self) -> proto_def::Config { - proto_def::Config { - pool_fees: Some(self.pool_fees.into_proto()), - activation_duration: self.activation_duration, - vault_config_key: self.vault_config_key.to_string(), - pool_creator_authority: self.pool_creator_authority.to_string(), - activation_type: self.activation_type.into(), - partner_fee_numerator: self.partner_fee_numerator, - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::LockEscrow; - impl IntoProto for LockEscrow { - fn into_proto(self) -> proto_def::LockEscrow { - proto_def::LockEscrow { - pool: self.pool.to_string(), - owner: self.owner.to_string(), - escrow_vault: self.escrow_vault.to_string(), - bump: self.bump.into(), - total_locked_amount: self.total_locked_amount, - lp_per_token: self.lp_per_token.to_string(), - unclaimed_fee_pending: self.unclaimed_fee_pending, - a_fee: self.a_fee, - b_fee: self.b_fee, - } - } - } - use super::Pool; - impl IntoProto for Pool { - fn into_proto(self) -> proto_def::Pool { - proto_def::Pool { - lp_mint: self.lp_mint.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - a_vault_lp_bump: self.a_vault_lp_bump.into(), - enabled: self.enabled, - protocol_token_a_fee: self.protocol_token_a_fee.to_string(), - protocol_token_b_fee: self.protocol_token_b_fee.to_string(), - fee_last_updated_at: self.fee_last_updated_at, - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - fees: Some(self.fees.into_proto()), - pool_type: self.pool_type as i32, - stake: self.stake.to_string(), - total_locked_lp: self.total_locked_lp, - bootstrapping: Some(self.bootstrapping.into_proto()), - partner_info: Some(self.partner_info.into_proto()), - padding: Some(self.padding.into_proto()), - curve_type: Some(self.curve_type.into_proto()), - } - } - } - - impl IntoProto for AmmProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - AmmProgramState::Config(data) => { - proto_def::program_state::StateOneof::Config(data.into_proto()) - }, - AmmProgramState::LockEscrow(data) => { - proto_def::program_state::StateOneof::LockEscrow(data.into_proto()) - }, - AmmProgramState::Pool(data) => { - proto_def::program_state::StateOneof::Pool(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/meteora-pools-parser/src/generated_parser/instructions_parser.rs b/crates/meteora-pools-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index 122298f4..00000000 --- a/crates/meteora-pools-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,1784 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - AddBalanceLiquidity as AddBalanceLiquidityIxAccounts, - AddBalanceLiquidityInstructionArgs as AddBalanceLiquidityIxData, - AddImbalanceLiquidity as AddImbalanceLiquidityIxAccounts, - AddImbalanceLiquidityInstructionArgs as AddImbalanceLiquidityIxData, - BootstrapLiquidity as BootstrapLiquidityIxAccounts, - BootstrapLiquidityInstructionArgs as BootstrapLiquidityIxData, - ClaimFee as ClaimFeeIxAccounts, ClaimFeeInstructionArgs as ClaimFeeIxData, - CloseConfig as CloseConfigIxAccounts, CreateConfig as CreateConfigIxAccounts, - CreateConfigInstructionArgs as CreateConfigIxData, - CreateLockEscrow as CreateLockEscrowIxAccounts, - CreateMintMetadata as CreateMintMetadataIxAccounts, - EnableOrDisablePool as EnableOrDisablePoolIxAccounts, - EnableOrDisablePoolInstructionArgs as EnableOrDisablePoolIxData, - GetPoolInfo as GetPoolInfoIxAccounts, - InitializeCustomizablePermissionlessConstantProductPool as InitializeCustomizablePermissionlessConstantProductPoolIxAccounts, - InitializeCustomizablePermissionlessConstantProductPoolInstructionArgs as InitializeCustomizablePermissionlessConstantProductPoolIxData, - InitializePermissionedPool as InitializePermissionedPoolIxAccounts, - InitializePermissionedPoolInstructionArgs as InitializePermissionedPoolIxData, - InitializePermissionlessConstantProductPoolWithConfig as InitializePermissionlessConstantProductPoolWithConfigIxAccounts, - InitializePermissionlessConstantProductPoolWithConfig2 as InitializePermissionlessConstantProductPoolWithConfig2IxAccounts, - InitializePermissionlessConstantProductPoolWithConfig2InstructionArgs as InitializePermissionlessConstantProductPoolWithConfig2IxData, - InitializePermissionlessConstantProductPoolWithConfigInstructionArgs as InitializePermissionlessConstantProductPoolWithConfigIxData, - InitializePermissionlessPool as InitializePermissionlessPoolIxAccounts, - InitializePermissionlessPoolInstructionArgs as InitializePermissionlessPoolIxData, - InitializePermissionlessPoolWithFeeTier as InitializePermissionlessPoolWithFeeTierIxAccounts, - InitializePermissionlessPoolWithFeeTierInstructionArgs as InitializePermissionlessPoolWithFeeTierIxData, - Lock as LockIxAccounts, LockInstructionArgs as LockIxData, - OverrideCurveParam as OverrideCurveParamIxAccounts, - OverrideCurveParamInstructionArgs as OverrideCurveParamIxData, - PartnerClaimFee as PartnerClaimFeeIxAccounts, - PartnerClaimFeeInstructionArgs as PartnerClaimFeeIxData, - RemoveBalanceLiquidity as RemoveBalanceLiquidityIxAccounts, - RemoveBalanceLiquidityInstructionArgs as RemoveBalanceLiquidityIxData, - RemoveLiquiditySingleSide as RemoveLiquiditySingleSideIxAccounts, - RemoveLiquiditySingleSideInstructionArgs as RemoveLiquiditySingleSideIxData, - SetPoolFees as SetPoolFeesIxAccounts, SetPoolFeesInstructionArgs as SetPoolFeesIxData, - SetWhitelistedVault as SetWhitelistedVaultIxAccounts, - SetWhitelistedVaultInstructionArgs as SetWhitelistedVaultIxData, Swap as SwapIxAccounts, - SwapInstructionArgs as SwapIxData, - UpdateActivationPoint as UpdateActivationPointIxAccounts, - UpdateActivationPointInstructionArgs as UpdateActivationPointIxData, - WithdrawProtocolFees as WithdrawProtocolFeesIxAccounts, - }, - ID, -}; - -/// Amm Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum AmmProgramIx { - InitializePermissionedPool( - InitializePermissionedPoolIxAccounts, - InitializePermissionedPoolIxData, - ), - InitializePermissionlessPool( - InitializePermissionlessPoolIxAccounts, - InitializePermissionlessPoolIxData, - ), - InitializePermissionlessPoolWithFeeTier( - InitializePermissionlessPoolWithFeeTierIxAccounts, - InitializePermissionlessPoolWithFeeTierIxData, - ), - EnableOrDisablePool(EnableOrDisablePoolIxAccounts, EnableOrDisablePoolIxData), - Swap(SwapIxAccounts, SwapIxData), - RemoveLiquiditySingleSide( - RemoveLiquiditySingleSideIxAccounts, - RemoveLiquiditySingleSideIxData, - ), - AddImbalanceLiquidity(AddImbalanceLiquidityIxAccounts, AddImbalanceLiquidityIxData), - RemoveBalanceLiquidity( - RemoveBalanceLiquidityIxAccounts, - RemoveBalanceLiquidityIxData, - ), - AddBalanceLiquidity(AddBalanceLiquidityIxAccounts, AddBalanceLiquidityIxData), - SetPoolFees(SetPoolFeesIxAccounts, SetPoolFeesIxData), - OverrideCurveParam(OverrideCurveParamIxAccounts, OverrideCurveParamIxData), - GetPoolInfo(GetPoolInfoIxAccounts), - BootstrapLiquidity(BootstrapLiquidityIxAccounts, BootstrapLiquidityIxData), - CreateMintMetadata(CreateMintMetadataIxAccounts), - CreateLockEscrow(CreateLockEscrowIxAccounts), - Lock(LockIxAccounts, LockIxData), - ClaimFee(ClaimFeeIxAccounts, ClaimFeeIxData), - CreateConfig(CreateConfigIxAccounts, CreateConfigIxData), - CloseConfig(CloseConfigIxAccounts), - InitializePermissionlessConstantProductPoolWithConfig( - InitializePermissionlessConstantProductPoolWithConfigIxAccounts, - InitializePermissionlessConstantProductPoolWithConfigIxData, - ), - InitializePermissionlessConstantProductPoolWithConfig2( - InitializePermissionlessConstantProductPoolWithConfig2IxAccounts, - InitializePermissionlessConstantProductPoolWithConfig2IxData, - ), - InitializeCustomizablePermissionlessConstantProductPool( - InitializeCustomizablePermissionlessConstantProductPoolIxAccounts, - InitializeCustomizablePermissionlessConstantProductPoolIxData, - ), - UpdateActivationPoint(UpdateActivationPointIxAccounts, UpdateActivationPointIxData), - WithdrawProtocolFees(WithdrawProtocolFeesIxAccounts), - SetWhitelistedVault(SetWhitelistedVaultIxAccounts, SetWhitelistedVaultIxData), - PartnerClaimFee(PartnerClaimFeeIxAccounts, PartnerClaimFeeIxData), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = AmmProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "Amm::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [77, 85, 178, 157, 50, 48, 212, 126] => { - let expected_accounts_len = 24; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePermissionedPoolIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - admin_token_a: next_account(accounts)?, - admin_token_b: next_account(accounts)?, - admin_pool_lp: next_account(accounts)?, - protocol_token_a_fee: next_account(accounts)?, - protocol_token_b_fee: next_account(accounts)?, - admin: next_account(accounts)?, - fee_owner: next_account(accounts)?, - rent: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializePermissionedPoolIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::InitializePermissionedPool( - ix_accounts, - de_ix_data, - )) - }, - [118, 173, 41, 157, 173, 72, 97, 103] => { - let expected_accounts_len = 26; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePermissionlessPoolIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - payer_token_a: next_account(accounts)?, - payer_token_b: next_account(accounts)?, - payer_pool_lp: next_account(accounts)?, - protocol_token_a_fee: next_account(accounts)?, - protocol_token_b_fee: next_account(accounts)?, - payer: next_account(accounts)?, - fee_owner: next_account(accounts)?, - rent: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializePermissionlessPoolIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::InitializePermissionlessPool( - ix_accounts, - de_ix_data, - )) - }, - [6, 135, 68, 147, 229, 82, 169, 113] => { - let expected_accounts_len = 26; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePermissionlessPoolWithFeeTierIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - payer_token_a: next_account(accounts)?, - payer_token_b: next_account(accounts)?, - payer_pool_lp: next_account(accounts)?, - protocol_token_a_fee: next_account(accounts)?, - protocol_token_b_fee: next_account(accounts)?, - payer: next_account(accounts)?, - fee_owner: next_account(accounts)?, - rent: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializePermissionlessPoolWithFeeTierIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::InitializePermissionlessPoolWithFeeTier( - ix_accounts, - de_ix_data, - )) - }, - [128, 6, 228, 131, 55, 161, 52, 169] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = EnableOrDisablePoolIxAccounts { - pool: next_account(accounts)?, - admin: next_account(accounts)?, - }; - let de_ix_data: EnableOrDisablePoolIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::EnableOrDisablePool(ix_accounts, de_ix_data)) - }, - [248, 198, 158, 145, 225, 117, 135, 200] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapIxAccounts { - pool: next_account(accounts)?, - user_source_token: next_account(accounts)?, - user_destination_token: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - protocol_token_fee: next_account(accounts)?, - user: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: SwapIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::Swap(ix_accounts, de_ix_data)) - }, - [84, 84, 177, 66, 254, 185, 10, 251] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveLiquiditySingleSideIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_pool_lp: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - user_destination_token: next_account(accounts)?, - user: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: RemoveLiquiditySingleSideIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::RemoveLiquiditySingleSide( - ix_accounts, - de_ix_data, - )) - }, - [79, 35, 122, 84, 173, 15, 93, 191] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddImbalanceLiquidityIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_pool_lp: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - user_a_token: next_account(accounts)?, - user_b_token: next_account(accounts)?, - user: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: AddImbalanceLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::AddImbalanceLiquidity(ix_accounts, de_ix_data)) - }, - [133, 109, 44, 179, 56, 238, 114, 33] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveBalanceLiquidityIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_pool_lp: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - user_a_token: next_account(accounts)?, - user_b_token: next_account(accounts)?, - user: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: RemoveBalanceLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::RemoveBalanceLiquidity( - ix_accounts, - de_ix_data, - )) - }, - [168, 227, 50, 62, 189, 171, 84, 176] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddBalanceLiquidityIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_pool_lp: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - user_a_token: next_account(accounts)?, - user_b_token: next_account(accounts)?, - user: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: AddBalanceLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::AddBalanceLiquidity(ix_accounts, de_ix_data)) - }, - [102, 44, 158, 54, 205, 37, 126, 78] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetPoolFeesIxAccounts { - pool: next_account(accounts)?, - fee_operator: next_account(accounts)?, - }; - let de_ix_data: SetPoolFeesIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::SetPoolFees(ix_accounts, de_ix_data)) - }, - [98, 86, 204, 51, 94, 71, 69, 187] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = OverrideCurveParamIxAccounts { - pool: next_account(accounts)?, - admin: next_account(accounts)?, - }; - let de_ix_data: OverrideCurveParamIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::OverrideCurveParam(ix_accounts, de_ix_data)) - }, - [9, 48, 220, 101, 22, 240, 78, 200] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = GetPoolInfoIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - }; - Ok(AmmProgramIx::GetPoolInfo(ix_accounts)) - }, - [4, 228, 215, 71, 225, 253, 119, 206] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = BootstrapLiquidityIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_pool_lp: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - user_a_token: next_account(accounts)?, - user_b_token: next_account(accounts)?, - user: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: BootstrapLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::BootstrapLiquidity(ix_accounts, de_ix_data)) - }, - [13, 70, 168, 41, 250, 100, 148, 90] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateMintMetadataIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - system_program: next_account(accounts)?, - payer: next_account(accounts)?, - }; - Ok(AmmProgramIx::CreateMintMetadata(ix_accounts)) - }, - [54, 87, 165, 19, 69, 227, 218, 224] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateLockEscrowIxAccounts { - pool: next_account(accounts)?, - lock_escrow: next_account(accounts)?, - owner: next_account(accounts)?, - lp_mint: next_account(accounts)?, - payer: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(AmmProgramIx::CreateLockEscrow(ix_accounts)) - }, - [21, 19, 208, 43, 237, 62, 255, 87] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = LockIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - lock_escrow: next_account(accounts)?, - owner: next_account(accounts)?, - source_tokens: next_account(accounts)?, - escrow_vault: next_account(accounts)?, - token_program: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - }; - let de_ix_data: LockIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::Lock(ix_accounts, de_ix_data)) - }, - [169, 32, 79, 137, 136, 232, 70, 137] => { - let expected_accounts_len = 18; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimFeeIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - lock_escrow: next_account(accounts)?, - owner: next_account(accounts)?, - source_tokens: next_account(accounts)?, - escrow_vault: next_account(accounts)?, - token_program: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - user_a_token: next_account(accounts)?, - user_b_token: next_account(accounts)?, - vault_program: next_account(accounts)?, - }; - let de_ix_data: ClaimFeeIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::ClaimFee(ix_accounts, de_ix_data)) - }, - [201, 207, 243, 114, 75, 111, 47, 189] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateConfigIxAccounts { - config: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: CreateConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::CreateConfig(ix_accounts, de_ix_data)) - }, - [145, 9, 72, 157, 95, 125, 61, 85] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CloseConfigIxAccounts { - config: next_account(accounts)?, - admin: next_account(accounts)?, - rent_receiver: next_account(accounts)?, - }; - Ok(AmmProgramIx::CloseConfig(ix_accounts)) - }, - [7, 166, 138, 171, 206, 171, 236, 244] => { - let expected_accounts_len = 26; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePermissionlessConstantProductPoolWithConfigIxAccounts { - pool: next_account(accounts)?, - config: next_account(accounts)?, - lp_mint: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - payer_token_a: next_account(accounts)?, - payer_token_b: next_account(accounts)?, - payer_pool_lp: next_account(accounts)?, - protocol_token_a_fee: next_account(accounts)?, - protocol_token_b_fee: next_account(accounts)?, - payer: next_account(accounts)?, - rent: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializePermissionlessConstantProductPoolWithConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok( - AmmProgramIx::InitializePermissionlessConstantProductPoolWithConfig( - ix_accounts, - de_ix_data, - ), - ) - }, - [48, 149, 220, 130, 61, 11, 9, 178] => { - let expected_accounts_len = 26; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = - InitializePermissionlessConstantProductPoolWithConfig2IxAccounts { - pool: next_account(accounts)?, - config: next_account(accounts)?, - lp_mint: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - payer_token_a: next_account(accounts)?, - payer_token_b: next_account(accounts)?, - payer_pool_lp: next_account(accounts)?, - protocol_token_a_fee: next_account(accounts)?, - protocol_token_b_fee: next_account(accounts)?, - payer: next_account(accounts)?, - rent: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializePermissionlessConstantProductPoolWithConfig2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok( - AmmProgramIx::InitializePermissionlessConstantProductPoolWithConfig2( - ix_accounts, - de_ix_data, - ), - ) - }, - [145, 24, 172, 194, 219, 125, 3, 190] => { - let expected_accounts_len = 25; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = - InitializeCustomizablePermissionlessConstantProductPoolIxAccounts { - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - token_a_mint: next_account(accounts)?, - token_b_mint: next_account(accounts)?, - a_vault: next_account(accounts)?, - b_vault: next_account(accounts)?, - a_token_vault: next_account(accounts)?, - b_token_vault: next_account(accounts)?, - a_vault_lp_mint: next_account(accounts)?, - b_vault_lp_mint: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - b_vault_lp: next_account(accounts)?, - payer_token_a: next_account(accounts)?, - payer_token_b: next_account(accounts)?, - payer_pool_lp: next_account(accounts)?, - protocol_token_a_fee: next_account(accounts)?, - protocol_token_b_fee: next_account(accounts)?, - payer: next_account(accounts)?, - rent: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializeCustomizablePermissionlessConstantProductPoolIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok( - AmmProgramIx::InitializeCustomizablePermissionlessConstantProductPool( - ix_accounts, - de_ix_data, - ), - ) - }, - [150, 62, 125, 219, 171, 220, 26, 237] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateActivationPointIxAccounts { - pool: next_account(accounts)?, - admin: next_account(accounts)?, - }; - let de_ix_data: UpdateActivationPointIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::UpdateActivationPoint(ix_accounts, de_ix_data)) - }, - [11, 68, 165, 98, 18, 208, 134, 73] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawProtocolFeesIxAccounts { - pool: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - protocol_token_a_fee: next_account(accounts)?, - protocol_token_b_fee: next_account(accounts)?, - treasury_token_a: next_account(accounts)?, - treasury_token_b: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(AmmProgramIx::WithdrawProtocolFees(ix_accounts)) - }, - [12, 148, 94, 42, 55, 57, 83, 247] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetWhitelistedVaultIxAccounts { - pool: next_account(accounts)?, - admin: next_account(accounts)?, - }; - let de_ix_data: SetWhitelistedVaultIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::SetWhitelistedVault(ix_accounts, de_ix_data)) - }, - [57, 53, 176, 30, 123, 70, 52, 64] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = PartnerClaimFeeIxAccounts { - pool: next_account(accounts)?, - a_vault_lp: next_account(accounts)?, - protocol_token_a_fee: next_account(accounts)?, - protocol_token_b_fee: next_account(accounts)?, - partner_token_a: next_account(accounts)?, - partner_token_b: next_account(accounts)?, - token_program: next_account(accounts)?, - partner_authority: next_account(accounts)?, - }; - let de_ix_data: PartnerClaimFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmProgramIx::PartnerClaimFee(ix_accounts, de_ix_data)) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AmmProgramIx, InitializePermissionedPoolIxAccounts, InstructionParser}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto - for InitializePermissionedPoolIxAccounts - { - fn into_proto(self) -> proto_def::InitializePermissionedPoolIxAccounts { - proto_def::InitializePermissionedPoolIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - admin_token_a: self.admin_token_a.to_string(), - admin_token_b: self.admin_token_b.to_string(), - admin_pool_lp: self.admin_pool_lp.to_string(), - protocol_token_a_fee: self.protocol_token_a_fee.to_string(), - protocol_token_b_fee: self.protocol_token_b_fee.to_string(), - admin: self.admin.to_string(), - fee_owner: self.fee_owner.to_string(), - rent: self.rent.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializePermissionedPoolIxData; - impl IntoProto for InitializePermissionedPoolIxData { - fn into_proto(self) -> proto_def::InitializePermissionedPoolIxData { - proto_def::InitializePermissionedPoolIxData { - curve_type: Some(self.curve_type.into_proto()), - } - } - } - use super::InitializePermissionlessPoolIxAccounts; - impl IntoProto - for InitializePermissionlessPoolIxAccounts - { - fn into_proto(self) -> proto_def::InitializePermissionlessPoolIxAccounts { - proto_def::InitializePermissionlessPoolIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - payer_token_a: self.payer_token_a.to_string(), - payer_token_b: self.payer_token_b.to_string(), - payer_pool_lp: self.payer_pool_lp.to_string(), - protocol_token_a_fee: self.protocol_token_a_fee.to_string(), - protocol_token_b_fee: self.protocol_token_b_fee.to_string(), - payer: self.payer.to_string(), - fee_owner: self.fee_owner.to_string(), - rent: self.rent.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializePermissionlessPoolIxData; - impl IntoProto - for InitializePermissionlessPoolIxData - { - fn into_proto(self) -> proto_def::InitializePermissionlessPoolIxData { - proto_def::InitializePermissionlessPoolIxData { - curve_type: Some(self.curve_type.into_proto()), - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - } - } - } - use super::InitializePermissionlessPoolWithFeeTierIxAccounts; - impl IntoProto - for InitializePermissionlessPoolWithFeeTierIxAccounts - { - fn into_proto(self) -> proto_def::InitializePermissionlessPoolWithFeeTierIxAccounts { - proto_def::InitializePermissionlessPoolWithFeeTierIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - payer_token_a: self.payer_token_a.to_string(), - payer_token_b: self.payer_token_b.to_string(), - payer_pool_lp: self.payer_pool_lp.to_string(), - protocol_token_a_fee: self.protocol_token_a_fee.to_string(), - protocol_token_b_fee: self.protocol_token_b_fee.to_string(), - payer: self.payer.to_string(), - fee_owner: self.fee_owner.to_string(), - rent: self.rent.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializePermissionlessPoolWithFeeTierIxData; - impl IntoProto - for InitializePermissionlessPoolWithFeeTierIxData - { - fn into_proto(self) -> proto_def::InitializePermissionlessPoolWithFeeTierIxData { - proto_def::InitializePermissionlessPoolWithFeeTierIxData { - curve_type: Some(self.curve_type.into_proto()), - trade_fee_bps: self.trade_fee_bps, - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - } - } - } - use super::EnableOrDisablePoolIxAccounts; - impl IntoProto for EnableOrDisablePoolIxAccounts { - fn into_proto(self) -> proto_def::EnableOrDisablePoolIxAccounts { - proto_def::EnableOrDisablePoolIxAccounts { - pool: self.pool.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::EnableOrDisablePoolIxData; - impl IntoProto for EnableOrDisablePoolIxData { - fn into_proto(self) -> proto_def::EnableOrDisablePoolIxData { - proto_def::EnableOrDisablePoolIxData { - enable: self.enable, - } - } - } - use super::SwapIxAccounts; - impl IntoProto for SwapIxAccounts { - fn into_proto(self) -> proto_def::SwapIxAccounts { - proto_def::SwapIxAccounts { - pool: self.pool.to_string(), - user_source_token: self.user_source_token.to_string(), - user_destination_token: self.user_destination_token.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - protocol_token_fee: self.protocol_token_fee.to_string(), - user: self.user.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::SwapIxData; - impl IntoProto for SwapIxData { - fn into_proto(self) -> proto_def::SwapIxData { - proto_def::SwapIxData { - in_amount: self.in_amount, - minimum_out_amount: self.minimum_out_amount, - } - } - } - use super::RemoveLiquiditySingleSideIxAccounts; - impl IntoProto - for RemoveLiquiditySingleSideIxAccounts - { - fn into_proto(self) -> proto_def::RemoveLiquiditySingleSideIxAccounts { - proto_def::RemoveLiquiditySingleSideIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - user_pool_lp: self.user_pool_lp.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - user_destination_token: self.user_destination_token.to_string(), - user: self.user.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::RemoveLiquiditySingleSideIxData; - impl IntoProto for RemoveLiquiditySingleSideIxData { - fn into_proto(self) -> proto_def::RemoveLiquiditySingleSideIxData { - proto_def::RemoveLiquiditySingleSideIxData { - pool_token_amount: self.pool_token_amount, - minimum_out_amount: self.minimum_out_amount, - } - } - } - use super::AddImbalanceLiquidityIxAccounts; - impl IntoProto for AddImbalanceLiquidityIxAccounts { - fn into_proto(self) -> proto_def::AddImbalanceLiquidityIxAccounts { - proto_def::AddImbalanceLiquidityIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - user_pool_lp: self.user_pool_lp.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - user_a_token: self.user_a_token.to_string(), - user_b_token: self.user_b_token.to_string(), - user: self.user.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::AddImbalanceLiquidityIxData; - impl IntoProto for AddImbalanceLiquidityIxData { - fn into_proto(self) -> proto_def::AddImbalanceLiquidityIxData { - proto_def::AddImbalanceLiquidityIxData { - minimum_pool_token_amount: self.minimum_pool_token_amount, - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - } - } - } - use super::RemoveBalanceLiquidityIxAccounts; - impl IntoProto for RemoveBalanceLiquidityIxAccounts { - fn into_proto(self) -> proto_def::RemoveBalanceLiquidityIxAccounts { - proto_def::RemoveBalanceLiquidityIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - user_pool_lp: self.user_pool_lp.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - user_a_token: self.user_a_token.to_string(), - user_b_token: self.user_b_token.to_string(), - user: self.user.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::RemoveBalanceLiquidityIxData; - impl IntoProto for RemoveBalanceLiquidityIxData { - fn into_proto(self) -> proto_def::RemoveBalanceLiquidityIxData { - proto_def::RemoveBalanceLiquidityIxData { - pool_token_amount: self.pool_token_amount, - minimum_a_token_out: self.minimum_a_token_out, - minimum_b_token_out: self.minimum_b_token_out, - } - } - } - use super::AddBalanceLiquidityIxAccounts; - impl IntoProto for AddBalanceLiquidityIxAccounts { - fn into_proto(self) -> proto_def::AddBalanceLiquidityIxAccounts { - proto_def::AddBalanceLiquidityIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - user_pool_lp: self.user_pool_lp.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - user_a_token: self.user_a_token.to_string(), - user_b_token: self.user_b_token.to_string(), - user: self.user.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::AddBalanceLiquidityIxData; - impl IntoProto for AddBalanceLiquidityIxData { - fn into_proto(self) -> proto_def::AddBalanceLiquidityIxData { - proto_def::AddBalanceLiquidityIxData { - pool_token_amount: self.pool_token_amount, - maximum_token_a_amount: self.maximum_token_a_amount, - maximum_token_b_amount: self.maximum_token_b_amount, - } - } - } - use super::SetPoolFeesIxAccounts; - impl IntoProto for SetPoolFeesIxAccounts { - fn into_proto(self) -> proto_def::SetPoolFeesIxAccounts { - proto_def::SetPoolFeesIxAccounts { - pool: self.pool.to_string(), - fee_operator: self.fee_operator.to_string(), - } - } - } - use super::SetPoolFeesIxData; - impl IntoProto for SetPoolFeesIxData { - fn into_proto(self) -> proto_def::SetPoolFeesIxData { - proto_def::SetPoolFeesIxData { - fees: Some(self.fees.into_proto()), - new_partner_fee_numerator: self.new_partner_fee_numerator, - } - } - } - use super::OverrideCurveParamIxAccounts; - impl IntoProto for OverrideCurveParamIxAccounts { - fn into_proto(self) -> proto_def::OverrideCurveParamIxAccounts { - proto_def::OverrideCurveParamIxAccounts { - pool: self.pool.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::OverrideCurveParamIxData; - impl IntoProto for OverrideCurveParamIxData { - fn into_proto(self) -> proto_def::OverrideCurveParamIxData { - proto_def::OverrideCurveParamIxData { - curve_type: Some(self.curve_type.into_proto()), - } - } - } - use super::GetPoolInfoIxAccounts; - impl IntoProto for GetPoolInfoIxAccounts { - fn into_proto(self) -> proto_def::GetPoolInfoIxAccounts { - proto_def::GetPoolInfoIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - } - } - } - use super::BootstrapLiquidityIxAccounts; - impl IntoProto for BootstrapLiquidityIxAccounts { - fn into_proto(self) -> proto_def::BootstrapLiquidityIxAccounts { - proto_def::BootstrapLiquidityIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - user_pool_lp: self.user_pool_lp.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - user_a_token: self.user_a_token.to_string(), - user_b_token: self.user_b_token.to_string(), - user: self.user.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::BootstrapLiquidityIxData; - impl IntoProto for BootstrapLiquidityIxData { - fn into_proto(self) -> proto_def::BootstrapLiquidityIxData { - proto_def::BootstrapLiquidityIxData { - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - } - } - } - use super::CreateMintMetadataIxAccounts; - impl IntoProto for CreateMintMetadataIxAccounts { - fn into_proto(self) -> proto_def::CreateMintMetadataIxAccounts { - proto_def::CreateMintMetadataIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - system_program: self.system_program.to_string(), - payer: self.payer.to_string(), - } - } - } - use super::CreateLockEscrowIxAccounts; - impl IntoProto for CreateLockEscrowIxAccounts { - fn into_proto(self) -> proto_def::CreateLockEscrowIxAccounts { - proto_def::CreateLockEscrowIxAccounts { - pool: self.pool.to_string(), - lock_escrow: self.lock_escrow.to_string(), - owner: self.owner.to_string(), - lp_mint: self.lp_mint.to_string(), - payer: self.payer.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::LockIxAccounts; - impl IntoProto for LockIxAccounts { - fn into_proto(self) -> proto_def::LockIxAccounts { - proto_def::LockIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - lock_escrow: self.lock_escrow.to_string(), - owner: self.owner.to_string(), - source_tokens: self.source_tokens.to_string(), - escrow_vault: self.escrow_vault.to_string(), - token_program: self.token_program.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - } - } - } - use super::LockIxData; - impl IntoProto for LockIxData { - fn into_proto(self) -> proto_def::LockIxData { - proto_def::LockIxData { - max_amount: self.max_amount, - } - } - } - use super::ClaimFeeIxAccounts; - impl IntoProto for ClaimFeeIxAccounts { - fn into_proto(self) -> proto_def::ClaimFeeIxAccounts { - proto_def::ClaimFeeIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - lock_escrow: self.lock_escrow.to_string(), - owner: self.owner.to_string(), - source_tokens: self.source_tokens.to_string(), - escrow_vault: self.escrow_vault.to_string(), - token_program: self.token_program.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - user_a_token: self.user_a_token.to_string(), - user_b_token: self.user_b_token.to_string(), - vault_program: self.vault_program.to_string(), - } - } - } - use super::ClaimFeeIxData; - impl IntoProto for ClaimFeeIxData { - fn into_proto(self) -> proto_def::ClaimFeeIxData { - proto_def::ClaimFeeIxData { - max_amount: self.max_amount, - } - } - } - use super::CreateConfigIxAccounts; - impl IntoProto for CreateConfigIxAccounts { - fn into_proto(self) -> proto_def::CreateConfigIxAccounts { - proto_def::CreateConfigIxAccounts { - config: self.config.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreateConfigIxData; - impl IntoProto for CreateConfigIxData { - fn into_proto(self) -> proto_def::CreateConfigIxData { - proto_def::CreateConfigIxData { - trade_fee_numerator: self.trade_fee_numerator, - protocol_trade_fee_numerator: self.protocol_trade_fee_numerator, - activation_duration: self.activation_duration, - vault_config_key: self.vault_config_key.to_string(), - pool_creator_authority: self.pool_creator_authority.to_string(), - activation_type: self.activation_type.into(), - index: self.index, - partner_fee_numerator: self.partner_fee_numerator, - } - } - } - use super::CloseConfigIxAccounts; - impl IntoProto for CloseConfigIxAccounts { - fn into_proto(self) -> proto_def::CloseConfigIxAccounts { - proto_def::CloseConfigIxAccounts { - config: self.config.to_string(), - admin: self.admin.to_string(), - rent_receiver: self.rent_receiver.to_string(), - } - } - } - use super::InitializePermissionlessConstantProductPoolWithConfigIxAccounts; - impl IntoProto - for InitializePermissionlessConstantProductPoolWithConfigIxAccounts - { - fn into_proto( - self, - ) -> proto_def::InitializePermissionlessConstantProductPoolWithConfigIxAccounts { - proto_def::InitializePermissionlessConstantProductPoolWithConfigIxAccounts { - pool: self.pool.to_string(), - config: self.config.to_string(), - lp_mint: self.lp_mint.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - payer_token_a: self.payer_token_a.to_string(), - payer_token_b: self.payer_token_b.to_string(), - payer_pool_lp: self.payer_pool_lp.to_string(), - protocol_token_a_fee: self.protocol_token_a_fee.to_string(), - protocol_token_b_fee: self.protocol_token_b_fee.to_string(), - payer: self.payer.to_string(), - rent: self.rent.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializePermissionlessConstantProductPoolWithConfigIxData; - impl IntoProto - for InitializePermissionlessConstantProductPoolWithConfigIxData - { - fn into_proto( - self, - ) -> proto_def::InitializePermissionlessConstantProductPoolWithConfigIxData { - proto_def::InitializePermissionlessConstantProductPoolWithConfigIxData { - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - } - } - } - use super::InitializePermissionlessConstantProductPoolWithConfig2IxAccounts; - impl IntoProto - for InitializePermissionlessConstantProductPoolWithConfig2IxAccounts - { - fn into_proto( - self, - ) -> proto_def::InitializePermissionlessConstantProductPoolWithConfig2IxAccounts { - proto_def::InitializePermissionlessConstantProductPoolWithConfig2IxAccounts { - pool: self.pool.to_string(), - config: self.config.to_string(), - lp_mint: self.lp_mint.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - payer_token_a: self.payer_token_a.to_string(), - payer_token_b: self.payer_token_b.to_string(), - payer_pool_lp: self.payer_pool_lp.to_string(), - protocol_token_a_fee: self.protocol_token_a_fee.to_string(), - protocol_token_b_fee: self.protocol_token_b_fee.to_string(), - payer: self.payer.to_string(), - rent: self.rent.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializePermissionlessConstantProductPoolWithConfig2IxData; - impl IntoProto - for InitializePermissionlessConstantProductPoolWithConfig2IxData - { - fn into_proto( - self, - ) -> proto_def::InitializePermissionlessConstantProductPoolWithConfig2IxData { - proto_def::InitializePermissionlessConstantProductPoolWithConfig2IxData { - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - activation_point: self.activation_point, - } - } - } - use super::InitializeCustomizablePermissionlessConstantProductPoolIxAccounts; - impl IntoProto - for InitializeCustomizablePermissionlessConstantProductPoolIxAccounts - { - fn into_proto( - self, - ) -> proto_def::InitializeCustomizablePermissionlessConstantProductPoolIxAccounts { - proto_def::InitializeCustomizablePermissionlessConstantProductPoolIxAccounts { - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - token_a_mint: self.token_a_mint.to_string(), - token_b_mint: self.token_b_mint.to_string(), - a_vault: self.a_vault.to_string(), - b_vault: self.b_vault.to_string(), - a_token_vault: self.a_token_vault.to_string(), - b_token_vault: self.b_token_vault.to_string(), - a_vault_lp_mint: self.a_vault_lp_mint.to_string(), - b_vault_lp_mint: self.b_vault_lp_mint.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - b_vault_lp: self.b_vault_lp.to_string(), - payer_token_a: self.payer_token_a.to_string(), - payer_token_b: self.payer_token_b.to_string(), - payer_pool_lp: self.payer_pool_lp.to_string(), - protocol_token_a_fee: self.protocol_token_a_fee.to_string(), - protocol_token_b_fee: self.protocol_token_b_fee.to_string(), - payer: self.payer.to_string(), - rent: self.rent.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializeCustomizablePermissionlessConstantProductPoolIxData; - impl IntoProto - for InitializeCustomizablePermissionlessConstantProductPoolIxData - { - fn into_proto( - self, - ) -> proto_def::InitializeCustomizablePermissionlessConstantProductPoolIxData { - proto_def::InitializeCustomizablePermissionlessConstantProductPoolIxData { - token_a_amount: self.token_a_amount, - token_b_amount: self.token_b_amount, - trade_fee_numerator: self.trade_fee_numerator, - activation_point: self.activation_point, - has_alpha_vault: self.has_alpha_vault, - activation_type: self.activation_type.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::UpdateActivationPointIxAccounts; - impl IntoProto for UpdateActivationPointIxAccounts { - fn into_proto(self) -> proto_def::UpdateActivationPointIxAccounts { - proto_def::UpdateActivationPointIxAccounts { - pool: self.pool.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::UpdateActivationPointIxData; - impl IntoProto for UpdateActivationPointIxData { - fn into_proto(self) -> proto_def::UpdateActivationPointIxData { - proto_def::UpdateActivationPointIxData { - new_activation_point: self.new_activation_point, - } - } - } - use super::WithdrawProtocolFeesIxAccounts; - impl IntoProto for WithdrawProtocolFeesIxAccounts { - fn into_proto(self) -> proto_def::WithdrawProtocolFeesIxAccounts { - proto_def::WithdrawProtocolFeesIxAccounts { - pool: self.pool.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - protocol_token_a_fee: self.protocol_token_a_fee.to_string(), - protocol_token_b_fee: self.protocol_token_b_fee.to_string(), - treasury_token_a: self.treasury_token_a.to_string(), - treasury_token_b: self.treasury_token_b.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::SetWhitelistedVaultIxAccounts; - impl IntoProto for SetWhitelistedVaultIxAccounts { - fn into_proto(self) -> proto_def::SetWhitelistedVaultIxAccounts { - proto_def::SetWhitelistedVaultIxAccounts { - pool: self.pool.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::SetWhitelistedVaultIxData; - impl IntoProto for SetWhitelistedVaultIxData { - fn into_proto(self) -> proto_def::SetWhitelistedVaultIxData { - proto_def::SetWhitelistedVaultIxData { - whitelisted_vault: self.whitelisted_vault.to_string(), - } - } - } - use super::PartnerClaimFeeIxAccounts; - impl IntoProto for PartnerClaimFeeIxAccounts { - fn into_proto(self) -> proto_def::PartnerClaimFeeIxAccounts { - proto_def::PartnerClaimFeeIxAccounts { - pool: self.pool.to_string(), - a_vault_lp: self.a_vault_lp.to_string(), - protocol_token_a_fee: self.protocol_token_a_fee.to_string(), - protocol_token_b_fee: self.protocol_token_b_fee.to_string(), - partner_token_a: self.partner_token_a.to_string(), - partner_token_b: self.partner_token_b.to_string(), - token_program: self.token_program.to_string(), - partner_authority: self.partner_authority.to_string(), - } - } - } - use super::PartnerClaimFeeIxData; - impl IntoProto for PartnerClaimFeeIxData { - fn into_proto(self) -> proto_def::PartnerClaimFeeIxData { - proto_def::PartnerClaimFeeIxData { - max_amount_a: self.max_amount_a, - max_amount_b: self.max_amount_b, - } - } - } - - impl IntoProto for AmmProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - AmmProgramIx::InitializePermissionedPool(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePermissionedPool(proto_def::InitializePermissionedPoolIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::InitializePermissionlessPool(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePermissionlessPool(proto_def::InitializePermissionlessPoolIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::InitializePermissionlessPoolWithFeeTier(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePermissionlessPoolWithFeeTier(proto_def::InitializePermissionlessPoolWithFeeTierIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::EnableOrDisablePool(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::EnableOrDisablePool(proto_def::EnableOrDisablePoolIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::Swap(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Swap(proto_def::SwapIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::RemoveLiquiditySingleSide(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveLiquiditySingleSide(proto_def::RemoveLiquiditySingleSideIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::AddImbalanceLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddImbalanceLiquidity(proto_def::AddImbalanceLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::RemoveBalanceLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveBalanceLiquidity(proto_def::RemoveBalanceLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::AddBalanceLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddBalanceLiquidity(proto_def::AddBalanceLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::SetPoolFees(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetPoolFees(proto_def::SetPoolFeesIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::OverrideCurveParam(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::OverrideCurveParam(proto_def::OverrideCurveParamIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::GetPoolInfo(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::GetPoolInfo(proto_def::GetPoolInfoIx { - accounts: Some(acc.into_proto()), - })), - }, - AmmProgramIx::BootstrapLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::BootstrapLiquidity(proto_def::BootstrapLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::CreateMintMetadata(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateMintMetadata(proto_def::CreateMintMetadataIx { - accounts: Some(acc.into_proto()), - })), - }, - AmmProgramIx::CreateLockEscrow(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateLockEscrow(proto_def::CreateLockEscrowIx { - accounts: Some(acc.into_proto()), - })), - }, - AmmProgramIx::Lock(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Lock(proto_def::LockIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::ClaimFee(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimFee(proto_def::ClaimFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::CreateConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateConfig(proto_def::CreateConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::CloseConfig(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CloseConfig(proto_def::CloseConfigIx { - accounts: Some(acc.into_proto()), - })), - }, - AmmProgramIx::InitializePermissionlessConstantProductPoolWithConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePermissionlessConstantProductPoolWithConfig(proto_def::InitializePermissionlessConstantProductPoolWithConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::InitializePermissionlessConstantProductPoolWithConfig2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePermissionlessConstantProductPoolWithConfig2(proto_def::InitializePermissionlessConstantProductPoolWithConfig2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::InitializeCustomizablePermissionlessConstantProductPool(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeCustomizablePermissionlessConstantProductPool(proto_def::InitializeCustomizablePermissionlessConstantProductPoolIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::UpdateActivationPoint(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateActivationPoint(proto_def::UpdateActivationPointIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::WithdrawProtocolFees(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::WithdrawProtocolFees(proto_def::WithdrawProtocolFeesIx { - accounts: Some(acc.into_proto()), - })), - }, - AmmProgramIx::SetWhitelistedVault(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetWhitelistedVault(proto_def::SetWhitelistedVaultIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmProgramIx::PartnerClaimFee(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::PartnerClaimFee(proto_def::PartnerClaimFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/meteora-pools-parser/src/generated_parser/mod.rs b/crates/meteora-pools-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/meteora-pools-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/meteora-pools-parser/src/generated_parser/proto_helpers.rs b/crates/meteora-pools-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index c2440a07..00000000 --- a/crates/meteora-pools-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,137 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::TokenMultiplier}; - impl IntoProto for TokenMultiplier { - fn into_proto(self) -> proto_def::TokenMultiplier { - proto_def::TokenMultiplier { - token_a_multiplier: self.token_a_multiplier, - token_b_multiplier: self.token_b_multiplier, - precision_factor: self.precision_factor.into(), - } - } - } - use crate::types::PoolFees; - impl IntoProto for PoolFees { - fn into_proto(self) -> proto_def::PoolFees { - proto_def::PoolFees { - trade_fee_numerator: self.trade_fee_numerator, - trade_fee_denominator: self.trade_fee_denominator, - protocol_trade_fee_numerator: self.protocol_trade_fee_numerator, - protocol_trade_fee_denominator: self.protocol_trade_fee_denominator, - } - } - } - use crate::types::Depeg; - impl IntoProto for Depeg { - fn into_proto(self) -> proto_def::Depeg { - proto_def::Depeg { - base_virtual_price: self.base_virtual_price, - base_cache_updated: self.base_cache_updated, - depeg_type: self.depeg_type as i32, - } - } - } - use crate::types::Padding; - impl IntoProto for Padding { - fn into_proto(self) -> proto_def::Padding { - proto_def::Padding { - padding0: self.padding0.into_iter().map(|x| x.into()).collect(), - padding1: self.padding1.to_vec(), - padding2: self.padding2.to_vec(), - } - } - } - use crate::types::PartnerInfo; - impl IntoProto for PartnerInfo { - fn into_proto(self) -> proto_def::PartnerInfo { - proto_def::PartnerInfo { - fee_numerator: self.fee_numerator, - partner_authority: self.partner_authority.to_string(), - pending_fee_a: self.pending_fee_a, - pending_fee_b: self.pending_fee_b, - } - } - } - use crate::types::Bootstrapping; - impl IntoProto for Bootstrapping { - fn into_proto(self) -> proto_def::Bootstrapping { - proto_def::Bootstrapping { - activation_point: self.activation_point, - whitelisted_vault: self.whitelisted_vault.to_string(), - pool_creator: self.pool_creator.to_string(), - activation_type: self.activation_type.into(), - } - } - } - - use proto_def::new_curve_type; - - use crate::types::NewCurveType; - impl IntoProto for NewCurveType { - fn into_proto(self) -> proto_def::NewCurveType { - let variant = match self { - NewCurveType::ConstantProduct => new_curve_type::Variant::ConstantProduct( - proto_def::NewCurveTypeConstantProduct {}, - ), - NewCurveType::Stable { - amp, - token_multiplier, - depeg, - last_amp_updated_timestamp, - } => new_curve_type::Variant::Stable(proto_def::NewCurveTypeStable { - amp, - token_multiplier: Some(token_multiplier.into_proto()), - depeg: Some(depeg.into_proto()), - last_amp_updated_timestamp, - }), - NewCurveType::NewCurve { - field_one, - field_two, - } => new_curve_type::Variant::NewCurve(proto_def::NewCurveTypeNewCurve { - field_one, - field_two, - }), - }; - - proto_def::NewCurveType { - variant: Some(variant), - } - } - } - use proto_def::curve_type; - - use crate::types::CurveType; - impl IntoProto for CurveType { - fn into_proto(self) -> proto_def::CurveType { - let variant = match self { - CurveType::ConstantProduct => { - curve_type::Variant::ConstantProduct(proto_def::CurveTypeConstantProduct {}) - }, - CurveType::Stable { - amp, - token_multiplier, - depeg, - last_amp_updated_timestamp, - } => curve_type::Variant::Stable(proto_def::CurveTypeStable { - amp, - token_multiplier: Some(token_multiplier.into_proto()), - depeg: Some(depeg.into_proto()), - last_amp_updated_timestamp, - }), - }; - - proto_def::CurveType { - variant: Some(variant), - } - } - } -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/accounts/config.rs b/crates/meteora-pools-parser/src/generated_sdk/accounts/config.rs deleted file mode 100644 index 5e0541aa..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/accounts/config.rs +++ /dev/null @@ -1,147 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::PoolFees; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Config { - pub discriminator: [u8; 8], - pub pool_fees: PoolFees, - pub activation_duration: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vault_config_key: Pubkey, - /// Only pool_creator_authority can use the current config to initialize new pool. When it's Pubkey::default, it's a public config. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_creator_authority: Pubkey, - /// Activation type - pub activation_type: u8, - pub partner_fee_numerator: u64, - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 219], -} - -impl Config { - pub const LEN: usize = 340; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Config { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Config::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Config::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Config { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Config {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Config { - fn owner() -> Pubkey { crate::AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Config {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Config { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/accounts/lock_escrow.rs b/crates/meteora-pools-parser/src/generated_sdk/accounts/lock_escrow.rs deleted file mode 100644 index 55fa62cf..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/accounts/lock_escrow.rs +++ /dev/null @@ -1,159 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// State of lock escrow account - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockEscrow { - pub discriminator: [u8; 8], - /// Pool address - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - /// Owner address - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - /// Vault address, store the lock user lock - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub escrow_vault: Pubkey, - /// bump, used to sign - pub bump: u8, - /// Total locked amount - pub total_locked_amount: u64, - /// Lp per token, virtual price of lp token - pub lp_per_token: u128, - /// Unclaimed fee pending - pub unclaimed_fee_pending: u64, - /// Total a fee claimed so far - pub a_fee: u64, - /// Total b fee claimed so far - pub b_fee: u64, -} - -impl LockEscrow { - pub const LEN: usize = 153; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for LockEscrow { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_lock_escrow( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_lock_escrow(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_lock_escrow( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = LockEscrow::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_lock_escrow( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_lock_escrow(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_lock_escrow( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = LockEscrow::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for LockEscrow { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for LockEscrow {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for LockEscrow { - fn owner() -> Pubkey { crate::AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for LockEscrow {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for LockEscrow { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/accounts/mod.rs b/crates/meteora-pools-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index 50adc71b..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#config; -pub(crate) mod r#lock_escrow; -pub(crate) mod r#pool; - -pub use self::{r#config::*, r#lock_escrow::*, r#pool::*}; diff --git a/crates/meteora-pools-parser/src/generated_sdk/accounts/pool.rs b/crates/meteora-pools-parser/src/generated_sdk/accounts/pool.rs deleted file mode 100644 index 4b142701..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/accounts/pool.rs +++ /dev/null @@ -1,209 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{Bootstrapping, CurveType, Padding, PartnerInfo, PoolFees, PoolType}; - -/// State of pool account - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Pool { - pub discriminator: [u8; 8], - /// LP token mint of the pool - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lp_mint: Pubkey, - /// Token A mint of the pool. Eg: USDT - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_a_mint: Pubkey, - /// Token B mint of the pool. Eg: USDC - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_b_mint: Pubkey, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub a_vault: Pubkey, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub b_vault: Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub a_vault_lp: Pubkey, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub b_vault_lp: Pubkey, - /// "A" vault lp bump. Used to create signer seeds. - pub a_vault_lp_bump: u8, - /// Flag to determine whether the pool is enabled, or disabled. - pub enabled: bool, - /// Protocol fee token account for token A. Used to receive trading fee. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_token_a_fee: Pubkey, - /// Protocol fee token account for token B. Used to receive trading fee. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_token_b_fee: Pubkey, - /// Fee last updated timestamp - pub fee_last_updated_at: u64, - pub padding0: [u8; 24], - /// Store the fee charges setting. - pub fees: PoolFees, - /// Pool type - pub pool_type: PoolType, - /// Stake pubkey of SPL stake pool - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub stake: Pubkey, - /// Total locked lp token - pub total_locked_lp: u64, - /// bootstrapping config - pub bootstrapping: Bootstrapping, - pub partner_info: PartnerInfo, - /// Padding for future pool field - pub padding: Padding, - /// The type of the swap curve supported by the pool. - pub curve_type: CurveType, -} - -impl Pool { - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Pool { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_pool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_pool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_pool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Pool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_pool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_pool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_pool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Pool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Pool { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Pool {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Pool { - fn owner() -> Pubkey { crate::AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Pool {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Pool { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/errors/amm.rs b/crates/meteora-pools-parser/src/generated_sdk/errors/amm.rs deleted file mode 100644 index 89a14279..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/errors/amm.rs +++ /dev/null @@ -1,184 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum AmmError { - /// 6000 - Math operation overflow - #[error("Math operation overflow")] - MathOverflow = 0x1770, - /// 6001 - Invalid fee setup - #[error("Invalid fee setup")] - InvalidFee = 0x1771, - /// 6002 - Invalid invariant d - #[error("Invalid invariant d")] - InvalidInvariant = 0x1772, - /// 6003 - Fee calculation failure - #[error("Fee calculation failure")] - FeeCalculationFailure = 0x1773, - /// 6004 - Exceeded slippage tolerance - #[error("Exceeded slippage tolerance")] - ExceededSlippage = 0x1774, - /// 6005 - Invalid curve calculation - #[error("Invalid curve calculation")] - InvalidCalculation = 0x1775, - /// 6006 - Given pool token amount results in zero trading tokens - #[error("Given pool token amount results in zero trading tokens")] - ZeroTradingTokens = 0x1776, - /// 6007 - Math conversion overflow - #[error("Math conversion overflow")] - ConversionError = 0x1777, - /// 6008 - LP mint authority must be 'A' vault lp, without freeze authority, and 0 supply - #[error("LP mint authority must be 'A' vault lp, without freeze authority, and 0 supply")] - FaultyLpMint = 0x1778, - /// 6009 - Token mint mismatched - #[error("Token mint mismatched")] - MismatchedTokenMint = 0x1779, - /// 6010 - LP mint mismatched - #[error("LP mint mismatched")] - MismatchedLpMint = 0x177a, - /// 6011 - Invalid lp token owner - #[error("Invalid lp token owner")] - MismatchedOwner = 0x177b, - /// 6012 - Invalid vault account - #[error("Invalid vault account")] - InvalidVaultAccount = 0x177c, - /// 6013 - Invalid vault lp account - #[error("Invalid vault lp account")] - InvalidVaultLpAccount = 0x177d, - /// 6014 - Invalid pool lp mint account - #[error("Invalid pool lp mint account")] - InvalidPoolLpMintAccount = 0x177e, - /// 6015 - Pool disabled - #[error("Pool disabled")] - PoolDisabled = 0x177f, - /// 6016 - Invalid admin account - #[error("Invalid admin account")] - InvalidAdminAccount = 0x1780, - /// 6017 - Invalid protocol fee account - #[error("Invalid protocol fee account")] - InvalidProtocolFeeAccount = 0x1781, - /// 6018 - Same admin account - #[error("Same admin account")] - SameAdminAccount = 0x1782, - /// 6019 - Identical user source and destination token account - #[error("Identical user source and destination token account")] - IdenticalSourceDestination = 0x1783, - /// 6020 - Apy calculation error - #[error("Apy calculation error")] - ApyCalculationError = 0x1784, - /// 6021 - Insufficient virtual price snapshot - #[error("Insufficient virtual price snapshot")] - InsufficientSnapshot = 0x1785, - /// 6022 - Current curve is non-updatable - #[error("Current curve is non-updatable")] - NonUpdatableCurve = 0x1786, - /// 6023 - New curve is mismatched with old curve - #[error("New curve is mismatched with old curve")] - MisMatchedCurve = 0x1787, - /// 6024 - Amplification is invalid - #[error("Amplification is invalid")] - InvalidAmplification = 0x1788, - /// 6025 - Operation is not supported - #[error("Operation is not supported")] - UnsupportedOperation = 0x1789, - /// 6026 - Exceed max amplification changes - #[error("Exceed max amplification changes")] - ExceedMaxAChanges = 0x178a, - /// 6027 - Invalid remaining accounts length - #[error("Invalid remaining accounts length")] - InvalidRemainingAccountsLen = 0x178b, - /// 6028 - Invalid remaining account - #[error("Invalid remaining account")] - InvalidRemainingAccounts = 0x178c, - /// 6029 - Token mint B doesn't matches depeg type token mint - #[error("Token mint B doesn't matches depeg type token mint")] - MismatchedDepegMint = 0x178d, - /// 6030 - Invalid APY account - #[error("Invalid APY account")] - InvalidApyAccount = 0x178e, - /// 6031 - Invalid token multiplier - #[error("Invalid token multiplier")] - InvalidTokenMultiplier = 0x178f, - /// 6032 - Invalid depeg information - #[error("Invalid depeg information")] - InvalidDepegInformation = 0x1790, - /// 6033 - Update time constraint violated - #[error("Update time constraint violated")] - UpdateTimeConstraint = 0x1791, - /// 6034 - Exceeded max fee bps - #[error("Exceeded max fee bps")] - ExceedMaxFeeBps = 0x1792, - /// 6035 - Invalid admin - #[error("Invalid admin")] - InvalidAdmin = 0x1793, - /// 6036 - Pool is not permissioned - #[error("Pool is not permissioned")] - PoolIsNotPermissioned = 0x1794, - /// 6037 - Invalid deposit amount - #[error("Invalid deposit amount")] - InvalidDepositAmount = 0x1795, - /// 6038 - Invalid fee owner - #[error("Invalid fee owner")] - InvalidFeeOwner = 0x1796, - /// 6039 - Pool is not depleted - #[error("Pool is not depleted")] - NonDepletedPool = 0x1797, - /// 6040 - Token amount is not 1:1 - #[error("Token amount is not 1:1")] - AmountNotPeg = 0x1798, - /// 6041 - Amount is zero - #[error("Amount is zero")] - AmountIsZero = 0x1799, - /// 6042 - Type cast error - #[error("Type cast error")] - TypeCastFailed = 0x179a, - /// 6043 - Amount is not enough - #[error("Amount is not enough")] - AmountIsNotEnough = 0x179b, - /// 6044 - Invalid activation duration - #[error("Invalid activation duration")] - InvalidActivationDuration = 0x179c, - /// 6045 - Pool is not launch pool - #[error("Pool is not launch pool")] - PoolIsNotLaunchPool = 0x179d, - /// 6046 - Unable to modify activation point - #[error("Unable to modify activation point")] - UnableToModifyActivationPoint = 0x179e, - /// 6047 - Invalid authority to create the pool - #[error("Invalid authority to create the pool")] - InvalidAuthorityToCreateThePool = 0x179f, - /// 6048 - Invalid activation type - #[error("Invalid activation type")] - InvalidActivationType = 0x17a0, - /// 6049 - Invalid activation point - #[error("Invalid activation point")] - InvalidActivationPoint = 0x17a1, - /// 6050 - Pre activation swap window started - #[error("Pre activation swap window started")] - PreActivationSwapStarted = 0x17a2, - /// 6051 - Invalid pool type - #[error("Invalid pool type")] - InvalidPoolType = 0x17a3, - /// 6052 - Quote token must be SOL,USDC - #[error("Quote token must be SOL,USDC")] - InvalidQuoteMint = 0x17a4, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for AmmError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for AmmError { - fn type_of() -> &'static str { "AmmError" } -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/errors/mod.rs b/crates/meteora-pools-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 7f63319a..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod amm; - -pub use self::amm::AmmError; diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/add_balance_liquidity.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/add_balance_liquidity.rs deleted file mode 100644 index 97bbd3f2..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/add_balance_liquidity.rs +++ /dev/null @@ -1,989 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct AddBalanceLiquidity { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// LP token mint of vault a - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault b - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: solana_pubkey::Pubkey, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: solana_pubkey::Pubkey, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: solana_pubkey::Pubkey, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, -} - -impl AddBalanceLiquidity { - pub fn instruction( - &self, - args: AddBalanceLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddBalanceLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_a_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_b_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddBalanceLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddBalanceLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl AddBalanceLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [168, 227, 50, 62, 189, 171, 84, 176], - } - } -} - -impl Default for AddBalanceLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddBalanceLiquidityInstructionArgs { - pub pool_token_amount: u64, - pub maximum_token_a_amount: u64, - pub maximum_token_b_amount: u64, -} - -/// Instruction builder for `AddBalanceLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` user_pool_lp -/// 3. `[writable]` a_vault_lp -/// 4. `[writable]` b_vault_lp -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_token_vault -/// 10. `[writable]` b_token_vault -/// 11. `[writable]` user_a_token -/// 12. `[writable]` user_b_token -/// 13. `[signer]` user -/// 14. `[]` vault_program -/// 15. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct AddBalanceLiquidityBuilder { - pool: Option, - lp_mint: Option, - user_pool_lp: Option, - a_vault_lp: Option, - b_vault_lp: Option, - a_vault: Option, - b_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_token_vault: Option, - b_token_vault: Option, - user_a_token: Option, - user_b_token: Option, - user: Option, - vault_program: Option, - token_program: Option, - pool_token_amount: Option, - maximum_token_a_amount: Option, - maximum_token_b_amount: Option, - __remaining_accounts: Vec, -} - -impl AddBalanceLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - #[inline(always)] - pub fn user_pool_lp(&mut self, user_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.user_pool_lp = Some(user_pool_lp); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_a_token(&mut self, user_a_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_a_token = Some(user_a_token); - self - } - - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_b_token(&mut self, user_b_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_b_token = Some(user_b_token); - self - } - - /// User account. Must be owner of user_a_token, and user_b_token. - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn pool_token_amount(&mut self, pool_token_amount: u64) -> &mut Self { - self.pool_token_amount = Some(pool_token_amount); - self - } - - #[inline(always)] - pub fn maximum_token_a_amount(&mut self, maximum_token_a_amount: u64) -> &mut Self { - self.maximum_token_a_amount = Some(maximum_token_a_amount); - self - } - - #[inline(always)] - pub fn maximum_token_b_amount(&mut self, maximum_token_b_amount: u64) -> &mut Self { - self.maximum_token_b_amount = Some(maximum_token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddBalanceLiquidity { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_pool_lp: self.user_pool_lp.expect("user_pool_lp is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - user_a_token: self.user_a_token.expect("user_a_token is not set"), - user_b_token: self.user_b_token.expect("user_b_token is not set"), - user: self.user.expect("user is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = AddBalanceLiquidityInstructionArgs { - pool_token_amount: self - .pool_token_amount - .clone() - .expect("pool_token_amount is not set"), - maximum_token_a_amount: self - .maximum_token_a_amount - .clone() - .expect("maximum_token_a_amount is not set"), - maximum_token_b_amount: self - .maximum_token_b_amount - .clone() - .expect("maximum_token_b_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_balance_liquidity` CPI accounts. -pub struct AddBalanceLiquidityCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: &'b solana_account_info::AccountInfo<'a>, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_balance_liquidity` CPI instruction. -pub struct AddBalanceLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: &'b solana_account_info::AccountInfo<'a>, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddBalanceLiquidityInstructionArgs, -} - -impl<'a, 'b> AddBalanceLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddBalanceLiquidityCpiAccounts<'a, 'b>, - args: AddBalanceLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - user_pool_lp: accounts.user_pool_lp, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - user_a_token: accounts.user_a_token, - user_b_token: accounts.user_b_token, - user: accounts.user, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_a_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_b_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddBalanceLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_pool_lp.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.user_a_token.clone()); - account_infos.push(self.user_b_token.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddBalanceLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` user_pool_lp -/// 3. `[writable]` a_vault_lp -/// 4. `[writable]` b_vault_lp -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_token_vault -/// 10. `[writable]` b_token_vault -/// 11. `[writable]` user_a_token -/// 12. `[writable]` user_b_token -/// 13. `[signer]` user -/// 14. `[]` vault_program -/// 15. `[]` token_program -#[derive(Clone, Debug)] -pub struct AddBalanceLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddBalanceLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddBalanceLiquidityCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - user_pool_lp: None, - a_vault_lp: None, - b_vault_lp: None, - a_vault: None, - b_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_token_vault: None, - b_token_vault: None, - user_a_token: None, - user_b_token: None, - user: None, - vault_program: None, - token_program: None, - pool_token_amount: None, - maximum_token_a_amount: None, - maximum_token_b_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - #[inline(always)] - pub fn user_pool_lp( - &mut self, - user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_pool_lp = Some(user_pool_lp); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_a_token( - &mut self, - user_a_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_a_token = Some(user_a_token); - self - } - - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_b_token( - &mut self, - user_b_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_b_token = Some(user_b_token); - self - } - - /// User account. Must be owner of user_a_token, and user_b_token. - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn pool_token_amount(&mut self, pool_token_amount: u64) -> &mut Self { - self.instruction.pool_token_amount = Some(pool_token_amount); - self - } - - #[inline(always)] - pub fn maximum_token_a_amount(&mut self, maximum_token_a_amount: u64) -> &mut Self { - self.instruction.maximum_token_a_amount = Some(maximum_token_a_amount); - self - } - - #[inline(always)] - pub fn maximum_token_b_amount(&mut self, maximum_token_b_amount: u64) -> &mut Self { - self.instruction.maximum_token_b_amount = Some(maximum_token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddBalanceLiquidityInstructionArgs { - pool_token_amount: self - .instruction - .pool_token_amount - .clone() - .expect("pool_token_amount is not set"), - maximum_token_a_amount: self - .instruction - .maximum_token_a_amount - .clone() - .expect("maximum_token_a_amount is not set"), - maximum_token_b_amount: self - .instruction - .maximum_token_b_amount - .clone() - .expect("maximum_token_b_amount is not set"), - }; - let instruction = AddBalanceLiquidityCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_pool_lp: self - .instruction - .user_pool_lp - .expect("user_pool_lp is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - user_a_token: self - .instruction - .user_a_token - .expect("user_a_token is not set"), - - user_b_token: self - .instruction - .user_b_token - .expect("user_b_token is not set"), - - user: self.instruction.user.expect("user is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddBalanceLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - user_a_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_b_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_token_amount: Option, - maximum_token_a_amount: Option, - maximum_token_b_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/add_imbalance_liquidity.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/add_imbalance_liquidity.rs deleted file mode 100644 index 5cf9d36d..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/add_imbalance_liquidity.rs +++ /dev/null @@ -1,989 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct AddImbalanceLiquidity { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// LP token mint of vault a - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault b - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: solana_pubkey::Pubkey, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: solana_pubkey::Pubkey, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: solana_pubkey::Pubkey, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, -} - -impl AddImbalanceLiquidity { - pub fn instruction( - &self, - args: AddImbalanceLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AddImbalanceLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_a_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_b_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AddImbalanceLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddImbalanceLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl AddImbalanceLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [79, 35, 122, 84, 173, 15, 93, 191], - } - } -} - -impl Default for AddImbalanceLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddImbalanceLiquidityInstructionArgs { - pub minimum_pool_token_amount: u64, - pub token_a_amount: u64, - pub token_b_amount: u64, -} - -/// Instruction builder for `AddImbalanceLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` user_pool_lp -/// 3. `[writable]` a_vault_lp -/// 4. `[writable]` b_vault_lp -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_token_vault -/// 10. `[writable]` b_token_vault -/// 11. `[writable]` user_a_token -/// 12. `[writable]` user_b_token -/// 13. `[signer]` user -/// 14. `[]` vault_program -/// 15. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct AddImbalanceLiquidityBuilder { - pool: Option, - lp_mint: Option, - user_pool_lp: Option, - a_vault_lp: Option, - b_vault_lp: Option, - a_vault: Option, - b_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_token_vault: Option, - b_token_vault: Option, - user_a_token: Option, - user_b_token: Option, - user: Option, - vault_program: Option, - token_program: Option, - minimum_pool_token_amount: Option, - token_a_amount: Option, - token_b_amount: Option, - __remaining_accounts: Vec, -} - -impl AddImbalanceLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - #[inline(always)] - pub fn user_pool_lp(&mut self, user_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.user_pool_lp = Some(user_pool_lp); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_a_token(&mut self, user_a_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_a_token = Some(user_a_token); - self - } - - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_b_token(&mut self, user_b_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_b_token = Some(user_b_token); - self - } - - /// User account. Must be owner of user_a_token, and user_b_token. - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn minimum_pool_token_amount(&mut self, minimum_pool_token_amount: u64) -> &mut Self { - self.minimum_pool_token_amount = Some(minimum_pool_token_amount); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.token_b_amount = Some(token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddImbalanceLiquidity { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_pool_lp: self.user_pool_lp.expect("user_pool_lp is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - user_a_token: self.user_a_token.expect("user_a_token is not set"), - user_b_token: self.user_b_token.expect("user_b_token is not set"), - user: self.user.expect("user is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = AddImbalanceLiquidityInstructionArgs { - minimum_pool_token_amount: self - .minimum_pool_token_amount - .clone() - .expect("minimum_pool_token_amount is not set"), - token_a_amount: self - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `add_imbalance_liquidity` CPI accounts. -pub struct AddImbalanceLiquidityCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: &'b solana_account_info::AccountInfo<'a>, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_imbalance_liquidity` CPI instruction. -pub struct AddImbalanceLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: &'b solana_account_info::AccountInfo<'a>, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AddImbalanceLiquidityInstructionArgs, -} - -impl<'a, 'b> AddImbalanceLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddImbalanceLiquidityCpiAccounts<'a, 'b>, - args: AddImbalanceLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - user_pool_lp: accounts.user_pool_lp, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - user_a_token: accounts.user_a_token, - user_b_token: accounts.user_b_token, - user: accounts.user, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_a_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_b_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AddImbalanceLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_pool_lp.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.user_a_token.clone()); - account_infos.push(self.user_b_token.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddImbalanceLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` user_pool_lp -/// 3. `[writable]` a_vault_lp -/// 4. `[writable]` b_vault_lp -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_token_vault -/// 10. `[writable]` b_token_vault -/// 11. `[writable]` user_a_token -/// 12. `[writable]` user_b_token -/// 13. `[signer]` user -/// 14. `[]` vault_program -/// 15. `[]` token_program -#[derive(Clone, Debug)] -pub struct AddImbalanceLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddImbalanceLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddImbalanceLiquidityCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - user_pool_lp: None, - a_vault_lp: None, - b_vault_lp: None, - a_vault: None, - b_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_token_vault: None, - b_token_vault: None, - user_a_token: None, - user_b_token: None, - user: None, - vault_program: None, - token_program: None, - minimum_pool_token_amount: None, - token_a_amount: None, - token_b_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - #[inline(always)] - pub fn user_pool_lp( - &mut self, - user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_pool_lp = Some(user_pool_lp); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_a_token( - &mut self, - user_a_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_a_token = Some(user_a_token); - self - } - - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_b_token( - &mut self, - user_b_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_b_token = Some(user_b_token); - self - } - - /// User account. Must be owner of user_a_token, and user_b_token. - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn minimum_pool_token_amount(&mut self, minimum_pool_token_amount: u64) -> &mut Self { - self.instruction.minimum_pool_token_amount = Some(minimum_pool_token_amount); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.instruction.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.instruction.token_b_amount = Some(token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AddImbalanceLiquidityInstructionArgs { - minimum_pool_token_amount: self - .instruction - .minimum_pool_token_amount - .clone() - .expect("minimum_pool_token_amount is not set"), - token_a_amount: self - .instruction - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .instruction - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - }; - let instruction = AddImbalanceLiquidityCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_pool_lp: self - .instruction - .user_pool_lp - .expect("user_pool_lp is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - user_a_token: self - .instruction - .user_a_token - .expect("user_a_token is not set"), - - user_b_token: self - .instruction - .user_b_token - .expect("user_b_token is not set"), - - user: self.instruction.user.expect("user is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddImbalanceLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - user_a_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_b_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - minimum_pool_token_amount: Option, - token_a_amount: Option, - token_b_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/bootstrap_liquidity.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/bootstrap_liquidity.rs deleted file mode 100644 index a565455b..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/bootstrap_liquidity.rs +++ /dev/null @@ -1,964 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct BootstrapLiquidity { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// LP token mint of vault a - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault b - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: solana_pubkey::Pubkey, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: solana_pubkey::Pubkey, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: solana_pubkey::Pubkey, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, -} - -impl BootstrapLiquidity { - pub fn instruction( - &self, - args: BootstrapLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: BootstrapLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_a_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_b_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&BootstrapLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BootstrapLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl BootstrapLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [4, 228, 215, 71, 225, 253, 119, 206], - } - } -} - -impl Default for BootstrapLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BootstrapLiquidityInstructionArgs { - pub token_a_amount: u64, - pub token_b_amount: u64, -} - -/// Instruction builder for `BootstrapLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` user_pool_lp -/// 3. `[writable]` a_vault_lp -/// 4. `[writable]` b_vault_lp -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_token_vault -/// 10. `[writable]` b_token_vault -/// 11. `[writable]` user_a_token -/// 12. `[writable]` user_b_token -/// 13. `[signer]` user -/// 14. `[]` vault_program -/// 15. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct BootstrapLiquidityBuilder { - pool: Option, - lp_mint: Option, - user_pool_lp: Option, - a_vault_lp: Option, - b_vault_lp: Option, - a_vault: Option, - b_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_token_vault: Option, - b_token_vault: Option, - user_a_token: Option, - user_b_token: Option, - user: Option, - vault_program: Option, - token_program: Option, - token_a_amount: Option, - token_b_amount: Option, - __remaining_accounts: Vec, -} - -impl BootstrapLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - #[inline(always)] - pub fn user_pool_lp(&mut self, user_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.user_pool_lp = Some(user_pool_lp); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_a_token(&mut self, user_a_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_a_token = Some(user_a_token); - self - } - - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_b_token(&mut self, user_b_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_b_token = Some(user_b_token); - self - } - - /// User account. Must be owner of user_a_token, and user_b_token. - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.token_b_amount = Some(token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = BootstrapLiquidity { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_pool_lp: self.user_pool_lp.expect("user_pool_lp is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - user_a_token: self.user_a_token.expect("user_a_token is not set"), - user_b_token: self.user_b_token.expect("user_b_token is not set"), - user: self.user.expect("user is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = BootstrapLiquidityInstructionArgs { - token_a_amount: self - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `bootstrap_liquidity` CPI accounts. -pub struct BootstrapLiquidityCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: &'b solana_account_info::AccountInfo<'a>, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `bootstrap_liquidity` CPI instruction. -pub struct BootstrapLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: &'b solana_account_info::AccountInfo<'a>, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: BootstrapLiquidityInstructionArgs, -} - -impl<'a, 'b> BootstrapLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: BootstrapLiquidityCpiAccounts<'a, 'b>, - args: BootstrapLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - user_pool_lp: accounts.user_pool_lp, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - user_a_token: accounts.user_a_token, - user_b_token: accounts.user_b_token, - user: accounts.user, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_a_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_b_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&BootstrapLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_pool_lp.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.user_a_token.clone()); - account_infos.push(self.user_b_token.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `BootstrapLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` user_pool_lp -/// 3. `[writable]` a_vault_lp -/// 4. `[writable]` b_vault_lp -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_token_vault -/// 10. `[writable]` b_token_vault -/// 11. `[writable]` user_a_token -/// 12. `[writable]` user_b_token -/// 13. `[signer]` user -/// 14. `[]` vault_program -/// 15. `[]` token_program -#[derive(Clone, Debug)] -pub struct BootstrapLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> BootstrapLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(BootstrapLiquidityCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - user_pool_lp: None, - a_vault_lp: None, - b_vault_lp: None, - a_vault: None, - b_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_token_vault: None, - b_token_vault: None, - user_a_token: None, - user_b_token: None, - user: None, - vault_program: None, - token_program: None, - token_a_amount: None, - token_b_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - #[inline(always)] - pub fn user_pool_lp( - &mut self, - user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_pool_lp = Some(user_pool_lp); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_a_token( - &mut self, - user_a_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_a_token = Some(user_a_token); - self - } - - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_b_token( - &mut self, - user_b_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_b_token = Some(user_b_token); - self - } - - /// User account. Must be owner of user_a_token, and user_b_token. - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.instruction.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.instruction.token_b_amount = Some(token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = BootstrapLiquidityInstructionArgs { - token_a_amount: self - .instruction - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .instruction - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - }; - let instruction = BootstrapLiquidityCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_pool_lp: self - .instruction - .user_pool_lp - .expect("user_pool_lp is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - user_a_token: self - .instruction - .user_a_token - .expect("user_a_token is not set"), - - user_b_token: self - .instruction - .user_b_token - .expect("user_b_token is not set"), - - user: self.instruction.user.expect("user is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct BootstrapLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - user_a_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_b_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_amount: Option, - token_b_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/claim_fee.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/claim_fee.rs deleted file mode 100644 index 72a45695..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/claim_fee.rs +++ /dev/null @@ -1,1016 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimFee { - /// Pool account - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// Lock account - pub lock_escrow: solana_pubkey::Pubkey, - /// Owner of lock account - pub owner: solana_pubkey::Pubkey, - /// owner lp token account - pub source_tokens: solana_pubkey::Pubkey, - /// Escrow vault - pub escrow_vault: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// LP token mint of vault a - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault b - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: solana_pubkey::Pubkey, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: solana_pubkey::Pubkey, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, -} - -impl ClaimFee { - pub fn instruction(&self, args: ClaimFeeInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ClaimFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.lock_escrow, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.owner, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.source_tokens, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.escrow_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_a_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_b_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ClaimFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimFeeInstructionData { - discriminator: [u8; 8], -} - -impl ClaimFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [169, 32, 79, 137, 136, 232, 70, 137], - } - } -} - -impl Default for ClaimFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimFeeInstructionArgs { - pub max_amount: u64, -} - -/// Instruction builder for `ClaimFee`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` lock_escrow -/// 3. `[writable, signer]` owner -/// 4. `[writable]` source_tokens -/// 5. `[writable]` escrow_vault -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[writable]` a_token_vault -/// 8. `[writable]` b_token_vault -/// 9. `[writable]` a_vault -/// 10. `[writable]` b_vault -/// 11. `[writable]` a_vault_lp -/// 12. `[writable]` b_vault_lp -/// 13. `[writable]` a_vault_lp_mint -/// 14. `[writable]` b_vault_lp_mint -/// 15. `[writable]` user_a_token -/// 16. `[writable]` user_b_token -/// 17. `[]` vault_program -#[derive(Clone, Debug, Default)] -pub struct ClaimFeeBuilder { - pool: Option, - lp_mint: Option, - lock_escrow: Option, - owner: Option, - source_tokens: Option, - escrow_vault: Option, - token_program: Option, - a_token_vault: Option, - b_token_vault: Option, - a_vault: Option, - b_vault: Option, - a_vault_lp: Option, - b_vault_lp: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - user_a_token: Option, - user_b_token: Option, - vault_program: Option, - max_amount: Option, - __remaining_accounts: Vec, -} - -impl ClaimFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// Lock account - #[inline(always)] - pub fn lock_escrow(&mut self, lock_escrow: solana_pubkey::Pubkey) -> &mut Self { - self.lock_escrow = Some(lock_escrow); - self - } - - /// Owner of lock account - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// owner lp token account - #[inline(always)] - pub fn source_tokens(&mut self, source_tokens: solana_pubkey::Pubkey) -> &mut Self { - self.source_tokens = Some(source_tokens); - self - } - - /// Escrow vault - #[inline(always)] - pub fn escrow_vault(&mut self, escrow_vault: solana_pubkey::Pubkey) -> &mut Self { - self.escrow_vault = Some(escrow_vault); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_a_token(&mut self, user_a_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_a_token = Some(user_a_token); - self - } - - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_b_token(&mut self, user_b_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_b_token = Some(user_b_token); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - #[inline(always)] - pub fn max_amount(&mut self, max_amount: u64) -> &mut Self { - self.max_amount = Some(max_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimFee { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - lock_escrow: self.lock_escrow.expect("lock_escrow is not set"), - owner: self.owner.expect("owner is not set"), - source_tokens: self.source_tokens.expect("source_tokens is not set"), - escrow_vault: self.escrow_vault.expect("escrow_vault is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - user_a_token: self.user_a_token.expect("user_a_token is not set"), - user_b_token: self.user_b_token.expect("user_b_token is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - }; - let args = ClaimFeeInstructionArgs { - max_amount: self.max_amount.clone().expect("max_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `claim_fee` CPI accounts. -pub struct ClaimFeeCpiAccounts<'a, 'b> { - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Lock account - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - /// Owner of lock account - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// owner lp token account - pub source_tokens: &'b solana_account_info::AccountInfo<'a>, - /// Escrow vault - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: &'b solana_account_info::AccountInfo<'a>, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_fee` CPI instruction. -pub struct ClaimFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Lock account - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - /// Owner of lock account - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// owner lp token account - pub source_tokens: &'b solana_account_info::AccountInfo<'a>, - /// Escrow vault - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: &'b solana_account_info::AccountInfo<'a>, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ClaimFeeInstructionArgs, -} - -impl<'a, 'b> ClaimFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimFeeCpiAccounts<'a, 'b>, - args: ClaimFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - lock_escrow: accounts.lock_escrow, - owner: accounts.owner, - source_tokens: accounts.source_tokens, - escrow_vault: accounts.escrow_vault, - token_program: accounts.token_program, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - user_a_token: accounts.user_a_token, - user_b_token: accounts.user_b_token, - vault_program: accounts.vault_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lock_escrow.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.owner.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.source_tokens.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.escrow_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_a_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_b_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ClaimFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(19 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.lock_escrow.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.source_tokens.clone()); - account_infos.push(self.escrow_vault.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.user_a_token.clone()); - account_infos.push(self.user_b_token.clone()); - account_infos.push(self.vault_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` lock_escrow -/// 3. `[writable, signer]` owner -/// 4. `[writable]` source_tokens -/// 5. `[writable]` escrow_vault -/// 6. `[]` token_program -/// 7. `[writable]` a_token_vault -/// 8. `[writable]` b_token_vault -/// 9. `[writable]` a_vault -/// 10. `[writable]` b_vault -/// 11. `[writable]` a_vault_lp -/// 12. `[writable]` b_vault_lp -/// 13. `[writable]` a_vault_lp_mint -/// 14. `[writable]` b_vault_lp_mint -/// 15. `[writable]` user_a_token -/// 16. `[writable]` user_b_token -/// 17. `[]` vault_program -#[derive(Clone, Debug)] -pub struct ClaimFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimFeeCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - lock_escrow: None, - owner: None, - source_tokens: None, - escrow_vault: None, - token_program: None, - a_token_vault: None, - b_token_vault: None, - a_vault: None, - b_vault: None, - a_vault_lp: None, - b_vault_lp: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - user_a_token: None, - user_b_token: None, - vault_program: None, - max_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// Lock account - #[inline(always)] - pub fn lock_escrow( - &mut self, - lock_escrow: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_escrow = Some(lock_escrow); - self - } - - /// Owner of lock account - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// owner lp token account - #[inline(always)] - pub fn source_tokens( - &mut self, - source_tokens: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_tokens = Some(source_tokens); - self - } - - /// Escrow vault - #[inline(always)] - pub fn escrow_vault( - &mut self, - escrow_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.escrow_vault = Some(escrow_vault); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_a_token( - &mut self, - user_a_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_a_token = Some(user_a_token); - self - } - - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_b_token( - &mut self, - user_b_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_b_token = Some(user_b_token); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - #[inline(always)] - pub fn max_amount(&mut self, max_amount: u64) -> &mut Self { - self.instruction.max_amount = Some(max_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ClaimFeeInstructionArgs { - max_amount: self - .instruction - .max_amount - .clone() - .expect("max_amount is not set"), - }; - let instruction = ClaimFeeCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - lock_escrow: self - .instruction - .lock_escrow - .expect("lock_escrow is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - source_tokens: self - .instruction - .source_tokens - .expect("source_tokens is not set"), - - escrow_vault: self - .instruction - .escrow_vault - .expect("escrow_vault is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - user_a_token: self - .instruction - .user_a_token - .expect("user_a_token is not set"), - - user_b_token: self - .instruction - .user_b_token - .expect("user_b_token is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_escrow: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - source_tokens: Option<&'b solana_account_info::AccountInfo<'a>>, - escrow_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_a_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_b_token: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - max_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/close_config.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/close_config.rs deleted file mode 100644 index cec9bf18..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/close_config.rs +++ /dev/null @@ -1,346 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CloseConfig { - pub config: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub rent_receiver: solana_pubkey::Pubkey, -} - -impl CloseConfig { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.rent_receiver, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CloseConfigInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseConfigInstructionData { - discriminator: [u8; 8], -} - -impl CloseConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [145, 9, 72, 157, 95, 125, 61, 85], - } - } -} - -impl Default for CloseConfigInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CloseConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` admin -/// 2. `[writable]` rent_receiver -#[derive(Clone, Debug, Default)] -pub struct CloseConfigBuilder { - config: Option, - admin: Option, - rent_receiver: Option, - __remaining_accounts: Vec, -} - -impl CloseConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn rent_receiver(&mut self, rent_receiver: solana_pubkey::Pubkey) -> &mut Self { - self.rent_receiver = Some(rent_receiver); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CloseConfig { - config: self.config.expect("config is not set"), - admin: self.admin.expect("admin is not set"), - rent_receiver: self.rent_receiver.expect("rent_receiver is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_config` CPI accounts. -pub struct CloseConfigCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_config` CPI instruction. -pub struct CloseConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub rent_receiver: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CloseConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CloseConfigCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - config: accounts.config, - admin: accounts.admin, - rent_receiver: accounts.rent_receiver, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.rent_receiver.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CloseConfigInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.rent_receiver.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CloseConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` admin -/// 2. `[writable]` rent_receiver -#[derive(Clone, Debug)] -pub struct CloseConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CloseConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CloseConfigCpiBuilderInstruction { - __program: program, - config: None, - admin: None, - rent_receiver: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn rent_receiver( - &mut self, - rent_receiver: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_receiver = Some(rent_receiver); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CloseConfigCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - rent_receiver: self - .instruction - .rent_receiver - .expect("rent_receiver is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CloseConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/create_config.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/create_config.rs deleted file mode 100644 index c32c3676..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/create_config.rs +++ /dev/null @@ -1,565 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct CreateConfig { - pub config: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateConfig { - pub fn instruction( - &self, - args: CreateConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, false)); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigInstructionData { - discriminator: [u8; 8], -} - -impl CreateConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [201, 207, 243, 114, 75, 111, 47, 189], - } - } -} - -impl Default for CreateConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigInstructionArgs { - pub trade_fee_numerator: u64, - pub protocol_trade_fee_numerator: u64, - pub activation_duration: u64, - pub vault_config_key: Pubkey, - pub pool_creator_authority: Pubkey, - pub activation_type: u8, - pub index: u64, - pub partner_fee_numerator: u64, -} - -/// Instruction builder for `CreateConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` admin -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateConfigBuilder { - config: Option, - admin: Option, - system_program: Option, - trade_fee_numerator: Option, - protocol_trade_fee_numerator: Option, - activation_duration: Option, - vault_config_key: Option, - pool_creator_authority: Option, - activation_type: Option, - index: Option, - partner_fee_numerator: Option, - __remaining_accounts: Vec, -} - -impl CreateConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn trade_fee_numerator(&mut self, trade_fee_numerator: u64) -> &mut Self { - self.trade_fee_numerator = Some(trade_fee_numerator); - self - } - - #[inline(always)] - pub fn protocol_trade_fee_numerator(&mut self, protocol_trade_fee_numerator: u64) -> &mut Self { - self.protocol_trade_fee_numerator = Some(protocol_trade_fee_numerator); - self - } - - #[inline(always)] - pub fn activation_duration(&mut self, activation_duration: u64) -> &mut Self { - self.activation_duration = Some(activation_duration); - self - } - - #[inline(always)] - pub fn vault_config_key(&mut self, vault_config_key: Pubkey) -> &mut Self { - self.vault_config_key = Some(vault_config_key); - self - } - - #[inline(always)] - pub fn pool_creator_authority(&mut self, pool_creator_authority: Pubkey) -> &mut Self { - self.pool_creator_authority = Some(pool_creator_authority); - self - } - - #[inline(always)] - pub fn activation_type(&mut self, activation_type: u8) -> &mut Self { - self.activation_type = Some(activation_type); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u64) -> &mut Self { - self.index = Some(index); - self - } - - #[inline(always)] - pub fn partner_fee_numerator(&mut self, partner_fee_numerator: u64) -> &mut Self { - self.partner_fee_numerator = Some(partner_fee_numerator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateConfig { - config: self.config.expect("config is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = CreateConfigInstructionArgs { - trade_fee_numerator: self - .trade_fee_numerator - .clone() - .expect("trade_fee_numerator is not set"), - protocol_trade_fee_numerator: self - .protocol_trade_fee_numerator - .clone() - .expect("protocol_trade_fee_numerator is not set"), - activation_duration: self - .activation_duration - .clone() - .expect("activation_duration is not set"), - vault_config_key: self - .vault_config_key - .clone() - .expect("vault_config_key is not set"), - pool_creator_authority: self - .pool_creator_authority - .clone() - .expect("pool_creator_authority is not set"), - activation_type: self - .activation_type - .clone() - .expect("activation_type is not set"), - index: self.index.clone().expect("index is not set"), - partner_fee_numerator: self - .partner_fee_numerator - .clone() - .expect("partner_fee_numerator is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_config` CPI accounts. -pub struct CreateConfigCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_config` CPI instruction. -pub struct CreateConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateConfigInstructionArgs, -} - -impl<'a, 'b> CreateConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateConfigCpiAccounts<'a, 'b>, - args: CreateConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - admin: accounts.admin, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` config -/// 1. `[writable, signer]` admin -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateConfigCpiBuilderInstruction { - __program: program, - config: None, - admin: None, - system_program: None, - trade_fee_numerator: None, - protocol_trade_fee_numerator: None, - activation_duration: None, - vault_config_key: None, - pool_creator_authority: None, - activation_type: None, - index: None, - partner_fee_numerator: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn trade_fee_numerator(&mut self, trade_fee_numerator: u64) -> &mut Self { - self.instruction.trade_fee_numerator = Some(trade_fee_numerator); - self - } - - #[inline(always)] - pub fn protocol_trade_fee_numerator(&mut self, protocol_trade_fee_numerator: u64) -> &mut Self { - self.instruction.protocol_trade_fee_numerator = Some(protocol_trade_fee_numerator); - self - } - - #[inline(always)] - pub fn activation_duration(&mut self, activation_duration: u64) -> &mut Self { - self.instruction.activation_duration = Some(activation_duration); - self - } - - #[inline(always)] - pub fn vault_config_key(&mut self, vault_config_key: Pubkey) -> &mut Self { - self.instruction.vault_config_key = Some(vault_config_key); - self - } - - #[inline(always)] - pub fn pool_creator_authority(&mut self, pool_creator_authority: Pubkey) -> &mut Self { - self.instruction.pool_creator_authority = Some(pool_creator_authority); - self - } - - #[inline(always)] - pub fn activation_type(&mut self, activation_type: u8) -> &mut Self { - self.instruction.activation_type = Some(activation_type); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u64) -> &mut Self { - self.instruction.index = Some(index); - self - } - - #[inline(always)] - pub fn partner_fee_numerator(&mut self, partner_fee_numerator: u64) -> &mut Self { - self.instruction.partner_fee_numerator = Some(partner_fee_numerator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateConfigInstructionArgs { - trade_fee_numerator: self - .instruction - .trade_fee_numerator - .clone() - .expect("trade_fee_numerator is not set"), - protocol_trade_fee_numerator: self - .instruction - .protocol_trade_fee_numerator - .clone() - .expect("protocol_trade_fee_numerator is not set"), - activation_duration: self - .instruction - .activation_duration - .clone() - .expect("activation_duration is not set"), - vault_config_key: self - .instruction - .vault_config_key - .clone() - .expect("vault_config_key is not set"), - pool_creator_authority: self - .instruction - .pool_creator_authority - .clone() - .expect("pool_creator_authority is not set"), - activation_type: self - .instruction - .activation_type - .clone() - .expect("activation_type is not set"), - index: self.instruction.index.clone().expect("index is not set"), - partner_fee_numerator: self - .instruction - .partner_fee_numerator - .clone() - .expect("partner_fee_numerator is not set"), - }; - let instruction = CreateConfigCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - trade_fee_numerator: Option, - protocol_trade_fee_numerator: Option, - activation_duration: Option, - vault_config_key: Option, - pool_creator_authority: Option, - activation_type: Option, - index: Option, - partner_fee_numerator: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/create_lock_escrow.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/create_lock_escrow.rs deleted file mode 100644 index 64b5ebe6..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/create_lock_escrow.rs +++ /dev/null @@ -1,476 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateLockEscrow { - /// Pool account - pub pool: solana_pubkey::Pubkey, - /// Lock account - pub lock_escrow: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// Payer account - pub payer: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateLockEscrow { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lock_escrow, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateLockEscrowInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateLockEscrowInstructionData { - discriminator: [u8; 8], -} - -impl CreateLockEscrowInstructionData { - pub fn new() -> Self { - Self { - discriminator: [54, 87, 165, 19, 69, 227, 218, 224], - } - } -} - -impl Default for CreateLockEscrowInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateLockEscrow`. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[writable]` lock_escrow -/// 2. `[]` owner -/// 3. `[]` lp_mint -/// 4. `[writable, signer]` payer -/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateLockEscrowBuilder { - pool: Option, - lock_escrow: Option, - owner: Option, - lp_mint: Option, - payer: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl CreateLockEscrowBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// Lock account - #[inline(always)] - pub fn lock_escrow(&mut self, lock_escrow: solana_pubkey::Pubkey) -> &mut Self { - self.lock_escrow = Some(lock_escrow); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// Payer account - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateLockEscrow { - pool: self.pool.expect("pool is not set"), - lock_escrow: self.lock_escrow.expect("lock_escrow is not set"), - owner: self.owner.expect("owner is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - payer: self.payer.expect("payer is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_lock_escrow` CPI accounts. -pub struct CreateLockEscrowCpiAccounts<'a, 'b> { - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Lock account - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Payer account - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_lock_escrow` CPI instruction. -pub struct CreateLockEscrowCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Lock account - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Payer account - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateLockEscrowCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateLockEscrowCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lock_escrow: accounts.lock_escrow, - owner: accounts.owner, - lp_mint: accounts.lp_mint, - payer: accounts.payer, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lock_escrow.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateLockEscrowInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lock_escrow.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateLockEscrow` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[writable]` lock_escrow -/// 2. `[]` owner -/// 3. `[]` lp_mint -/// 4. `[writable, signer]` payer -/// 5. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateLockEscrowCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateLockEscrowCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateLockEscrowCpiBuilderInstruction { - __program: program, - pool: None, - lock_escrow: None, - owner: None, - lp_mint: None, - payer: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// Lock account - #[inline(always)] - pub fn lock_escrow( - &mut self, - lock_escrow: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_escrow = Some(lock_escrow); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// Payer account - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateLockEscrowCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lock_escrow: self - .instruction - .lock_escrow - .expect("lock_escrow is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateLockEscrowCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_escrow: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/create_mint_metadata.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/create_mint_metadata.rs deleted file mode 100644 index 47628f45..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/create_mint_metadata.rs +++ /dev/null @@ -1,522 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateMintMetadata { - /// Pool account - pub pool: solana_pubkey::Pubkey, - /// LP mint account of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// Vault A LP account of the pool - pub a_vault_lp: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, - /// Payer - pub payer: solana_pubkey::Pubkey, -} - -impl CreateMintMetadata { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateMintMetadataInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateMintMetadataInstructionData { - discriminator: [u8; 8], -} - -impl CreateMintMetadataInstructionData { - pub fn new() -> Self { - Self { - discriminator: [13, 70, 168, 41, 250, 100, 148, 90], - } - } -} - -impl Default for CreateMintMetadataInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateMintMetadata`. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[]` lp_mint -/// 2. `[]` a_vault_lp -/// 3. `[writable]` mint_metadata -/// 4. `[]` metadata_program -/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 6. `[writable, signer]` payer -#[derive(Clone, Debug, Default)] -pub struct CreateMintMetadataBuilder { - pool: Option, - lp_mint: Option, - a_vault_lp: Option, - mint_metadata: Option, - metadata_program: Option, - system_program: Option, - payer: Option, - __remaining_accounts: Vec, -} - -impl CreateMintMetadataBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP mint account of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// Vault A LP account of the pool - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Payer - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateMintMetadata { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - payer: self.payer.expect("payer is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_mint_metadata` CPI accounts. -pub struct CreateMintMetadataCpiAccounts<'a, 'b> { - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP mint account of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault A LP account of the pool - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Payer - pub payer: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_mint_metadata` CPI instruction. -pub struct CreateMintMetadataCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP mint account of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault A LP account of the pool - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Payer - pub payer: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateMintMetadataCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateMintMetadataCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - a_vault_lp: accounts.a_vault_lp, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - system_program: accounts.system_program, - payer: accounts.payer, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateMintMetadataInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.payer.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateMintMetadata` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[]` lp_mint -/// 2. `[]` a_vault_lp -/// 3. `[writable]` mint_metadata -/// 4. `[]` metadata_program -/// 5. `[]` system_program -/// 6. `[writable, signer]` payer -#[derive(Clone, Debug)] -pub struct CreateMintMetadataCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateMintMetadataCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateMintMetadataCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - a_vault_lp: None, - mint_metadata: None, - metadata_program: None, - system_program: None, - payer: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP mint account of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// Vault A LP account of the pool - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Payer - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateMintMetadataCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateMintMetadataCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/enable_or_disable_pool.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/enable_or_disable_pool.rs deleted file mode 100644 index 81ad3dfd..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/enable_or_disable_pool.rs +++ /dev/null @@ -1,352 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct EnableOrDisablePool { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// Admin account. Must be owner of the pool. - pub admin: solana_pubkey::Pubkey, -} - -impl EnableOrDisablePool { - pub fn instruction( - &self, - args: EnableOrDisablePoolInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: EnableOrDisablePoolInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&EnableOrDisablePoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EnableOrDisablePoolInstructionData { - discriminator: [u8; 8], -} - -impl EnableOrDisablePoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [128, 6, 228, 131, 55, 161, 52, 169], - } - } -} - -impl Default for EnableOrDisablePoolInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EnableOrDisablePoolInstructionArgs { - pub enable: bool, -} - -/// Instruction builder for `EnableOrDisablePool`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct EnableOrDisablePoolBuilder { - pool: Option, - admin: Option, - enable: Option, - __remaining_accounts: Vec, -} - -impl EnableOrDisablePoolBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// Admin account. Must be owner of the pool. - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn enable(&mut self, enable: bool) -> &mut Self { - self.enable = Some(enable); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = EnableOrDisablePool { - pool: self.pool.expect("pool is not set"), - admin: self.admin.expect("admin is not set"), - }; - let args = EnableOrDisablePoolInstructionArgs { - enable: self.enable.clone().expect("enable is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `enable_or_disable_pool` CPI accounts. -pub struct EnableOrDisablePoolCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. Must be owner of the pool. - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `enable_or_disable_pool` CPI instruction. -pub struct EnableOrDisablePoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. Must be owner of the pool. - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: EnableOrDisablePoolInstructionArgs, -} - -impl<'a, 'b> EnableOrDisablePoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: EnableOrDisablePoolCpiAccounts<'a, 'b>, - args: EnableOrDisablePoolInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - admin: accounts.admin, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&EnableOrDisablePoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `EnableOrDisablePool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` admin -#[derive(Clone, Debug)] -pub struct EnableOrDisablePoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> EnableOrDisablePoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(EnableOrDisablePoolCpiBuilderInstruction { - __program: program, - pool: None, - admin: None, - enable: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// Admin account. Must be owner of the pool. - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn enable(&mut self, enable: bool) -> &mut Self { - self.instruction.enable = Some(enable); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = EnableOrDisablePoolInstructionArgs { - enable: self.instruction.enable.clone().expect("enable is not set"), - }; - let instruction = EnableOrDisablePoolCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct EnableOrDisablePoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - enable: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/get_pool_info.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/get_pool_info.rs deleted file mode 100644 index 3c5beda4..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/get_pool_info.rs +++ /dev/null @@ -1,564 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct GetPoolInfo { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// LP token mint of vault a - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault b - pub b_vault_lp_mint: solana_pubkey::Pubkey, -} - -impl GetPoolInfo { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.b_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.b_vault_lp_mint, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&GetPoolInfoInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct GetPoolInfoInstructionData { - discriminator: [u8; 8], -} - -impl GetPoolInfoInstructionData { - pub fn new() -> Self { - Self { - discriminator: [9, 48, 220, 101, 22, 240, 78, 200], - } - } -} - -impl Default for GetPoolInfoInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `GetPoolInfo`. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[]` lp_mint -/// 2. `[]` a_vault_lp -/// 3. `[]` b_vault_lp -/// 4. `[]` a_vault -/// 5. `[]` b_vault -/// 6. `[]` a_vault_lp_mint -/// 7. `[]` b_vault_lp_mint -#[derive(Clone, Debug, Default)] -pub struct GetPoolInfoBuilder { - pool: Option, - lp_mint: Option, - a_vault_lp: Option, - b_vault_lp: Option, - a_vault: Option, - b_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - __remaining_accounts: Vec, -} - -impl GetPoolInfoBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = GetPoolInfo { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `get_pool_info` CPI accounts. -pub struct GetPoolInfoCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, -} - -/// `get_pool_info` CPI instruction. -pub struct GetPoolInfoCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> GetPoolInfoCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: GetPoolInfoCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.b_vault_lp_mint.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&GetPoolInfoInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `GetPoolInfo` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[]` lp_mint -/// 2. `[]` a_vault_lp -/// 3. `[]` b_vault_lp -/// 4. `[]` a_vault -/// 5. `[]` b_vault -/// 6. `[]` a_vault_lp_mint -/// 7. `[]` b_vault_lp_mint -#[derive(Clone, Debug)] -pub struct GetPoolInfoCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> GetPoolInfoCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(GetPoolInfoCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - a_vault_lp: None, - b_vault_lp: None, - a_vault: None, - b_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = GetPoolInfoCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct GetPoolInfoCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_customizable_permissionless_constant_product_pool.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_customizable_permissionless_constant_product_pool.rs deleted file mode 100644 index 428b92d0..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_customizable_permissionless_constant_product_pool.rs +++ /dev/null @@ -1,1489 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeCustomizablePermissionlessConstantProductPool { - /// Pool account (PDA address) - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: solana_pubkey::Pubkey, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: solana_pubkey::Pubkey, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// LP token mint of vault A - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault B - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: solana_pubkey::Pubkey, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: solana_pubkey::Pubkey, - - pub payer_pool_lp: solana_pubkey::Pubkey, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: solana_pubkey::Pubkey, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: solana_pubkey::Pubkey, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: solana_pubkey::Pubkey, - /// Rent account. - pub rent: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, - /// Associated token program. - pub associated_token_program: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeCustomizablePermissionlessConstantProductPool { - pub fn instruction( - &self, - args: InitializeCustomizablePermissionlessConstantProductPoolInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeCustomizablePermissionlessConstantProductPoolInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(25 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_a_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_b_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec( - &InitializeCustomizablePermissionlessConstantProductPoolInstructionData::new(), - ) - .unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeCustomizablePermissionlessConstantProductPoolInstructionData { - discriminator: [u8; 8], -} - -impl InitializeCustomizablePermissionlessConstantProductPoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [145, 24, 172, 194, 219, 125, 3, 190], - } - } -} - -impl Default for InitializeCustomizablePermissionlessConstantProductPoolInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeCustomizablePermissionlessConstantProductPoolInstructionArgs { - pub token_a_amount: u64, - pub token_b_amount: u64, - pub trade_fee_numerator: u32, - pub activation_point: Option, - pub has_alpha_vault: bool, - pub activation_type: u8, - pub padding: [u8; 90], -} - -/// Instruction builder for `InitializeCustomizablePermissionlessConstantProductPool`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[]` token_a_mint -/// 3. `[]` token_b_mint -/// 4. `[writable]` a_vault -/// 5. `[writable]` b_vault -/// 6. `[writable]` a_token_vault -/// 7. `[writable]` b_token_vault -/// 8. `[writable]` a_vault_lp_mint -/// 9. `[writable]` b_vault_lp_mint -/// 10. `[writable]` a_vault_lp -/// 11. `[writable]` b_vault_lp -/// 12. `[writable]` payer_token_a -/// 13. `[writable]` payer_token_b -/// 14. `[writable]` payer_pool_lp -/// 15. `[writable]` protocol_token_a_fee -/// 16. `[writable]` protocol_token_b_fee -/// 17. `[writable, signer]` payer -/// 18. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 19. `[writable]` mint_metadata -/// 20. `[]` metadata_program -/// 21. `[]` vault_program -/// 22. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 23. `[]` associated_token_program -/// 24. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeCustomizablePermissionlessConstantProductPoolBuilder { - pool: Option, - lp_mint: Option, - token_a_mint: Option, - token_b_mint: Option, - a_vault: Option, - b_vault: Option, - a_token_vault: Option, - b_token_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_vault_lp: Option, - b_vault_lp: Option, - payer_token_a: Option, - payer_token_b: Option, - payer_pool_lp: Option, - protocol_token_a_fee: Option, - protocol_token_b_fee: Option, - payer: Option, - rent: Option, - mint_metadata: Option, - metadata_program: Option, - vault_program: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - token_a_amount: Option, - token_b_amount: Option, - trade_fee_numerator: Option, - activation_point: Option, - has_alpha_vault: Option, - activation_type: Option, - padding: Option<[u8; 90]>, - __remaining_accounts: Vec, -} - -impl InitializeCustomizablePermissionlessConstantProductPoolBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA address) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_a(&mut self, payer_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_a = Some(payer_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_b(&mut self, payer_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_b = Some(payer_token_b); - self - } - - #[inline(always)] - pub fn payer_pool_lp(&mut self, payer_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.payer_pool_lp = Some(payer_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.token_b_amount = Some(token_b_amount); - self - } - - #[inline(always)] - pub fn trade_fee_numerator(&mut self, trade_fee_numerator: u32) -> &mut Self { - self.trade_fee_numerator = Some(trade_fee_numerator); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn activation_point(&mut self, activation_point: u64) -> &mut Self { - self.activation_point = Some(activation_point); - self - } - - #[inline(always)] - pub fn has_alpha_vault(&mut self, has_alpha_vault: bool) -> &mut Self { - self.has_alpha_vault = Some(has_alpha_vault); - self - } - - #[inline(always)] - pub fn activation_type(&mut self, activation_type: u8) -> &mut Self { - self.activation_type = Some(activation_type); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 90]) -> &mut Self { - self.padding = Some(padding); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeCustomizablePermissionlessConstantProductPool { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - payer_token_a: self.payer_token_a.expect("payer_token_a is not set"), - payer_token_b: self.payer_token_b.expect("payer_token_b is not set"), - payer_pool_lp: self.payer_pool_lp.expect("payer_pool_lp is not set"), - protocol_token_a_fee: self - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - protocol_token_b_fee: self - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - payer: self.payer.expect("payer is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializeCustomizablePermissionlessConstantProductPoolInstructionArgs { - token_a_amount: self - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - trade_fee_numerator: self - .trade_fee_numerator - .clone() - .expect("trade_fee_numerator is not set"), - activation_point: self.activation_point.clone(), - has_alpha_vault: self - .has_alpha_vault - .clone() - .expect("has_alpha_vault is not set"), - activation_type: self - .activation_type - .clone() - .expect("activation_type is not set"), - padding: self.padding.clone().expect("padding is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_customizable_permissionless_constant_product_pool` CPI accounts. -pub struct InitializeCustomizablePermissionlessConstantProductPoolCpiAccounts<'a, 'b> { - /// Pool account (PDA address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_customizable_permissionless_constant_product_pool` CPI instruction. -pub struct InitializeCustomizablePermissionlessConstantProductPoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeCustomizablePermissionlessConstantProductPoolInstructionArgs, -} - -impl<'a, 'b> InitializeCustomizablePermissionlessConstantProductPoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCustomizablePermissionlessConstantProductPoolCpiAccounts<'a, 'b>, - args: InitializeCustomizablePermissionlessConstantProductPoolInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - payer_token_a: accounts.payer_token_a, - payer_token_b: accounts.payer_token_b, - payer_pool_lp: accounts.payer_pool_lp, - protocol_token_a_fee: accounts.protocol_token_a_fee, - protocol_token_b_fee: accounts.protocol_token_b_fee, - payer: accounts.payer, - rent: accounts.rent, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(25 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_a_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_b_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec( - &InitializeCustomizablePermissionlessConstantProductPoolInstructionData::new(), - ) - .unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(26 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.payer_token_a.clone()); - account_infos.push(self.payer_token_b.clone()); - account_infos.push(self.payer_pool_lp.clone()); - account_infos.push(self.protocol_token_a_fee.clone()); - account_infos.push(self.protocol_token_b_fee.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeCustomizablePermissionlessConstantProductPool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[]` token_a_mint -/// 3. `[]` token_b_mint -/// 4. `[writable]` a_vault -/// 5. `[writable]` b_vault -/// 6. `[writable]` a_token_vault -/// 7. `[writable]` b_token_vault -/// 8. `[writable]` a_vault_lp_mint -/// 9. `[writable]` b_vault_lp_mint -/// 10. `[writable]` a_vault_lp -/// 11. `[writable]` b_vault_lp -/// 12. `[writable]` payer_token_a -/// 13. `[writable]` payer_token_b -/// 14. `[writable]` payer_pool_lp -/// 15. `[writable]` protocol_token_a_fee -/// 16. `[writable]` protocol_token_b_fee -/// 17. `[writable, signer]` payer -/// 18. `[]` rent -/// 19. `[writable]` mint_metadata -/// 20. `[]` metadata_program -/// 21. `[]` vault_program -/// 22. `[]` token_program -/// 23. `[]` associated_token_program -/// 24. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeCustomizablePermissionlessConstantProductPoolCpiBuilder<'a, 'b> { - instruction: - Box>, -} - -impl<'a, 'b> InitializeCustomizablePermissionlessConstantProductPoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new( - InitializeCustomizablePermissionlessConstantProductPoolCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - token_a_mint: None, - token_b_mint: None, - a_vault: None, - b_vault: None, - a_token_vault: None, - b_token_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_vault_lp: None, - b_vault_lp: None, - payer_token_a: None, - payer_token_b: None, - payer_pool_lp: None, - protocol_token_a_fee: None, - protocol_token_b_fee: None, - payer: None, - rent: None, - mint_metadata: None, - metadata_program: None, - vault_program: None, - token_program: None, - associated_token_program: None, - system_program: None, - token_a_amount: None, - token_b_amount: None, - trade_fee_numerator: None, - activation_point: None, - has_alpha_vault: None, - activation_type: None, - padding: None, - __remaining_accounts: Vec::new(), - }, - ); - Self { instruction } - } - - /// Pool account (PDA address) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_a( - &mut self, - payer_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_a = Some(payer_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_b( - &mut self, - payer_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_b = Some(payer_token_b); - self - } - - #[inline(always)] - pub fn payer_pool_lp( - &mut self, - payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_pool_lp = Some(payer_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.instruction.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.instruction.token_b_amount = Some(token_b_amount); - self - } - - #[inline(always)] - pub fn trade_fee_numerator(&mut self, trade_fee_numerator: u32) -> &mut Self { - self.instruction.trade_fee_numerator = Some(trade_fee_numerator); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn activation_point(&mut self, activation_point: u64) -> &mut Self { - self.instruction.activation_point = Some(activation_point); - self - } - - #[inline(always)] - pub fn has_alpha_vault(&mut self, has_alpha_vault: bool) -> &mut Self { - self.instruction.has_alpha_vault = Some(has_alpha_vault); - self - } - - #[inline(always)] - pub fn activation_type(&mut self, activation_type: u8) -> &mut Self { - self.instruction.activation_type = Some(activation_type); - self - } - - #[inline(always)] - pub fn padding(&mut self, padding: [u8; 90]) -> &mut Self { - self.instruction.padding = Some(padding); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeCustomizablePermissionlessConstantProductPoolInstructionArgs { - token_a_amount: self - .instruction - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .instruction - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - trade_fee_numerator: self - .instruction - .trade_fee_numerator - .clone() - .expect("trade_fee_numerator is not set"), - activation_point: self.instruction.activation_point.clone(), - has_alpha_vault: self - .instruction - .has_alpha_vault - .clone() - .expect("has_alpha_vault is not set"), - activation_type: self - .instruction - .activation_type - .clone() - .expect("activation_type is not set"), - padding: self - .instruction - .padding - .clone() - .expect("padding is not set"), - }; - let instruction = InitializeCustomizablePermissionlessConstantProductPoolCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - payer_token_a: self - .instruction - .payer_token_a - .expect("payer_token_a is not set"), - - payer_token_b: self - .instruction - .payer_token_b - .expect("payer_token_b is not set"), - - payer_pool_lp: self - .instruction - .payer_pool_lp - .expect("payer_pool_lp is not set"), - - protocol_token_a_fee: self - .instruction - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - - protocol_token_b_fee: self - .instruction - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCustomizablePermissionlessConstantProductPoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_a_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_b_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_amount: Option, - token_b_amount: Option, - trade_fee_numerator: Option, - activation_point: Option, - has_alpha_vault: Option, - activation_type: Option, - padding: Option<[u8; 90]>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissioned_pool.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissioned_pool.rs deleted file mode 100644 index 47510767..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissioned_pool.rs +++ /dev/null @@ -1,1292 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::CurveType; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePermissionedPool { - /// Pool account (arbitrary address) - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: solana_pubkey::Pubkey, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: solana_pubkey::Pubkey, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// LP token mint of vault A - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault B - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Admin token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub admin_token_a: solana_pubkey::Pubkey, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub admin_token_b: solana_pubkey::Pubkey, - /// Admin pool LP token account. Used to receive LP during first deposit (initialize pool) - /// Admin pool LP token account. Used to receive LP during first deposit (initialize pool) - pub admin_pool_lp: solana_pubkey::Pubkey, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: solana_pubkey::Pubkey, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: solana_pubkey::Pubkey, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub admin: solana_pubkey::Pubkey, - - pub fee_owner: solana_pubkey::Pubkey, - /// Rent account. - pub rent: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, - /// Associated token program. - pub associated_token_program: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializePermissionedPool { - pub fn instruction( - &self, - args: InitializePermissionedPoolInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePermissionedPoolInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(24 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, true)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.admin_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.admin_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.admin_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_a_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_b_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePermissionedPoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionedPoolInstructionData { - discriminator: [u8; 8], -} - -impl InitializePermissionedPoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [77, 85, 178, 157, 50, 48, 212, 126], - } - } -} - -impl Default for InitializePermissionedPoolInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionedPoolInstructionArgs { - pub curve_type: CurveType, -} - -/// Instruction builder for `InitializePermissionedPool`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` pool -/// 1. `[writable]` lp_mint -/// 2. `[]` token_a_mint -/// 3. `[]` token_b_mint -/// 4. `[writable]` a_vault -/// 5. `[writable]` b_vault -/// 6. `[writable]` a_vault_lp_mint -/// 7. `[writable]` b_vault_lp_mint -/// 8. `[writable]` a_vault_lp -/// 9. `[writable]` b_vault_lp -/// 10. `[writable]` admin_token_a -/// 11. `[writable]` admin_token_b -/// 12. `[writable]` admin_pool_lp -/// 13. `[writable]` protocol_token_a_fee -/// 14. `[writable]` protocol_token_b_fee -/// 15. `[writable, signer]` admin -/// 16. `[]` fee_owner -/// 17. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 18. `[writable]` mint_metadata -/// 19. `[]` metadata_program -/// 20. `[]` vault_program -/// 21. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 22. `[]` associated_token_program -/// 23. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializePermissionedPoolBuilder { - pool: Option, - lp_mint: Option, - token_a_mint: Option, - token_b_mint: Option, - a_vault: Option, - b_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_vault_lp: Option, - b_vault_lp: Option, - admin_token_a: Option, - admin_token_b: Option, - admin_pool_lp: Option, - protocol_token_a_fee: Option, - protocol_token_b_fee: Option, - admin: Option, - fee_owner: Option, - rent: Option, - mint_metadata: Option, - metadata_program: Option, - vault_program: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - curve_type: Option, - __remaining_accounts: Vec, -} - -impl InitializePermissionedPoolBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (arbitrary address) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Admin token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn admin_token_a(&mut self, admin_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.admin_token_a = Some(admin_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn admin_token_b(&mut self, admin_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.admin_token_b = Some(admin_token_b); - self - } - - /// Admin pool LP token account. Used to receive LP during first deposit (initialize pool) - /// Admin pool LP token account. Used to receive LP during first deposit (initialize pool) - #[inline(always)] - pub fn admin_pool_lp(&mut self, admin_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.admin_pool_lp = Some(admin_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn fee_owner(&mut self, fee_owner: solana_pubkey::Pubkey) -> &mut Self { - self.fee_owner = Some(fee_owner); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: CurveType) -> &mut Self { - self.curve_type = Some(curve_type); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePermissionedPool { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - admin_token_a: self.admin_token_a.expect("admin_token_a is not set"), - admin_token_b: self.admin_token_b.expect("admin_token_b is not set"), - admin_pool_lp: self.admin_pool_lp.expect("admin_pool_lp is not set"), - protocol_token_a_fee: self - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - protocol_token_b_fee: self - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - admin: self.admin.expect("admin is not set"), - fee_owner: self.fee_owner.expect("fee_owner is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializePermissionedPoolInstructionArgs { - curve_type: self.curve_type.clone().expect("curve_type is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_permissioned_pool` CPI accounts. -pub struct InitializePermissionedPoolCpiAccounts<'a, 'b> { - /// Pool account (arbitrary address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub admin_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub admin_token_b: &'b solana_account_info::AccountInfo<'a>, - /// Admin pool LP token account. Used to receive LP during first deposit (initialize pool) - /// Admin pool LP token account. Used to receive LP during first deposit (initialize pool) - pub admin_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub fee_owner: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_permissioned_pool` CPI instruction. -pub struct InitializePermissionedPoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (arbitrary address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub admin_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub admin_token_b: &'b solana_account_info::AccountInfo<'a>, - /// Admin pool LP token account. Used to receive LP during first deposit (initialize pool) - /// Admin pool LP token account. Used to receive LP during first deposit (initialize pool) - pub admin_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub fee_owner: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePermissionedPoolInstructionArgs, -} - -impl<'a, 'b> InitializePermissionedPoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePermissionedPoolCpiAccounts<'a, 'b>, - args: InitializePermissionedPoolInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - admin_token_a: accounts.admin_token_a, - admin_token_b: accounts.admin_token_b, - admin_pool_lp: accounts.admin_pool_lp, - protocol_token_a_fee: accounts.protocol_token_a_fee, - protocol_token_b_fee: accounts.protocol_token_b_fee, - admin: accounts.admin, - fee_owner: accounts.fee_owner, - rent: accounts.rent, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(24 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.admin_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.admin_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.admin_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_a_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_b_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePermissionedPoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(25 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.admin_token_a.clone()); - account_infos.push(self.admin_token_b.clone()); - account_infos.push(self.admin_pool_lp.clone()); - account_infos.push(self.protocol_token_a_fee.clone()); - account_infos.push(self.protocol_token_b_fee.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.fee_owner.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePermissionedPool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` pool -/// 1. `[writable]` lp_mint -/// 2. `[]` token_a_mint -/// 3. `[]` token_b_mint -/// 4. `[writable]` a_vault -/// 5. `[writable]` b_vault -/// 6. `[writable]` a_vault_lp_mint -/// 7. `[writable]` b_vault_lp_mint -/// 8. `[writable]` a_vault_lp -/// 9. `[writable]` b_vault_lp -/// 10. `[writable]` admin_token_a -/// 11. `[writable]` admin_token_b -/// 12. `[writable]` admin_pool_lp -/// 13. `[writable]` protocol_token_a_fee -/// 14. `[writable]` protocol_token_b_fee -/// 15. `[writable, signer]` admin -/// 16. `[]` fee_owner -/// 17. `[]` rent -/// 18. `[writable]` mint_metadata -/// 19. `[]` metadata_program -/// 20. `[]` vault_program -/// 21. `[]` token_program -/// 22. `[]` associated_token_program -/// 23. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializePermissionedPoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePermissionedPoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePermissionedPoolCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - token_a_mint: None, - token_b_mint: None, - a_vault: None, - b_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_vault_lp: None, - b_vault_lp: None, - admin_token_a: None, - admin_token_b: None, - admin_pool_lp: None, - protocol_token_a_fee: None, - protocol_token_b_fee: None, - admin: None, - fee_owner: None, - rent: None, - mint_metadata: None, - metadata_program: None, - vault_program: None, - token_program: None, - associated_token_program: None, - system_program: None, - curve_type: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (arbitrary address) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Admin token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn admin_token_a( - &mut self, - admin_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.admin_token_a = Some(admin_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn admin_token_b( - &mut self, - admin_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.admin_token_b = Some(admin_token_b); - self - } - - /// Admin pool LP token account. Used to receive LP during first deposit (initialize pool) - /// Admin pool LP token account. Used to receive LP during first deposit (initialize pool) - #[inline(always)] - pub fn admin_pool_lp( - &mut self, - admin_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.admin_pool_lp = Some(admin_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn fee_owner(&mut self, fee_owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_owner = Some(fee_owner); - self - } - - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: CurveType) -> &mut Self { - self.instruction.curve_type = Some(curve_type); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePermissionedPoolInstructionArgs { - curve_type: self - .instruction - .curve_type - .clone() - .expect("curve_type is not set"), - }; - let instruction = InitializePermissionedPoolCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - admin_token_a: self - .instruction - .admin_token_a - .expect("admin_token_a is not set"), - - admin_token_b: self - .instruction - .admin_token_b - .expect("admin_token_b is not set"), - - admin_pool_lp: self - .instruction - .admin_pool_lp - .expect("admin_pool_lp is not set"), - - protocol_token_a_fee: self - .instruction - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - - protocol_token_b_fee: self - .instruction - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - fee_owner: self.instruction.fee_owner.expect("fee_owner is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePermissionedPoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - admin_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - admin_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - admin_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_a_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_b_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_type: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_constant_product_pool_with_config.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_constant_product_pool_with_config.rs deleted file mode 100644 index e411efb8..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_constant_product_pool_with_config.rs +++ /dev/null @@ -1,1408 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePermissionlessConstantProductPoolWithConfig { - /// Pool account (PDA address) - pub pool: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: solana_pubkey::Pubkey, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: solana_pubkey::Pubkey, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// LP token mint of vault A - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault B - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: solana_pubkey::Pubkey, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: solana_pubkey::Pubkey, - - pub payer_pool_lp: solana_pubkey::Pubkey, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: solana_pubkey::Pubkey, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: solana_pubkey::Pubkey, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: solana_pubkey::Pubkey, - /// Rent account. - pub rent: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, - /// Associated token program. - pub associated_token_program: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializePermissionlessConstantProductPoolWithConfig { - pub fn instruction( - &self, - args: InitializePermissionlessConstantProductPoolWithConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePermissionlessConstantProductPoolWithConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(26 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_a_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_b_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec( - &InitializePermissionlessConstantProductPoolWithConfigInstructionData::new(), - ) - .unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionlessConstantProductPoolWithConfigInstructionData { - discriminator: [u8; 8], -} - -impl InitializePermissionlessConstantProductPoolWithConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [7, 166, 138, 171, 206, 171, 236, 244], - } - } -} - -impl Default for InitializePermissionlessConstantProductPoolWithConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionlessConstantProductPoolWithConfigInstructionArgs { - pub token_a_amount: u64, - pub token_b_amount: u64, -} - -/// Instruction builder for `InitializePermissionlessConstantProductPoolWithConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` config -/// 2. `[writable]` lp_mint -/// 3. `[]` token_a_mint -/// 4. `[]` token_b_mint -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_token_vault -/// 8. `[writable]` b_token_vault -/// 9. `[writable]` a_vault_lp_mint -/// 10. `[writable]` b_vault_lp_mint -/// 11. `[writable]` a_vault_lp -/// 12. `[writable]` b_vault_lp -/// 13. `[writable]` payer_token_a -/// 14. `[writable]` payer_token_b -/// 15. `[writable]` payer_pool_lp -/// 16. `[writable]` protocol_token_a_fee -/// 17. `[writable]` protocol_token_b_fee -/// 18. `[writable, signer]` payer -/// 19. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 20. `[writable]` mint_metadata -/// 21. `[]` metadata_program -/// 22. `[]` vault_program -/// 23. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 24. `[]` associated_token_program -/// 25. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializePermissionlessConstantProductPoolWithConfigBuilder { - pool: Option, - config: Option, - lp_mint: Option, - token_a_mint: Option, - token_b_mint: Option, - a_vault: Option, - b_vault: Option, - a_token_vault: Option, - b_token_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_vault_lp: Option, - b_vault_lp: Option, - payer_token_a: Option, - payer_token_b: Option, - payer_pool_lp: Option, - protocol_token_a_fee: Option, - protocol_token_b_fee: Option, - payer: Option, - rent: Option, - mint_metadata: Option, - metadata_program: Option, - vault_program: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - token_a_amount: Option, - token_b_amount: Option, - __remaining_accounts: Vec, -} - -impl InitializePermissionlessConstantProductPoolWithConfigBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA address) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_a(&mut self, payer_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_a = Some(payer_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_b(&mut self, payer_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_b = Some(payer_token_b); - self - } - - #[inline(always)] - pub fn payer_pool_lp(&mut self, payer_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.payer_pool_lp = Some(payer_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.token_b_amount = Some(token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePermissionlessConstantProductPoolWithConfig { - pool: self.pool.expect("pool is not set"), - config: self.config.expect("config is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - payer_token_a: self.payer_token_a.expect("payer_token_a is not set"), - payer_token_b: self.payer_token_b.expect("payer_token_b is not set"), - payer_pool_lp: self.payer_pool_lp.expect("payer_pool_lp is not set"), - protocol_token_a_fee: self - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - protocol_token_b_fee: self - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - payer: self.payer.expect("payer is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializePermissionlessConstantProductPoolWithConfigInstructionArgs { - token_a_amount: self - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_permissionless_constant_product_pool_with_config` CPI accounts. -pub struct InitializePermissionlessConstantProductPoolWithConfigCpiAccounts<'a, 'b> { - /// Pool account (PDA address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_permissionless_constant_product_pool_with_config` CPI instruction. -pub struct InitializePermissionlessConstantProductPoolWithConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePermissionlessConstantProductPoolWithConfigInstructionArgs, -} - -impl<'a, 'b> InitializePermissionlessConstantProductPoolWithConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePermissionlessConstantProductPoolWithConfigCpiAccounts<'a, 'b>, - args: InitializePermissionlessConstantProductPoolWithConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - config: accounts.config, - lp_mint: accounts.lp_mint, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - payer_token_a: accounts.payer_token_a, - payer_token_b: accounts.payer_token_b, - payer_pool_lp: accounts.payer_pool_lp, - protocol_token_a_fee: accounts.protocol_token_a_fee, - protocol_token_b_fee: accounts.protocol_token_b_fee, - payer: accounts.payer, - rent: accounts.rent, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(26 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_a_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_b_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec( - &InitializePermissionlessConstantProductPoolWithConfigInstructionData::new(), - ) - .unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(27 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.payer_token_a.clone()); - account_infos.push(self.payer_token_b.clone()); - account_infos.push(self.payer_pool_lp.clone()); - account_infos.push(self.protocol_token_a_fee.clone()); - account_infos.push(self.protocol_token_b_fee.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePermissionlessConstantProductPoolWithConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` config -/// 2. `[writable]` lp_mint -/// 3. `[]` token_a_mint -/// 4. `[]` token_b_mint -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_token_vault -/// 8. `[writable]` b_token_vault -/// 9. `[writable]` a_vault_lp_mint -/// 10. `[writable]` b_vault_lp_mint -/// 11. `[writable]` a_vault_lp -/// 12. `[writable]` b_vault_lp -/// 13. `[writable]` payer_token_a -/// 14. `[writable]` payer_token_b -/// 15. `[writable]` payer_pool_lp -/// 16. `[writable]` protocol_token_a_fee -/// 17. `[writable]` protocol_token_b_fee -/// 18. `[writable, signer]` payer -/// 19. `[]` rent -/// 20. `[writable]` mint_metadata -/// 21. `[]` metadata_program -/// 22. `[]` vault_program -/// 23. `[]` token_program -/// 24. `[]` associated_token_program -/// 25. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializePermissionlessConstantProductPoolWithConfigCpiBuilder<'a, 'b> { - instruction: - Box>, -} - -impl<'a, 'b> InitializePermissionlessConstantProductPoolWithConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new( - InitializePermissionlessConstantProductPoolWithConfigCpiBuilderInstruction { - __program: program, - pool: None, - config: None, - lp_mint: None, - token_a_mint: None, - token_b_mint: None, - a_vault: None, - b_vault: None, - a_token_vault: None, - b_token_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_vault_lp: None, - b_vault_lp: None, - payer_token_a: None, - payer_token_b: None, - payer_pool_lp: None, - protocol_token_a_fee: None, - protocol_token_b_fee: None, - payer: None, - rent: None, - mint_metadata: None, - metadata_program: None, - vault_program: None, - token_program: None, - associated_token_program: None, - system_program: None, - token_a_amount: None, - token_b_amount: None, - __remaining_accounts: Vec::new(), - }, - ); - Self { instruction } - } - - /// Pool account (PDA address) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_a( - &mut self, - payer_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_a = Some(payer_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_b( - &mut self, - payer_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_b = Some(payer_token_b); - self - } - - #[inline(always)] - pub fn payer_pool_lp( - &mut self, - payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_pool_lp = Some(payer_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.instruction.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.instruction.token_b_amount = Some(token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePermissionlessConstantProductPoolWithConfigInstructionArgs { - token_a_amount: self - .instruction - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .instruction - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - }; - let instruction = InitializePermissionlessConstantProductPoolWithConfigCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - config: self.instruction.config.expect("config is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - payer_token_a: self - .instruction - .payer_token_a - .expect("payer_token_a is not set"), - - payer_token_b: self - .instruction - .payer_token_b - .expect("payer_token_b is not set"), - - payer_pool_lp: self - .instruction - .payer_pool_lp - .expect("payer_pool_lp is not set"), - - protocol_token_a_fee: self - .instruction - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - - protocol_token_b_fee: self - .instruction - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePermissionlessConstantProductPoolWithConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_a_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_b_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_amount: Option, - token_b_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_constant_product_pool_with_config2.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_constant_product_pool_with_config2.rs deleted file mode 100644 index 4cfb108b..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_constant_product_pool_with_config2.rs +++ /dev/null @@ -1,1428 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePermissionlessConstantProductPoolWithConfig2 { - /// Pool account (PDA address) - pub pool: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: solana_pubkey::Pubkey, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: solana_pubkey::Pubkey, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// LP token mint of vault A - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault B - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: solana_pubkey::Pubkey, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: solana_pubkey::Pubkey, - - pub payer_pool_lp: solana_pubkey::Pubkey, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: solana_pubkey::Pubkey, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: solana_pubkey::Pubkey, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: solana_pubkey::Pubkey, - /// Rent account. - pub rent: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, - /// Associated token program. - pub associated_token_program: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializePermissionlessConstantProductPoolWithConfig2 { - pub fn instruction( - &self, - args: InitializePermissionlessConstantProductPoolWithConfig2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePermissionlessConstantProductPoolWithConfig2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(26 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_a_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_b_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec( - &InitializePermissionlessConstantProductPoolWithConfig2InstructionData::new(), - ) - .unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionlessConstantProductPoolWithConfig2InstructionData { - discriminator: [u8; 8], -} - -impl InitializePermissionlessConstantProductPoolWithConfig2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [48, 149, 220, 130, 61, 11, 9, 178], - } - } -} - -impl Default for InitializePermissionlessConstantProductPoolWithConfig2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionlessConstantProductPoolWithConfig2InstructionArgs { - pub token_a_amount: u64, - pub token_b_amount: u64, - pub activation_point: Option, -} - -/// Instruction builder for `InitializePermissionlessConstantProductPoolWithConfig2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` config -/// 2. `[writable]` lp_mint -/// 3. `[]` token_a_mint -/// 4. `[]` token_b_mint -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_token_vault -/// 8. `[writable]` b_token_vault -/// 9. `[writable]` a_vault_lp_mint -/// 10. `[writable]` b_vault_lp_mint -/// 11. `[writable]` a_vault_lp -/// 12. `[writable]` b_vault_lp -/// 13. `[writable]` payer_token_a -/// 14. `[writable]` payer_token_b -/// 15. `[writable]` payer_pool_lp -/// 16. `[writable]` protocol_token_a_fee -/// 17. `[writable]` protocol_token_b_fee -/// 18. `[writable, signer]` payer -/// 19. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 20. `[writable]` mint_metadata -/// 21. `[]` metadata_program -/// 22. `[]` vault_program -/// 23. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 24. `[]` associated_token_program -/// 25. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializePermissionlessConstantProductPoolWithConfig2Builder { - pool: Option, - config: Option, - lp_mint: Option, - token_a_mint: Option, - token_b_mint: Option, - a_vault: Option, - b_vault: Option, - a_token_vault: Option, - b_token_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_vault_lp: Option, - b_vault_lp: Option, - payer_token_a: Option, - payer_token_b: Option, - payer_pool_lp: Option, - protocol_token_a_fee: Option, - protocol_token_b_fee: Option, - payer: Option, - rent: Option, - mint_metadata: Option, - metadata_program: Option, - vault_program: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - token_a_amount: Option, - token_b_amount: Option, - activation_point: Option, - __remaining_accounts: Vec, -} - -impl InitializePermissionlessConstantProductPoolWithConfig2Builder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA address) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_a(&mut self, payer_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_a = Some(payer_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_b(&mut self, payer_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_b = Some(payer_token_b); - self - } - - #[inline(always)] - pub fn payer_pool_lp(&mut self, payer_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.payer_pool_lp = Some(payer_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.token_b_amount = Some(token_b_amount); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn activation_point(&mut self, activation_point: u64) -> &mut Self { - self.activation_point = Some(activation_point); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePermissionlessConstantProductPoolWithConfig2 { - pool: self.pool.expect("pool is not set"), - config: self.config.expect("config is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - payer_token_a: self.payer_token_a.expect("payer_token_a is not set"), - payer_token_b: self.payer_token_b.expect("payer_token_b is not set"), - payer_pool_lp: self.payer_pool_lp.expect("payer_pool_lp is not set"), - protocol_token_a_fee: self - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - protocol_token_b_fee: self - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - payer: self.payer.expect("payer is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializePermissionlessConstantProductPoolWithConfig2InstructionArgs { - token_a_amount: self - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - activation_point: self.activation_point.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_permissionless_constant_product_pool_with_config2` CPI accounts. -pub struct InitializePermissionlessConstantProductPoolWithConfig2CpiAccounts<'a, 'b> { - /// Pool account (PDA address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_permissionless_constant_product_pool_with_config2` CPI instruction. -pub struct InitializePermissionlessConstantProductPoolWithConfig2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePermissionlessConstantProductPoolWithConfig2InstructionArgs, -} - -impl<'a, 'b> InitializePermissionlessConstantProductPoolWithConfig2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePermissionlessConstantProductPoolWithConfig2CpiAccounts<'a, 'b>, - args: InitializePermissionlessConstantProductPoolWithConfig2InstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - config: accounts.config, - lp_mint: accounts.lp_mint, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - payer_token_a: accounts.payer_token_a, - payer_token_b: accounts.payer_token_b, - payer_pool_lp: accounts.payer_pool_lp, - protocol_token_a_fee: accounts.protocol_token_a_fee, - protocol_token_b_fee: accounts.protocol_token_b_fee, - payer: accounts.payer, - rent: accounts.rent, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(26 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_a_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_b_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec( - &InitializePermissionlessConstantProductPoolWithConfig2InstructionData::new(), - ) - .unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(27 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.payer_token_a.clone()); - account_infos.push(self.payer_token_b.clone()); - account_infos.push(self.payer_pool_lp.clone()); - account_infos.push(self.protocol_token_a_fee.clone()); - account_infos.push(self.protocol_token_b_fee.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePermissionlessConstantProductPoolWithConfig2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` config -/// 2. `[writable]` lp_mint -/// 3. `[]` token_a_mint -/// 4. `[]` token_b_mint -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_token_vault -/// 8. `[writable]` b_token_vault -/// 9. `[writable]` a_vault_lp_mint -/// 10. `[writable]` b_vault_lp_mint -/// 11. `[writable]` a_vault_lp -/// 12. `[writable]` b_vault_lp -/// 13. `[writable]` payer_token_a -/// 14. `[writable]` payer_token_b -/// 15. `[writable]` payer_pool_lp -/// 16. `[writable]` protocol_token_a_fee -/// 17. `[writable]` protocol_token_b_fee -/// 18. `[writable, signer]` payer -/// 19. `[]` rent -/// 20. `[writable]` mint_metadata -/// 21. `[]` metadata_program -/// 22. `[]` vault_program -/// 23. `[]` token_program -/// 24. `[]` associated_token_program -/// 25. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializePermissionlessConstantProductPoolWithConfig2CpiBuilder<'a, 'b> { - instruction: - Box>, -} - -impl<'a, 'b> InitializePermissionlessConstantProductPoolWithConfig2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new( - InitializePermissionlessConstantProductPoolWithConfig2CpiBuilderInstruction { - __program: program, - pool: None, - config: None, - lp_mint: None, - token_a_mint: None, - token_b_mint: None, - a_vault: None, - b_vault: None, - a_token_vault: None, - b_token_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_vault_lp: None, - b_vault_lp: None, - payer_token_a: None, - payer_token_b: None, - payer_pool_lp: None, - protocol_token_a_fee: None, - protocol_token_b_fee: None, - payer: None, - rent: None, - mint_metadata: None, - metadata_program: None, - vault_program: None, - token_program: None, - associated_token_program: None, - system_program: None, - token_a_amount: None, - token_b_amount: None, - activation_point: None, - __remaining_accounts: Vec::new(), - }, - ); - Self { instruction } - } - - /// Pool account (PDA address) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_a( - &mut self, - payer_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_a = Some(payer_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_b( - &mut self, - payer_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_b = Some(payer_token_b); - self - } - - #[inline(always)] - pub fn payer_pool_lp( - &mut self, - payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_pool_lp = Some(payer_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.instruction.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.instruction.token_b_amount = Some(token_b_amount); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn activation_point(&mut self, activation_point: u64) -> &mut Self { - self.instruction.activation_point = Some(activation_point); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePermissionlessConstantProductPoolWithConfig2InstructionArgs { - token_a_amount: self - .instruction - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .instruction - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - activation_point: self.instruction.activation_point.clone(), - }; - let instruction = InitializePermissionlessConstantProductPoolWithConfig2Cpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - config: self.instruction.config.expect("config is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - payer_token_a: self - .instruction - .payer_token_a - .expect("payer_token_a is not set"), - - payer_token_b: self - .instruction - .payer_token_b - .expect("payer_token_b is not set"), - - payer_pool_lp: self - .instruction - .payer_pool_lp - .expect("payer_pool_lp is not set"), - - protocol_token_a_fee: self - .instruction - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - - protocol_token_b_fee: self - .instruction - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePermissionlessConstantProductPoolWithConfig2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_a_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_b_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_amount: Option, - token_b_amount: Option, - activation_point: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_pool.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_pool.rs deleted file mode 100644 index 4412468c..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_pool.rs +++ /dev/null @@ -1,1423 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::CurveType; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePermissionlessPool { - /// Pool account (PDA address) - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: solana_pubkey::Pubkey, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: solana_pubkey::Pubkey, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// LP token mint of vault A - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault B - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: solana_pubkey::Pubkey, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: solana_pubkey::Pubkey, - - pub payer_pool_lp: solana_pubkey::Pubkey, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: solana_pubkey::Pubkey, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: solana_pubkey::Pubkey, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: solana_pubkey::Pubkey, - - pub fee_owner: solana_pubkey::Pubkey, - /// Rent account. - pub rent: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, - /// Associated token program. - pub associated_token_program: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializePermissionlessPool { - pub fn instruction( - &self, - args: InitializePermissionlessPoolInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePermissionlessPoolInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(26 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_a_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_b_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePermissionlessPoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionlessPoolInstructionData { - discriminator: [u8; 8], -} - -impl InitializePermissionlessPoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [118, 173, 41, 157, 173, 72, 97, 103], - } - } -} - -impl Default for InitializePermissionlessPoolInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionlessPoolInstructionArgs { - pub curve_type: CurveType, - pub token_a_amount: u64, - pub token_b_amount: u64, -} - -/// Instruction builder for `InitializePermissionlessPool`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[]` token_a_mint -/// 3. `[]` token_b_mint -/// 4. `[writable]` a_vault -/// 5. `[writable]` b_vault -/// 6. `[writable]` a_token_vault -/// 7. `[writable]` b_token_vault -/// 8. `[writable]` a_vault_lp_mint -/// 9. `[writable]` b_vault_lp_mint -/// 10. `[writable]` a_vault_lp -/// 11. `[writable]` b_vault_lp -/// 12. `[writable]` payer_token_a -/// 13. `[writable]` payer_token_b -/// 14. `[writable]` payer_pool_lp -/// 15. `[writable]` protocol_token_a_fee -/// 16. `[writable]` protocol_token_b_fee -/// 17. `[writable, signer]` payer -/// 18. `[]` fee_owner -/// 19. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 20. `[writable]` mint_metadata -/// 21. `[]` metadata_program -/// 22. `[]` vault_program -/// 23. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 24. `[]` associated_token_program -/// 25. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializePermissionlessPoolBuilder { - pool: Option, - lp_mint: Option, - token_a_mint: Option, - token_b_mint: Option, - a_vault: Option, - b_vault: Option, - a_token_vault: Option, - b_token_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_vault_lp: Option, - b_vault_lp: Option, - payer_token_a: Option, - payer_token_b: Option, - payer_pool_lp: Option, - protocol_token_a_fee: Option, - protocol_token_b_fee: Option, - payer: Option, - fee_owner: Option, - rent: Option, - mint_metadata: Option, - metadata_program: Option, - vault_program: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - curve_type: Option, - token_a_amount: Option, - token_b_amount: Option, - __remaining_accounts: Vec, -} - -impl InitializePermissionlessPoolBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA address) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_a(&mut self, payer_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_a = Some(payer_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_b(&mut self, payer_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_b = Some(payer_token_b); - self - } - - #[inline(always)] - pub fn payer_pool_lp(&mut self, payer_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.payer_pool_lp = Some(payer_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn fee_owner(&mut self, fee_owner: solana_pubkey::Pubkey) -> &mut Self { - self.fee_owner = Some(fee_owner); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: CurveType) -> &mut Self { - self.curve_type = Some(curve_type); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.token_b_amount = Some(token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePermissionlessPool { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - payer_token_a: self.payer_token_a.expect("payer_token_a is not set"), - payer_token_b: self.payer_token_b.expect("payer_token_b is not set"), - payer_pool_lp: self.payer_pool_lp.expect("payer_pool_lp is not set"), - protocol_token_a_fee: self - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - protocol_token_b_fee: self - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - payer: self.payer.expect("payer is not set"), - fee_owner: self.fee_owner.expect("fee_owner is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializePermissionlessPoolInstructionArgs { - curve_type: self.curve_type.clone().expect("curve_type is not set"), - token_a_amount: self - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_permissionless_pool` CPI accounts. -pub struct InitializePermissionlessPoolCpiAccounts<'a, 'b> { - /// Pool account (PDA address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub fee_owner: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_permissionless_pool` CPI instruction. -pub struct InitializePermissionlessPoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub fee_owner: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePermissionlessPoolInstructionArgs, -} - -impl<'a, 'b> InitializePermissionlessPoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePermissionlessPoolCpiAccounts<'a, 'b>, - args: InitializePermissionlessPoolInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - payer_token_a: accounts.payer_token_a, - payer_token_b: accounts.payer_token_b, - payer_pool_lp: accounts.payer_pool_lp, - protocol_token_a_fee: accounts.protocol_token_a_fee, - protocol_token_b_fee: accounts.protocol_token_b_fee, - payer: accounts.payer, - fee_owner: accounts.fee_owner, - rent: accounts.rent, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(26 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_a_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_b_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePermissionlessPoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(27 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.payer_token_a.clone()); - account_infos.push(self.payer_token_b.clone()); - account_infos.push(self.payer_pool_lp.clone()); - account_infos.push(self.protocol_token_a_fee.clone()); - account_infos.push(self.protocol_token_b_fee.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.fee_owner.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePermissionlessPool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[]` token_a_mint -/// 3. `[]` token_b_mint -/// 4. `[writable]` a_vault -/// 5. `[writable]` b_vault -/// 6. `[writable]` a_token_vault -/// 7. `[writable]` b_token_vault -/// 8. `[writable]` a_vault_lp_mint -/// 9. `[writable]` b_vault_lp_mint -/// 10. `[writable]` a_vault_lp -/// 11. `[writable]` b_vault_lp -/// 12. `[writable]` payer_token_a -/// 13. `[writable]` payer_token_b -/// 14. `[writable]` payer_pool_lp -/// 15. `[writable]` protocol_token_a_fee -/// 16. `[writable]` protocol_token_b_fee -/// 17. `[writable, signer]` payer -/// 18. `[]` fee_owner -/// 19. `[]` rent -/// 20. `[writable]` mint_metadata -/// 21. `[]` metadata_program -/// 22. `[]` vault_program -/// 23. `[]` token_program -/// 24. `[]` associated_token_program -/// 25. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializePermissionlessPoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePermissionlessPoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePermissionlessPoolCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - token_a_mint: None, - token_b_mint: None, - a_vault: None, - b_vault: None, - a_token_vault: None, - b_token_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_vault_lp: None, - b_vault_lp: None, - payer_token_a: None, - payer_token_b: None, - payer_pool_lp: None, - protocol_token_a_fee: None, - protocol_token_b_fee: None, - payer: None, - fee_owner: None, - rent: None, - mint_metadata: None, - metadata_program: None, - vault_program: None, - token_program: None, - associated_token_program: None, - system_program: None, - curve_type: None, - token_a_amount: None, - token_b_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA address) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_a( - &mut self, - payer_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_a = Some(payer_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_b( - &mut self, - payer_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_b = Some(payer_token_b); - self - } - - #[inline(always)] - pub fn payer_pool_lp( - &mut self, - payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_pool_lp = Some(payer_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn fee_owner(&mut self, fee_owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_owner = Some(fee_owner); - self - } - - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: CurveType) -> &mut Self { - self.instruction.curve_type = Some(curve_type); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.instruction.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.instruction.token_b_amount = Some(token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePermissionlessPoolInstructionArgs { - curve_type: self - .instruction - .curve_type - .clone() - .expect("curve_type is not set"), - token_a_amount: self - .instruction - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .instruction - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - }; - let instruction = InitializePermissionlessPoolCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - payer_token_a: self - .instruction - .payer_token_a - .expect("payer_token_a is not set"), - - payer_token_b: self - .instruction - .payer_token_b - .expect("payer_token_b is not set"), - - payer_pool_lp: self - .instruction - .payer_pool_lp - .expect("payer_pool_lp is not set"), - - protocol_token_a_fee: self - .instruction - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - - protocol_token_b_fee: self - .instruction - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - fee_owner: self.instruction.fee_owner.expect("fee_owner is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePermissionlessPoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_a_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_b_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_type: Option, - token_a_amount: Option, - token_b_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_pool_with_fee_tier.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_pool_with_fee_tier.rs deleted file mode 100644 index 6f184fd9..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/initialize_permissionless_pool_with_fee_tier.rs +++ /dev/null @@ -1,1452 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::CurveType; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePermissionlessPoolWithFeeTier { - /// Pool account (PDA address) - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: solana_pubkey::Pubkey, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: solana_pubkey::Pubkey, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// LP token mint of vault A - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault B - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: solana_pubkey::Pubkey, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: solana_pubkey::Pubkey, - - pub payer_pool_lp: solana_pubkey::Pubkey, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: solana_pubkey::Pubkey, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: solana_pubkey::Pubkey, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: solana_pubkey::Pubkey, - - pub fee_owner: solana_pubkey::Pubkey, - /// Rent account. - pub rent: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, - /// Associated token program. - pub associated_token_program: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializePermissionlessPoolWithFeeTier { - pub fn instruction( - &self, - args: InitializePermissionlessPoolWithFeeTierInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePermissionlessPoolWithFeeTierInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(26 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_a_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_b_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_a_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_b_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = - borsh::to_vec(&InitializePermissionlessPoolWithFeeTierInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionlessPoolWithFeeTierInstructionData { - discriminator: [u8; 8], -} - -impl InitializePermissionlessPoolWithFeeTierInstructionData { - pub fn new() -> Self { - Self { - discriminator: [6, 135, 68, 147, 229, 82, 169, 113], - } - } -} - -impl Default for InitializePermissionlessPoolWithFeeTierInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePermissionlessPoolWithFeeTierInstructionArgs { - pub curve_type: CurveType, - pub trade_fee_bps: u64, - pub token_a_amount: u64, - pub token_b_amount: u64, -} - -/// Instruction builder for `InitializePermissionlessPoolWithFeeTier`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[]` token_a_mint -/// 3. `[]` token_b_mint -/// 4. `[writable]` a_vault -/// 5. `[writable]` b_vault -/// 6. `[writable]` a_token_vault -/// 7. `[writable]` b_token_vault -/// 8. `[writable]` a_vault_lp_mint -/// 9. `[writable]` b_vault_lp_mint -/// 10. `[writable]` a_vault_lp -/// 11. `[writable]` b_vault_lp -/// 12. `[writable]` payer_token_a -/// 13. `[writable]` payer_token_b -/// 14. `[writable]` payer_pool_lp -/// 15. `[writable]` protocol_token_a_fee -/// 16. `[writable]` protocol_token_b_fee -/// 17. `[writable, signer]` payer -/// 18. `[]` fee_owner -/// 19. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 20. `[writable]` mint_metadata -/// 21. `[]` metadata_program -/// 22. `[]` vault_program -/// 23. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 24. `[]` associated_token_program -/// 25. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializePermissionlessPoolWithFeeTierBuilder { - pool: Option, - lp_mint: Option, - token_a_mint: Option, - token_b_mint: Option, - a_vault: Option, - b_vault: Option, - a_token_vault: Option, - b_token_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_vault_lp: Option, - b_vault_lp: Option, - payer_token_a: Option, - payer_token_b: Option, - payer_pool_lp: Option, - protocol_token_a_fee: Option, - protocol_token_b_fee: Option, - payer: Option, - fee_owner: Option, - rent: Option, - mint_metadata: Option, - metadata_program: Option, - vault_program: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - curve_type: Option, - trade_fee_bps: Option, - token_a_amount: Option, - token_b_amount: Option, - __remaining_accounts: Vec, -} - -impl InitializePermissionlessPoolWithFeeTierBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA address) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint(&mut self, token_a_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint(&mut self, token_b_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_a(&mut self, payer_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_a = Some(payer_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_b(&mut self, payer_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token_b = Some(payer_token_b); - self - } - - #[inline(always)] - pub fn payer_pool_lp(&mut self, payer_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.payer_pool_lp = Some(payer_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn fee_owner(&mut self, fee_owner: solana_pubkey::Pubkey) -> &mut Self { - self.fee_owner = Some(fee_owner); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: CurveType) -> &mut Self { - self.curve_type = Some(curve_type); - self - } - - #[inline(always)] - pub fn trade_fee_bps(&mut self, trade_fee_bps: u64) -> &mut Self { - self.trade_fee_bps = Some(trade_fee_bps); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.token_b_amount = Some(token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePermissionlessPoolWithFeeTier { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - token_a_mint: self.token_a_mint.expect("token_a_mint is not set"), - token_b_mint: self.token_b_mint.expect("token_b_mint is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - payer_token_a: self.payer_token_a.expect("payer_token_a is not set"), - payer_token_b: self.payer_token_b.expect("payer_token_b is not set"), - payer_pool_lp: self.payer_pool_lp.expect("payer_pool_lp is not set"), - protocol_token_a_fee: self - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - protocol_token_b_fee: self - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - payer: self.payer.expect("payer is not set"), - fee_owner: self.fee_owner.expect("fee_owner is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializePermissionlessPoolWithFeeTierInstructionArgs { - curve_type: self.curve_type.clone().expect("curve_type is not set"), - trade_fee_bps: self - .trade_fee_bps - .clone() - .expect("trade_fee_bps is not set"), - token_a_amount: self - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_permissionless_pool_with_fee_tier` CPI accounts. -pub struct InitializePermissionlessPoolWithFeeTierCpiAccounts<'a, 'b> { - /// Pool account (PDA address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub fee_owner: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_permissionless_pool_with_fee_tier` CPI instruction. -pub struct InitializePermissionlessPoolWithFeeTierCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA address) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token A mint of the pool. Eg: USDT - pub token_a_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token B mint of the pool. Eg: USDC - pub token_b_mint: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_a: &'b solana_account_info::AccountInfo<'a>, - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - pub payer_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token A. Used to receive trading fee. - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account for token B. Used to receive trading fee. - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub fee_owner: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePermissionlessPoolWithFeeTierInstructionArgs, -} - -impl<'a, 'b> InitializePermissionlessPoolWithFeeTierCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePermissionlessPoolWithFeeTierCpiAccounts<'a, 'b>, - args: InitializePermissionlessPoolWithFeeTierInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - token_a_mint: accounts.token_a_mint, - token_b_mint: accounts.token_b_mint, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - payer_token_a: accounts.payer_token_a, - payer_token_b: accounts.payer_token_b, - payer_pool_lp: accounts.payer_pool_lp, - protocol_token_a_fee: accounts.protocol_token_a_fee, - protocol_token_b_fee: accounts.protocol_token_b_fee, - payer: accounts.payer, - fee_owner: accounts.fee_owner, - rent: accounts.rent, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(26 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_a_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_b_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_a_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_b_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = - borsh::to_vec(&InitializePermissionlessPoolWithFeeTierInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(27 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.token_a_mint.clone()); - account_infos.push(self.token_b_mint.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.payer_token_a.clone()); - account_infos.push(self.payer_token_b.clone()); - account_infos.push(self.payer_pool_lp.clone()); - account_infos.push(self.protocol_token_a_fee.clone()); - account_infos.push(self.protocol_token_b_fee.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.fee_owner.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePermissionlessPoolWithFeeTier` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[]` token_a_mint -/// 3. `[]` token_b_mint -/// 4. `[writable]` a_vault -/// 5. `[writable]` b_vault -/// 6. `[writable]` a_token_vault -/// 7. `[writable]` b_token_vault -/// 8. `[writable]` a_vault_lp_mint -/// 9. `[writable]` b_vault_lp_mint -/// 10. `[writable]` a_vault_lp -/// 11. `[writable]` b_vault_lp -/// 12. `[writable]` payer_token_a -/// 13. `[writable]` payer_token_b -/// 14. `[writable]` payer_pool_lp -/// 15. `[writable]` protocol_token_a_fee -/// 16. `[writable]` protocol_token_b_fee -/// 17. `[writable, signer]` payer -/// 18. `[]` fee_owner -/// 19. `[]` rent -/// 20. `[writable]` mint_metadata -/// 21. `[]` metadata_program -/// 22. `[]` vault_program -/// 23. `[]` token_program -/// 24. `[]` associated_token_program -/// 25. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializePermissionlessPoolWithFeeTierCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePermissionlessPoolWithFeeTierCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new( - InitializePermissionlessPoolWithFeeTierCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - token_a_mint: None, - token_b_mint: None, - a_vault: None, - b_vault: None, - a_token_vault: None, - b_token_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_vault_lp: None, - b_vault_lp: None, - payer_token_a: None, - payer_token_b: None, - payer_pool_lp: None, - protocol_token_a_fee: None, - protocol_token_b_fee: None, - payer: None, - fee_owner: None, - rent: None, - mint_metadata: None, - metadata_program: None, - vault_program: None, - token_program: None, - associated_token_program: None, - system_program: None, - curve_type: None, - trade_fee_bps: None, - token_a_amount: None, - token_b_amount: None, - __remaining_accounts: Vec::new(), - }, - ); - Self { instruction } - } - - /// Pool account (PDA address) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// Token A mint of the pool. Eg: USDT - #[inline(always)] - pub fn token_a_mint( - &mut self, - token_a_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_a_mint = Some(token_a_mint); - self - } - - /// Token B mint of the pool. Eg: USDC - #[inline(always)] - pub fn token_b_mint( - &mut self, - token_b_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_b_mint = Some(token_b_mint); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_a( - &mut self, - payer_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_a = Some(payer_token_a); - self - } - - /// Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity. - #[inline(always)] - pub fn payer_token_b( - &mut self, - payer_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token_b = Some(payer_token_b); - self - } - - #[inline(always)] - pub fn payer_pool_lp( - &mut self, - payer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_pool_lp = Some(payer_pool_lp); - self - } - - /// Protocol fee token account for token A. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - /// Protocol fee token account for token B. Used to receive trading fee. - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - /// Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool. - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn fee_owner(&mut self, fee_owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_owner = Some(fee_owner); - self - } - - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: CurveType) -> &mut Self { - self.instruction.curve_type = Some(curve_type); - self - } - - #[inline(always)] - pub fn trade_fee_bps(&mut self, trade_fee_bps: u64) -> &mut Self { - self.instruction.trade_fee_bps = Some(trade_fee_bps); - self - } - - #[inline(always)] - pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self { - self.instruction.token_a_amount = Some(token_a_amount); - self - } - - #[inline(always)] - pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self { - self.instruction.token_b_amount = Some(token_b_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePermissionlessPoolWithFeeTierInstructionArgs { - curve_type: self - .instruction - .curve_type - .clone() - .expect("curve_type is not set"), - trade_fee_bps: self - .instruction - .trade_fee_bps - .clone() - .expect("trade_fee_bps is not set"), - token_a_amount: self - .instruction - .token_a_amount - .clone() - .expect("token_a_amount is not set"), - token_b_amount: self - .instruction - .token_b_amount - .clone() - .expect("token_b_amount is not set"), - }; - let instruction = InitializePermissionlessPoolWithFeeTierCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - token_a_mint: self - .instruction - .token_a_mint - .expect("token_a_mint is not set"), - - token_b_mint: self - .instruction - .token_b_mint - .expect("token_b_mint is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - payer_token_a: self - .instruction - .payer_token_a - .expect("payer_token_a is not set"), - - payer_token_b: self - .instruction - .payer_token_b - .expect("payer_token_b is not set"), - - payer_pool_lp: self - .instruction - .payer_pool_lp - .expect("payer_pool_lp is not set"), - - protocol_token_a_fee: self - .instruction - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - - protocol_token_b_fee: self - .instruction - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - fee_owner: self.instruction.fee_owner.expect("fee_owner is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePermissionlessPoolWithFeeTierCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_a_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_b_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_a_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_b_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_type: Option, - trade_fee_bps: Option, - token_a_amount: Option, - token_b_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/lock.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/lock.rs deleted file mode 100644 index deb748e9..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/lock.rs +++ /dev/null @@ -1,811 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Lock { - /// Pool account - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// Lock account - pub lock_escrow: solana_pubkey::Pubkey, - /// Can be anyone - pub owner: solana_pubkey::Pubkey, - /// owner lp token account - pub source_tokens: solana_pubkey::Pubkey, - /// Escrow vault - pub escrow_vault: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// LP token mint of vault a - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault b - pub b_vault_lp_mint: solana_pubkey::Pubkey, -} - -impl Lock { - pub fn instruction(&self, args: LockInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: LockInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lock_escrow, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.owner, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.source_tokens, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.escrow_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.b_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.b_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.b_vault_lp_mint, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&LockInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockInstructionData { - discriminator: [u8; 8], -} - -impl LockInstructionData { - pub fn new() -> Self { - Self { - discriminator: [21, 19, 208, 43, 237, 62, 255, 87], - } - } -} - -impl Default for LockInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockInstructionArgs { - pub max_amount: u64, -} - -/// Instruction builder for `Lock`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` lp_mint -/// 2. `[writable]` lock_escrow -/// 3. `[writable, signer]` owner -/// 4. `[writable]` source_tokens -/// 5. `[writable]` escrow_vault -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[]` a_vault -/// 8. `[]` b_vault -/// 9. `[]` a_vault_lp -/// 10. `[]` b_vault_lp -/// 11. `[]` a_vault_lp_mint -/// 12. `[]` b_vault_lp_mint -#[derive(Clone, Debug, Default)] -pub struct LockBuilder { - pool: Option, - lp_mint: Option, - lock_escrow: Option, - owner: Option, - source_tokens: Option, - escrow_vault: Option, - token_program: Option, - a_vault: Option, - b_vault: Option, - a_vault_lp: Option, - b_vault_lp: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - max_amount: Option, - __remaining_accounts: Vec, -} - -impl LockBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// Lock account - #[inline(always)] - pub fn lock_escrow(&mut self, lock_escrow: solana_pubkey::Pubkey) -> &mut Self { - self.lock_escrow = Some(lock_escrow); - self - } - - /// Can be anyone - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// owner lp token account - #[inline(always)] - pub fn source_tokens(&mut self, source_tokens: solana_pubkey::Pubkey) -> &mut Self { - self.source_tokens = Some(source_tokens); - self - } - - /// Escrow vault - #[inline(always)] - pub fn escrow_vault(&mut self, escrow_vault: solana_pubkey::Pubkey) -> &mut Self { - self.escrow_vault = Some(escrow_vault); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - #[inline(always)] - pub fn max_amount(&mut self, max_amount: u64) -> &mut Self { - self.max_amount = Some(max_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Lock { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - lock_escrow: self.lock_escrow.expect("lock_escrow is not set"), - owner: self.owner.expect("owner is not set"), - source_tokens: self.source_tokens.expect("source_tokens is not set"), - escrow_vault: self.escrow_vault.expect("escrow_vault is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - }; - let args = LockInstructionArgs { - max_amount: self.max_amount.clone().expect("max_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `lock` CPI accounts. -pub struct LockCpiAccounts<'a, 'b> { - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Lock account - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - /// Can be anyone - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// owner lp token account - pub source_tokens: &'b solana_account_info::AccountInfo<'a>, - /// Escrow vault - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, -} - -/// `lock` CPI instruction. -pub struct LockCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Lock account - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - /// Can be anyone - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// owner lp token account - pub source_tokens: &'b solana_account_info::AccountInfo<'a>, - /// Escrow vault - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: LockInstructionArgs, -} - -impl<'a, 'b> LockCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: LockCpiAccounts<'a, 'b>, - args: LockInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - lock_escrow: accounts.lock_escrow, - owner: accounts.owner, - source_tokens: accounts.source_tokens, - escrow_vault: accounts.escrow_vault, - token_program: accounts.token_program, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lock_escrow.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.owner.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.source_tokens.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.escrow_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.b_vault_lp_mint.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&LockInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.lock_escrow.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.source_tokens.clone()); - account_infos.push(self.escrow_vault.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Lock` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` lp_mint -/// 2. `[writable]` lock_escrow -/// 3. `[writable, signer]` owner -/// 4. `[writable]` source_tokens -/// 5. `[writable]` escrow_vault -/// 6. `[]` token_program -/// 7. `[]` a_vault -/// 8. `[]` b_vault -/// 9. `[]` a_vault_lp -/// 10. `[]` b_vault_lp -/// 11. `[]` a_vault_lp_mint -/// 12. `[]` b_vault_lp_mint -#[derive(Clone, Debug)] -pub struct LockCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> LockCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(LockCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - lock_escrow: None, - owner: None, - source_tokens: None, - escrow_vault: None, - token_program: None, - a_vault: None, - b_vault: None, - a_vault_lp: None, - b_vault_lp: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - max_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// Lock account - #[inline(always)] - pub fn lock_escrow( - &mut self, - lock_escrow: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_escrow = Some(lock_escrow); - self - } - - /// Can be anyone - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// owner lp token account - #[inline(always)] - pub fn source_tokens( - &mut self, - source_tokens: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.source_tokens = Some(source_tokens); - self - } - - /// Escrow vault - #[inline(always)] - pub fn escrow_vault( - &mut self, - escrow_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.escrow_vault = Some(escrow_vault); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - #[inline(always)] - pub fn max_amount(&mut self, max_amount: u64) -> &mut Self { - self.instruction.max_amount = Some(max_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = LockInstructionArgs { - max_amount: self - .instruction - .max_amount - .clone() - .expect("max_amount is not set"), - }; - let instruction = LockCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - lock_escrow: self - .instruction - .lock_escrow - .expect("lock_escrow is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - source_tokens: self - .instruction - .source_tokens - .expect("source_tokens is not set"), - - escrow_vault: self - .instruction - .escrow_vault - .expect("escrow_vault is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct LockCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_escrow: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - source_tokens: Option<&'b solana_account_info::AccountInfo<'a>>, - escrow_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - max_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/mod.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index c42aac96..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,47 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#add_balance_liquidity; -pub(crate) mod r#add_imbalance_liquidity; -pub(crate) mod r#bootstrap_liquidity; -pub(crate) mod r#claim_fee; -pub(crate) mod r#close_config; -pub(crate) mod r#create_config; -pub(crate) mod r#create_lock_escrow; -pub(crate) mod r#create_mint_metadata; -pub(crate) mod r#enable_or_disable_pool; -pub(crate) mod r#get_pool_info; -pub(crate) mod r#initialize_customizable_permissionless_constant_product_pool; -pub(crate) mod r#initialize_permissioned_pool; -pub(crate) mod r#initialize_permissionless_constant_product_pool_with_config; -pub(crate) mod r#initialize_permissionless_constant_product_pool_with_config2; -pub(crate) mod r#initialize_permissionless_pool; -pub(crate) mod r#initialize_permissionless_pool_with_fee_tier; -pub(crate) mod r#lock; -pub(crate) mod r#override_curve_param; -pub(crate) mod r#partner_claim_fee; -pub(crate) mod r#remove_balance_liquidity; -pub(crate) mod r#remove_liquidity_single_side; -pub(crate) mod r#set_pool_fees; -pub(crate) mod r#set_whitelisted_vault; -pub(crate) mod r#swap; -pub(crate) mod r#update_activation_point; -pub(crate) mod r#withdraw_protocol_fees; - -pub use self::{ - r#add_balance_liquidity::*, r#add_imbalance_liquidity::*, r#bootstrap_liquidity::*, - r#claim_fee::*, r#close_config::*, r#create_config::*, r#create_lock_escrow::*, - r#create_mint_metadata::*, r#enable_or_disable_pool::*, r#get_pool_info::*, - r#initialize_customizable_permissionless_constant_product_pool::*, - r#initialize_permissioned_pool::*, - r#initialize_permissionless_constant_product_pool_with_config::*, - r#initialize_permissionless_constant_product_pool_with_config2::*, - r#initialize_permissionless_pool::*, r#initialize_permissionless_pool_with_fee_tier::*, - r#lock::*, r#override_curve_param::*, r#partner_claim_fee::*, r#remove_balance_liquidity::*, - r#remove_liquidity_single_side::*, r#set_pool_fees::*, r#set_whitelisted_vault::*, r#swap::*, - r#update_activation_point::*, r#withdraw_protocol_fees::*, -}; diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/override_curve_param.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/override_curve_param.rs deleted file mode 100644 index 86734a16..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/override_curve_param.rs +++ /dev/null @@ -1,358 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::CurveType; - -/// Accounts. -#[derive(Debug)] -pub struct OverrideCurveParam { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// Admin account. - pub admin: solana_pubkey::Pubkey, -} - -impl OverrideCurveParam { - pub fn instruction( - &self, - args: OverrideCurveParamInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: OverrideCurveParamInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&OverrideCurveParamInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OverrideCurveParamInstructionData { - discriminator: [u8; 8], -} - -impl OverrideCurveParamInstructionData { - pub fn new() -> Self { - Self { - discriminator: [98, 86, 204, 51, 94, 71, 69, 187], - } - } -} - -impl Default for OverrideCurveParamInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OverrideCurveParamInstructionArgs { - pub curve_type: CurveType, -} - -/// Instruction builder for `OverrideCurveParam`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct OverrideCurveParamBuilder { - pool: Option, - admin: Option, - curve_type: Option, - __remaining_accounts: Vec, -} - -impl OverrideCurveParamBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// Admin account. - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: CurveType) -> &mut Self { - self.curve_type = Some(curve_type); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = OverrideCurveParam { - pool: self.pool.expect("pool is not set"), - admin: self.admin.expect("admin is not set"), - }; - let args = OverrideCurveParamInstructionArgs { - curve_type: self.curve_type.clone().expect("curve_type is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `override_curve_param` CPI accounts. -pub struct OverrideCurveParamCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `override_curve_param` CPI instruction. -pub struct OverrideCurveParamCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: OverrideCurveParamInstructionArgs, -} - -impl<'a, 'b> OverrideCurveParamCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: OverrideCurveParamCpiAccounts<'a, 'b>, - args: OverrideCurveParamInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - admin: accounts.admin, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&OverrideCurveParamInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `OverrideCurveParam` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` admin -#[derive(Clone, Debug)] -pub struct OverrideCurveParamCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> OverrideCurveParamCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(OverrideCurveParamCpiBuilderInstruction { - __program: program, - pool: None, - admin: None, - curve_type: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// Admin account. - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: CurveType) -> &mut Self { - self.instruction.curve_type = Some(curve_type); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = OverrideCurveParamInstructionArgs { - curve_type: self - .instruction - .curve_type - .clone() - .expect("curve_type is not set"), - }; - let instruction = OverrideCurveParamCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct OverrideCurveParamCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_type: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/partner_claim_fee.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/partner_claim_fee.rs deleted file mode 100644 index 9c5e4713..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/partner_claim_fee.rs +++ /dev/null @@ -1,647 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct PartnerClaimFee { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - - pub a_vault_lp: solana_pubkey::Pubkey, - - pub protocol_token_a_fee: solana_pubkey::Pubkey, - - pub protocol_token_b_fee: solana_pubkey::Pubkey, - - pub partner_token_a: solana_pubkey::Pubkey, - - pub partner_token_b: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub partner_authority: solana_pubkey::Pubkey, -} - -impl PartnerClaimFee { - pub fn instruction( - &self, - args: PartnerClaimFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: PartnerClaimFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_a_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_b_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.partner_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.partner_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.partner_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&PartnerClaimFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PartnerClaimFeeInstructionData { - discriminator: [u8; 8], -} - -impl PartnerClaimFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [57, 53, 176, 30, 123, 70, 52, 64], - } - } -} - -impl Default for PartnerClaimFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PartnerClaimFeeInstructionArgs { - pub max_amount_a: u64, - pub max_amount_b: u64, -} - -/// Instruction builder for `PartnerClaimFee`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` a_vault_lp -/// 2. `[writable]` protocol_token_a_fee -/// 3. `[writable]` protocol_token_b_fee -/// 4. `[writable]` partner_token_a -/// 5. `[writable]` partner_token_b -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[signer]` partner_authority -#[derive(Clone, Debug, Default)] -pub struct PartnerClaimFeeBuilder { - pool: Option, - a_vault_lp: Option, - protocol_token_a_fee: Option, - protocol_token_b_fee: Option, - partner_token_a: Option, - partner_token_b: Option, - token_program: Option, - partner_authority: Option, - max_amount_a: Option, - max_amount_b: Option, - __remaining_accounts: Vec, -} - -impl PartnerClaimFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - #[inline(always)] - pub fn partner_token_a(&mut self, partner_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.partner_token_a = Some(partner_token_a); - self - } - - #[inline(always)] - pub fn partner_token_b(&mut self, partner_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.partner_token_b = Some(partner_token_b); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn partner_authority(&mut self, partner_authority: solana_pubkey::Pubkey) -> &mut Self { - self.partner_authority = Some(partner_authority); - self - } - - #[inline(always)] - pub fn max_amount_a(&mut self, max_amount_a: u64) -> &mut Self { - self.max_amount_a = Some(max_amount_a); - self - } - - #[inline(always)] - pub fn max_amount_b(&mut self, max_amount_b: u64) -> &mut Self { - self.max_amount_b = Some(max_amount_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = PartnerClaimFee { - pool: self.pool.expect("pool is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - protocol_token_a_fee: self - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - protocol_token_b_fee: self - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - partner_token_a: self.partner_token_a.expect("partner_token_a is not set"), - partner_token_b: self.partner_token_b.expect("partner_token_b is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - partner_authority: self - .partner_authority - .expect("partner_authority is not set"), - }; - let args = PartnerClaimFeeInstructionArgs { - max_amount_a: self.max_amount_a.clone().expect("max_amount_a is not set"), - max_amount_b: self.max_amount_b.clone().expect("max_amount_b is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `partner_claim_fee` CPI accounts. -pub struct PartnerClaimFeeCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - - pub partner_token_a: &'b solana_account_info::AccountInfo<'a>, - - pub partner_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub partner_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `partner_claim_fee` CPI instruction. -pub struct PartnerClaimFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - - pub partner_token_a: &'b solana_account_info::AccountInfo<'a>, - - pub partner_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub partner_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: PartnerClaimFeeInstructionArgs, -} - -impl<'a, 'b> PartnerClaimFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: PartnerClaimFeeCpiAccounts<'a, 'b>, - args: PartnerClaimFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - a_vault_lp: accounts.a_vault_lp, - protocol_token_a_fee: accounts.protocol_token_a_fee, - protocol_token_b_fee: accounts.protocol_token_b_fee, - partner_token_a: accounts.partner_token_a, - partner_token_b: accounts.partner_token_b, - token_program: accounts.token_program, - partner_authority: accounts.partner_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_a_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_b_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.partner_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.partner_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.partner_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&PartnerClaimFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.protocol_token_a_fee.clone()); - account_infos.push(self.protocol_token_b_fee.clone()); - account_infos.push(self.partner_token_a.clone()); - account_infos.push(self.partner_token_b.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.partner_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `PartnerClaimFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` a_vault_lp -/// 2. `[writable]` protocol_token_a_fee -/// 3. `[writable]` protocol_token_b_fee -/// 4. `[writable]` partner_token_a -/// 5. `[writable]` partner_token_b -/// 6. `[]` token_program -/// 7. `[signer]` partner_authority -#[derive(Clone, Debug)] -pub struct PartnerClaimFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> PartnerClaimFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(PartnerClaimFeeCpiBuilderInstruction { - __program: program, - pool: None, - a_vault_lp: None, - protocol_token_a_fee: None, - protocol_token_b_fee: None, - partner_token_a: None, - partner_token_b: None, - token_program: None, - partner_authority: None, - max_amount_a: None, - max_amount_b: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - #[inline(always)] - pub fn partner_token_a( - &mut self, - partner_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.partner_token_a = Some(partner_token_a); - self - } - - #[inline(always)] - pub fn partner_token_b( - &mut self, - partner_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.partner_token_b = Some(partner_token_b); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn partner_authority( - &mut self, - partner_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.partner_authority = Some(partner_authority); - self - } - - #[inline(always)] - pub fn max_amount_a(&mut self, max_amount_a: u64) -> &mut Self { - self.instruction.max_amount_a = Some(max_amount_a); - self - } - - #[inline(always)] - pub fn max_amount_b(&mut self, max_amount_b: u64) -> &mut Self { - self.instruction.max_amount_b = Some(max_amount_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = PartnerClaimFeeInstructionArgs { - max_amount_a: self - .instruction - .max_amount_a - .clone() - .expect("max_amount_a is not set"), - max_amount_b: self - .instruction - .max_amount_b - .clone() - .expect("max_amount_b is not set"), - }; - let instruction = PartnerClaimFeeCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - protocol_token_a_fee: self - .instruction - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - - protocol_token_b_fee: self - .instruction - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - - partner_token_a: self - .instruction - .partner_token_a - .expect("partner_token_a is not set"), - - partner_token_b: self - .instruction - .partner_token_b - .expect("partner_token_b is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - partner_authority: self - .instruction - .partner_authority - .expect("partner_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct PartnerClaimFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_a_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_b_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - partner_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - partner_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - partner_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - max_amount_a: Option, - max_amount_b: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/remove_balance_liquidity.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/remove_balance_liquidity.rs deleted file mode 100644 index d90b3435..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/remove_balance_liquidity.rs +++ /dev/null @@ -1,989 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveBalanceLiquidity { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// LP token mint of vault a - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault b - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: solana_pubkey::Pubkey, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: solana_pubkey::Pubkey, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: solana_pubkey::Pubkey, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, -} - -impl RemoveBalanceLiquidity { - pub fn instruction( - &self, - args: RemoveBalanceLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemoveBalanceLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_a_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_b_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RemoveBalanceLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveBalanceLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl RemoveBalanceLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [133, 109, 44, 179, 56, 238, 114, 33], - } - } -} - -impl Default for RemoveBalanceLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveBalanceLiquidityInstructionArgs { - pub pool_token_amount: u64, - pub minimum_a_token_out: u64, - pub minimum_b_token_out: u64, -} - -/// Instruction builder for `RemoveBalanceLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` user_pool_lp -/// 3. `[writable]` a_vault_lp -/// 4. `[writable]` b_vault_lp -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_token_vault -/// 10. `[writable]` b_token_vault -/// 11. `[writable]` user_a_token -/// 12. `[writable]` user_b_token -/// 13. `[signer]` user -/// 14. `[]` vault_program -/// 15. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct RemoveBalanceLiquidityBuilder { - pool: Option, - lp_mint: Option, - user_pool_lp: Option, - a_vault_lp: Option, - b_vault_lp: Option, - a_vault: Option, - b_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_token_vault: Option, - b_token_vault: Option, - user_a_token: Option, - user_b_token: Option, - user: Option, - vault_program: Option, - token_program: Option, - pool_token_amount: Option, - minimum_a_token_out: Option, - minimum_b_token_out: Option, - __remaining_accounts: Vec, -} - -impl RemoveBalanceLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - #[inline(always)] - pub fn user_pool_lp(&mut self, user_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.user_pool_lp = Some(user_pool_lp); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_a_token(&mut self, user_a_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_a_token = Some(user_a_token); - self - } - - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_b_token(&mut self, user_b_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_b_token = Some(user_b_token); - self - } - - /// User account. Must be owner of user_a_token, and user_b_token. - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn pool_token_amount(&mut self, pool_token_amount: u64) -> &mut Self { - self.pool_token_amount = Some(pool_token_amount); - self - } - - #[inline(always)] - pub fn minimum_a_token_out(&mut self, minimum_a_token_out: u64) -> &mut Self { - self.minimum_a_token_out = Some(minimum_a_token_out); - self - } - - #[inline(always)] - pub fn minimum_b_token_out(&mut self, minimum_b_token_out: u64) -> &mut Self { - self.minimum_b_token_out = Some(minimum_b_token_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveBalanceLiquidity { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_pool_lp: self.user_pool_lp.expect("user_pool_lp is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - user_a_token: self.user_a_token.expect("user_a_token is not set"), - user_b_token: self.user_b_token.expect("user_b_token is not set"), - user: self.user.expect("user is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = RemoveBalanceLiquidityInstructionArgs { - pool_token_amount: self - .pool_token_amount - .clone() - .expect("pool_token_amount is not set"), - minimum_a_token_out: self - .minimum_a_token_out - .clone() - .expect("minimum_a_token_out is not set"), - minimum_b_token_out: self - .minimum_b_token_out - .clone() - .expect("minimum_b_token_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_balance_liquidity` CPI accounts. -pub struct RemoveBalanceLiquidityCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: &'b solana_account_info::AccountInfo<'a>, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_balance_liquidity` CPI instruction. -pub struct RemoveBalanceLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - pub user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_a_token: &'b solana_account_info::AccountInfo<'a>, - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - pub user_b_token: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of user_a_token, and user_b_token. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemoveBalanceLiquidityInstructionArgs, -} - -impl<'a, 'b> RemoveBalanceLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveBalanceLiquidityCpiAccounts<'a, 'b>, - args: RemoveBalanceLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - user_pool_lp: accounts.user_pool_lp, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - user_a_token: accounts.user_a_token, - user_b_token: accounts.user_b_token, - user: accounts.user, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_a_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_b_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RemoveBalanceLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_pool_lp.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.user_a_token.clone()); - account_infos.push(self.user_b_token.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveBalanceLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` user_pool_lp -/// 3. `[writable]` a_vault_lp -/// 4. `[writable]` b_vault_lp -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_token_vault -/// 10. `[writable]` b_token_vault -/// 11. `[writable]` user_a_token -/// 12. `[writable]` user_b_token -/// 13. `[signer]` user -/// 14. `[]` vault_program -/// 15. `[]` token_program -#[derive(Clone, Debug)] -pub struct RemoveBalanceLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveBalanceLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveBalanceLiquidityCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - user_pool_lp: None, - a_vault_lp: None, - b_vault_lp: None, - a_vault: None, - b_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_token_vault: None, - b_token_vault: None, - user_a_token: None, - user_b_token: None, - user: None, - vault_program: None, - token_program: None, - pool_token_amount: None, - minimum_a_token_out: None, - minimum_b_token_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// user pool lp token account. lp will be burned from this account upon success liquidity removal. - #[inline(always)] - pub fn user_pool_lp( - &mut self, - user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_pool_lp = Some(user_pool_lp); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_a_token( - &mut self, - user_a_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_a_token = Some(user_a_token); - self - } - - /// User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account. - #[inline(always)] - pub fn user_b_token( - &mut self, - user_b_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_b_token = Some(user_b_token); - self - } - - /// User account. Must be owner of user_a_token, and user_b_token. - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn pool_token_amount(&mut self, pool_token_amount: u64) -> &mut Self { - self.instruction.pool_token_amount = Some(pool_token_amount); - self - } - - #[inline(always)] - pub fn minimum_a_token_out(&mut self, minimum_a_token_out: u64) -> &mut Self { - self.instruction.minimum_a_token_out = Some(minimum_a_token_out); - self - } - - #[inline(always)] - pub fn minimum_b_token_out(&mut self, minimum_b_token_out: u64) -> &mut Self { - self.instruction.minimum_b_token_out = Some(minimum_b_token_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RemoveBalanceLiquidityInstructionArgs { - pool_token_amount: self - .instruction - .pool_token_amount - .clone() - .expect("pool_token_amount is not set"), - minimum_a_token_out: self - .instruction - .minimum_a_token_out - .clone() - .expect("minimum_a_token_out is not set"), - minimum_b_token_out: self - .instruction - .minimum_b_token_out - .clone() - .expect("minimum_b_token_out is not set"), - }; - let instruction = RemoveBalanceLiquidityCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_pool_lp: self - .instruction - .user_pool_lp - .expect("user_pool_lp is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - user_a_token: self - .instruction - .user_a_token - .expect("user_a_token is not set"), - - user_b_token: self - .instruction - .user_b_token - .expect("user_b_token is not set"), - - user: self.instruction.user.expect("user is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveBalanceLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - user_a_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_b_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_token_amount: Option, - minimum_a_token_out: Option, - minimum_b_token_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/remove_liquidity_single_side.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/remove_liquidity_single_side.rs deleted file mode 100644 index 3cf089f3..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/remove_liquidity_single_side.rs +++ /dev/null @@ -1,925 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveLiquiditySingleSide { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// LP token mint of the pool - pub lp_mint: solana_pubkey::Pubkey, - /// User pool lp token account. LP will be burned from this account upon success liquidity removal. - pub user_pool_lp: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// LP token mint of vault A - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token mint of vault B - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// User token account to receive token upon success liquidity removal. - pub user_destination_token: solana_pubkey::Pubkey, - /// User account. Must be owner of the user_pool_lp account. - pub user: solana_pubkey::Pubkey, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, -} - -impl RemoveLiquiditySingleSide { - pub fn instruction( - &self, - args: RemoveLiquiditySingleSideInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemoveLiquiditySingleSideInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_destination_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RemoveLiquiditySingleSideInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquiditySingleSideInstructionData { - discriminator: [u8; 8], -} - -impl RemoveLiquiditySingleSideInstructionData { - pub fn new() -> Self { - Self { - discriminator: [84, 84, 177, 66, 254, 185, 10, 251], - } - } -} - -impl Default for RemoveLiquiditySingleSideInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveLiquiditySingleSideInstructionArgs { - pub pool_token_amount: u64, - pub minimum_out_amount: u64, -} - -/// Instruction builder for `RemoveLiquiditySingleSide`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` user_pool_lp -/// 3. `[writable]` a_vault_lp -/// 4. `[writable]` b_vault_lp -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_token_vault -/// 10. `[writable]` b_token_vault -/// 11. `[writable]` user_destination_token -/// 12. `[signer]` user -/// 13. `[]` vault_program -/// 14. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct RemoveLiquiditySingleSideBuilder { - pool: Option, - lp_mint: Option, - user_pool_lp: Option, - a_vault_lp: Option, - b_vault_lp: Option, - a_vault: Option, - b_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_token_vault: Option, - b_token_vault: Option, - user_destination_token: Option, - user: Option, - vault_program: Option, - token_program: Option, - pool_token_amount: Option, - minimum_out_amount: Option, - __remaining_accounts: Vec, -} - -impl RemoveLiquiditySingleSideBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// User pool lp token account. LP will be burned from this account upon success liquidity removal. - #[inline(always)] - pub fn user_pool_lp(&mut self, user_pool_lp: solana_pubkey::Pubkey) -> &mut Self { - self.user_pool_lp = Some(user_pool_lp); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// User token account to receive token upon success liquidity removal. - #[inline(always)] - pub fn user_destination_token( - &mut self, - user_destination_token: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_destination_token = Some(user_destination_token); - self - } - - /// User account. Must be owner of the user_pool_lp account. - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn pool_token_amount(&mut self, pool_token_amount: u64) -> &mut Self { - self.pool_token_amount = Some(pool_token_amount); - self - } - - #[inline(always)] - pub fn minimum_out_amount(&mut self, minimum_out_amount: u64) -> &mut Self { - self.minimum_out_amount = Some(minimum_out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveLiquiditySingleSide { - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_pool_lp: self.user_pool_lp.expect("user_pool_lp is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - user_destination_token: self - .user_destination_token - .expect("user_destination_token is not set"), - user: self.user.expect("user is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = RemoveLiquiditySingleSideInstructionArgs { - pool_token_amount: self - .pool_token_amount - .clone() - .expect("pool_token_amount is not set"), - minimum_out_amount: self - .minimum_out_amount - .clone() - .expect("minimum_out_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_liquidity_single_side` CPI accounts. -pub struct RemoveLiquiditySingleSideCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// User pool lp token account. LP will be burned from this account upon success liquidity removal. - pub user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// User token account to receive token upon success liquidity removal. - pub user_destination_token: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of the user_pool_lp account. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_liquidity_single_side` CPI instruction. -pub struct RemoveLiquiditySingleSideCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of the pool - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// User pool lp token account. LP will be burned from this account upon success liquidity removal. - pub user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault A - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token mint of vault B - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// User token account to receive token upon success liquidity removal. - pub user_destination_token: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of the user_pool_lp account. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemoveLiquiditySingleSideInstructionArgs, -} - -impl<'a, 'b> RemoveLiquiditySingleSideCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveLiquiditySingleSideCpiAccounts<'a, 'b>, - args: RemoveLiquiditySingleSideInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - user_pool_lp: accounts.user_pool_lp, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - user_destination_token: accounts.user_destination_token, - user: accounts.user, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_destination_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RemoveLiquiditySingleSideInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_pool_lp.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.user_destination_token.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveLiquiditySingleSide` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` lp_mint -/// 2. `[writable]` user_pool_lp -/// 3. `[writable]` a_vault_lp -/// 4. `[writable]` b_vault_lp -/// 5. `[writable]` a_vault -/// 6. `[writable]` b_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_token_vault -/// 10. `[writable]` b_token_vault -/// 11. `[writable]` user_destination_token -/// 12. `[signer]` user -/// 13. `[]` vault_program -/// 14. `[]` token_program -#[derive(Clone, Debug)] -pub struct RemoveLiquiditySingleSideCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveLiquiditySingleSideCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveLiquiditySingleSideCpiBuilderInstruction { - __program: program, - pool: None, - lp_mint: None, - user_pool_lp: None, - a_vault_lp: None, - b_vault_lp: None, - a_vault: None, - b_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_token_vault: None, - b_token_vault: None, - user_destination_token: None, - user: None, - vault_program: None, - token_program: None, - pool_token_amount: None, - minimum_out_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// LP token mint of the pool - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// User pool lp token account. LP will be burned from this account upon success liquidity removal. - #[inline(always)] - pub fn user_pool_lp( - &mut self, - user_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_pool_lp = Some(user_pool_lp); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// LP token mint of vault A - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// LP token mint of vault B - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// User token account to receive token upon success liquidity removal. - #[inline(always)] - pub fn user_destination_token( - &mut self, - user_destination_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_destination_token = Some(user_destination_token); - self - } - - /// User account. Must be owner of the user_pool_lp account. - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - /// Vault program. The pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn pool_token_amount(&mut self, pool_token_amount: u64) -> &mut Self { - self.instruction.pool_token_amount = Some(pool_token_amount); - self - } - - #[inline(always)] - pub fn minimum_out_amount(&mut self, minimum_out_amount: u64) -> &mut Self { - self.instruction.minimum_out_amount = Some(minimum_out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RemoveLiquiditySingleSideInstructionArgs { - pool_token_amount: self - .instruction - .pool_token_amount - .clone() - .expect("pool_token_amount is not set"), - minimum_out_amount: self - .instruction - .minimum_out_amount - .clone() - .expect("minimum_out_amount is not set"), - }; - let instruction = RemoveLiquiditySingleSideCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_pool_lp: self - .instruction - .user_pool_lp - .expect("user_pool_lp is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - user_destination_token: self - .instruction - .user_destination_token - .expect("user_destination_token is not set"), - - user: self.instruction.user.expect("user is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveLiquiditySingleSideCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - user_destination_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_token_amount: Option, - minimum_out_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/set_pool_fees.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/set_pool_fees.rs deleted file mode 100644 index 8e30ee8e..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/set_pool_fees.rs +++ /dev/null @@ -1,383 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::PoolFees; - -/// Accounts. -#[derive(Debug)] -pub struct SetPoolFees { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// Fee operator account - pub fee_operator: solana_pubkey::Pubkey, -} - -impl SetPoolFees { - pub fn instruction(&self, args: SetPoolFeesInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetPoolFeesInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_operator, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetPoolFeesInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPoolFeesInstructionData { - discriminator: [u8; 8], -} - -impl SetPoolFeesInstructionData { - pub fn new() -> Self { - Self { - discriminator: [102, 44, 158, 54, 205, 37, 126, 78], - } - } -} - -impl Default for SetPoolFeesInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPoolFeesInstructionArgs { - pub fees: PoolFees, - pub new_partner_fee_numerator: u64, -} - -/// Instruction builder for `SetPoolFees`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` fee_operator -#[derive(Clone, Debug, Default)] -pub struct SetPoolFeesBuilder { - pool: Option, - fee_operator: Option, - fees: Option, - new_partner_fee_numerator: Option, - __remaining_accounts: Vec, -} - -impl SetPoolFeesBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// Fee operator account - #[inline(always)] - pub fn fee_operator(&mut self, fee_operator: solana_pubkey::Pubkey) -> &mut Self { - self.fee_operator = Some(fee_operator); - self - } - - #[inline(always)] - pub fn fees(&mut self, fees: PoolFees) -> &mut Self { - self.fees = Some(fees); - self - } - - #[inline(always)] - pub fn new_partner_fee_numerator(&mut self, new_partner_fee_numerator: u64) -> &mut Self { - self.new_partner_fee_numerator = Some(new_partner_fee_numerator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetPoolFees { - pool: self.pool.expect("pool is not set"), - fee_operator: self.fee_operator.expect("fee_operator is not set"), - }; - let args = SetPoolFeesInstructionArgs { - fees: self.fees.clone().expect("fees is not set"), - new_partner_fee_numerator: self - .new_partner_fee_numerator - .clone() - .expect("new_partner_fee_numerator is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_pool_fees` CPI accounts. -pub struct SetPoolFeesCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Fee operator account - pub fee_operator: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_pool_fees` CPI instruction. -pub struct SetPoolFeesCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Fee operator account - pub fee_operator: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetPoolFeesInstructionArgs, -} - -impl<'a, 'b> SetPoolFeesCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetPoolFeesCpiAccounts<'a, 'b>, - args: SetPoolFeesInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - fee_operator: accounts.fee_operator, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_operator.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetPoolFeesInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.fee_operator.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetPoolFees` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` fee_operator -#[derive(Clone, Debug)] -pub struct SetPoolFeesCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetPoolFeesCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetPoolFeesCpiBuilderInstruction { - __program: program, - pool: None, - fee_operator: None, - fees: None, - new_partner_fee_numerator: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// Fee operator account - #[inline(always)] - pub fn fee_operator( - &mut self, - fee_operator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_operator = Some(fee_operator); - self - } - - #[inline(always)] - pub fn fees(&mut self, fees: PoolFees) -> &mut Self { - self.instruction.fees = Some(fees); - self - } - - #[inline(always)] - pub fn new_partner_fee_numerator(&mut self, new_partner_fee_numerator: u64) -> &mut Self { - self.instruction.new_partner_fee_numerator = Some(new_partner_fee_numerator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetPoolFeesInstructionArgs { - fees: self.instruction.fees.clone().expect("fees is not set"), - new_partner_fee_numerator: self - .instruction - .new_partner_fee_numerator - .clone() - .expect("new_partner_fee_numerator is not set"), - }; - let instruction = SetPoolFeesCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - fee_operator: self - .instruction - .fee_operator - .expect("fee_operator is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetPoolFeesCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_operator: Option<&'b solana_account_info::AccountInfo<'a>>, - fees: Option, - new_partner_fee_numerator: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/set_whitelisted_vault.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/set_whitelisted_vault.rs deleted file mode 100644 index f7a9705d..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/set_whitelisted_vault.rs +++ /dev/null @@ -1,354 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct SetWhitelistedVault { - pub pool: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, -} - -impl SetWhitelistedVault { - pub fn instruction( - &self, - args: SetWhitelistedVaultInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetWhitelistedVaultInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetWhitelistedVaultInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetWhitelistedVaultInstructionData { - discriminator: [u8; 8], -} - -impl SetWhitelistedVaultInstructionData { - pub fn new() -> Self { - Self { - discriminator: [12, 148, 94, 42, 55, 57, 83, 247], - } - } -} - -impl Default for SetWhitelistedVaultInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetWhitelistedVaultInstructionArgs { - pub whitelisted_vault: Pubkey, -} - -/// Instruction builder for `SetWhitelistedVault`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct SetWhitelistedVaultBuilder { - pool: Option, - admin: Option, - whitelisted_vault: Option, - __remaining_accounts: Vec, -} - -impl SetWhitelistedVaultBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn whitelisted_vault(&mut self, whitelisted_vault: Pubkey) -> &mut Self { - self.whitelisted_vault = Some(whitelisted_vault); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetWhitelistedVault { - pool: self.pool.expect("pool is not set"), - admin: self.admin.expect("admin is not set"), - }; - let args = SetWhitelistedVaultInstructionArgs { - whitelisted_vault: self - .whitelisted_vault - .clone() - .expect("whitelisted_vault is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_whitelisted_vault` CPI accounts. -pub struct SetWhitelistedVaultCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_whitelisted_vault` CPI instruction. -pub struct SetWhitelistedVaultCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetWhitelistedVaultInstructionArgs, -} - -impl<'a, 'b> SetWhitelistedVaultCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetWhitelistedVaultCpiAccounts<'a, 'b>, - args: SetWhitelistedVaultInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - admin: accounts.admin, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetWhitelistedVaultInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetWhitelistedVault` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` admin -#[derive(Clone, Debug)] -pub struct SetWhitelistedVaultCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetWhitelistedVaultCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetWhitelistedVaultCpiBuilderInstruction { - __program: program, - pool: None, - admin: None, - whitelisted_vault: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn whitelisted_vault(&mut self, whitelisted_vault: Pubkey) -> &mut Self { - self.instruction.whitelisted_vault = Some(whitelisted_vault); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetWhitelistedVaultInstructionArgs { - whitelisted_vault: self - .instruction - .whitelisted_vault - .clone() - .expect("whitelisted_vault is not set"), - }; - let instruction = SetWhitelistedVaultCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetWhitelistedVaultCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - whitelisted_vault: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/swap.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/swap.rs deleted file mode 100644 index f5c7fad2..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/swap.rs +++ /dev/null @@ -1,932 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Swap { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// User token account. Token from this account will be transfer into the vault by the pool in exchange for another token of the pool. - pub user_source_token: solana_pubkey::Pubkey, - /// User token account. The exchanged token will be transfer into this account from the pool. - pub user_destination_token: solana_pubkey::Pubkey, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: solana_pubkey::Pubkey, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: solana_pubkey::Pubkey, - /// Token vault account of vault A - pub a_token_vault: solana_pubkey::Pubkey, - /// Token vault account of vault B - pub b_token_vault: solana_pubkey::Pubkey, - /// Lp token mint of vault a - pub a_vault_lp_mint: solana_pubkey::Pubkey, - /// Lp token mint of vault b - pub b_vault_lp_mint: solana_pubkey::Pubkey, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: solana_pubkey::Pubkey, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: solana_pubkey::Pubkey, - /// Protocol fee token account. Used to receive trading fee. It's mint field must matched with user_source_token mint field. - pub protocol_token_fee: solana_pubkey::Pubkey, - /// User account. Must be owner of user_source_token. - pub user: solana_pubkey::Pubkey, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, -} - -impl Swap { - pub fn instruction(&self, args: SwapInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_source_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_destination_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.a_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.a_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.b_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.a_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new(self.b_vault_lp, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionData { - discriminator: [u8; 8], -} - -impl SwapInstructionData { - pub fn new() -> Self { - Self { - discriminator: [248, 198, 158, 145, 225, 117, 135, 200], - } - } -} - -impl Default for SwapInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionArgs { - pub in_amount: u64, - pub minimum_out_amount: u64, -} - -/// Instruction builder for `Swap`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` user_source_token -/// 2. `[writable]` user_destination_token -/// 3. `[writable]` a_vault -/// 4. `[writable]` b_vault -/// 5. `[writable]` a_token_vault -/// 6. `[writable]` b_token_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_vault_lp -/// 10. `[writable]` b_vault_lp -/// 11. `[writable]` protocol_token_fee -/// 12. `[signer]` user -/// 13. `[]` vault_program -/// 14. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct SwapBuilder { - pool: Option, - user_source_token: Option, - user_destination_token: Option, - a_vault: Option, - b_vault: Option, - a_token_vault: Option, - b_token_vault: Option, - a_vault_lp_mint: Option, - b_vault_lp_mint: Option, - a_vault_lp: Option, - b_vault_lp: Option, - protocol_token_fee: Option, - user: Option, - vault_program: Option, - token_program: Option, - in_amount: Option, - minimum_out_amount: Option, - __remaining_accounts: Vec, -} - -impl SwapBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// User token account. Token from this account will be transfer into the vault by the pool in exchange for another token of the pool. - #[inline(always)] - pub fn user_source_token(&mut self, user_source_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_source_token = Some(user_source_token); - self - } - - /// User token account. The exchanged token will be transfer into this account from the pool. - #[inline(always)] - pub fn user_destination_token( - &mut self, - user_destination_token: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_destination_token = Some(user_destination_token); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault(&mut self, a_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault(&mut self, b_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.b_token_vault = Some(b_token_vault); - self - } - - /// Lp token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint(&mut self, a_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// Lp token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint(&mut self, b_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp(&mut self, b_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.b_vault_lp = Some(b_vault_lp); - self - } - - /// Protocol fee token account. Used to receive trading fee. It's mint field must matched with user_source_token mint field. - #[inline(always)] - pub fn protocol_token_fee(&mut self, protocol_token_fee: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_token_fee = Some(protocol_token_fee); - self - } - - /// User account. Must be owner of user_source_token. - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn in_amount(&mut self, in_amount: u64) -> &mut Self { - self.in_amount = Some(in_amount); - self - } - - #[inline(always)] - pub fn minimum_out_amount(&mut self, minimum_out_amount: u64) -> &mut Self { - self.minimum_out_amount = Some(minimum_out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Swap { - pool: self.pool.expect("pool is not set"), - user_source_token: self - .user_source_token - .expect("user_source_token is not set"), - user_destination_token: self - .user_destination_token - .expect("user_destination_token is not set"), - a_vault: self.a_vault.expect("a_vault is not set"), - b_vault: self.b_vault.expect("b_vault is not set"), - a_token_vault: self.a_token_vault.expect("a_token_vault is not set"), - b_token_vault: self.b_token_vault.expect("b_token_vault is not set"), - a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"), - b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"), - protocol_token_fee: self - .protocol_token_fee - .expect("protocol_token_fee is not set"), - user: self.user.expect("user is not set"), - vault_program: self.vault_program.expect("vault_program is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = SwapInstructionArgs { - in_amount: self.in_amount.clone().expect("in_amount is not set"), - minimum_out_amount: self - .minimum_out_amount - .clone() - .expect("minimum_out_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap` CPI accounts. -pub struct SwapCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// User token account. Token from this account will be transfer into the vault by the pool in exchange for another token of the pool. - pub user_source_token: &'b solana_account_info::AccountInfo<'a>, - /// User token account. The exchanged token will be transfer into this account from the pool. - pub user_destination_token: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Lp token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Lp token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account. Used to receive trading fee. It's mint field must matched with user_source_token mint field. - pub protocol_token_fee: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of user_source_token. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap` CPI instruction. -pub struct SwapCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// User token account. Token from this account will be transfer into the vault by the pool in exchange for another token of the pool. - pub user_source_token: &'b solana_account_info::AccountInfo<'a>, - /// User token account. The exchanged token will be transfer into this account from the pool. - pub user_destination_token: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - pub a_vault: &'b solana_account_info::AccountInfo<'a>, - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - pub b_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault A - pub a_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account of vault B - pub b_token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Lp token mint of vault a - pub a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// Lp token mint of vault b - pub b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - pub b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - /// Protocol fee token account. Used to receive trading fee. It's mint field must matched with user_source_token mint field. - pub protocol_token_fee: &'b solana_account_info::AccountInfo<'a>, - /// User account. Must be owner of user_source_token. - pub user: &'b solana_account_info::AccountInfo<'a>, - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapInstructionArgs, -} - -impl<'a, 'b> SwapCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapCpiAccounts<'a, 'b>, - args: SwapInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - user_source_token: accounts.user_source_token, - user_destination_token: accounts.user_destination_token, - a_vault: accounts.a_vault, - b_vault: accounts.b_vault, - a_token_vault: accounts.a_token_vault, - b_token_vault: accounts.b_token_vault, - a_vault_lp_mint: accounts.a_vault_lp_mint, - b_vault_lp_mint: accounts.b_vault_lp_mint, - a_vault_lp: accounts.a_vault_lp, - b_vault_lp: accounts.b_vault_lp, - protocol_token_fee: accounts.protocol_token_fee, - user: accounts.user, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_source_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_destination_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.b_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.user_source_token.clone()); - account_infos.push(self.user_destination_token.clone()); - account_infos.push(self.a_vault.clone()); - account_infos.push(self.b_vault.clone()); - account_infos.push(self.a_token_vault.clone()); - account_infos.push(self.b_token_vault.clone()); - account_infos.push(self.a_vault_lp_mint.clone()); - account_infos.push(self.b_vault_lp_mint.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.b_vault_lp.clone()); - account_infos.push(self.protocol_token_fee.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Swap` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[writable]` user_source_token -/// 2. `[writable]` user_destination_token -/// 3. `[writable]` a_vault -/// 4. `[writable]` b_vault -/// 5. `[writable]` a_token_vault -/// 6. `[writable]` b_token_vault -/// 7. `[writable]` a_vault_lp_mint -/// 8. `[writable]` b_vault_lp_mint -/// 9. `[writable]` a_vault_lp -/// 10. `[writable]` b_vault_lp -/// 11. `[writable]` protocol_token_fee -/// 12. `[signer]` user -/// 13. `[]` vault_program -/// 14. `[]` token_program -#[derive(Clone, Debug)] -pub struct SwapCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapCpiBuilderInstruction { - __program: program, - pool: None, - user_source_token: None, - user_destination_token: None, - a_vault: None, - b_vault: None, - a_token_vault: None, - b_token_vault: None, - a_vault_lp_mint: None, - b_vault_lp_mint: None, - a_vault_lp: None, - b_vault_lp: None, - protocol_token_fee: None, - user: None, - vault_program: None, - token_program: None, - in_amount: None, - minimum_out_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// User token account. Token from this account will be transfer into the vault by the pool in exchange for another token of the pool. - #[inline(always)] - pub fn user_source_token( - &mut self, - user_source_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_source_token = Some(user_source_token); - self - } - - /// User token account. The exchanged token will be transfer into this account from the pool. - #[inline(always)] - pub fn user_destination_token( - &mut self, - user_destination_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_destination_token = Some(user_destination_token); - self - } - - /// Vault account for token a. token a of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn a_vault(&mut self, a_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.a_vault = Some(a_vault); - self - } - - /// Vault account for token b. token b of the pool will be deposit / withdraw from this vault account. - #[inline(always)] - pub fn b_vault(&mut self, b_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.b_vault = Some(b_vault); - self - } - - /// Token vault account of vault A - #[inline(always)] - pub fn a_token_vault( - &mut self, - a_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_token_vault = Some(a_token_vault); - self - } - - /// Token vault account of vault B - #[inline(always)] - pub fn b_token_vault( - &mut self, - b_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_token_vault = Some(b_token_vault); - self - } - - /// Lp token mint of vault a - #[inline(always)] - pub fn a_vault_lp_mint( - &mut self, - a_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint); - self - } - - /// Lp token mint of vault b - #[inline(always)] - pub fn b_vault_lp_mint( - &mut self, - b_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint); - self - } - - /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault. - #[inline(always)] - pub fn b_vault_lp( - &mut self, - b_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.b_vault_lp = Some(b_vault_lp); - self - } - - /// Protocol fee token account. Used to receive trading fee. It's mint field must matched with user_source_token mint field. - #[inline(always)] - pub fn protocol_token_fee( - &mut self, - protocol_token_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_fee = Some(protocol_token_fee); - self - } - - /// User account. Must be owner of user_source_token. - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - /// Vault program. the pool will deposit/withdraw liquidity from the vault. - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn in_amount(&mut self, in_amount: u64) -> &mut Self { - self.instruction.in_amount = Some(in_amount); - self - } - - #[inline(always)] - pub fn minimum_out_amount(&mut self, minimum_out_amount: u64) -> &mut Self { - self.instruction.minimum_out_amount = Some(minimum_out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapInstructionArgs { - in_amount: self - .instruction - .in_amount - .clone() - .expect("in_amount is not set"), - minimum_out_amount: self - .instruction - .minimum_out_amount - .clone() - .expect("minimum_out_amount is not set"), - }; - let instruction = SwapCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - user_source_token: self - .instruction - .user_source_token - .expect("user_source_token is not set"), - - user_destination_token: self - .instruction - .user_destination_token - .expect("user_destination_token is not set"), - - a_vault: self.instruction.a_vault.expect("a_vault is not set"), - - b_vault: self.instruction.b_vault.expect("b_vault is not set"), - - a_token_vault: self - .instruction - .a_token_vault - .expect("a_token_vault is not set"), - - b_token_vault: self - .instruction - .b_token_vault - .expect("b_token_vault is not set"), - - a_vault_lp_mint: self - .instruction - .a_vault_lp_mint - .expect("a_vault_lp_mint is not set"), - - b_vault_lp_mint: self - .instruction - .b_vault_lp_mint - .expect("b_vault_lp_mint is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"), - - protocol_token_fee: self - .instruction - .protocol_token_fee - .expect("protocol_token_fee is not set"), - - user: self.instruction.user.expect("user is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - user_source_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_destination_token: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - b_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - b_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - in_amount: Option, - minimum_out_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/update_activation_point.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/update_activation_point.rs deleted file mode 100644 index a1b59202..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/update_activation_point.rs +++ /dev/null @@ -1,359 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateActivationPoint { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - /// Admin account. - pub admin: solana_pubkey::Pubkey, -} - -impl UpdateActivationPoint { - pub fn instruction( - &self, - args: UpdateActivationPointInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateActivationPointInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateActivationPointInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateActivationPointInstructionData { - discriminator: [u8; 8], -} - -impl UpdateActivationPointInstructionData { - pub fn new() -> Self { - Self { - discriminator: [150, 62, 125, 219, 171, 220, 26, 237], - } - } -} - -impl Default for UpdateActivationPointInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateActivationPointInstructionArgs { - pub new_activation_point: u64, -} - -/// Instruction builder for `UpdateActivationPoint`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct UpdateActivationPointBuilder { - pool: Option, - admin: Option, - new_activation_point: Option, - __remaining_accounts: Vec, -} - -impl UpdateActivationPointBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// Admin account. - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn new_activation_point(&mut self, new_activation_point: u64) -> &mut Self { - self.new_activation_point = Some(new_activation_point); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateActivationPoint { - pool: self.pool.expect("pool is not set"), - admin: self.admin.expect("admin is not set"), - }; - let args = UpdateActivationPointInstructionArgs { - new_activation_point: self - .new_activation_point - .clone() - .expect("new_activation_point is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_activation_point` CPI accounts. -pub struct UpdateActivationPointCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_activation_point` CPI instruction. -pub struct UpdateActivationPointCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - /// Admin account. - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateActivationPointInstructionArgs, -} - -impl<'a, 'b> UpdateActivationPointCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateActivationPointCpiAccounts<'a, 'b>, - args: UpdateActivationPointInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - admin: accounts.admin, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateActivationPointInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateActivationPoint` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[signer]` admin -#[derive(Clone, Debug)] -pub struct UpdateActivationPointCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateActivationPointCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateActivationPointCpiBuilderInstruction { - __program: program, - pool: None, - admin: None, - new_activation_point: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - /// Admin account. - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn new_activation_point(&mut self, new_activation_point: u64) -> &mut Self { - self.instruction.new_activation_point = Some(new_activation_point); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateActivationPointInstructionArgs { - new_activation_point: self - .instruction - .new_activation_point - .clone() - .expect("new_activation_point is not set"), - }; - let instruction = UpdateActivationPointCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateActivationPointCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - new_activation_point: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/instructions/withdraw_protocol_fees.rs b/crates/meteora-pools-parser/src/generated_sdk/instructions/withdraw_protocol_fees.rs deleted file mode 100644 index ef5b26eb..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/instructions/withdraw_protocol_fees.rs +++ /dev/null @@ -1,542 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct WithdrawProtocolFees { - /// Pool account (PDA) - pub pool: solana_pubkey::Pubkey, - - pub a_vault_lp: solana_pubkey::Pubkey, - - pub protocol_token_a_fee: solana_pubkey::Pubkey, - - pub protocol_token_b_fee: solana_pubkey::Pubkey, - - pub treasury_token_a: solana_pubkey::Pubkey, - - pub treasury_token_b: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl WithdrawProtocolFees { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.a_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_a_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_b_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.treasury_token_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.treasury_token_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&WithdrawProtocolFeesInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawProtocolFeesInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawProtocolFeesInstructionData { - pub fn new() -> Self { - Self { - discriminator: [11, 68, 165, 98, 18, 208, 134, 73], - } - } -} - -impl Default for WithdrawProtocolFeesInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `WithdrawProtocolFees`. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[]` a_vault_lp -/// 2. `[writable]` protocol_token_a_fee -/// 3. `[writable]` protocol_token_b_fee -/// 4. `[writable]` treasury_token_a -/// 5. `[writable]` treasury_token_b -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct WithdrawProtocolFeesBuilder { - pool: Option, - a_vault_lp: Option, - protocol_token_a_fee: Option, - protocol_token_b_fee: Option, - treasury_token_a: Option, - treasury_token_b: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl WithdrawProtocolFeesBuilder { - pub fn new() -> Self { Self::default() } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn a_vault_lp(&mut self, a_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.a_vault_lp = Some(a_vault_lp); - self - } - - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - #[inline(always)] - pub fn treasury_token_a(&mut self, treasury_token_a: solana_pubkey::Pubkey) -> &mut Self { - self.treasury_token_a = Some(treasury_token_a); - self - } - - #[inline(always)] - pub fn treasury_token_b(&mut self, treasury_token_b: solana_pubkey::Pubkey) -> &mut Self { - self.treasury_token_b = Some(treasury_token_b); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = WithdrawProtocolFees { - pool: self.pool.expect("pool is not set"), - a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"), - protocol_token_a_fee: self - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - protocol_token_b_fee: self - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - treasury_token_a: self.treasury_token_a.expect("treasury_token_a is not set"), - treasury_token_b: self.treasury_token_b.expect("treasury_token_b is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `withdraw_protocol_fees` CPI accounts. -pub struct WithdrawProtocolFeesCpiAccounts<'a, 'b> { - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - - pub treasury_token_a: &'b solana_account_info::AccountInfo<'a>, - - pub treasury_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw_protocol_fees` CPI instruction. -pub struct WithdrawProtocolFeesCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pool account (PDA) - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - - pub treasury_token_a: &'b solana_account_info::AccountInfo<'a>, - - pub treasury_token_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> WithdrawProtocolFeesCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawProtocolFeesCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - a_vault_lp: accounts.a_vault_lp, - protocol_token_a_fee: accounts.protocol_token_a_fee, - protocol_token_b_fee: accounts.protocol_token_b_fee, - treasury_token_a: accounts.treasury_token_a, - treasury_token_b: accounts.treasury_token_b, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.a_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_a_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_b_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.treasury_token_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.treasury_token_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&WithdrawProtocolFeesInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.a_vault_lp.clone()); - account_infos.push(self.protocol_token_a_fee.clone()); - account_infos.push(self.protocol_token_b_fee.clone()); - account_infos.push(self.treasury_token_a.clone()); - account_infos.push(self.treasury_token_b.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `WithdrawProtocolFees` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[]` a_vault_lp -/// 2. `[writable]` protocol_token_a_fee -/// 3. `[writable]` protocol_token_b_fee -/// 4. `[writable]` treasury_token_a -/// 5. `[writable]` treasury_token_b -/// 6. `[]` token_program -#[derive(Clone, Debug)] -pub struct WithdrawProtocolFeesCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawProtocolFeesCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawProtocolFeesCpiBuilderInstruction { - __program: program, - pool: None, - a_vault_lp: None, - protocol_token_a_fee: None, - protocol_token_b_fee: None, - treasury_token_a: None, - treasury_token_b: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pool account (PDA) - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn a_vault_lp( - &mut self, - a_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.a_vault_lp = Some(a_vault_lp); - self - } - - #[inline(always)] - pub fn protocol_token_a_fee( - &mut self, - protocol_token_a_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_a_fee = Some(protocol_token_a_fee); - self - } - - #[inline(always)] - pub fn protocol_token_b_fee( - &mut self, - protocol_token_b_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_b_fee = Some(protocol_token_b_fee); - self - } - - #[inline(always)] - pub fn treasury_token_a( - &mut self, - treasury_token_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.treasury_token_a = Some(treasury_token_a); - self - } - - #[inline(always)] - pub fn treasury_token_b( - &mut self, - treasury_token_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.treasury_token_b = Some(treasury_token_b); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = WithdrawProtocolFeesCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"), - - protocol_token_a_fee: self - .instruction - .protocol_token_a_fee - .expect("protocol_token_a_fee is not set"), - - protocol_token_b_fee: self - .instruction - .protocol_token_b_fee - .expect("protocol_token_b_fee is not set"), - - treasury_token_a: self - .instruction - .treasury_token_a - .expect("treasury_token_a is not set"), - - treasury_token_b: self - .instruction - .treasury_token_b - .expect("treasury_token_b is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawProtocolFeesCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - a_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_a_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_b_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - treasury_token_a: Option<&'b solana_account_info::AccountInfo<'a>>, - treasury_token_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/mod.rs b/crates/meteora-pools-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/meteora-pools-parser/src/generated_sdk/programs.rs b/crates/meteora-pools-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 23791aa2..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `amm` program ID. -pub const AMM_ID: Pubkey = pubkey!("Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB"); diff --git a/crates/meteora-pools-parser/src/generated_sdk/shared.rs b/crates/meteora-pools-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/activation_type.rs b/crates/meteora-pools-parser/src/generated_sdk/types/activation_type.rs deleted file mode 100644 index 88b13245..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/activation_type.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Type of the activation -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum ActivationType { - Slot, - Timestamp, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/bootstrapping.rs b/crates/meteora-pools-parser/src/generated_sdk/types/bootstrapping.rs deleted file mode 100644 index fc11a698..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/bootstrapping.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Bootstrapping { - /// Activation point, can be slot or timestamp - pub activation_point: u64, - /// Whitelisted vault to be able to buy pool before activation_point - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whitelisted_vault: Pubkey, - /// Need to store pool creator in lauch pool, so they can modify liquidity before activation_point - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_creator: Pubkey, - /// Activation type, 0 means by slot, 1 means by timestamp - pub activation_type: u8, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/curve_type.rs b/crates/meteora-pools-parser/src/generated_sdk/types/curve_type.rs deleted file mode 100644 index 66ffab88..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/curve_type.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{Depeg, TokenMultiplier}; - -/// Type of the swap curve -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum CurveType { - ConstantProduct, - Stable { - /// Amplification coefficient - amp: u64, - /// Multiplier for the pool token. Used to normalized token with different decimal into the same precision. - token_multiplier: TokenMultiplier, - /// Depeg pool information. Contains functions to allow token amount to be repeg using stake / interest bearing token virtual price - depeg: Depeg, - /// The last amp updated timestamp. Used to prevent update_curve_info called infinitely many times within a short period - last_amp_updated_timestamp: u64, - }, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/depeg.rs b/crates/meteora-pools-parser/src/generated_sdk/types/depeg.rs deleted file mode 100644 index dd11d49a..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/depeg.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::DepegType; - -/// Contains information for depeg pool -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Depeg { - /// The virtual price of staking / interest bearing token - pub base_virtual_price: u64, - /// The last time base_virtual_price is updated - pub base_cache_updated: u64, - /// Type of the depeg pool - pub depeg_type: DepegType, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/depeg_type.rs b/crates/meteora-pools-parser/src/generated_sdk/types/depeg_type.rs deleted file mode 100644 index 729f5cb5..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/depeg_type.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Type of depeg pool -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum DepegType { - None, - Marinade, - Lido, - SplStake, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/mod.rs b/crates/meteora-pools-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index db147701..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#activation_type; -pub(crate) mod r#bootstrapping; -pub(crate) mod r#curve_type; -pub(crate) mod r#depeg; -pub(crate) mod r#depeg_type; -pub(crate) mod r#new_curve_type; -pub(crate) mod r#padding; -pub(crate) mod r#partner_info; -pub(crate) mod r#pool_fees; -pub(crate) mod r#pool_type; -pub(crate) mod r#round_direction; -pub(crate) mod r#rounding; -pub(crate) mod r#token_multiplier; -pub(crate) mod r#trade_direction; - -pub use self::{ - r#activation_type::*, r#bootstrapping::*, r#curve_type::*, r#depeg::*, r#depeg_type::*, - r#new_curve_type::*, r#padding::*, r#partner_info::*, r#pool_fees::*, r#pool_type::*, - r#round_direction::*, r#rounding::*, r#token_multiplier::*, r#trade_direction::*, -}; diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/new_curve_type.rs b/crates/meteora-pools-parser/src/generated_sdk/types/new_curve_type.rs deleted file mode 100644 index b16760b8..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/new_curve_type.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{Depeg, TokenMultiplier}; - -/// Type of the swap curve -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum NewCurveType { - ConstantProduct, - Stable { - /// Amplification coefficient - amp: u64, - /// Multiplier for the pool token. Used to normalized token with different decimal into the same precision. - token_multiplier: TokenMultiplier, - /// Depeg pool information. Contains functions to allow token amount to be repeg using stake / interest bearing token virtual price - depeg: Depeg, - /// The last amp updated timestamp. Used to prevent update_curve_info called infinitely many times within a short period - last_amp_updated_timestamp: u64, - }, - NewCurve { - field_one: u64, - field_two: u64, - }, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/padding.rs b/crates/meteora-pools-parser/src/generated_sdk/types/padding.rs deleted file mode 100644 index 10d716eb..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/padding.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Padding for future pool fields -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Padding { - /// Padding 0 - pub padding0: [u8; 6], - /// Padding 1 - pub padding1: [u64; 21], - /// Padding 2 - pub padding2: [u64; 21], -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/partner_info.rs b/crates/meteora-pools-parser/src/generated_sdk/types/partner_info.rs deleted file mode 100644 index 8ed3efda..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/partner_info.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PartnerInfo { - pub fee_numerator: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub partner_authority: Pubkey, - pub pending_fee_a: u64, - pub pending_fee_b: u64, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/pool_fees.rs b/crates/meteora-pools-parser/src/generated_sdk/types/pool_fees.rs deleted file mode 100644 index 0d04316f..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/pool_fees.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Information regarding fee charges -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolFees { - /// 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 - pub trade_fee_numerator: u64, - /// Trade fee denominator - pub trade_fee_denominator: u64, - /// 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 - pub protocol_trade_fee_numerator: u64, - /// Protocol trade fee denominator - pub protocol_trade_fee_denominator: u64, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/pool_type.rs b/crates/meteora-pools-parser/src/generated_sdk/types/pool_type.rs deleted file mode 100644 index c0c8f768..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/pool_type.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Pool type -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum PoolType { - Permissioned, - Permissionless, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/round_direction.rs b/crates/meteora-pools-parser/src/generated_sdk/types/round_direction.rs deleted file mode 100644 index dc15d5eb..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/round_direction.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Rounding direction -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum RoundDirection { - Floor, - Ceiling, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/rounding.rs b/crates/meteora-pools-parser/src/generated_sdk/types/rounding.rs deleted file mode 100644 index 4913a477..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/rounding.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Round up, down -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum Rounding { - Up, - Down, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/token_multiplier.rs b/crates/meteora-pools-parser/src/generated_sdk/types/token_multiplier.rs deleted file mode 100644 index 44253bc9..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/token_multiplier.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Multiplier for the pool token. Used to normalized token with different decimal into the same precision. -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenMultiplier { - /// Multiplier for token A of the pool. - pub token_a_multiplier: u64, - /// Multiplier for token B of the pool. - pub token_b_multiplier: u64, - /// Record the highest token decimal in the pool. For example, Token A is 6 decimal, token B is 9 decimal. This will save value of 9. - pub precision_factor: u8, -} diff --git a/crates/meteora-pools-parser/src/generated_sdk/types/trade_direction.rs b/crates/meteora-pools-parser/src/generated_sdk/types/trade_direction.rs deleted file mode 100644 index 0a12d182..00000000 --- a/crates/meteora-pools-parser/src/generated_sdk/types/trade_direction.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Trade (swap) direction -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TradeDirection { - AtoB, - BtoA, -} diff --git a/crates/meteora-pools-parser/src/lib.rs b/crates/meteora-pools-parser/src/lib.rs deleted file mode 100644 index 620278bf..00000000 --- a/crates/meteora-pools-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = AMM_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.meteora_pools"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/meteora-vault-parser/Cargo.toml b/crates/meteora-vault-parser/Cargo.toml deleted file mode 100644 index f32aec22..00000000 --- a/crates/meteora-vault-parser/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "yellowstone-vixen-meteora-vault-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Meteora Vault program" -license.workspace = true -repository.workspace = true -authors.workspace = true - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info.workspace = true -solana-cpi.workspace = true -solana-decode-error.workspace = true -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction.workspace = true -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true \ No newline at end of file diff --git a/crates/meteora-vault-parser/build.rs b/crates/meteora-vault-parser/build.rs deleted file mode 100644 index d0ed6d37..00000000 --- a/crates/meteora-vault-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/meteora_vault.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/meteora-vault-parser/idl.json b/crates/meteora-vault-parser/idl.json deleted file mode 100644 index 4b09119c..00000000 --- a/crates/meteora-vault-parser/idl.json +++ /dev/null @@ -1,1555 +0,0 @@ -{ - "version": "0.7.2", - "name": "vault", - "docs": [ - "Program for vault" - ], - "instructions": [ - { - "name": "initialize", - "docs": [ - "initialize new vault" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "This is base account for all vault", - "No need base key now because we only allow 1 vault per token now", - "Vault account" - ] - }, - { - "name": "payer", - "isMut": true, - "isSigner": true, - "docs": [ - "Payer can be anyone" - ] - }, - { - "name": "tokenVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Token vault account" - ] - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false, - "docs": [ - "Token mint account" - ] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false, - "docs": [ - "rent" - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "token_program" - ] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "system_program" - ] - } - ], - "args": [] - }, - { - "name": "enableVault", - "docs": [ - "enable vault" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account" - ] - }, - { - "name": "admin", - "isMut": false, - "isSigner": true, - "docs": [ - "Admin account" - ] - } - ], - "args": [ - { - "name": "enabled", - "type": "u8" - } - ] - }, - { - "name": "setOperator", - "docs": [ - "set new operator" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account" - ] - }, - { - "name": "operator", - "isMut": false, - "isSigner": false - }, - { - "name": "admin", - "isMut": false, - "isSigner": true, - "docs": [ - "admin" - ] - } - ], - "args": [] - }, - { - "name": "initializeStrategy", - "docs": [ - "Initialize a strategy and add strategy to vault.strategies index" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account" - ] - }, - { - "name": "strategyProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "strategy", - "isMut": true, - "isSigner": false, - "docs": [ - "Strategy account" - ] - }, - { - "name": "reserve", - "isMut": true, - "isSigner": false - }, - { - "name": "collateralVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Collateral vault account" - ] - }, - { - "name": "collateralMint", - "isMut": false, - "isSigner": false, - "docs": [ - "Collateral mint account" - ] - }, - { - "name": "admin", - "isMut": true, - "isSigner": true, - "docs": [ - "Admin account" - ] - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "System program account" - ] - }, - { - "name": "rent", - "isMut": false, - "isSigner": false, - "docs": [ - "Rent account" - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "Token program account" - ] - } - ], - "args": [ - { - "name": "bumps", - "type": { - "defined": "StrategyBumps" - } - }, - { - "name": "strategyType", - "type": { - "defined": "StrategyType" - } - } - ] - }, - { - "name": "removeStrategy", - "docs": [ - "remove a strategy" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account" - ] - }, - { - "name": "strategy", - "isMut": true, - "isSigner": false, - "docs": [ - "Strategy account" - ] - }, - { - "name": "strategyProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "collateralVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Collateral vault account" - ] - }, - { - "name": "reserve", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault", - "isMut": true, - "isSigner": false, - "docs": [ - "token_vault" - ] - }, - { - "name": "feeVault", - "isMut": true, - "isSigner": false, - "docs": [ - "fee_vault" - ] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": [ - "lp_mint" - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "token_program" - ] - }, - { - "name": "admin", - "isMut": false, - "isSigner": true, - "docs": [ - "admin" - ] - } - ], - "args": [] - }, - { - "name": "removeStrategy2", - "docs": [ - "remove a strategy by advance payment" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "Vault account" - ] - }, - { - "name": "strategy", - "isMut": true, - "isSigner": false, - "docs": [ - "Strategy account" - ] - }, - { - "name": "strategyProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "collateralVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Collateral vault account" - ] - }, - { - "name": "reserve", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault", - "isMut": true, - "isSigner": false, - "docs": [ - "token_vault" - ] - }, - { - "name": "tokenAdminAdvancePayment", - "isMut": true, - "isSigner": false, - "docs": [ - "token_advance_payemnt", - "the owner of token_advance_payment must be admin" - ] - }, - { - "name": "tokenVaultAdvancePayment", - "isMut": true, - "isSigner": false, - "docs": [ - "token_vault_advance_payment", - "the account must be different from token_vault", - "the owner of token_advance_payment must be vault" - ] - }, - { - "name": "feeVault", - "isMut": true, - "isSigner": false, - "docs": [ - "fee_vault" - ] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": [ - "lp_mint" - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "token_program" - ] - }, - { - "name": "admin", - "isMut": false, - "isSigner": true, - "docs": [ - "admin" - ] - } - ], - "args": [ - { - "name": "maxAdminPayAmount", - "type": "u64" - } - ] - }, - { - "name": "collectDust", - "docs": [ - "collect token, that someone send wrongly", - "also help in case Mango reimbursement" - ], - "accounts": [ - { - "name": "vault", - "isMut": false, - "isSigner": false, - "docs": [ - "vault" - ] - }, - { - "name": "tokenVault", - "isMut": true, - "isSigner": false, - "docs": [ - "Token vault, must be different from vault.token_vault" - ] - }, - { - "name": "tokenAdmin", - "isMut": true, - "isSigner": false, - "docs": [ - "token admin, enforce owner is admin to avoid mistake" - ] - }, - { - "name": "admin", - "isMut": false, - "isSigner": true, - "docs": [ - "admin" - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "token_program" - ] - } - ], - "args": [] - }, - { - "name": "addStrategy", - "docs": [ - "add a strategy" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "vault" - ] - }, - { - "name": "strategy", - "isMut": false, - "isSigner": false, - "docs": [ - "strategy" - ] - }, - { - "name": "admin", - "isMut": false, - "isSigner": true, - "docs": [ - "admin" - ] - } - ], - "args": [] - }, - { - "name": "depositStrategy", - "docs": [ - "deposit liquidity to a strategy" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "vault" - ] - }, - { - "name": "strategy", - "isMut": true, - "isSigner": false, - "docs": [ - "strategy" - ] - }, - { - "name": "tokenVault", - "isMut": true, - "isSigner": false, - "docs": [ - "token_vault" - ] - }, - { - "name": "feeVault", - "isMut": true, - "isSigner": false, - "docs": [ - "fee_vault" - ] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": [ - "lp_mint" - ] - }, - { - "name": "strategyProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "collateralVault", - "isMut": true, - "isSigner": false, - "docs": [ - "collateral_vault" - ] - }, - { - "name": "reserve", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "token_program" - ] - }, - { - "name": "operator", - "isMut": false, - "isSigner": true, - "docs": [ - "operator" - ] - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "withdrawStrategy", - "docs": [ - "withdraw liquidity from a strategy" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "vault" - ] - }, - { - "name": "strategy", - "isMut": true, - "isSigner": false, - "docs": [ - "strategy" - ] - }, - { - "name": "tokenVault", - "isMut": true, - "isSigner": false, - "docs": [ - "token_vault" - ] - }, - { - "name": "feeVault", - "isMut": true, - "isSigner": false, - "docs": [ - "fee_vault" - ] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": [ - "lp_mint" - ] - }, - { - "name": "strategyProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "collateralVault", - "isMut": true, - "isSigner": false, - "docs": [ - "collateral_vault" - ] - }, - { - "name": "reserve", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "token_program" - ] - }, - { - "name": "operator", - "isMut": false, - "isSigner": true, - "docs": [ - "operator" - ] - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "withdraw2", - "docs": [ - "Withdraw v2. Withdraw from token vault if no remaining accounts are available. Else, it will attempt to withdraw from strategy and token vault. This method just proxy between 2 methods. Protocol integration should be using withdraw instead of this function." - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "vault" - ] - }, - { - "name": "tokenVault", - "isMut": true, - "isSigner": false, - "docs": [ - "token_vault" - ] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": [ - "lp_mint" - ] - }, - { - "name": "userToken", - "isMut": true, - "isSigner": false, - "docs": [ - "user_token" - ] - }, - { - "name": "userLp", - "isMut": true, - "isSigner": false, - "docs": [ - "user_lp" - ] - }, - { - "name": "user", - "isMut": false, - "isSigner": true, - "docs": [ - "user" - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "token_program" - ] - } - ], - "args": [ - { - "name": "unmintAmount", - "type": "u64" - }, - { - "name": "minOutAmount", - "type": "u64" - } - ] - }, - { - "name": "deposit", - "docs": [ - "user deposit liquidity to vault" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "vault" - ] - }, - { - "name": "tokenVault", - "isMut": true, - "isSigner": false, - "docs": [ - "token_vault" - ] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": [ - "lp_mint" - ] - }, - { - "name": "userToken", - "isMut": true, - "isSigner": false, - "docs": [ - "user_token" - ] - }, - { - "name": "userLp", - "isMut": true, - "isSigner": false, - "docs": [ - "user_lp" - ] - }, - { - "name": "user", - "isMut": false, - "isSigner": true, - "docs": [ - "user" - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "token_program" - ] - } - ], - "args": [ - { - "name": "tokenAmount", - "type": "u64" - }, - { - "name": "minimumLpTokenAmount", - "type": "u64" - } - ] - }, - { - "name": "withdraw", - "docs": [ - "user withdraw liquidity from vault" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "vault" - ] - }, - { - "name": "tokenVault", - "isMut": true, - "isSigner": false, - "docs": [ - "token_vault" - ] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": [ - "lp_mint" - ] - }, - { - "name": "userToken", - "isMut": true, - "isSigner": false, - "docs": [ - "user_token" - ] - }, - { - "name": "userLp", - "isMut": true, - "isSigner": false, - "docs": [ - "user_lp" - ] - }, - { - "name": "user", - "isMut": false, - "isSigner": true, - "docs": [ - "user" - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "token_program" - ] - } - ], - "args": [ - { - "name": "unmintAmount", - "type": "u64" - }, - { - "name": "minOutAmount", - "type": "u64" - } - ] - }, - { - "name": "withdrawDirectlyFromStrategy", - "docs": [ - "user withdraw liquidity from vault, if vault reserve doesn't have enough liquidity, it will withdraw from the strategy firstly" - ], - "accounts": [ - { - "name": "vault", - "isMut": true, - "isSigner": false, - "docs": [ - "vault" - ] - }, - { - "name": "strategy", - "isMut": true, - "isSigner": false, - "docs": [ - "strategy" - ] - }, - { - "name": "reserve", - "isMut": true, - "isSigner": false - }, - { - "name": "strategyProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "collateralVault", - "isMut": true, - "isSigner": false, - "docs": [ - "collateral_vault" - ] - }, - { - "name": "tokenVault", - "isMut": true, - "isSigner": false, - "docs": [ - "token_vault" - ] - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false, - "docs": [ - "lp_mint" - ] - }, - { - "name": "feeVault", - "isMut": true, - "isSigner": false, - "docs": [ - "fee_vault" - ] - }, - { - "name": "userToken", - "isMut": true, - "isSigner": false, - "docs": [ - "user_token" - ] - }, - { - "name": "userLp", - "isMut": true, - "isSigner": false, - "docs": [ - "user_lp" - ] - }, - { - "name": "user", - "isMut": false, - "isSigner": true, - "docs": [ - "user" - ] - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false, - "docs": [ - "token_program" - ] - } - ], - "args": [ - { - "name": "unmintAmount", - "type": "u64" - }, - { - "name": "minOutAmount", - "type": "u64" - } - ] - } - ], - "accounts": [ - { - "name": "Vault", - "docs": [ - "Vault struct" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "enabled", - "docs": [ - "The flag, if admin set enable = false, then the user can only withdraw and cannot deposit in the vault." - ], - "type": "u8" - }, - { - "name": "bumps", - "docs": [ - "Vault nonce, to create vault seeds" - ], - "type": { - "defined": "VaultBumps" - } - }, - { - "name": "totalAmount", - "docs": [ - "The total liquidity of the vault, including remaining tokens in token_vault and the liquidity in all strategies." - ], - "type": "u64" - }, - { - "name": "tokenVault", - "docs": [ - "Token account, hold liquidity in vault reserve" - ], - "type": "publicKey" - }, - { - "name": "feeVault", - "docs": [ - "Hold lp token of vault, each time rebalance crank is called, vault calculate performance fee and mint corresponding lp token amount to fee_vault. fee_vault is owned by treasury address" - ], - "type": "publicKey" - }, - { - "name": "tokenMint", - "docs": [ - "Token mint that vault supports" - ], - "type": "publicKey" - }, - { - "name": "lpMint", - "docs": [ - "Lp mint of vault" - ], - "type": "publicKey" - }, - { - "name": "strategies", - "docs": [ - "The list of strategy addresses that vault supports, vault can support up to MAX_STRATEGY strategies at the same time." - ], - "type": { - "array": [ - "publicKey", - 30 - ] - } - }, - { - "name": "base", - "docs": [ - "The base address to create vault seeds" - ], - "type": "publicKey" - }, - { - "name": "admin", - "docs": [ - "Admin of vault" - ], - "type": "publicKey" - }, - { - "name": "operator", - "docs": [ - "Person who can send the crank. Operator can only send liquidity to strategies that admin defined, and claim reward to account of treasury address" - ], - "type": "publicKey" - }, - { - "name": "lockedProfitTracker", - "docs": [ - "Stores information for locked profit." - ], - "type": { - "defined": "LockedProfitTracker" - } - } - ] - } - }, - { - "name": "Strategy", - "docs": [ - "Strategy struct" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "reserve", - "docs": [ - "Lending pool address, that the strategy will deposit/withdraw balance" - ], - "type": "publicKey" - }, - { - "name": "collateralVault", - "docs": [ - "The token account, that holds the collateral token" - ], - "type": "publicKey" - }, - { - "name": "strategyType", - "docs": [ - "Specify type of strategy" - ], - "type": { - "defined": "StrategyType" - } - }, - { - "name": "currentLiquidity", - "docs": [ - "The liquidity in strategy at the time vault deposit/withdraw from a lending protocol" - ], - "type": "u64" - }, - { - "name": "bumps", - "docs": [ - "Hold some bumps, in case the strategy needs to use other seeds to sign a CPI call." - ], - "type": { - "array": [ - "u8", - 10 - ] - } - }, - { - "name": "vault", - "docs": [ - "Vault address, that the strategy belongs" - ], - "type": "publicKey" - }, - { - "name": "isDisable", - "docs": [ - "If we remove strategy by remove_strategy2 endpoint, this account will be never added again" - ], - "type": "u8" - } - ] - } - } - ], - "types": [ - { - "name": "VaultBumps", - "docs": [ - "Vault bumps struct" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "vaultBump", - "docs": [ - "vault_bump" - ], - "type": "u8" - }, - { - "name": "tokenVaultBump", - "docs": [ - "token_vault_bump" - ], - "type": "u8" - } - ] - } - }, - { - "name": "StrategyBumps", - "docs": [ - "Strategy bumps struct" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "strategyIndex", - "docs": [ - "strategy_index" - ], - "type": "u8" - }, - { - "name": "otherBumps", - "docs": [ - "Bumps of PDAs for the integrated protocol." - ], - "type": { - "array": [ - "u8", - 10 - ] - } - } - ] - } - }, - { - "name": "LockedProfitTracker", - "docs": [ - "LockedProfitTracker struct" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "lastUpdatedLockedProfit", - "docs": [ - "The total locked profit from the last report" - ], - "type": "u64" - }, - { - "name": "lastReport", - "docs": [ - "The last timestamp (in seconds) rebalancing" - ], - "type": "u64" - }, - { - "name": "lockedProfitDegradation", - "docs": [ - "Rate per second of degradation" - ], - "type": "u64" - } - ] - } - }, - { - "name": "StrategyType", - "docs": [ - "StrategyType struct" - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "PortFinanceWithoutLM" - }, - { - "name": "PortFinanceWithLM" - }, - { - "name": "SolendWithoutLM" - }, - { - "name": "Mango" - }, - { - "name": "SolendWithLM" - }, - { - "name": "ApricotWithoutLM" - }, - { - "name": "Francium" - }, - { - "name": "Tulip" - }, - { - "name": "Vault" - }, - { - "name": "Drift" - }, - { - "name": "Frakt" - }, - { - "name": "Marginfi" - } - ] - } - } - ], - "events": [ - { - "name": "AddLiquidity", - "fields": [ - { - "name": "lpMintAmount", - "type": "u64", - "index": false - }, - { - "name": "tokenAmount", - "type": "u64", - "index": false - } - ] - }, - { - "name": "RemoveLiquidity", - "fields": [ - { - "name": "lpUnmintAmount", - "type": "u64", - "index": false - }, - { - "name": "tokenAmount", - "type": "u64", - "index": false - } - ] - }, - { - "name": "StrategyDeposit", - "fields": [ - { - "name": "strategyType", - "type": { - "defined": "StrategyType" - }, - "index": false - }, - { - "name": "tokenAmount", - "type": "u64", - "index": false - } - ] - }, - { - "name": "StrategyWithdraw", - "fields": [ - { - "name": "strategyType", - "type": { - "defined": "StrategyType" - }, - "index": false - }, - { - "name": "collateralAmount", - "type": "u64", - "index": false - }, - { - "name": "estimatedTokenAmount", - "type": "u64", - "index": false - } - ] - }, - { - "name": "ClaimReward", - "fields": [ - { - "name": "strategyType", - "type": { - "defined": "StrategyType" - }, - "index": false - }, - { - "name": "tokenAmount", - "type": "u64", - "index": false - }, - { - "name": "mintAccount", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "PerformanceFee", - "fields": [ - { - "name": "lpMintMore", - "type": "u64", - "index": false - } - ] - }, - { - "name": "ReportLoss", - "fields": [ - { - "name": "strategy", - "type": "publicKey", - "index": false - }, - { - "name": "loss", - "type": "u64", - "index": false - } - ] - }, - { - "name": "TotalAmount", - "fields": [ - { - "name": "totalAmount", - "type": "u64", - "index": false - } - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "VaultIsDisabled", - "msg": "Vault is disabled" - }, - { - "code": 6001, - "name": "ExceededSlippage", - "msg": "Exceeded slippage tolerance" - }, - { - "code": 6002, - "name": "StrategyIsNotExisted", - "msg": "Strategy is not existed" - }, - { - "code": 6003, - "name": "UnAuthorized", - "msg": "UnAuthorized" - }, - { - "code": 6004, - "name": "MathOverflow", - "msg": "Math operation overflow" - }, - { - "code": 6005, - "name": "ProtocolIsNotSupported", - "msg": "Protocol is not supported" - }, - { - "code": 6006, - "name": "UnMatchReserve", - "msg": "Reserve does not support token mint" - }, - { - "code": 6007, - "name": "InvalidLockedProfitDegradation", - "msg": "lockedProfitDegradation is invalid" - }, - { - "code": 6008, - "name": "MaxStrategyReached", - "msg": "Maximum number of strategies have been reached" - }, - { - "code": 6009, - "name": "StrategyExisted", - "msg": "Strategy existed" - }, - { - "code": 6010, - "name": "InvalidUnmintAmount", - "msg": "Invalid unmint amount" - }, - { - "code": 6011, - "name": "InvalidAccountsForStrategy", - "msg": "Invalid accounts for strategy" - }, - { - "code": 6012, - "name": "InvalidBump", - "msg": "Invalid bump" - }, - { - "code": 6013, - "name": "AmountMustGreaterThanZero", - "msg": "Amount must be greater than 0" - }, - { - "code": 6014, - "name": "MangoIsNotSupportedAnymore", - "msg": "Mango is not supported anymore" - }, - { - "code": 6015, - "name": "StrategyIsNotSupported", - "msg": "Strategy is not supported" - }, - { - "code": 6016, - "name": "PayAmountIsExeeced", - "msg": "Pay amount is exceeded" - }, - { - "code": 6017, - "name": "FeeVaultIsNotSet", - "msg": "Fee vault is not set" - }, - { - "code": 6018, - "name": "LendingAssertionViolation", - "msg": "deposit amount in lending is not matched" - }, - { - "code": 6019, - "name": "HaveMoneyInLending", - "msg": "Cannot remove strategy becase we have some in lending" - } - ] -} \ No newline at end of file diff --git a/crates/meteora-vault-parser/proto/meteora_vault.proto b/crates/meteora-vault-parser/proto/meteora_vault.proto deleted file mode 100644 index 5d6ed369..00000000 --- a/crates/meteora-vault-parser/proto/meteora_vault.proto +++ /dev/null @@ -1,351 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.meteora_vault; - -message InitializeIx { - InitializeIxAccounts accounts = 1; -} - -message EnableVaultIx { - EnableVaultIxAccounts accounts = 1; - EnableVaultIxData data = 2; -} - -message SetOperatorIx { - SetOperatorIxAccounts accounts = 1; -} - -message InitializeStrategyIx { - InitializeStrategyIxAccounts accounts = 1; - InitializeStrategyIxData data = 2; -} - -message RemoveStrategyIx { - RemoveStrategyIxAccounts accounts = 1; -} - -message RemoveStrategy2Ix { - RemoveStrategy2IxAccounts accounts = 1; - RemoveStrategy2IxData data = 2; -} - -message CollectDustIx { - CollectDustIxAccounts accounts = 1; -} - -message AddStrategyIx { - AddStrategyIxAccounts accounts = 1; -} - -message DepositStrategyIx { - DepositStrategyIxAccounts accounts = 1; - DepositStrategyIxData data = 2; -} - -message WithdrawStrategyIx { - WithdrawStrategyIxAccounts accounts = 1; - WithdrawStrategyIxData data = 2; -} - -message Withdraw2Ix { - Withdraw2IxAccounts accounts = 1; - Withdraw2IxData data = 2; -} - -message DepositIx { - DepositIxAccounts accounts = 1; - DepositIxData data = 2; -} - -message WithdrawIx { - WithdrawIxAccounts accounts = 1; - WithdrawIxData data = 2; -} - -message WithdrawDirectlyFromStrategyIx { - WithdrawDirectlyFromStrategyIxAccounts accounts = 1; - WithdrawDirectlyFromStrategyIxData data = 2; -} - - -message VaultBumps { - uint32 vault_bump = 1; - uint32 token_vault_bump = 2; -} - -message LockedProfitTracker { - uint64 last_updated_locked_profit = 1; - uint64 last_report = 2; - uint64 locked_profit_degradation = 3; -} - -enum StrategyType { - StrategyTypePortFinanceWithoutLM = 0; - StrategyTypePortFinanceWithLM = 1; - StrategyTypeSolendWithoutLM = 2; - StrategyTypeMango = 3; - StrategyTypeSolendWithLM = 4; - StrategyTypeApricotWithoutLM = 5; - StrategyTypeFrancium = 6; - StrategyTypeTulip = 7; - StrategyTypeVault = 8; - StrategyTypeDrift = 9; - StrategyTypeFrakt = 10; - StrategyTypeMarginfi = 11; -} - - -message Vault { - uint32 enabled = 1; - VaultBumps bumps = 2; - uint64 total_amount = 3; - string token_vault = 4; - string fee_vault = 5; - string token_mint = 6; - string lp_mint = 7; - repeated string strategies = 8; - string base = 9; - string admin = 10; - string operator = 11; - LockedProfitTracker locked_profit_tracker = 12; -} - -message Strategy { - string reserve = 1; - string collateral_vault = 2; - StrategyType strategy_type = 3; - uint64 current_liquidity = 4; - repeated uint32 bumps = 5; - string vault = 6; - uint32 is_disable = 7; -} - - -message InitializeIxAccounts { - string vault = 1; - string payer = 2; - string token_vault = 3; - string token_mint = 4; - string lp_mint = 5; - string rent = 6; - string token_program = 7; - string system_program = 8; -} - - -message EnableVaultIxAccounts { - string vault = 1; - string admin = 2; -} - -message EnableVaultIxData { - uint32 enabled = 1; -} - -message SetOperatorIxAccounts { - string vault = 1; - string operator = 2; - string admin = 3; -} - - -message InitializeStrategyIxAccounts { - string vault = 1; - string strategy_program = 2; - string strategy = 3; - string reserve = 4; - string collateral_vault = 5; - string collateral_mint = 6; - string admin = 7; - string system_program = 8; - string rent = 9; - string token_program = 10; -} - -message InitializeStrategyIxData { - uint32 strategy_index = 1; - repeated uint32 other_bumps = 2; - StrategyType strategy_type = 3; -} - -message RemoveStrategyIxAccounts { - string vault = 1; - string strategy = 2; - string strategy_program = 3; - string collateral_vault = 4; - string reserve = 5; - string token_vault = 6; - string fee_vault = 7; - string lp_mint = 8; - string token_program = 9; - string admin = 10; -} - - -message RemoveStrategy2IxAccounts { - string vault = 1; - string strategy = 2; - string strategy_program = 3; - string collateral_vault = 4; - string reserve = 5; - string token_vault = 6; - string token_admin_advance_payment = 7; - string token_vault_advance_payment = 8; - string fee_vault = 9; - string lp_mint = 10; - string token_program = 11; - string admin = 12; -} - -message RemoveStrategy2IxData { - uint64 max_admin_pay_amount = 1; -} - -message CollectDustIxAccounts { - string vault = 1; - string token_vault = 2; - string token_admin = 3; - string admin = 4; - string token_program = 5; -} - - -message AddStrategyIxAccounts { - string vault = 1; - string strategy = 2; - string admin = 3; -} - - -message DepositStrategyIxAccounts { - string vault = 1; - string strategy = 2; - string token_vault = 3; - string fee_vault = 4; - string lp_mint = 5; - string strategy_program = 6; - string collateral_vault = 7; - string reserve = 8; - string token_program = 9; - string operator = 10; -} - -message DepositStrategyIxData { - uint64 amount = 1; -} - -message WithdrawStrategyIxAccounts { - string vault = 1; - string strategy = 2; - string token_vault = 3; - string fee_vault = 4; - string lp_mint = 5; - string strategy_program = 6; - string collateral_vault = 7; - string reserve = 8; - string token_program = 9; - string operator = 10; -} - -message WithdrawStrategyIxData { - uint64 amount = 1; -} - -message Withdraw2IxAccounts { - string vault = 1; - string token_vault = 2; - string lp_mint = 3; - string user_token = 4; - string user_lp = 5; - string user = 6; - string token_program = 7; -} - -message Withdraw2IxData { - uint64 unmint_amount = 1; - uint64 min_out_amount = 2; -} - -message DepositIxAccounts { - string vault = 1; - string token_vault = 2; - string lp_mint = 3; - string user_token = 4; - string user_lp = 5; - string user = 6; - string token_program = 7; -} - -message DepositIxData { - uint64 token_amount = 1; - uint64 minimum_lp_token_amount = 2; -} - -message WithdrawIxAccounts { - string vault = 1; - string token_vault = 2; - string lp_mint = 3; - string user_token = 4; - string user_lp = 5; - string user = 6; - string token_program = 7; -} - -message WithdrawIxData { - uint64 unmint_amount = 1; - uint64 min_out_amount = 2; -} - -message WithdrawDirectlyFromStrategyIxAccounts { - string vault = 1; - string strategy = 2; - string reserve = 3; - string strategy_program = 4; - string collateral_vault = 5; - string token_vault = 6; - string lp_mint = 7; - string fee_vault = 8; - string user_token = 9; - string user_lp = 10; - string user = 11; - string token_program = 12; -} - -message WithdrawDirectlyFromStrategyIxData { - uint64 unmint_amount = 1; - uint64 min_out_amount = 2; -} - - -message ProgramState { - oneof state_oneof { - Vault vault = 1; - Strategy strategy = 2; - } -} - -message ProgramIxs { - oneof ix_oneof { - InitializeIx initialize = 1; - EnableVaultIx enable_vault = 2; - SetOperatorIx set_operator = 3; - InitializeStrategyIx initialize_strategy = 4; - RemoveStrategyIx remove_strategy = 5; - RemoveStrategy2Ix remove_strategy2 = 6; - CollectDustIx collect_dust = 7; - AddStrategyIx add_strategy = 8; - DepositStrategyIx deposit_strategy = 9; - WithdrawStrategyIx withdraw_strategy = 10; - Withdraw2Ix withdraw2 = 11; - DepositIx deposit = 12; - WithdrawIx withdraw = 13; - WithdrawDirectlyFromStrategyIx withdraw_directly_from_strategy = 14; - } -} - diff --git a/crates/meteora-vault-parser/src/generated_parser/accounts_parser.rs b/crates/meteora-vault-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index ab031bd4..00000000 --- a/crates/meteora-vault-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,172 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{Strategy, Vault}, - deserialize_checked, ID, -}; - -/// Vault Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum VaultProgramState { - Vault(Vault), - Strategy(Strategy), -} - -impl VaultProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [211, 8, 232, 43, 2, 152, 117, 119] => Ok(VaultProgramState::Vault( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [174, 110, 39, 119, 82, 106, 169, 102] => Ok(VaultProgramState::Strategy( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = VaultProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "vault::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = VaultProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, Vault, VaultProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for Vault { - fn into_proto(self) -> proto_def::Vault { - proto_def::Vault { - enabled: self.enabled.into(), - bumps: Some(self.bumps.into_proto()), - total_amount: self.total_amount, - token_vault: self.token_vault.to_string(), - fee_vault: self.fee_vault.to_string(), - token_mint: self.token_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - strategies: self.strategies.into_iter().map(|x| x.to_string()).collect(), - base: self.base.to_string(), - admin: self.admin.to_string(), - operator: self.operator.to_string(), - locked_profit_tracker: Some(self.locked_profit_tracker.into_proto()), - } - } - } - use super::Strategy; - impl IntoProto for Strategy { - fn into_proto(self) -> proto_def::Strategy { - proto_def::Strategy { - reserve: self.reserve.to_string(), - collateral_vault: self.collateral_vault.to_string(), - strategy_type: self.strategy_type as i32, - current_liquidity: self.current_liquidity, - bumps: self.bumps.into_iter().map(|x| x.into()).collect(), - vault: self.vault.to_string(), - is_disable: self.is_disable.into(), - } - } - } - - impl IntoProto for VaultProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - VaultProgramState::Vault(data) => { - proto_def::program_state::StateOneof::Vault(data.into_proto()) - }, - VaultProgramState::Strategy(data) => { - proto_def::program_state::StateOneof::Strategy(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/meteora-vault-parser/src/generated_parser/instructions_parser.rs b/crates/meteora-vault-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index 072cf5f2..00000000 --- a/crates/meteora-vault-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,859 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - AddStrategy as AddStrategyIxAccounts, CollectDust as CollectDustIxAccounts, - Deposit as DepositIxAccounts, DepositInstructionArgs as DepositIxData, - DepositStrategy as DepositStrategyIxAccounts, - DepositStrategyInstructionArgs as DepositStrategyIxData, - EnableVault as EnableVaultIxAccounts, EnableVaultInstructionArgs as EnableVaultIxData, - Initialize as InitializeIxAccounts, InitializeStrategy as InitializeStrategyIxAccounts, - InitializeStrategyInstructionArgs as InitializeStrategyIxData, - RemoveStrategy as RemoveStrategyIxAccounts, RemoveStrategy2 as RemoveStrategy2IxAccounts, - RemoveStrategy2InstructionArgs as RemoveStrategy2IxData, - SetOperator as SetOperatorIxAccounts, Withdraw as WithdrawIxAccounts, - Withdraw2 as Withdraw2IxAccounts, Withdraw2InstructionArgs as Withdraw2IxData, - WithdrawDirectlyFromStrategy as WithdrawDirectlyFromStrategyIxAccounts, - WithdrawDirectlyFromStrategyInstructionArgs as WithdrawDirectlyFromStrategyIxData, - WithdrawInstructionArgs as WithdrawIxData, WithdrawStrategy as WithdrawStrategyIxAccounts, - WithdrawStrategyInstructionArgs as WithdrawStrategyIxData, - }, - ID, -}; - -/// Vault Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum VaultProgramIx { - Initialize(InitializeIxAccounts), - EnableVault(EnableVaultIxAccounts, EnableVaultIxData), - SetOperator(SetOperatorIxAccounts), - InitializeStrategy(InitializeStrategyIxAccounts, InitializeStrategyIxData), - RemoveStrategy(RemoveStrategyIxAccounts), - RemoveStrategy2(RemoveStrategy2IxAccounts, RemoveStrategy2IxData), - CollectDust(CollectDustIxAccounts), - AddStrategy(AddStrategyIxAccounts), - DepositStrategy(DepositStrategyIxAccounts, DepositStrategyIxData), - WithdrawStrategy(WithdrawStrategyIxAccounts, WithdrawStrategyIxData), - Withdraw2(Withdraw2IxAccounts, Withdraw2IxData), - Deposit(DepositIxAccounts, DepositIxData), - Withdraw(WithdrawIxAccounts, WithdrawIxData), - WithdrawDirectlyFromStrategy( - WithdrawDirectlyFromStrategyIxAccounts, - WithdrawDirectlyFromStrategyIxData, - ), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = VaultProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "Vault::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [175, 175, 109, 31, 13, 152, 155, 237] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeIxAccounts { - vault: next_account(accounts)?, - payer: next_account(accounts)?, - token_vault: next_account(accounts)?, - token_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - rent: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(VaultProgramIx::Initialize(ix_accounts)) - }, - [145, 82, 241, 156, 26, 154, 233, 211] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = EnableVaultIxAccounts { - vault: next_account(accounts)?, - admin: next_account(accounts)?, - }; - let de_ix_data: EnableVaultIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VaultProgramIx::EnableVault(ix_accounts, de_ix_data)) - }, - [238, 153, 101, 169, 243, 131, 36, 1] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetOperatorIxAccounts { - vault: next_account(accounts)?, - operator: next_account(accounts)?, - admin: next_account(accounts)?, - }; - Ok(VaultProgramIx::SetOperator(ix_accounts)) - }, - [208, 119, 144, 145, 178, 57, 105, 252] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeStrategyIxAccounts { - vault: next_account(accounts)?, - strategy_program: next_account(accounts)?, - strategy: next_account(accounts)?, - reserve: next_account(accounts)?, - collateral_vault: next_account(accounts)?, - collateral_mint: next_account(accounts)?, - admin: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: InitializeStrategyIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VaultProgramIx::InitializeStrategy(ix_accounts, de_ix_data)) - }, - [185, 238, 33, 91, 134, 210, 97, 26] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveStrategyIxAccounts { - vault: next_account(accounts)?, - strategy: next_account(accounts)?, - strategy_program: next_account(accounts)?, - collateral_vault: next_account(accounts)?, - reserve: next_account(accounts)?, - token_vault: next_account(accounts)?, - fee_vault: next_account(accounts)?, - lp_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - admin: next_account(accounts)?, - }; - Ok(VaultProgramIx::RemoveStrategy(ix_accounts)) - }, - [138, 104, 208, 148, 126, 35, 195, 14] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemoveStrategy2IxAccounts { - vault: next_account(accounts)?, - strategy: next_account(accounts)?, - strategy_program: next_account(accounts)?, - collateral_vault: next_account(accounts)?, - reserve: next_account(accounts)?, - token_vault: next_account(accounts)?, - token_admin_advance_payment: next_account(accounts)?, - token_vault_advance_payment: next_account(accounts)?, - fee_vault: next_account(accounts)?, - lp_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - admin: next_account(accounts)?, - }; - let de_ix_data: RemoveStrategy2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VaultProgramIx::RemoveStrategy2(ix_accounts, de_ix_data)) - }, - [246, 149, 21, 82, 160, 74, 254, 240] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectDustIxAccounts { - vault: next_account(accounts)?, - token_vault: next_account(accounts)?, - token_admin: next_account(accounts)?, - admin: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(VaultProgramIx::CollectDust(ix_accounts)) - }, - [64, 123, 127, 227, 192, 234, 198, 20] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AddStrategyIxAccounts { - vault: next_account(accounts)?, - strategy: next_account(accounts)?, - admin: next_account(accounts)?, - }; - Ok(VaultProgramIx::AddStrategy(ix_accounts)) - }, - [246, 82, 57, 226, 131, 222, 253, 249] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DepositStrategyIxAccounts { - vault: next_account(accounts)?, - strategy: next_account(accounts)?, - token_vault: next_account(accounts)?, - fee_vault: next_account(accounts)?, - lp_mint: next_account(accounts)?, - strategy_program: next_account(accounts)?, - collateral_vault: next_account(accounts)?, - reserve: next_account(accounts)?, - token_program: next_account(accounts)?, - operator: next_account(accounts)?, - }; - let de_ix_data: DepositStrategyIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VaultProgramIx::DepositStrategy(ix_accounts, de_ix_data)) - }, - [31, 45, 162, 5, 193, 217, 134, 188] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawStrategyIxAccounts { - vault: next_account(accounts)?, - strategy: next_account(accounts)?, - token_vault: next_account(accounts)?, - fee_vault: next_account(accounts)?, - lp_mint: next_account(accounts)?, - strategy_program: next_account(accounts)?, - collateral_vault: next_account(accounts)?, - reserve: next_account(accounts)?, - token_program: next_account(accounts)?, - operator: next_account(accounts)?, - }; - let de_ix_data: WithdrawStrategyIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VaultProgramIx::WithdrawStrategy(ix_accounts, de_ix_data)) - }, - [80, 6, 111, 73, 174, 211, 66, 132] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = Withdraw2IxAccounts { - vault: next_account(accounts)?, - token_vault: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_token: next_account(accounts)?, - user_lp: next_account(accounts)?, - user: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: Withdraw2IxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VaultProgramIx::Withdraw2(ix_accounts, de_ix_data)) - }, - [242, 35, 198, 137, 82, 225, 242, 182] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DepositIxAccounts { - vault: next_account(accounts)?, - token_vault: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_token: next_account(accounts)?, - user_lp: next_account(accounts)?, - user: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: DepositIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VaultProgramIx::Deposit(ix_accounts, de_ix_data)) - }, - [183, 18, 70, 156, 148, 109, 161, 34] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawIxAccounts { - vault: next_account(accounts)?, - token_vault: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_token: next_account(accounts)?, - user_lp: next_account(accounts)?, - user: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: WithdrawIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VaultProgramIx::Withdraw(ix_accounts, de_ix_data)) - }, - [201, 141, 146, 46, 173, 116, 198, 22] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawDirectlyFromStrategyIxAccounts { - vault: next_account(accounts)?, - strategy: next_account(accounts)?, - reserve: next_account(accounts)?, - strategy_program: next_account(accounts)?, - collateral_vault: next_account(accounts)?, - token_vault: next_account(accounts)?, - lp_mint: next_account(accounts)?, - fee_vault: next_account(accounts)?, - user_token: next_account(accounts)?, - user_lp: next_account(accounts)?, - user: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: WithdrawDirectlyFromStrategyIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VaultProgramIx::WithdrawDirectlyFromStrategy( - ix_accounts, - de_ix_data, - )) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{InitializeIxAccounts, InstructionParser, VaultProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for InitializeIxAccounts { - fn into_proto(self) -> proto_def::InitializeIxAccounts { - proto_def::InitializeIxAccounts { - vault: self.vault.to_string(), - payer: self.payer.to_string(), - token_vault: self.token_vault.to_string(), - token_mint: self.token_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - rent: self.rent.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::EnableVaultIxAccounts; - impl IntoProto for EnableVaultIxAccounts { - fn into_proto(self) -> proto_def::EnableVaultIxAccounts { - proto_def::EnableVaultIxAccounts { - vault: self.vault.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::EnableVaultIxData; - impl IntoProto for EnableVaultIxData { - fn into_proto(self) -> proto_def::EnableVaultIxData { - proto_def::EnableVaultIxData { - enabled: self.enabled.into(), - } - } - } - use super::SetOperatorIxAccounts; - impl IntoProto for SetOperatorIxAccounts { - fn into_proto(self) -> proto_def::SetOperatorIxAccounts { - proto_def::SetOperatorIxAccounts { - vault: self.vault.to_string(), - operator: self.operator.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::InitializeStrategyIxAccounts; - impl IntoProto for InitializeStrategyIxAccounts { - fn into_proto(self) -> proto_def::InitializeStrategyIxAccounts { - proto_def::InitializeStrategyIxAccounts { - vault: self.vault.to_string(), - strategy_program: self.strategy_program.to_string(), - strategy: self.strategy.to_string(), - reserve: self.reserve.to_string(), - collateral_vault: self.collateral_vault.to_string(), - collateral_mint: self.collateral_mint.to_string(), - admin: self.admin.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::InitializeStrategyIxData; - impl IntoProto for InitializeStrategyIxData { - fn into_proto(self) -> proto_def::InitializeStrategyIxData { - proto_def::InitializeStrategyIxData { - strategy_index: self.strategy_index.into(), - other_bumps: self.other_bumps.into_iter().map(|x| x.into()).collect(), - strategy_type: self.strategy_type as i32, - } - } - } - use super::RemoveStrategyIxAccounts; - impl IntoProto for RemoveStrategyIxAccounts { - fn into_proto(self) -> proto_def::RemoveStrategyIxAccounts { - proto_def::RemoveStrategyIxAccounts { - vault: self.vault.to_string(), - strategy: self.strategy.to_string(), - strategy_program: self.strategy_program.to_string(), - collateral_vault: self.collateral_vault.to_string(), - reserve: self.reserve.to_string(), - token_vault: self.token_vault.to_string(), - fee_vault: self.fee_vault.to_string(), - lp_mint: self.lp_mint.to_string(), - token_program: self.token_program.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::RemoveStrategy2IxAccounts; - impl IntoProto for RemoveStrategy2IxAccounts { - fn into_proto(self) -> proto_def::RemoveStrategy2IxAccounts { - proto_def::RemoveStrategy2IxAccounts { - vault: self.vault.to_string(), - strategy: self.strategy.to_string(), - strategy_program: self.strategy_program.to_string(), - collateral_vault: self.collateral_vault.to_string(), - reserve: self.reserve.to_string(), - token_vault: self.token_vault.to_string(), - token_admin_advance_payment: self.token_admin_advance_payment.to_string(), - token_vault_advance_payment: self.token_vault_advance_payment.to_string(), - fee_vault: self.fee_vault.to_string(), - lp_mint: self.lp_mint.to_string(), - token_program: self.token_program.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::RemoveStrategy2IxData; - impl IntoProto for RemoveStrategy2IxData { - fn into_proto(self) -> proto_def::RemoveStrategy2IxData { - proto_def::RemoveStrategy2IxData { - max_admin_pay_amount: self.max_admin_pay_amount, - } - } - } - use super::CollectDustIxAccounts; - impl IntoProto for CollectDustIxAccounts { - fn into_proto(self) -> proto_def::CollectDustIxAccounts { - proto_def::CollectDustIxAccounts { - vault: self.vault.to_string(), - token_vault: self.token_vault.to_string(), - token_admin: self.token_admin.to_string(), - admin: self.admin.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::AddStrategyIxAccounts; - impl IntoProto for AddStrategyIxAccounts { - fn into_proto(self) -> proto_def::AddStrategyIxAccounts { - proto_def::AddStrategyIxAccounts { - vault: self.vault.to_string(), - strategy: self.strategy.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::DepositStrategyIxAccounts; - impl IntoProto for DepositStrategyIxAccounts { - fn into_proto(self) -> proto_def::DepositStrategyIxAccounts { - proto_def::DepositStrategyIxAccounts { - vault: self.vault.to_string(), - strategy: self.strategy.to_string(), - token_vault: self.token_vault.to_string(), - fee_vault: self.fee_vault.to_string(), - lp_mint: self.lp_mint.to_string(), - strategy_program: self.strategy_program.to_string(), - collateral_vault: self.collateral_vault.to_string(), - reserve: self.reserve.to_string(), - token_program: self.token_program.to_string(), - operator: self.operator.to_string(), - } - } - } - use super::DepositStrategyIxData; - impl IntoProto for DepositStrategyIxData { - fn into_proto(self) -> proto_def::DepositStrategyIxData { - proto_def::DepositStrategyIxData { - amount: self.amount, - } - } - } - use super::WithdrawStrategyIxAccounts; - impl IntoProto for WithdrawStrategyIxAccounts { - fn into_proto(self) -> proto_def::WithdrawStrategyIxAccounts { - proto_def::WithdrawStrategyIxAccounts { - vault: self.vault.to_string(), - strategy: self.strategy.to_string(), - token_vault: self.token_vault.to_string(), - fee_vault: self.fee_vault.to_string(), - lp_mint: self.lp_mint.to_string(), - strategy_program: self.strategy_program.to_string(), - collateral_vault: self.collateral_vault.to_string(), - reserve: self.reserve.to_string(), - token_program: self.token_program.to_string(), - operator: self.operator.to_string(), - } - } - } - use super::WithdrawStrategyIxData; - impl IntoProto for WithdrawStrategyIxData { - fn into_proto(self) -> proto_def::WithdrawStrategyIxData { - proto_def::WithdrawStrategyIxData { - amount: self.amount, - } - } - } - use super::Withdraw2IxAccounts; - impl IntoProto for Withdraw2IxAccounts { - fn into_proto(self) -> proto_def::Withdraw2IxAccounts { - proto_def::Withdraw2IxAccounts { - vault: self.vault.to_string(), - token_vault: self.token_vault.to_string(), - lp_mint: self.lp_mint.to_string(), - user_token: self.user_token.to_string(), - user_lp: self.user_lp.to_string(), - user: self.user.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::Withdraw2IxData; - impl IntoProto for Withdraw2IxData { - fn into_proto(self) -> proto_def::Withdraw2IxData { - proto_def::Withdraw2IxData { - unmint_amount: self.unmint_amount, - min_out_amount: self.min_out_amount, - } - } - } - use super::DepositIxAccounts; - impl IntoProto for DepositIxAccounts { - fn into_proto(self) -> proto_def::DepositIxAccounts { - proto_def::DepositIxAccounts { - vault: self.vault.to_string(), - token_vault: self.token_vault.to_string(), - lp_mint: self.lp_mint.to_string(), - user_token: self.user_token.to_string(), - user_lp: self.user_lp.to_string(), - user: self.user.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::DepositIxData; - impl IntoProto for DepositIxData { - fn into_proto(self) -> proto_def::DepositIxData { - proto_def::DepositIxData { - token_amount: self.token_amount, - minimum_lp_token_amount: self.minimum_lp_token_amount, - } - } - } - use super::WithdrawIxAccounts; - impl IntoProto for WithdrawIxAccounts { - fn into_proto(self) -> proto_def::WithdrawIxAccounts { - proto_def::WithdrawIxAccounts { - vault: self.vault.to_string(), - token_vault: self.token_vault.to_string(), - lp_mint: self.lp_mint.to_string(), - user_token: self.user_token.to_string(), - user_lp: self.user_lp.to_string(), - user: self.user.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::WithdrawIxData; - impl IntoProto for WithdrawIxData { - fn into_proto(self) -> proto_def::WithdrawIxData { - proto_def::WithdrawIxData { - unmint_amount: self.unmint_amount, - min_out_amount: self.min_out_amount, - } - } - } - use super::WithdrawDirectlyFromStrategyIxAccounts; - impl IntoProto - for WithdrawDirectlyFromStrategyIxAccounts - { - fn into_proto(self) -> proto_def::WithdrawDirectlyFromStrategyIxAccounts { - proto_def::WithdrawDirectlyFromStrategyIxAccounts { - vault: self.vault.to_string(), - strategy: self.strategy.to_string(), - reserve: self.reserve.to_string(), - strategy_program: self.strategy_program.to_string(), - collateral_vault: self.collateral_vault.to_string(), - token_vault: self.token_vault.to_string(), - lp_mint: self.lp_mint.to_string(), - fee_vault: self.fee_vault.to_string(), - user_token: self.user_token.to_string(), - user_lp: self.user_lp.to_string(), - user: self.user.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::WithdrawDirectlyFromStrategyIxData; - impl IntoProto - for WithdrawDirectlyFromStrategyIxData - { - fn into_proto(self) -> proto_def::WithdrawDirectlyFromStrategyIxData { - proto_def::WithdrawDirectlyFromStrategyIxData { - unmint_amount: self.unmint_amount, - min_out_amount: self.min_out_amount, - } - } - } - - impl IntoProto for VaultProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - VaultProgramIx::Initialize(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Initialize( - proto_def::InitializeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - VaultProgramIx::EnableVault(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::EnableVault( - proto_def::EnableVaultIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - VaultProgramIx::SetOperator(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetOperator( - proto_def::SetOperatorIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - VaultProgramIx::InitializeStrategy(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeStrategy( - proto_def::InitializeStrategyIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - VaultProgramIx::RemoveStrategy(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveStrategy( - proto_def::RemoveStrategyIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - VaultProgramIx::RemoveStrategy2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemoveStrategy2( - proto_def::RemoveStrategy2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - VaultProgramIx::CollectDust(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectDust( - proto_def::CollectDustIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - VaultProgramIx::AddStrategy(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AddStrategy( - proto_def::AddStrategyIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - VaultProgramIx::DepositStrategy(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::DepositStrategy( - proto_def::DepositStrategyIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - VaultProgramIx::WithdrawStrategy(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::WithdrawStrategy( - proto_def::WithdrawStrategyIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - VaultProgramIx::Withdraw2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Withdraw2( - proto_def::Withdraw2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - VaultProgramIx::Deposit(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Deposit( - proto_def::DepositIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - VaultProgramIx::Withdraw(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Withdraw( - proto_def::WithdrawIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - VaultProgramIx::WithdrawDirectlyFromStrategy(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::WithdrawDirectlyFromStrategy( - proto_def::WithdrawDirectlyFromStrategyIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/meteora-vault-parser/src/generated_parser/mod.rs b/crates/meteora-vault-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/meteora-vault-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/meteora-vault-parser/src/generated_parser/proto_helpers.rs b/crates/meteora-vault-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index 42620a6c..00000000 --- a/crates/meteora-vault-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::VaultBumps}; - impl IntoProto for VaultBumps { - fn into_proto(self) -> proto_def::VaultBumps { - proto_def::VaultBumps { - vault_bump: self.vault_bump.into(), - token_vault_bump: self.token_vault_bump.into(), - } - } - } - use crate::types::LockedProfitTracker; - impl IntoProto for LockedProfitTracker { - fn into_proto(self) -> proto_def::LockedProfitTracker { - proto_def::LockedProfitTracker { - last_updated_locked_profit: self.last_updated_locked_profit, - last_report: self.last_report, - locked_profit_degradation: self.locked_profit_degradation, - } - } - } -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/accounts/mod.rs b/crates/meteora-vault-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index 15363490..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#strategy; -pub(crate) mod r#vault; - -pub use self::{r#strategy::*, r#vault::*}; diff --git a/crates/meteora-vault-parser/src/generated_sdk/accounts/strategy.rs b/crates/meteora-vault-parser/src/generated_sdk/accounts/strategy.rs deleted file mode 100644 index e0891bfd..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/accounts/strategy.rs +++ /dev/null @@ -1,157 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::StrategyType; - -/// Strategy struct - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Strategy { - pub discriminator: [u8; 8], - /// Lending pool address, that the strategy will deposit/withdraw balance - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub reserve: Pubkey, - /// The token account, that holds the collateral token - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub collateral_vault: Pubkey, - /// Specify type of strategy - pub strategy_type: StrategyType, - /// The liquidity in strategy at the time vault deposit/withdraw from a lending protocol - pub current_liquidity: u64, - /// Hold some bumps, in case the strategy needs to use other seeds to sign a CPI call. - pub bumps: [u8; 10], - /// Vault address, that the strategy belongs - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vault: Pubkey, - /// If we remove strategy by remove_strategy2 endpoint, this account will be never added again - pub is_disable: u8, -} - -impl Strategy { - pub const LEN: usize = 124; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Strategy { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_strategy( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_strategy(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_strategy( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Strategy::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_strategy( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_strategy(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_strategy( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Strategy::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Strategy { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Strategy {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Strategy { - fn owner() -> Pubkey { crate::VAULT_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Strategy {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Strategy { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/accounts/vault.rs b/crates/meteora-vault-parser/src/generated_sdk/accounts/vault.rs deleted file mode 100644 index f934208e..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/accounts/vault.rs +++ /dev/null @@ -1,183 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{LockedProfitTracker, VaultBumps}; - -/// Vault struct - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Vault { - pub discriminator: [u8; 8], - /// The flag, if admin set enable = false, then the user can only withdraw and cannot deposit in the vault. - pub enabled: u8, - /// Vault nonce, to create vault seeds - pub bumps: VaultBumps, - /// The total liquidity of the vault, including remaining tokens in token_vault and the liquidity in all strategies. - pub total_amount: u64, - /// Token account, hold liquidity in vault reserve - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_vault: Pubkey, - /// Hold lp token of vault, each time rebalance crank is called, vault calculate performance fee and mint corresponding lp token amount to fee_vault. fee_vault is owned by treasury address - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_vault: Pubkey, - /// Token mint that vault supports - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_mint: Pubkey, - /// Lp mint of vault - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lp_mint: Pubkey, - /// The list of strategy addresses that vault supports, vault can support up to MAX_STRATEGY strategies at the same time. - pub strategies: [Pubkey; 30], - /// The base address to create vault seeds - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base: Pubkey, - /// Admin of vault - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub admin: Pubkey, - /// Person who can send the crank. Operator can only send liquidity to strategies that admin defined, and claim reward to account of treasury address - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub operator: Pubkey, - /// Stores information for locked profit. - pub locked_profit_tracker: LockedProfitTracker, -} - -impl Vault { - pub const LEN: usize = 1227; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Vault { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_vault( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_vault(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_vault( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Vault::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_vault( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_vault(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_vault( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Vault::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Vault { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Vault {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Vault { - fn owner() -> Pubkey { crate::VAULT_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Vault {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Vault { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/errors/mod.rs b/crates/meteora-vault-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 86c3677b..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod vault; - -pub use self::vault::VaultError; diff --git a/crates/meteora-vault-parser/src/generated_sdk/errors/vault.rs b/crates/meteora-vault-parser/src/generated_sdk/errors/vault.rs deleted file mode 100644 index 58dc2c0d..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/errors/vault.rs +++ /dev/null @@ -1,85 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum VaultError { - /// 6000 - Vault is disabled - #[error("Vault is disabled")] - VaultIsDisabled = 0x1770, - /// 6001 - Exceeded slippage tolerance - #[error("Exceeded slippage tolerance")] - ExceededSlippage = 0x1771, - /// 6002 - Strategy is not existed - #[error("Strategy is not existed")] - StrategyIsNotExisted = 0x1772, - /// 6003 - UnAuthorized - #[error("UnAuthorized")] - UnAuthorized = 0x1773, - /// 6004 - Math operation overflow - #[error("Math operation overflow")] - MathOverflow = 0x1774, - /// 6005 - Protocol is not supported - #[error("Protocol is not supported")] - ProtocolIsNotSupported = 0x1775, - /// 6006 - Reserve does not support token mint - #[error("Reserve does not support token mint")] - UnMatchReserve = 0x1776, - /// 6007 - lockedProfitDegradation is invalid - #[error("lockedProfitDegradation is invalid")] - InvalidLockedProfitDegradation = 0x1777, - /// 6008 - Maximum number of strategies have been reached - #[error("Maximum number of strategies have been reached")] - MaxStrategyReached = 0x1778, - /// 6009 - Strategy existed - #[error("Strategy existed")] - StrategyExisted = 0x1779, - /// 6010 - Invalid unmint amount - #[error("Invalid unmint amount")] - InvalidUnmintAmount = 0x177a, - /// 6011 - Invalid accounts for strategy - #[error("Invalid accounts for strategy")] - InvalidAccountsForStrategy = 0x177b, - /// 6012 - Invalid bump - #[error("Invalid bump")] - InvalidBump = 0x177c, - /// 6013 - Amount must be greater than 0 - #[error("Amount must be greater than 0")] - AmountMustGreaterThanZero = 0x177d, - /// 6014 - Mango is not supported anymore - #[error("Mango is not supported anymore")] - MangoIsNotSupportedAnymore = 0x177e, - /// 6015 - Strategy is not supported - #[error("Strategy is not supported")] - StrategyIsNotSupported = 0x177f, - /// 6016 - Pay amount is exceeded - #[error("Pay amount is exceeded")] - PayAmountIsExeeced = 0x1780, - /// 6017 - Fee vault is not set - #[error("Fee vault is not set")] - FeeVaultIsNotSet = 0x1781, - /// 6018 - deposit amount in lending is not matched - #[error("deposit amount in lending is not matched")] - LendingAssertionViolation = 0x1782, - /// 6019 - Cannot remove strategy becase we have some in lending - #[error("Cannot remove strategy becase we have some in lending")] - HaveMoneyInLending = 0x1783, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for VaultError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for VaultError { - fn type_of() -> &'static str { "VaultError" } -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/add_strategy.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/add_strategy.rs deleted file mode 100644 index 69727e68..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/add_strategy.rs +++ /dev/null @@ -1,350 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct AddStrategy { - /// vault - pub vault: solana_pubkey::Pubkey, - /// strategy - pub strategy: solana_pubkey::Pubkey, - /// admin - pub admin: solana_pubkey::Pubkey, -} - -impl AddStrategy { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.strategy, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&AddStrategyInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AddStrategyInstructionData { - discriminator: [u8; 8], -} - -impl AddStrategyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [64, 123, 127, 227, 192, 234, 198, 20], - } - } -} - -impl Default for AddStrategyInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `AddStrategy`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[]` strategy -/// 2. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct AddStrategyBuilder { - vault: Option, - strategy: Option, - admin: Option, - __remaining_accounts: Vec, -} - -impl AddStrategyBuilder { - pub fn new() -> Self { Self::default() } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// strategy - #[inline(always)] - pub fn strategy(&mut self, strategy: solana_pubkey::Pubkey) -> &mut Self { - self.strategy = Some(strategy); - self - } - - /// admin - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AddStrategy { - vault: self.vault.expect("vault is not set"), - strategy: self.strategy.expect("strategy is not set"), - admin: self.admin.expect("admin is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `add_strategy` CPI accounts. -pub struct AddStrategyCpiAccounts<'a, 'b> { - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// strategy - pub strategy: &'b solana_account_info::AccountInfo<'a>, - /// admin - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `add_strategy` CPI instruction. -pub struct AddStrategyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// strategy - pub strategy: &'b solana_account_info::AccountInfo<'a>, - /// admin - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> AddStrategyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AddStrategyCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - strategy: accounts.strategy, - admin: accounts.admin, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.strategy.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&AddStrategyInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.strategy.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AddStrategy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[]` strategy -/// 2. `[signer]` admin -#[derive(Clone, Debug)] -pub struct AddStrategyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AddStrategyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AddStrategyCpiBuilderInstruction { - __program: program, - vault: None, - strategy: None, - admin: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// strategy - #[inline(always)] - pub fn strategy(&mut self, strategy: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.strategy = Some(strategy); - self - } - - /// admin - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = AddStrategyCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - strategy: self.instruction.strategy.expect("strategy is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AddStrategyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/collect_dust.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/collect_dust.rs deleted file mode 100644 index 01d6ee5f..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/collect_dust.rs +++ /dev/null @@ -1,452 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CollectDust { - /// vault - pub vault: solana_pubkey::Pubkey, - /// Token vault, must be different from vault.token_vault - pub token_vault: solana_pubkey::Pubkey, - /// token admin, enforce owner is admin to avoid mistake - pub token_admin: solana_pubkey::Pubkey, - /// admin - pub admin: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, -} - -impl CollectDust { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_admin, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CollectDustInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectDustInstructionData { - discriminator: [u8; 8], -} - -impl CollectDustInstructionData { - pub fn new() -> Self { - Self { - discriminator: [246, 149, 21, 82, 160, 74, 254, 240], - } - } -} - -impl Default for CollectDustInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CollectDust`. -/// -/// ### Accounts: -/// -/// 0. `[]` vault -/// 1. `[writable]` token_vault -/// 2. `[writable]` token_admin -/// 3. `[signer]` admin -/// 4. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct CollectDustBuilder { - vault: Option, - token_vault: Option, - token_admin: Option, - admin: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl CollectDustBuilder { - pub fn new() -> Self { Self::default() } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// Token vault, must be different from vault.token_vault - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - /// token admin, enforce owner is admin to avoid mistake - #[inline(always)] - pub fn token_admin(&mut self, token_admin: solana_pubkey::Pubkey) -> &mut Self { - self.token_admin = Some(token_admin); - self - } - - /// admin - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectDust { - vault: self.vault.expect("vault is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - token_admin: self.token_admin.expect("token_admin is not set"), - admin: self.admin.expect("admin is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `collect_dust` CPI accounts. -pub struct CollectDustCpiAccounts<'a, 'b> { - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault, must be different from vault.token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// token admin, enforce owner is admin to avoid mistake - pub token_admin: &'b solana_account_info::AccountInfo<'a>, - /// admin - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_dust` CPI instruction. -pub struct CollectDustCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// Token vault, must be different from vault.token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// token admin, enforce owner is admin to avoid mistake - pub token_admin: &'b solana_account_info::AccountInfo<'a>, - /// admin - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CollectDustCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectDustCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - token_vault: accounts.token_vault, - token_admin: accounts.token_admin, - admin: accounts.admin, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_admin.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CollectDustInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.token_admin.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectDust` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` vault -/// 1. `[writable]` token_vault -/// 2. `[writable]` token_admin -/// 3. `[signer]` admin -/// 4. `[]` token_program -#[derive(Clone, Debug)] -pub struct CollectDustCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectDustCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectDustCpiBuilderInstruction { - __program: program, - vault: None, - token_vault: None, - token_admin: None, - admin: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// Token vault, must be different from vault.token_vault - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - /// token admin, enforce owner is admin to avoid mistake - #[inline(always)] - pub fn token_admin( - &mut self, - token_admin: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_admin = Some(token_admin); - self - } - - /// admin - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CollectDustCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - token_admin: self - .instruction - .token_admin - .expect("token_admin is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectDustCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_admin: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/deposit.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/deposit.rs deleted file mode 100644 index b28bf0c1..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/deposit.rs +++ /dev/null @@ -1,577 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Deposit { - /// vault - pub vault: solana_pubkey::Pubkey, - /// token_vault - pub token_vault: solana_pubkey::Pubkey, - /// lp_mint - pub lp_mint: solana_pubkey::Pubkey, - /// user_token - pub user_token: solana_pubkey::Pubkey, - /// user_lp - pub user_lp: solana_pubkey::Pubkey, - /// user - pub user: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, -} - -impl Deposit { - pub fn instruction(&self, args: DepositInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DepositInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new(self.user_token, false)); - accounts.push(solana_instruction::AccountMeta::new(self.user_lp, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DepositInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositInstructionData { - discriminator: [u8; 8], -} - -impl DepositInstructionData { - pub fn new() -> Self { - Self { - discriminator: [242, 35, 198, 137, 82, 225, 242, 182], - } - } -} - -impl Default for DepositInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositInstructionArgs { - pub token_amount: u64, - pub minimum_lp_token_amount: u64, -} - -/// Instruction builder for `Deposit`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` token_vault -/// 2. `[writable]` lp_mint -/// 3. `[writable]` user_token -/// 4. `[writable]` user_lp -/// 5. `[signer]` user -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct DepositBuilder { - vault: Option, - token_vault: Option, - lp_mint: Option, - user_token: Option, - user_lp: Option, - user: Option, - token_program: Option, - token_amount: Option, - minimum_lp_token_amount: Option, - __remaining_accounts: Vec, -} - -impl DepositBuilder { - pub fn new() -> Self { Self::default() } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// user_token - #[inline(always)] - pub fn user_token(&mut self, user_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_token = Some(user_token); - self - } - - /// user_lp - #[inline(always)] - pub fn user_lp(&mut self, user_lp: solana_pubkey::Pubkey) -> &mut Self { - self.user_lp = Some(user_lp); - self - } - - /// user - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_amount(&mut self, token_amount: u64) -> &mut Self { - self.token_amount = Some(token_amount); - self - } - - #[inline(always)] - pub fn minimum_lp_token_amount(&mut self, minimum_lp_token_amount: u64) -> &mut Self { - self.minimum_lp_token_amount = Some(minimum_lp_token_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Deposit { - vault: self.vault.expect("vault is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_token: self.user_token.expect("user_token is not set"), - user_lp: self.user_lp.expect("user_lp is not set"), - user: self.user.expect("user is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = DepositInstructionArgs { - token_amount: self.token_amount.clone().expect("token_amount is not set"), - minimum_lp_token_amount: self - .minimum_lp_token_amount - .clone() - .expect("minimum_lp_token_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `deposit` CPI accounts. -pub struct DepositCpiAccounts<'a, 'b> { - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user_token - pub user_token: &'b solana_account_info::AccountInfo<'a>, - /// user_lp - pub user_lp: &'b solana_account_info::AccountInfo<'a>, - /// user - pub user: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `deposit` CPI instruction. -pub struct DepositCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user_token - pub user_token: &'b solana_account_info::AccountInfo<'a>, - /// user_lp - pub user_lp: &'b solana_account_info::AccountInfo<'a>, - /// user - pub user: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DepositInstructionArgs, -} - -impl<'a, 'b> DepositCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DepositCpiAccounts<'a, 'b>, - args: DepositInstructionArgs, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - token_vault: accounts.token_vault, - lp_mint: accounts.lp_mint, - user_token: accounts.user_token, - user_lp: accounts.user_lp, - user: accounts.user, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DepositInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_token.clone()); - account_infos.push(self.user_lp.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Deposit` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` token_vault -/// 2. `[writable]` lp_mint -/// 3. `[writable]` user_token -/// 4. `[writable]` user_lp -/// 5. `[signer]` user -/// 6. `[]` token_program -#[derive(Clone, Debug)] -pub struct DepositCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DepositCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DepositCpiBuilderInstruction { - __program: program, - vault: None, - token_vault: None, - lp_mint: None, - user_token: None, - user_lp: None, - user: None, - token_program: None, - token_amount: None, - minimum_lp_token_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// user_token - #[inline(always)] - pub fn user_token( - &mut self, - user_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token = Some(user_token); - self - } - - /// user_lp - #[inline(always)] - pub fn user_lp(&mut self, user_lp: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user_lp = Some(user_lp); - self - } - - /// user - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_amount(&mut self, token_amount: u64) -> &mut Self { - self.instruction.token_amount = Some(token_amount); - self - } - - #[inline(always)] - pub fn minimum_lp_token_amount(&mut self, minimum_lp_token_amount: u64) -> &mut Self { - self.instruction.minimum_lp_token_amount = Some(minimum_lp_token_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DepositInstructionArgs { - token_amount: self - .instruction - .token_amount - .clone() - .expect("token_amount is not set"), - minimum_lp_token_amount: self - .instruction - .minimum_lp_token_amount - .clone() - .expect("minimum_lp_token_amount is not set"), - }; - let instruction = DepositCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_token: self.instruction.user_token.expect("user_token is not set"), - - user_lp: self.instruction.user_lp.expect("user_lp is not set"), - - user: self.instruction.user.expect("user is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DepositCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_amount: Option, - minimum_lp_token_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/deposit_strategy.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/deposit_strategy.rs deleted file mode 100644 index b6e8fea9..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/deposit_strategy.rs +++ /dev/null @@ -1,668 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct DepositStrategy { - /// vault - pub vault: solana_pubkey::Pubkey, - /// strategy - pub strategy: solana_pubkey::Pubkey, - /// token_vault - pub token_vault: solana_pubkey::Pubkey, - /// fee_vault - pub fee_vault: solana_pubkey::Pubkey, - /// lp_mint - pub lp_mint: solana_pubkey::Pubkey, - - pub strategy_program: solana_pubkey::Pubkey, - /// collateral_vault - pub collateral_vault: solana_pubkey::Pubkey, - - pub reserve: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, - /// operator - pub operator: solana_pubkey::Pubkey, -} - -impl DepositStrategy { - pub fn instruction( - &self, - args: DepositStrategyInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DepositStrategyInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.strategy, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.fee_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.strategy_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.collateral_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DepositStrategyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositStrategyInstructionData { - discriminator: [u8; 8], -} - -impl DepositStrategyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [246, 82, 57, 226, 131, 222, 253, 249], - } - } -} - -impl Default for DepositStrategyInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositStrategyInstructionArgs { - pub amount: u64, -} - -/// Instruction builder for `DepositStrategy`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` strategy -/// 2. `[writable]` token_vault -/// 3. `[writable]` fee_vault -/// 4. `[writable]` lp_mint -/// 5. `[]` strategy_program -/// 6. `[writable]` collateral_vault -/// 7. `[writable]` reserve -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[signer]` operator -#[derive(Clone, Debug, Default)] -pub struct DepositStrategyBuilder { - vault: Option, - strategy: Option, - token_vault: Option, - fee_vault: Option, - lp_mint: Option, - strategy_program: Option, - collateral_vault: Option, - reserve: Option, - token_program: Option, - operator: Option, - amount: Option, - __remaining_accounts: Vec, -} - -impl DepositStrategyBuilder { - pub fn new() -> Self { Self::default() } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// strategy - #[inline(always)] - pub fn strategy(&mut self, strategy: solana_pubkey::Pubkey) -> &mut Self { - self.strategy = Some(strategy); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - /// fee_vault - #[inline(always)] - pub fn fee_vault(&mut self, fee_vault: solana_pubkey::Pubkey) -> &mut Self { - self.fee_vault = Some(fee_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn strategy_program(&mut self, strategy_program: solana_pubkey::Pubkey) -> &mut Self { - self.strategy_program = Some(strategy_program); - self - } - - /// collateral_vault - #[inline(always)] - pub fn collateral_vault(&mut self, collateral_vault: solana_pubkey::Pubkey) -> &mut Self { - self.collateral_vault = Some(collateral_vault); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self { - self.reserve = Some(reserve); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// operator - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = DepositStrategy { - vault: self.vault.expect("vault is not set"), - strategy: self.strategy.expect("strategy is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - fee_vault: self.fee_vault.expect("fee_vault is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - strategy_program: self.strategy_program.expect("strategy_program is not set"), - collateral_vault: self.collateral_vault.expect("collateral_vault is not set"), - reserve: self.reserve.expect("reserve is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - operator: self.operator.expect("operator is not set"), - }; - let args = DepositStrategyInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `deposit_strategy` CPI accounts. -pub struct DepositStrategyCpiAccounts<'a, 'b> { - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// strategy - pub strategy: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// fee_vault - pub fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// collateral_vault - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// operator - pub operator: &'b solana_account_info::AccountInfo<'a>, -} - -/// `deposit_strategy` CPI instruction. -pub struct DepositStrategyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// strategy - pub strategy: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// fee_vault - pub fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// collateral_vault - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// operator - pub operator: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DepositStrategyInstructionArgs, -} - -impl<'a, 'b> DepositStrategyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DepositStrategyCpiAccounts<'a, 'b>, - args: DepositStrategyInstructionArgs, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - strategy: accounts.strategy, - token_vault: accounts.token_vault, - fee_vault: accounts.fee_vault, - lp_mint: accounts.lp_mint, - strategy_program: accounts.strategy_program, - collateral_vault: accounts.collateral_vault, - reserve: accounts.reserve, - token_program: accounts.token_program, - operator: accounts.operator, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.strategy.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.strategy_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.collateral_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DepositStrategyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.strategy.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.fee_vault.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.strategy_program.clone()); - account_infos.push(self.collateral_vault.clone()); - account_infos.push(self.reserve.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.operator.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `DepositStrategy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` strategy -/// 2. `[writable]` token_vault -/// 3. `[writable]` fee_vault -/// 4. `[writable]` lp_mint -/// 5. `[]` strategy_program -/// 6. `[writable]` collateral_vault -/// 7. `[writable]` reserve -/// 8. `[]` token_program -/// 9. `[signer]` operator -#[derive(Clone, Debug)] -pub struct DepositStrategyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DepositStrategyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DepositStrategyCpiBuilderInstruction { - __program: program, - vault: None, - strategy: None, - token_vault: None, - fee_vault: None, - lp_mint: None, - strategy_program: None, - collateral_vault: None, - reserve: None, - token_program: None, - operator: None, - amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// strategy - #[inline(always)] - pub fn strategy(&mut self, strategy: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.strategy = Some(strategy); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - /// fee_vault - #[inline(always)] - pub fn fee_vault(&mut self, fee_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_vault = Some(fee_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn strategy_program( - &mut self, - strategy_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.strategy_program = Some(strategy_program); - self - } - - /// collateral_vault - #[inline(always)] - pub fn collateral_vault( - &mut self, - collateral_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.collateral_vault = Some(collateral_vault); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve = Some(reserve); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// operator - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DepositStrategyInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - }; - let instruction = DepositStrategyCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - strategy: self.instruction.strategy.expect("strategy is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - fee_vault: self.instruction.fee_vault.expect("fee_vault is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - strategy_program: self - .instruction - .strategy_program - .expect("strategy_program is not set"), - - collateral_vault: self - .instruction - .collateral_vault - .expect("collateral_vault is not set"), - - reserve: self.instruction.reserve.expect("reserve is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DepositStrategyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy_program: Option<&'b solana_account_info::AccountInfo<'a>>, - collateral_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/enable_vault.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/enable_vault.rs deleted file mode 100644 index 926250f5..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/enable_vault.rs +++ /dev/null @@ -1,353 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct EnableVault { - /// Vault account - pub vault: solana_pubkey::Pubkey, - /// Admin account - pub admin: solana_pubkey::Pubkey, -} - -impl EnableVault { - pub fn instruction(&self, args: EnableVaultInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: EnableVaultInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&EnableVaultInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EnableVaultInstructionData { - discriminator: [u8; 8], -} - -impl EnableVaultInstructionData { - pub fn new() -> Self { - Self { - discriminator: [145, 82, 241, 156, 26, 154, 233, 211], - } - } -} - -impl Default for EnableVaultInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EnableVaultInstructionArgs { - pub enabled: u8, -} - -/// Instruction builder for `EnableVault`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct EnableVaultBuilder { - vault: Option, - admin: Option, - enabled: Option, - __remaining_accounts: Vec, -} - -impl EnableVaultBuilder { - pub fn new() -> Self { Self::default() } - - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// Admin account - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn enabled(&mut self, enabled: u8) -> &mut Self { - self.enabled = Some(enabled); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = EnableVault { - vault: self.vault.expect("vault is not set"), - admin: self.admin.expect("admin is not set"), - }; - let args = EnableVaultInstructionArgs { - enabled: self.enabled.clone().expect("enabled is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `enable_vault` CPI accounts. -pub struct EnableVaultCpiAccounts<'a, 'b> { - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// Admin account - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `enable_vault` CPI instruction. -pub struct EnableVaultCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// Admin account - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: EnableVaultInstructionArgs, -} - -impl<'a, 'b> EnableVaultCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: EnableVaultCpiAccounts<'a, 'b>, - args: EnableVaultInstructionArgs, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - admin: accounts.admin, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&EnableVaultInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `EnableVault` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[signer]` admin -#[derive(Clone, Debug)] -pub struct EnableVaultCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> EnableVaultCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(EnableVaultCpiBuilderInstruction { - __program: program, - vault: None, - admin: None, - enabled: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// Admin account - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn enabled(&mut self, enabled: u8) -> &mut Self { - self.instruction.enabled = Some(enabled); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = EnableVaultInstructionArgs { - enabled: self - .instruction - .enabled - .clone() - .expect("enabled is not set"), - }; - let instruction = EnableVaultCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct EnableVaultCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - enabled: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/initialize.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/initialize.rs deleted file mode 100644 index db7a7453..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/initialize.rs +++ /dev/null @@ -1,569 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Initialize { - /// This is base account for all vault - /// No need base key now because we only allow 1 vault per token now - /// Vault account - pub vault: solana_pubkey::Pubkey, - /// Payer can be anyone - pub payer: solana_pubkey::Pubkey, - /// Token vault account - pub token_vault: solana_pubkey::Pubkey, - /// Token mint account - pub token_mint: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - /// rent - pub rent: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, - /// system_program - pub system_program: solana_pubkey::Pubkey, -} - -impl Initialize { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionData { - discriminator: [u8; 8], -} - -impl InitializeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [175, 175, 109, 31, 13, 152, 155, 237], - } - } -} - -impl Default for InitializeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `Initialize`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable, signer]` payer -/// 2. `[writable]` token_vault -/// 3. `[]` token_mint -/// 4. `[writable]` lp_mint -/// 5. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeBuilder { - vault: Option, - payer: Option, - token_vault: Option, - token_mint: Option, - lp_mint: Option, - rent: Option, - token_program: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl InitializeBuilder { - pub fn new() -> Self { Self::default() } - - /// This is base account for all vault - /// No need base key now because we only allow 1 vault per token now - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// Payer can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// Token vault account - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - /// Token mint account - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// rent - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// system_program - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Initialize { - vault: self.vault.expect("vault is not set"), - payer: self.payer.expect("payer is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize` CPI accounts. -pub struct InitializeCpiAccounts<'a, 'b> { - /// This is base account for all vault - /// No need base key now because we only allow 1 vault per token now - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// Payer can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token mint account - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// rent - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// system_program - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize` CPI instruction. -pub struct InitializeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// This is base account for all vault - /// No need base key now because we only allow 1 vault per token now - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// Payer can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// Token vault account - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token mint account - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// rent - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// system_program - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - payer: accounts.payer, - token_vault: accounts.token_vault, - token_mint: accounts.token_mint, - lp_mint: accounts.lp_mint, - rent: accounts.rent, - token_program: accounts.token_program, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Initialize` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable, signer]` payer -/// 2. `[writable]` token_vault -/// 3. `[]` token_mint -/// 4. `[writable]` lp_mint -/// 5. `[]` rent -/// 6. `[]` token_program -/// 7. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCpiBuilderInstruction { - __program: program, - vault: None, - payer: None, - token_vault: None, - token_mint: None, - lp_mint: None, - rent: None, - token_program: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// This is base account for all vault - /// No need base key now because we only allow 1 vault per token now - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// Payer can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// Token vault account - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - /// Token mint account - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// rent - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// system_program - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializeCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/initialize_strategy.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/initialize_strategy.rs deleted file mode 100644 index f42ef2f2..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/initialize_strategy.rs +++ /dev/null @@ -1,735 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::StrategyType; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeStrategy { - /// Vault account - pub vault: solana_pubkey::Pubkey, - - pub strategy_program: solana_pubkey::Pubkey, - /// Strategy account - pub strategy: solana_pubkey::Pubkey, - - pub reserve: solana_pubkey::Pubkey, - /// Collateral vault account - pub collateral_vault: solana_pubkey::Pubkey, - /// Collateral mint account - pub collateral_mint: solana_pubkey::Pubkey, - /// Admin account - pub admin: solana_pubkey::Pubkey, - /// System program account - pub system_program: solana_pubkey::Pubkey, - /// Rent account - pub rent: solana_pubkey::Pubkey, - /// Token program account - pub token_program: solana_pubkey::Pubkey, -} - -impl InitializeStrategy { - pub fn instruction( - &self, - args: InitializeStrategyInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeStrategyInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.strategy_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.strategy, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.collateral_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.collateral_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeStrategyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeStrategyInstructionData { - discriminator: [u8; 8], -} - -impl InitializeStrategyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [208, 119, 144, 145, 178, 57, 105, 252], - } - } -} - -impl Default for InitializeStrategyInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeStrategyInstructionArgs { - pub strategy_index: u8, - pub other_bumps: [u8; 10], - pub strategy_type: StrategyType, -} - -/// Instruction builder for `InitializeStrategy`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[]` strategy_program -/// 2. `[writable]` strategy -/// 3. `[writable]` reserve -/// 4. `[writable]` collateral_vault -/// 5. `[]` collateral_mint -/// 6. `[writable, signer]` admin -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 8. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct InitializeStrategyBuilder { - vault: Option, - strategy_program: Option, - strategy: Option, - reserve: Option, - collateral_vault: Option, - collateral_mint: Option, - admin: Option, - system_program: Option, - rent: Option, - token_program: Option, - strategy_index: Option, - other_bumps: Option<[u8; 10]>, - strategy_type: Option, - __remaining_accounts: Vec, -} - -impl InitializeStrategyBuilder { - pub fn new() -> Self { Self::default() } - - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - #[inline(always)] - pub fn strategy_program(&mut self, strategy_program: solana_pubkey::Pubkey) -> &mut Self { - self.strategy_program = Some(strategy_program); - self - } - - /// Strategy account - #[inline(always)] - pub fn strategy(&mut self, strategy: solana_pubkey::Pubkey) -> &mut Self { - self.strategy = Some(strategy); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self { - self.reserve = Some(reserve); - self - } - - /// Collateral vault account - #[inline(always)] - pub fn collateral_vault(&mut self, collateral_vault: solana_pubkey::Pubkey) -> &mut Self { - self.collateral_vault = Some(collateral_vault); - self - } - - /// Collateral mint account - #[inline(always)] - pub fn collateral_mint(&mut self, collateral_mint: solana_pubkey::Pubkey) -> &mut Self { - self.collateral_mint = Some(collateral_mint); - self - } - - /// Admin account - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program account - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent account - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program account - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn strategy_index(&mut self, strategy_index: u8) -> &mut Self { - self.strategy_index = Some(strategy_index); - self - } - - #[inline(always)] - pub fn other_bumps(&mut self, other_bumps: [u8; 10]) -> &mut Self { - self.other_bumps = Some(other_bumps); - self - } - - #[inline(always)] - pub fn strategy_type(&mut self, strategy_type: StrategyType) -> &mut Self { - self.strategy_type = Some(strategy_type); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeStrategy { - vault: self.vault.expect("vault is not set"), - strategy_program: self.strategy_program.expect("strategy_program is not set"), - strategy: self.strategy.expect("strategy is not set"), - reserve: self.reserve.expect("reserve is not set"), - collateral_vault: self.collateral_vault.expect("collateral_vault is not set"), - collateral_mint: self.collateral_mint.expect("collateral_mint is not set"), - admin: self.admin.expect("admin is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = InitializeStrategyInstructionArgs { - strategy_index: self - .strategy_index - .clone() - .expect("strategy_index is not set"), - other_bumps: self.other_bumps.clone().expect("other_bumps is not set"), - strategy_type: self - .strategy_type - .clone() - .expect("strategy_type is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_strategy` CPI accounts. -pub struct InitializeStrategyCpiAccounts<'a, 'b> { - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// Strategy account - pub strategy: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - /// Collateral vault account - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - /// Collateral mint account - pub collateral_mint: &'b solana_account_info::AccountInfo<'a>, - /// Admin account - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// System program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Rent account - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// Token program account - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_strategy` CPI instruction. -pub struct InitializeStrategyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// Strategy account - pub strategy: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - /// Collateral vault account - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - /// Collateral mint account - pub collateral_mint: &'b solana_account_info::AccountInfo<'a>, - /// Admin account - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// System program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Rent account - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// Token program account - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeStrategyInstructionArgs, -} - -impl<'a, 'b> InitializeStrategyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeStrategyCpiAccounts<'a, 'b>, - args: InitializeStrategyInstructionArgs, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - strategy_program: accounts.strategy_program, - strategy: accounts.strategy, - reserve: accounts.reserve, - collateral_vault: accounts.collateral_vault, - collateral_mint: accounts.collateral_mint, - admin: accounts.admin, - system_program: accounts.system_program, - rent: accounts.rent, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.strategy_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.strategy.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.collateral_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.collateral_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeStrategyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.strategy_program.clone()); - account_infos.push(self.strategy.clone()); - account_infos.push(self.reserve.clone()); - account_infos.push(self.collateral_vault.clone()); - account_infos.push(self.collateral_mint.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeStrategy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[]` strategy_program -/// 2. `[writable]` strategy -/// 3. `[writable]` reserve -/// 4. `[writable]` collateral_vault -/// 5. `[]` collateral_mint -/// 6. `[writable, signer]` admin -/// 7. `[]` system_program -/// 8. `[]` rent -/// 9. `[]` token_program -#[derive(Clone, Debug)] -pub struct InitializeStrategyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeStrategyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeStrategyCpiBuilderInstruction { - __program: program, - vault: None, - strategy_program: None, - strategy: None, - reserve: None, - collateral_vault: None, - collateral_mint: None, - admin: None, - system_program: None, - rent: None, - token_program: None, - strategy_index: None, - other_bumps: None, - strategy_type: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - #[inline(always)] - pub fn strategy_program( - &mut self, - strategy_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.strategy_program = Some(strategy_program); - self - } - - /// Strategy account - #[inline(always)] - pub fn strategy(&mut self, strategy: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.strategy = Some(strategy); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve = Some(reserve); - self - } - - /// Collateral vault account - #[inline(always)] - pub fn collateral_vault( - &mut self, - collateral_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.collateral_vault = Some(collateral_vault); - self - } - - /// Collateral mint account - #[inline(always)] - pub fn collateral_mint( - &mut self, - collateral_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.collateral_mint = Some(collateral_mint); - self - } - - /// Admin account - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - /// System program account - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Rent account - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - /// Token program account - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn strategy_index(&mut self, strategy_index: u8) -> &mut Self { - self.instruction.strategy_index = Some(strategy_index); - self - } - - #[inline(always)] - pub fn other_bumps(&mut self, other_bumps: [u8; 10]) -> &mut Self { - self.instruction.other_bumps = Some(other_bumps); - self - } - - #[inline(always)] - pub fn strategy_type(&mut self, strategy_type: StrategyType) -> &mut Self { - self.instruction.strategy_type = Some(strategy_type); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeStrategyInstructionArgs { - strategy_index: self - .instruction - .strategy_index - .clone() - .expect("strategy_index is not set"), - other_bumps: self - .instruction - .other_bumps - .clone() - .expect("other_bumps is not set"), - strategy_type: self - .instruction - .strategy_type - .clone() - .expect("strategy_type is not set"), - }; - let instruction = InitializeStrategyCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - strategy_program: self - .instruction - .strategy_program - .expect("strategy_program is not set"), - - strategy: self.instruction.strategy.expect("strategy is not set"), - - reserve: self.instruction.reserve.expect("reserve is not set"), - - collateral_vault: self - .instruction - .collateral_vault - .expect("collateral_vault is not set"), - - collateral_mint: self - .instruction - .collateral_mint - .expect("collateral_mint is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeStrategyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy_program: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve: Option<&'b solana_account_info::AccountInfo<'a>>, - collateral_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - collateral_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy_index: Option, - other_bumps: Option<[u8; 10]>, - strategy_type: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/mod.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index f53501c6..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#add_strategy; -pub(crate) mod r#collect_dust; -pub(crate) mod r#deposit; -pub(crate) mod r#deposit_strategy; -pub(crate) mod r#enable_vault; -pub(crate) mod r#initialize; -pub(crate) mod r#initialize_strategy; -pub(crate) mod r#remove_strategy; -pub(crate) mod r#remove_strategy2; -pub(crate) mod r#set_operator; -pub(crate) mod r#withdraw; -pub(crate) mod r#withdraw2; -pub(crate) mod r#withdraw_directly_from_strategy; -pub(crate) mod r#withdraw_strategy; - -pub use self::{ - r#add_strategy::*, r#collect_dust::*, r#deposit::*, r#deposit_strategy::*, r#enable_vault::*, - r#initialize::*, r#initialize_strategy::*, r#remove_strategy::*, r#remove_strategy2::*, - r#set_operator::*, r#withdraw::*, r#withdraw2::*, r#withdraw_directly_from_strategy::*, - r#withdraw_strategy::*, -}; diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/remove_strategy.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/remove_strategy.rs deleted file mode 100644 index 773c0f3d..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/remove_strategy.rs +++ /dev/null @@ -1,627 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveStrategy { - /// Vault account - pub vault: solana_pubkey::Pubkey, - /// Strategy account - pub strategy: solana_pubkey::Pubkey, - - pub strategy_program: solana_pubkey::Pubkey, - /// Collateral vault account - pub collateral_vault: solana_pubkey::Pubkey, - - pub reserve: solana_pubkey::Pubkey, - /// token_vault - pub token_vault: solana_pubkey::Pubkey, - /// fee_vault - pub fee_vault: solana_pubkey::Pubkey, - /// lp_mint - pub lp_mint: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, - /// admin - pub admin: solana_pubkey::Pubkey, -} - -impl RemoveStrategy { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.strategy, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.strategy_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.collateral_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.fee_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&RemoveStrategyInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveStrategyInstructionData { - discriminator: [u8; 8], -} - -impl RemoveStrategyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [185, 238, 33, 91, 134, 210, 97, 26], - } - } -} - -impl Default for RemoveStrategyInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `RemoveStrategy`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` strategy -/// 2. `[]` strategy_program -/// 3. `[writable]` collateral_vault -/// 4. `[writable]` reserve -/// 5. `[writable]` token_vault -/// 6. `[writable]` fee_vault -/// 7. `[writable]` lp_mint -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct RemoveStrategyBuilder { - vault: Option, - strategy: Option, - strategy_program: Option, - collateral_vault: Option, - reserve: Option, - token_vault: Option, - fee_vault: Option, - lp_mint: Option, - token_program: Option, - admin: Option, - __remaining_accounts: Vec, -} - -impl RemoveStrategyBuilder { - pub fn new() -> Self { Self::default() } - - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// Strategy account - #[inline(always)] - pub fn strategy(&mut self, strategy: solana_pubkey::Pubkey) -> &mut Self { - self.strategy = Some(strategy); - self - } - - #[inline(always)] - pub fn strategy_program(&mut self, strategy_program: solana_pubkey::Pubkey) -> &mut Self { - self.strategy_program = Some(strategy_program); - self - } - - /// Collateral vault account - #[inline(always)] - pub fn collateral_vault(&mut self, collateral_vault: solana_pubkey::Pubkey) -> &mut Self { - self.collateral_vault = Some(collateral_vault); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self { - self.reserve = Some(reserve); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - /// fee_vault - #[inline(always)] - pub fn fee_vault(&mut self, fee_vault: solana_pubkey::Pubkey) -> &mut Self { - self.fee_vault = Some(fee_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// admin - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveStrategy { - vault: self.vault.expect("vault is not set"), - strategy: self.strategy.expect("strategy is not set"), - strategy_program: self.strategy_program.expect("strategy_program is not set"), - collateral_vault: self.collateral_vault.expect("collateral_vault is not set"), - reserve: self.reserve.expect("reserve is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - fee_vault: self.fee_vault.expect("fee_vault is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - admin: self.admin.expect("admin is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `remove_strategy` CPI accounts. -pub struct RemoveStrategyCpiAccounts<'a, 'b> { - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// Strategy account - pub strategy: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// Collateral vault account - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// fee_vault - pub fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// admin - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_strategy` CPI instruction. -pub struct RemoveStrategyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// Strategy account - pub strategy: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// Collateral vault account - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// fee_vault - pub fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// admin - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> RemoveStrategyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveStrategyCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - strategy: accounts.strategy, - strategy_program: accounts.strategy_program, - collateral_vault: accounts.collateral_vault, - reserve: accounts.reserve, - token_vault: accounts.token_vault, - fee_vault: accounts.fee_vault, - lp_mint: accounts.lp_mint, - token_program: accounts.token_program, - admin: accounts.admin, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.strategy.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.strategy_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.collateral_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&RemoveStrategyInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.strategy.clone()); - account_infos.push(self.strategy_program.clone()); - account_infos.push(self.collateral_vault.clone()); - account_infos.push(self.reserve.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.fee_vault.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveStrategy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` strategy -/// 2. `[]` strategy_program -/// 3. `[writable]` collateral_vault -/// 4. `[writable]` reserve -/// 5. `[writable]` token_vault -/// 6. `[writable]` fee_vault -/// 7. `[writable]` lp_mint -/// 8. `[]` token_program -/// 9. `[signer]` admin -#[derive(Clone, Debug)] -pub struct RemoveStrategyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveStrategyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveStrategyCpiBuilderInstruction { - __program: program, - vault: None, - strategy: None, - strategy_program: None, - collateral_vault: None, - reserve: None, - token_vault: None, - fee_vault: None, - lp_mint: None, - token_program: None, - admin: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// Strategy account - #[inline(always)] - pub fn strategy(&mut self, strategy: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.strategy = Some(strategy); - self - } - - #[inline(always)] - pub fn strategy_program( - &mut self, - strategy_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.strategy_program = Some(strategy_program); - self - } - - /// Collateral vault account - #[inline(always)] - pub fn collateral_vault( - &mut self, - collateral_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.collateral_vault = Some(collateral_vault); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve = Some(reserve); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - /// fee_vault - #[inline(always)] - pub fn fee_vault(&mut self, fee_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_vault = Some(fee_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// admin - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = RemoveStrategyCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - strategy: self.instruction.strategy.expect("strategy is not set"), - - strategy_program: self - .instruction - .strategy_program - .expect("strategy_program is not set"), - - collateral_vault: self - .instruction - .collateral_vault - .expect("collateral_vault is not set"), - - reserve: self.instruction.reserve.expect("reserve is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - fee_vault: self.instruction.fee_vault.expect("fee_vault is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveStrategyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy_program: Option<&'b solana_account_info::AccountInfo<'a>>, - collateral_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/remove_strategy2.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/remove_strategy2.rs deleted file mode 100644 index e33dbef0..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/remove_strategy2.rs +++ /dev/null @@ -1,787 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct RemoveStrategy2 { - /// Vault account - pub vault: solana_pubkey::Pubkey, - /// Strategy account - pub strategy: solana_pubkey::Pubkey, - - pub strategy_program: solana_pubkey::Pubkey, - /// Collateral vault account - pub collateral_vault: solana_pubkey::Pubkey, - - pub reserve: solana_pubkey::Pubkey, - /// token_vault - pub token_vault: solana_pubkey::Pubkey, - /// token_advance_payemnt - /// the owner of token_advance_payment must be admin - pub token_admin_advance_payment: solana_pubkey::Pubkey, - /// token_vault_advance_payment - /// the account must be different from token_vault - /// the owner of token_advance_payment must be vault - pub token_vault_advance_payment: solana_pubkey::Pubkey, - /// fee_vault - pub fee_vault: solana_pubkey::Pubkey, - /// lp_mint - pub lp_mint: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, - /// admin - pub admin: solana_pubkey::Pubkey, -} - -impl RemoveStrategy2 { - pub fn instruction( - &self, - args: RemoveStrategy2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemoveStrategy2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.strategy, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.strategy_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.collateral_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_admin_advance_payment, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_advance_payment, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.fee_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RemoveStrategy2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveStrategy2InstructionData { - discriminator: [u8; 8], -} - -impl RemoveStrategy2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [138, 104, 208, 148, 126, 35, 195, 14], - } - } -} - -impl Default for RemoveStrategy2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemoveStrategy2InstructionArgs { - pub max_admin_pay_amount: u64, -} - -/// Instruction builder for `RemoveStrategy2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` strategy -/// 2. `[]` strategy_program -/// 3. `[writable]` collateral_vault -/// 4. `[writable]` reserve -/// 5. `[writable]` token_vault -/// 6. `[writable]` token_admin_advance_payment -/// 7. `[writable]` token_vault_advance_payment -/// 8. `[writable]` fee_vault -/// 9. `[writable]` lp_mint -/// 10. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 11. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct RemoveStrategy2Builder { - vault: Option, - strategy: Option, - strategy_program: Option, - collateral_vault: Option, - reserve: Option, - token_vault: Option, - token_admin_advance_payment: Option, - token_vault_advance_payment: Option, - fee_vault: Option, - lp_mint: Option, - token_program: Option, - admin: Option, - max_admin_pay_amount: Option, - __remaining_accounts: Vec, -} - -impl RemoveStrategy2Builder { - pub fn new() -> Self { Self::default() } - - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// Strategy account - #[inline(always)] - pub fn strategy(&mut self, strategy: solana_pubkey::Pubkey) -> &mut Self { - self.strategy = Some(strategy); - self - } - - #[inline(always)] - pub fn strategy_program(&mut self, strategy_program: solana_pubkey::Pubkey) -> &mut Self { - self.strategy_program = Some(strategy_program); - self - } - - /// Collateral vault account - #[inline(always)] - pub fn collateral_vault(&mut self, collateral_vault: solana_pubkey::Pubkey) -> &mut Self { - self.collateral_vault = Some(collateral_vault); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self { - self.reserve = Some(reserve); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - /// token_advance_payemnt - /// the owner of token_advance_payment must be admin - #[inline(always)] - pub fn token_admin_advance_payment( - &mut self, - token_admin_advance_payment: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_admin_advance_payment = Some(token_admin_advance_payment); - self - } - - /// token_vault_advance_payment - /// the account must be different from token_vault - /// the owner of token_advance_payment must be vault - #[inline(always)] - pub fn token_vault_advance_payment( - &mut self, - token_vault_advance_payment: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_vault_advance_payment = Some(token_vault_advance_payment); - self - } - - /// fee_vault - #[inline(always)] - pub fn fee_vault(&mut self, fee_vault: solana_pubkey::Pubkey) -> &mut Self { - self.fee_vault = Some(fee_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// admin - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn max_admin_pay_amount(&mut self, max_admin_pay_amount: u64) -> &mut Self { - self.max_admin_pay_amount = Some(max_admin_pay_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemoveStrategy2 { - vault: self.vault.expect("vault is not set"), - strategy: self.strategy.expect("strategy is not set"), - strategy_program: self.strategy_program.expect("strategy_program is not set"), - collateral_vault: self.collateral_vault.expect("collateral_vault is not set"), - reserve: self.reserve.expect("reserve is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - token_admin_advance_payment: self - .token_admin_advance_payment - .expect("token_admin_advance_payment is not set"), - token_vault_advance_payment: self - .token_vault_advance_payment - .expect("token_vault_advance_payment is not set"), - fee_vault: self.fee_vault.expect("fee_vault is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - admin: self.admin.expect("admin is not set"), - }; - let args = RemoveStrategy2InstructionArgs { - max_admin_pay_amount: self - .max_admin_pay_amount - .clone() - .expect("max_admin_pay_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_strategy2` CPI accounts. -pub struct RemoveStrategy2CpiAccounts<'a, 'b> { - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// Strategy account - pub strategy: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// Collateral vault account - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// token_advance_payemnt - /// the owner of token_advance_payment must be admin - pub token_admin_advance_payment: &'b solana_account_info::AccountInfo<'a>, - /// token_vault_advance_payment - /// the account must be different from token_vault - /// the owner of token_advance_payment must be vault - pub token_vault_advance_payment: &'b solana_account_info::AccountInfo<'a>, - /// fee_vault - pub fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// admin - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_strategy2` CPI instruction. -pub struct RemoveStrategy2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// Strategy account - pub strategy: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// Collateral vault account - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// token_advance_payemnt - /// the owner of token_advance_payment must be admin - pub token_admin_advance_payment: &'b solana_account_info::AccountInfo<'a>, - /// token_vault_advance_payment - /// the account must be different from token_vault - /// the owner of token_advance_payment must be vault - pub token_vault_advance_payment: &'b solana_account_info::AccountInfo<'a>, - /// fee_vault - pub fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// admin - pub admin: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemoveStrategy2InstructionArgs, -} - -impl<'a, 'b> RemoveStrategy2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemoveStrategy2CpiAccounts<'a, 'b>, - args: RemoveStrategy2InstructionArgs, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - strategy: accounts.strategy, - strategy_program: accounts.strategy_program, - collateral_vault: accounts.collateral_vault, - reserve: accounts.reserve, - token_vault: accounts.token_vault, - token_admin_advance_payment: accounts.token_admin_advance_payment, - token_vault_advance_payment: accounts.token_vault_advance_payment, - fee_vault: accounts.fee_vault, - lp_mint: accounts.lp_mint, - token_program: accounts.token_program, - admin: accounts.admin, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.strategy.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.strategy_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.collateral_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_admin_advance_payment.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_advance_payment.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RemoveStrategy2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.strategy.clone()); - account_infos.push(self.strategy_program.clone()); - account_infos.push(self.collateral_vault.clone()); - account_infos.push(self.reserve.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.token_admin_advance_payment.clone()); - account_infos.push(self.token_vault_advance_payment.clone()); - account_infos.push(self.fee_vault.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemoveStrategy2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` strategy -/// 2. `[]` strategy_program -/// 3. `[writable]` collateral_vault -/// 4. `[writable]` reserve -/// 5. `[writable]` token_vault -/// 6. `[writable]` token_admin_advance_payment -/// 7. `[writable]` token_vault_advance_payment -/// 8. `[writable]` fee_vault -/// 9. `[writable]` lp_mint -/// 10. `[]` token_program -/// 11. `[signer]` admin -#[derive(Clone, Debug)] -pub struct RemoveStrategy2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemoveStrategy2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemoveStrategy2CpiBuilderInstruction { - __program: program, - vault: None, - strategy: None, - strategy_program: None, - collateral_vault: None, - reserve: None, - token_vault: None, - token_admin_advance_payment: None, - token_vault_advance_payment: None, - fee_vault: None, - lp_mint: None, - token_program: None, - admin: None, - max_admin_pay_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// Strategy account - #[inline(always)] - pub fn strategy(&mut self, strategy: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.strategy = Some(strategy); - self - } - - #[inline(always)] - pub fn strategy_program( - &mut self, - strategy_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.strategy_program = Some(strategy_program); - self - } - - /// Collateral vault account - #[inline(always)] - pub fn collateral_vault( - &mut self, - collateral_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.collateral_vault = Some(collateral_vault); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve = Some(reserve); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - /// token_advance_payemnt - /// the owner of token_advance_payment must be admin - #[inline(always)] - pub fn token_admin_advance_payment( - &mut self, - token_admin_advance_payment: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_admin_advance_payment = Some(token_admin_advance_payment); - self - } - - /// token_vault_advance_payment - /// the account must be different from token_vault - /// the owner of token_advance_payment must be vault - #[inline(always)] - pub fn token_vault_advance_payment( - &mut self, - token_vault_advance_payment: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_advance_payment = Some(token_vault_advance_payment); - self - } - - /// fee_vault - #[inline(always)] - pub fn fee_vault(&mut self, fee_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_vault = Some(fee_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// admin - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn max_admin_pay_amount(&mut self, max_admin_pay_amount: u64) -> &mut Self { - self.instruction.max_admin_pay_amount = Some(max_admin_pay_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RemoveStrategy2InstructionArgs { - max_admin_pay_amount: self - .instruction - .max_admin_pay_amount - .clone() - .expect("max_admin_pay_amount is not set"), - }; - let instruction = RemoveStrategy2Cpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - strategy: self.instruction.strategy.expect("strategy is not set"), - - strategy_program: self - .instruction - .strategy_program - .expect("strategy_program is not set"), - - collateral_vault: self - .instruction - .collateral_vault - .expect("collateral_vault is not set"), - - reserve: self.instruction.reserve.expect("reserve is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - token_admin_advance_payment: self - .instruction - .token_admin_advance_payment - .expect("token_admin_advance_payment is not set"), - - token_vault_advance_payment: self - .instruction - .token_vault_advance_payment - .expect("token_vault_advance_payment is not set"), - - fee_vault: self.instruction.fee_vault.expect("fee_vault is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemoveStrategy2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy_program: Option<&'b solana_account_info::AccountInfo<'a>>, - collateral_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_admin_advance_payment: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_advance_payment: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - max_admin_pay_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/set_operator.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/set_operator.rs deleted file mode 100644 index 8f4e5955..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/set_operator.rs +++ /dev/null @@ -1,348 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetOperator { - /// Vault account - pub vault: solana_pubkey::Pubkey, - - pub operator: solana_pubkey::Pubkey, - /// admin - pub admin: solana_pubkey::Pubkey, -} - -impl SetOperator { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetOperatorInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetOperatorInstructionData { - discriminator: [u8; 8], -} - -impl SetOperatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [238, 153, 101, 169, 243, 131, 36, 1], - } - } -} - -impl Default for SetOperatorInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetOperator`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[]` operator -/// 2. `[signer]` admin -#[derive(Clone, Debug, Default)] -pub struct SetOperatorBuilder { - vault: Option, - operator: Option, - admin: Option, - __remaining_accounts: Vec, -} - -impl SetOperatorBuilder { - pub fn new() -> Self { Self::default() } - - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - /// admin - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetOperator { - vault: self.vault.expect("vault is not set"), - operator: self.operator.expect("operator is not set"), - admin: self.admin.expect("admin is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_operator` CPI accounts. -pub struct SetOperatorCpiAccounts<'a, 'b> { - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - /// admin - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_operator` CPI instruction. -pub struct SetOperatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Vault account - pub vault: &'b solana_account_info::AccountInfo<'a>, - - pub operator: &'b solana_account_info::AccountInfo<'a>, - /// admin - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetOperatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetOperatorCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - operator: accounts.operator, - admin: accounts.admin, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetOperatorInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.operator.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetOperator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[]` operator -/// 2. `[signer]` admin -#[derive(Clone, Debug)] -pub struct SetOperatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetOperatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetOperatorCpiBuilderInstruction { - __program: program, - vault: None, - operator: None, - admin: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Vault account - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - /// admin - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetOperatorCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetOperatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw.rs deleted file mode 100644 index a2318079..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw.rs +++ /dev/null @@ -1,580 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Withdraw { - /// vault - pub vault: solana_pubkey::Pubkey, - /// token_vault - pub token_vault: solana_pubkey::Pubkey, - /// lp_mint - pub lp_mint: solana_pubkey::Pubkey, - /// user_token - pub user_token: solana_pubkey::Pubkey, - /// user_lp - pub user_lp: solana_pubkey::Pubkey, - /// user - pub user: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, -} - -impl Withdraw { - pub fn instruction(&self, args: WithdrawInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: WithdrawInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new(self.user_token, false)); - accounts.push(solana_instruction::AccountMeta::new(self.user_lp, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawInstructionData { - pub fn new() -> Self { - Self { - discriminator: [183, 18, 70, 156, 148, 109, 161, 34], - } - } -} - -impl Default for WithdrawInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawInstructionArgs { - pub unmint_amount: u64, - pub min_out_amount: u64, -} - -/// Instruction builder for `Withdraw`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` token_vault -/// 2. `[writable]` lp_mint -/// 3. `[writable]` user_token -/// 4. `[writable]` user_lp -/// 5. `[signer]` user -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct WithdrawBuilder { - vault: Option, - token_vault: Option, - lp_mint: Option, - user_token: Option, - user_lp: Option, - user: Option, - token_program: Option, - unmint_amount: Option, - min_out_amount: Option, - __remaining_accounts: Vec, -} - -impl WithdrawBuilder { - pub fn new() -> Self { Self::default() } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// user_token - #[inline(always)] - pub fn user_token(&mut self, user_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_token = Some(user_token); - self - } - - /// user_lp - #[inline(always)] - pub fn user_lp(&mut self, user_lp: solana_pubkey::Pubkey) -> &mut Self { - self.user_lp = Some(user_lp); - self - } - - /// user - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn unmint_amount(&mut self, unmint_amount: u64) -> &mut Self { - self.unmint_amount = Some(unmint_amount); - self - } - - #[inline(always)] - pub fn min_out_amount(&mut self, min_out_amount: u64) -> &mut Self { - self.min_out_amount = Some(min_out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Withdraw { - vault: self.vault.expect("vault is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_token: self.user_token.expect("user_token is not set"), - user_lp: self.user_lp.expect("user_lp is not set"), - user: self.user.expect("user is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = WithdrawInstructionArgs { - unmint_amount: self - .unmint_amount - .clone() - .expect("unmint_amount is not set"), - min_out_amount: self - .min_out_amount - .clone() - .expect("min_out_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw` CPI accounts. -pub struct WithdrawCpiAccounts<'a, 'b> { - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user_token - pub user_token: &'b solana_account_info::AccountInfo<'a>, - /// user_lp - pub user_lp: &'b solana_account_info::AccountInfo<'a>, - /// user - pub user: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw` CPI instruction. -pub struct WithdrawCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user_token - pub user_token: &'b solana_account_info::AccountInfo<'a>, - /// user_lp - pub user_lp: &'b solana_account_info::AccountInfo<'a>, - /// user - pub user: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: WithdrawInstructionArgs, -} - -impl<'a, 'b> WithdrawCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawCpiAccounts<'a, 'b>, - args: WithdrawInstructionArgs, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - token_vault: accounts.token_vault, - lp_mint: accounts.lp_mint, - user_token: accounts.user_token, - user_lp: accounts.user_lp, - user: accounts.user, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_token.clone()); - account_infos.push(self.user_lp.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Withdraw` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` token_vault -/// 2. `[writable]` lp_mint -/// 3. `[writable]` user_token -/// 4. `[writable]` user_lp -/// 5. `[signer]` user -/// 6. `[]` token_program -#[derive(Clone, Debug)] -pub struct WithdrawCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawCpiBuilderInstruction { - __program: program, - vault: None, - token_vault: None, - lp_mint: None, - user_token: None, - user_lp: None, - user: None, - token_program: None, - unmint_amount: None, - min_out_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// user_token - #[inline(always)] - pub fn user_token( - &mut self, - user_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token = Some(user_token); - self - } - - /// user_lp - #[inline(always)] - pub fn user_lp(&mut self, user_lp: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user_lp = Some(user_lp); - self - } - - /// user - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn unmint_amount(&mut self, unmint_amount: u64) -> &mut Self { - self.instruction.unmint_amount = Some(unmint_amount); - self - } - - #[inline(always)] - pub fn min_out_amount(&mut self, min_out_amount: u64) -> &mut Self { - self.instruction.min_out_amount = Some(min_out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = WithdrawInstructionArgs { - unmint_amount: self - .instruction - .unmint_amount - .clone() - .expect("unmint_amount is not set"), - min_out_amount: self - .instruction - .min_out_amount - .clone() - .expect("min_out_amount is not set"), - }; - let instruction = WithdrawCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_token: self.instruction.user_token.expect("user_token is not set"), - - user_lp: self.instruction.user_lp.expect("user_lp is not set"), - - user: self.instruction.user.expect("user is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - unmint_amount: Option, - min_out_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw2.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw2.rs deleted file mode 100644 index d49a778b..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw2.rs +++ /dev/null @@ -1,580 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Withdraw2 { - /// vault - pub vault: solana_pubkey::Pubkey, - /// token_vault - pub token_vault: solana_pubkey::Pubkey, - /// lp_mint - pub lp_mint: solana_pubkey::Pubkey, - /// user_token - pub user_token: solana_pubkey::Pubkey, - /// user_lp - pub user_lp: solana_pubkey::Pubkey, - /// user - pub user: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, -} - -impl Withdraw2 { - pub fn instruction(&self, args: Withdraw2InstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: Withdraw2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new(self.user_token, false)); - accounts.push(solana_instruction::AccountMeta::new(self.user_lp, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&Withdraw2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Withdraw2InstructionData { - discriminator: [u8; 8], -} - -impl Withdraw2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [80, 6, 111, 73, 174, 211, 66, 132], - } - } -} - -impl Default for Withdraw2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Withdraw2InstructionArgs { - pub unmint_amount: u64, - pub min_out_amount: u64, -} - -/// Instruction builder for `Withdraw2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` token_vault -/// 2. `[writable]` lp_mint -/// 3. `[writable]` user_token -/// 4. `[writable]` user_lp -/// 5. `[signer]` user -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct Withdraw2Builder { - vault: Option, - token_vault: Option, - lp_mint: Option, - user_token: Option, - user_lp: Option, - user: Option, - token_program: Option, - unmint_amount: Option, - min_out_amount: Option, - __remaining_accounts: Vec, -} - -impl Withdraw2Builder { - pub fn new() -> Self { Self::default() } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// user_token - #[inline(always)] - pub fn user_token(&mut self, user_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_token = Some(user_token); - self - } - - /// user_lp - #[inline(always)] - pub fn user_lp(&mut self, user_lp: solana_pubkey::Pubkey) -> &mut Self { - self.user_lp = Some(user_lp); - self - } - - /// user - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn unmint_amount(&mut self, unmint_amount: u64) -> &mut Self { - self.unmint_amount = Some(unmint_amount); - self - } - - #[inline(always)] - pub fn min_out_amount(&mut self, min_out_amount: u64) -> &mut Self { - self.min_out_amount = Some(min_out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Withdraw2 { - vault: self.vault.expect("vault is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_token: self.user_token.expect("user_token is not set"), - user_lp: self.user_lp.expect("user_lp is not set"), - user: self.user.expect("user is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = Withdraw2InstructionArgs { - unmint_amount: self - .unmint_amount - .clone() - .expect("unmint_amount is not set"), - min_out_amount: self - .min_out_amount - .clone() - .expect("min_out_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw2` CPI accounts. -pub struct Withdraw2CpiAccounts<'a, 'b> { - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user_token - pub user_token: &'b solana_account_info::AccountInfo<'a>, - /// user_lp - pub user_lp: &'b solana_account_info::AccountInfo<'a>, - /// user - pub user: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw2` CPI instruction. -pub struct Withdraw2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// user_token - pub user_token: &'b solana_account_info::AccountInfo<'a>, - /// user_lp - pub user_lp: &'b solana_account_info::AccountInfo<'a>, - /// user - pub user: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: Withdraw2InstructionArgs, -} - -impl<'a, 'b> Withdraw2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: Withdraw2CpiAccounts<'a, 'b>, - args: Withdraw2InstructionArgs, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - token_vault: accounts.token_vault, - lp_mint: accounts.lp_mint, - user_token: accounts.user_token, - user_lp: accounts.user_lp, - user: accounts.user, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&Withdraw2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_token.clone()); - account_infos.push(self.user_lp.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Withdraw2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` token_vault -/// 2. `[writable]` lp_mint -/// 3. `[writable]` user_token -/// 4. `[writable]` user_lp -/// 5. `[signer]` user -/// 6. `[]` token_program -#[derive(Clone, Debug)] -pub struct Withdraw2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> Withdraw2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(Withdraw2CpiBuilderInstruction { - __program: program, - vault: None, - token_vault: None, - lp_mint: None, - user_token: None, - user_lp: None, - user: None, - token_program: None, - unmint_amount: None, - min_out_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// user_token - #[inline(always)] - pub fn user_token( - &mut self, - user_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token = Some(user_token); - self - } - - /// user_lp - #[inline(always)] - pub fn user_lp(&mut self, user_lp: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user_lp = Some(user_lp); - self - } - - /// user - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn unmint_amount(&mut self, unmint_amount: u64) -> &mut Self { - self.instruction.unmint_amount = Some(unmint_amount); - self - } - - #[inline(always)] - pub fn min_out_amount(&mut self, min_out_amount: u64) -> &mut Self { - self.instruction.min_out_amount = Some(min_out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = Withdraw2InstructionArgs { - unmint_amount: self - .instruction - .unmint_amount - .clone() - .expect("unmint_amount is not set"), - min_out_amount: self - .instruction - .min_out_amount - .clone() - .expect("min_out_amount is not set"), - }; - let instruction = Withdraw2Cpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_token: self.instruction.user_token.expect("user_token is not set"), - - user_lp: self.instruction.user_lp.expect("user_lp is not set"), - - user: self.instruction.user.expect("user is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct Withdraw2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - unmint_amount: Option, - min_out_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw_directly_from_strategy.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw_directly_from_strategy.rs deleted file mode 100644 index 2ddd68f5..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw_directly_from_strategy.rs +++ /dev/null @@ -1,772 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct WithdrawDirectlyFromStrategy { - /// vault - pub vault: solana_pubkey::Pubkey, - /// strategy - pub strategy: solana_pubkey::Pubkey, - - pub reserve: solana_pubkey::Pubkey, - - pub strategy_program: solana_pubkey::Pubkey, - /// collateral_vault - pub collateral_vault: solana_pubkey::Pubkey, - /// token_vault - pub token_vault: solana_pubkey::Pubkey, - /// lp_mint - pub lp_mint: solana_pubkey::Pubkey, - /// fee_vault - pub fee_vault: solana_pubkey::Pubkey, - /// user_token - pub user_token: solana_pubkey::Pubkey, - /// user_lp - pub user_lp: solana_pubkey::Pubkey, - /// user - pub user: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, -} - -impl WithdrawDirectlyFromStrategy { - pub fn instruction( - &self, - args: WithdrawDirectlyFromStrategyInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: WithdrawDirectlyFromStrategyInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.strategy, false)); - accounts.push(solana_instruction::AccountMeta::new(self.reserve, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.strategy_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.collateral_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new(self.fee_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.user_token, false)); - accounts.push(solana_instruction::AccountMeta::new(self.user_lp, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawDirectlyFromStrategyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawDirectlyFromStrategyInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawDirectlyFromStrategyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [201, 141, 146, 46, 173, 116, 198, 22], - } - } -} - -impl Default for WithdrawDirectlyFromStrategyInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawDirectlyFromStrategyInstructionArgs { - pub unmint_amount: u64, - pub min_out_amount: u64, -} - -/// Instruction builder for `WithdrawDirectlyFromStrategy`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` strategy -/// 2. `[writable]` reserve -/// 3. `[]` strategy_program -/// 4. `[writable]` collateral_vault -/// 5. `[writable]` token_vault -/// 6. `[writable]` lp_mint -/// 7. `[writable]` fee_vault -/// 8. `[writable]` user_token -/// 9. `[writable]` user_lp -/// 10. `[signer]` user -/// 11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct WithdrawDirectlyFromStrategyBuilder { - vault: Option, - strategy: Option, - reserve: Option, - strategy_program: Option, - collateral_vault: Option, - token_vault: Option, - lp_mint: Option, - fee_vault: Option, - user_token: Option, - user_lp: Option, - user: Option, - token_program: Option, - unmint_amount: Option, - min_out_amount: Option, - __remaining_accounts: Vec, -} - -impl WithdrawDirectlyFromStrategyBuilder { - pub fn new() -> Self { Self::default() } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// strategy - #[inline(always)] - pub fn strategy(&mut self, strategy: solana_pubkey::Pubkey) -> &mut Self { - self.strategy = Some(strategy); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self { - self.reserve = Some(reserve); - self - } - - #[inline(always)] - pub fn strategy_program(&mut self, strategy_program: solana_pubkey::Pubkey) -> &mut Self { - self.strategy_program = Some(strategy_program); - self - } - - /// collateral_vault - #[inline(always)] - pub fn collateral_vault(&mut self, collateral_vault: solana_pubkey::Pubkey) -> &mut Self { - self.collateral_vault = Some(collateral_vault); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// fee_vault - #[inline(always)] - pub fn fee_vault(&mut self, fee_vault: solana_pubkey::Pubkey) -> &mut Self { - self.fee_vault = Some(fee_vault); - self - } - - /// user_token - #[inline(always)] - pub fn user_token(&mut self, user_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_token = Some(user_token); - self - } - - /// user_lp - #[inline(always)] - pub fn user_lp(&mut self, user_lp: solana_pubkey::Pubkey) -> &mut Self { - self.user_lp = Some(user_lp); - self - } - - /// user - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn unmint_amount(&mut self, unmint_amount: u64) -> &mut Self { - self.unmint_amount = Some(unmint_amount); - self - } - - #[inline(always)] - pub fn min_out_amount(&mut self, min_out_amount: u64) -> &mut Self { - self.min_out_amount = Some(min_out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = WithdrawDirectlyFromStrategy { - vault: self.vault.expect("vault is not set"), - strategy: self.strategy.expect("strategy is not set"), - reserve: self.reserve.expect("reserve is not set"), - strategy_program: self.strategy_program.expect("strategy_program is not set"), - collateral_vault: self.collateral_vault.expect("collateral_vault is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - fee_vault: self.fee_vault.expect("fee_vault is not set"), - user_token: self.user_token.expect("user_token is not set"), - user_lp: self.user_lp.expect("user_lp is not set"), - user: self.user.expect("user is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = WithdrawDirectlyFromStrategyInstructionArgs { - unmint_amount: self - .unmint_amount - .clone() - .expect("unmint_amount is not set"), - min_out_amount: self - .min_out_amount - .clone() - .expect("min_out_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw_directly_from_strategy` CPI accounts. -pub struct WithdrawDirectlyFromStrategyCpiAccounts<'a, 'b> { - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// strategy - pub strategy: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// collateral_vault - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// fee_vault - pub fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// user_token - pub user_token: &'b solana_account_info::AccountInfo<'a>, - /// user_lp - pub user_lp: &'b solana_account_info::AccountInfo<'a>, - /// user - pub user: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw_directly_from_strategy` CPI instruction. -pub struct WithdrawDirectlyFromStrategyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// strategy - pub strategy: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// collateral_vault - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// fee_vault - pub fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// user_token - pub user_token: &'b solana_account_info::AccountInfo<'a>, - /// user_lp - pub user_lp: &'b solana_account_info::AccountInfo<'a>, - /// user - pub user: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: WithdrawDirectlyFromStrategyInstructionArgs, -} - -impl<'a, 'b> WithdrawDirectlyFromStrategyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawDirectlyFromStrategyCpiAccounts<'a, 'b>, - args: WithdrawDirectlyFromStrategyInstructionArgs, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - strategy: accounts.strategy, - reserve: accounts.reserve, - strategy_program: accounts.strategy_program, - collateral_vault: accounts.collateral_vault, - token_vault: accounts.token_vault, - lp_mint: accounts.lp_mint, - fee_vault: accounts.fee_vault, - user_token: accounts.user_token, - user_lp: accounts.user_lp, - user: accounts.user, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.strategy.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.strategy_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.collateral_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&WithdrawDirectlyFromStrategyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.strategy.clone()); - account_infos.push(self.reserve.clone()); - account_infos.push(self.strategy_program.clone()); - account_infos.push(self.collateral_vault.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.fee_vault.clone()); - account_infos.push(self.user_token.clone()); - account_infos.push(self.user_lp.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `WithdrawDirectlyFromStrategy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` strategy -/// 2. `[writable]` reserve -/// 3. `[]` strategy_program -/// 4. `[writable]` collateral_vault -/// 5. `[writable]` token_vault -/// 6. `[writable]` lp_mint -/// 7. `[writable]` fee_vault -/// 8. `[writable]` user_token -/// 9. `[writable]` user_lp -/// 10. `[signer]` user -/// 11. `[]` token_program -#[derive(Clone, Debug)] -pub struct WithdrawDirectlyFromStrategyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawDirectlyFromStrategyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawDirectlyFromStrategyCpiBuilderInstruction { - __program: program, - vault: None, - strategy: None, - reserve: None, - strategy_program: None, - collateral_vault: None, - token_vault: None, - lp_mint: None, - fee_vault: None, - user_token: None, - user_lp: None, - user: None, - token_program: None, - unmint_amount: None, - min_out_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// strategy - #[inline(always)] - pub fn strategy(&mut self, strategy: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.strategy = Some(strategy); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve = Some(reserve); - self - } - - #[inline(always)] - pub fn strategy_program( - &mut self, - strategy_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.strategy_program = Some(strategy_program); - self - } - - /// collateral_vault - #[inline(always)] - pub fn collateral_vault( - &mut self, - collateral_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.collateral_vault = Some(collateral_vault); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// fee_vault - #[inline(always)] - pub fn fee_vault(&mut self, fee_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_vault = Some(fee_vault); - self - } - - /// user_token - #[inline(always)] - pub fn user_token( - &mut self, - user_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token = Some(user_token); - self - } - - /// user_lp - #[inline(always)] - pub fn user_lp(&mut self, user_lp: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user_lp = Some(user_lp); - self - } - - /// user - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn unmint_amount(&mut self, unmint_amount: u64) -> &mut Self { - self.instruction.unmint_amount = Some(unmint_amount); - self - } - - #[inline(always)] - pub fn min_out_amount(&mut self, min_out_amount: u64) -> &mut Self { - self.instruction.min_out_amount = Some(min_out_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = WithdrawDirectlyFromStrategyInstructionArgs { - unmint_amount: self - .instruction - .unmint_amount - .clone() - .expect("unmint_amount is not set"), - min_out_amount: self - .instruction - .min_out_amount - .clone() - .expect("min_out_amount is not set"), - }; - let instruction = WithdrawDirectlyFromStrategyCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - strategy: self.instruction.strategy.expect("strategy is not set"), - - reserve: self.instruction.reserve.expect("reserve is not set"), - - strategy_program: self - .instruction - .strategy_program - .expect("strategy_program is not set"), - - collateral_vault: self - .instruction - .collateral_vault - .expect("collateral_vault is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - fee_vault: self.instruction.fee_vault.expect("fee_vault is not set"), - - user_token: self.instruction.user_token.expect("user_token is not set"), - - user_lp: self.instruction.user_lp.expect("user_lp is not set"), - - user: self.instruction.user.expect("user is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawDirectlyFromStrategyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy_program: Option<&'b solana_account_info::AccountInfo<'a>>, - collateral_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - unmint_amount: Option, - min_out_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw_strategy.rs b/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw_strategy.rs deleted file mode 100644 index 6f65797d..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/instructions/withdraw_strategy.rs +++ /dev/null @@ -1,668 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct WithdrawStrategy { - /// vault - pub vault: solana_pubkey::Pubkey, - /// strategy - pub strategy: solana_pubkey::Pubkey, - /// token_vault - pub token_vault: solana_pubkey::Pubkey, - /// fee_vault - pub fee_vault: solana_pubkey::Pubkey, - /// lp_mint - pub lp_mint: solana_pubkey::Pubkey, - - pub strategy_program: solana_pubkey::Pubkey, - /// collateral_vault - pub collateral_vault: solana_pubkey::Pubkey, - - pub reserve: solana_pubkey::Pubkey, - /// token_program - pub token_program: solana_pubkey::Pubkey, - /// operator - pub operator: solana_pubkey::Pubkey, -} - -impl WithdrawStrategy { - pub fn instruction( - &self, - args: WithdrawStrategyInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: WithdrawStrategyInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.strategy, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.fee_vault, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.strategy_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.collateral_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.reserve, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operator, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawStrategyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawStrategyInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawStrategyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [31, 45, 162, 5, 193, 217, 134, 188], - } - } -} - -impl Default for WithdrawStrategyInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawStrategyInstructionArgs { - pub amount: u64, -} - -/// Instruction builder for `WithdrawStrategy`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` strategy -/// 2. `[writable]` token_vault -/// 3. `[writable]` fee_vault -/// 4. `[writable]` lp_mint -/// 5. `[]` strategy_program -/// 6. `[writable]` collateral_vault -/// 7. `[writable]` reserve -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[signer]` operator -#[derive(Clone, Debug, Default)] -pub struct WithdrawStrategyBuilder { - vault: Option, - strategy: Option, - token_vault: Option, - fee_vault: Option, - lp_mint: Option, - strategy_program: Option, - collateral_vault: Option, - reserve: Option, - token_program: Option, - operator: Option, - amount: Option, - __remaining_accounts: Vec, -} - -impl WithdrawStrategyBuilder { - pub fn new() -> Self { Self::default() } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: solana_pubkey::Pubkey) -> &mut Self { - self.vault = Some(vault); - self - } - - /// strategy - #[inline(always)] - pub fn strategy(&mut self, strategy: solana_pubkey::Pubkey) -> &mut Self { - self.strategy = Some(strategy); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - /// fee_vault - #[inline(always)] - pub fn fee_vault(&mut self, fee_vault: solana_pubkey::Pubkey) -> &mut Self { - self.fee_vault = Some(fee_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn strategy_program(&mut self, strategy_program: solana_pubkey::Pubkey) -> &mut Self { - self.strategy_program = Some(strategy_program); - self - } - - /// collateral_vault - #[inline(always)] - pub fn collateral_vault(&mut self, collateral_vault: solana_pubkey::Pubkey) -> &mut Self { - self.collateral_vault = Some(collateral_vault); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self { - self.reserve = Some(reserve); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token_program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// operator - #[inline(always)] - pub fn operator(&mut self, operator: solana_pubkey::Pubkey) -> &mut Self { - self.operator = Some(operator); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = WithdrawStrategy { - vault: self.vault.expect("vault is not set"), - strategy: self.strategy.expect("strategy is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - fee_vault: self.fee_vault.expect("fee_vault is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - strategy_program: self.strategy_program.expect("strategy_program is not set"), - collateral_vault: self.collateral_vault.expect("collateral_vault is not set"), - reserve: self.reserve.expect("reserve is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - operator: self.operator.expect("operator is not set"), - }; - let args = WithdrawStrategyInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw_strategy` CPI accounts. -pub struct WithdrawStrategyCpiAccounts<'a, 'b> { - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// strategy - pub strategy: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// fee_vault - pub fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// collateral_vault - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// operator - pub operator: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw_strategy` CPI instruction. -pub struct WithdrawStrategyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// vault - pub vault: &'b solana_account_info::AccountInfo<'a>, - /// strategy - pub strategy: &'b solana_account_info::AccountInfo<'a>, - /// token_vault - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - /// fee_vault - pub fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// lp_mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub strategy_program: &'b solana_account_info::AccountInfo<'a>, - /// collateral_vault - pub collateral_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reserve: &'b solana_account_info::AccountInfo<'a>, - /// token_program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// operator - pub operator: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: WithdrawStrategyInstructionArgs, -} - -impl<'a, 'b> WithdrawStrategyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawStrategyCpiAccounts<'a, 'b>, - args: WithdrawStrategyInstructionArgs, - ) -> Self { - Self { - __program: program, - vault: accounts.vault, - strategy: accounts.strategy, - token_vault: accounts.token_vault, - fee_vault: accounts.fee_vault, - lp_mint: accounts.lp_mint, - strategy_program: accounts.strategy_program, - collateral_vault: accounts.collateral_vault, - reserve: accounts.reserve, - token_program: accounts.token_program, - operator: accounts.operator, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vault.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.strategy.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.strategy_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.collateral_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reserve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operator.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&WithdrawStrategyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VAULT_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vault.clone()); - account_infos.push(self.strategy.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.fee_vault.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.strategy_program.clone()); - account_infos.push(self.collateral_vault.clone()); - account_infos.push(self.reserve.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.operator.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `WithdrawStrategy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vault -/// 1. `[writable]` strategy -/// 2. `[writable]` token_vault -/// 3. `[writable]` fee_vault -/// 4. `[writable]` lp_mint -/// 5. `[]` strategy_program -/// 6. `[writable]` collateral_vault -/// 7. `[writable]` reserve -/// 8. `[]` token_program -/// 9. `[signer]` operator -#[derive(Clone, Debug)] -pub struct WithdrawStrategyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawStrategyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawStrategyCpiBuilderInstruction { - __program: program, - vault: None, - strategy: None, - token_vault: None, - fee_vault: None, - lp_mint: None, - strategy_program: None, - collateral_vault: None, - reserve: None, - token_program: None, - operator: None, - amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// vault - #[inline(always)] - pub fn vault(&mut self, vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vault = Some(vault); - self - } - - /// strategy - #[inline(always)] - pub fn strategy(&mut self, strategy: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.strategy = Some(strategy); - self - } - - /// token_vault - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - /// fee_vault - #[inline(always)] - pub fn fee_vault(&mut self, fee_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_vault = Some(fee_vault); - self - } - - /// lp_mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn strategy_program( - &mut self, - strategy_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.strategy_program = Some(strategy_program); - self - } - - /// collateral_vault - #[inline(always)] - pub fn collateral_vault( - &mut self, - collateral_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.collateral_vault = Some(collateral_vault); - self - } - - #[inline(always)] - pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.reserve = Some(reserve); - self - } - - /// token_program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// operator - #[inline(always)] - pub fn operator(&mut self, operator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.operator = Some(operator); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = WithdrawStrategyInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - }; - let instruction = WithdrawStrategyCpi { - __program: self.instruction.__program, - - vault: self.instruction.vault.expect("vault is not set"), - - strategy: self.instruction.strategy.expect("strategy is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - fee_vault: self.instruction.fee_vault.expect("fee_vault is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - strategy_program: self - .instruction - .strategy_program - .expect("strategy_program is not set"), - - collateral_vault: self - .instruction - .collateral_vault - .expect("collateral_vault is not set"), - - reserve: self.instruction.reserve.expect("reserve is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - operator: self.instruction.operator.expect("operator is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawStrategyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vault: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - strategy_program: Option<&'b solana_account_info::AccountInfo<'a>>, - collateral_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reserve: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - operator: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/mod.rs b/crates/meteora-vault-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/meteora-vault-parser/src/generated_sdk/programs.rs b/crates/meteora-vault-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 8522e0bd..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `vault` program ID. -pub const VAULT_ID: Pubkey = pubkey!("24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"); diff --git a/crates/meteora-vault-parser/src/generated_sdk/shared.rs b/crates/meteora-vault-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/types/locked_profit_tracker.rs b/crates/meteora-vault-parser/src/generated_sdk/types/locked_profit_tracker.rs deleted file mode 100644 index 84a499ec..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/types/locked_profit_tracker.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// LockedProfitTracker struct -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockedProfitTracker { - /// The total locked profit from the last report - pub last_updated_locked_profit: u64, - /// The last timestamp (in seconds) rebalancing - pub last_report: u64, - /// Rate per second of degradation - pub locked_profit_degradation: u64, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/types/mod.rs b/crates/meteora-vault-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index 9b2e3f3b..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#locked_profit_tracker; -pub(crate) mod r#strategy_type; -pub(crate) mod r#vault_bumps; - -pub use self::{r#locked_profit_tracker::*, r#strategy_type::*, r#vault_bumps::*}; diff --git a/crates/meteora-vault-parser/src/generated_sdk/types/strategy_type.rs b/crates/meteora-vault-parser/src/generated_sdk/types/strategy_type.rs deleted file mode 100644 index 7b2de268..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/types/strategy_type.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// StrategyType struct -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum StrategyType { - PortFinanceWithoutLM, - PortFinanceWithLM, - SolendWithoutLM, - Mango, - SolendWithLM, - ApricotWithoutLM, - Francium, - Tulip, - Vault, - Drift, - Frakt, - Marginfi, -} diff --git a/crates/meteora-vault-parser/src/generated_sdk/types/vault_bumps.rs b/crates/meteora-vault-parser/src/generated_sdk/types/vault_bumps.rs deleted file mode 100644 index 57453e5c..00000000 --- a/crates/meteora-vault-parser/src/generated_sdk/types/vault_bumps.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Vault bumps struct -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct VaultBumps { - /// vault_bump - pub vault_bump: u8, - /// token_vault_bump - pub token_vault_bump: u8, -} diff --git a/crates/meteora-vault-parser/src/lib.rs b/crates/meteora-vault-parser/src/lib.rs deleted file mode 100644 index 28f2c0d0..00000000 --- a/crates/meteora-vault-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = VAULT_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.meteora_vault"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/moonshot-parser/Cargo.toml b/crates/moonshot-parser/Cargo.toml deleted file mode 100644 index b6815afc..00000000 --- a/crates/moonshot-parser/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "yellowstone-vixen-moonshot-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Moonshot program" -license.workspace = true -repository.workspace = true -authors.workspace = true - - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info.workspace = true -solana-cpi.workspace = true -solana-decode-error.workspace = true -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction.workspace = true -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true diff --git a/crates/moonshot-parser/build.rs b/crates/moonshot-parser/build.rs deleted file mode 100644 index 6ec33f6e..00000000 --- a/crates/moonshot-parser/build.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/moonshot.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/moonshot-parser/idl.json b/crates/moonshot-parser/idl.json deleted file mode 100644 index 4033b963..00000000 --- a/crates/moonshot-parser/idl.json +++ /dev/null @@ -1,995 +0,0 @@ -{ - "version": "0.1.0", - "name": "token_launchpad", - "instructions": [ - { - "name": "tokenMint", - "accounts": [ - { - "name": "sender", - "isMut": true, - "isSigner": true - }, - { - "name": "backendAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "curveAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "mint", - "isMut": true, - "isSigner": true - }, - { - "name": "mintMetadata", - "isMut": true, - "isSigner": false, - "docs": [ - "Type validating that the account is owned by the System Program = uninitialized", - "seeds should ensure that the address is correct" - ] - }, - { - "name": "curveTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "configAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "mplTokenMetadata", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "mintParams", - "type": { - "defined": "TokenMintParams" - } - } - ] - }, - { - "name": "buy", - "accounts": [ - { - "name": "sender", - "isMut": true, - "isSigner": true - }, - { - "name": "senderTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "curveAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "curveTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "dexFee", - "isMut": true, - "isSigner": false - }, - { - "name": "helioFee", - "isMut": true, - "isSigner": false - }, - { - "name": "mint", - "isMut": false, - "isSigner": false - }, - { - "name": "configAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "data", - "type": { - "defined": "TradeParams" - } - } - ] - }, - { - "name": "sell", - "accounts": [ - { - "name": "sender", - "isMut": true, - "isSigner": true - }, - { - "name": "senderTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "curveAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "curveTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "dexFee", - "isMut": true, - "isSigner": false - }, - { - "name": "helioFee", - "isMut": true, - "isSigner": false - }, - { - "name": "mint", - "isMut": false, - "isSigner": false - }, - { - "name": "configAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "data", - "type": { - "defined": "TradeParams" - } - } - ] - }, - { - "name": "migrateFunds", - "accounts": [ - { - "name": "backendAuthority", - "isMut": false, - "isSigner": true, - "docs": [ - "BE Authority" - ] - }, - { - "name": "migrationAuthority", - "isMut": true, - "isSigner": true, - "docs": [ - "Migration Authority", - "Owner and Payer over Token Accounts, needs to be mutable" - ] - }, - { - "name": "curveAccount", - "isMut": true, - "isSigner": false, - "docs": [ - "Curve Account", - "The account is closed after this instruction" - ] - }, - { - "name": "curveTokenAccount", - "isMut": true, - "isSigner": false, - "docs": [ - "Curve Token Account", - "The account is closed after this instruction" - ] - }, - { - "name": "migrationAuthorityTokenAccount", - "isMut": true, - "isSigner": false, - "docs": [ - "Authority token Account", - "Init on demand" - ] - }, - { - "name": "mint", - "isMut": true, - "isSigner": false, - "docs": [ - "InterfaceAccount: checks program ownership + deserialize into Mint" - ] - }, - { - "name": "dexFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "helioFeeAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "configAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "configInit", - "accounts": [ - { - "name": "configAuthority", - "isMut": true, - "isSigner": true - }, - { - "name": "configAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "data", - "type": { - "defined": "ConfigParams" - } - } - ] - }, - { - "name": "configUpdate", - "accounts": [ - { - "name": "configAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "configAccount", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "data", - "type": { - "defined": "ConfigParams" - } - } - ] - } - ], - "accounts": [ - { - "name": "ConfigAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "migrationAuthority", - "type": "publicKey" - }, - { - "name": "backendAuthority", - "type": "publicKey" - }, - { - "name": "configAuthority", - "type": "publicKey" - }, - { - "name": "helioFee", - "type": "publicKey" - }, - { - "name": "dexFee", - "type": "publicKey" - }, - { - "name": "feeBps", - "type": "u16" - }, - { - "name": "dexFeeShare", - "type": "u8" - }, - { - "name": "migrationFee", - "type": "u64" - }, - { - "name": "marketcapThreshold", - "type": "u64" - }, - { - "name": "marketcapCurrency", - "type": { - "defined": "Currency" - } - }, - { - "name": "minSupportedDecimalPlaces", - "type": "u8" - }, - { - "name": "maxSupportedDecimalPlaces", - "type": "u8" - }, - { - "name": "minSupportedTokenSupply", - "type": "u64" - }, - { - "name": "maxSupportedTokenSupply", - "type": "u64" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "coefB", - "type": "u32" - } - ] - } - }, - { - "name": "CurveAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "totalSupply", - "type": "u64" - }, - { - "name": "curveAmount", - "type": "u64" - }, - { - "name": "mint", - "type": "publicKey" - }, - { - "name": "decimals", - "type": "u8" - }, - { - "name": "collateralCurrency", - "type": { - "defined": "Currency" - } - }, - { - "name": "curveType", - "type": { - "defined": "CurveType" - } - }, - { - "name": "marketcapThreshold", - "type": "u64" - }, - { - "name": "marketcapCurrency", - "type": { - "defined": "Currency" - } - }, - { - "name": "migrationFee", - "type": "u64" - }, - { - "name": "coefB", - "type": "u32" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "migrationTarget", - "type": { - "defined": "MigrationTarget" - } - } - ] - } - } - ], - "types": [ - { - "name": "TokenMintParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "name", - "type": "string" - }, - { - "name": "symbol", - "type": "string" - }, - { - "name": "uri", - "type": "string" - }, - { - "name": "decimals", - "type": "u8" - }, - { - "name": "collateralCurrency", - "type": "u8" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "curveType", - "type": "u8" - }, - { - "name": "migrationTarget", - "type": "u8" - } - ] - } - }, - { - "name": "TradeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenAmount", - "type": "u64" - }, - { - "name": "collateralAmount", - "type": "u64" - }, - { - "name": "fixedSide", - "type": "u8" - }, - { - "name": "slippageBps", - "type": "u64" - } - ] - } - }, - { - "name": "ConfigParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "migrationAuthority", - "type": { - "option": "publicKey" - } - }, - { - "name": "backendAuthority", - "type": { - "option": "publicKey" - } - }, - { - "name": "configAuthority", - "type": { - "option": "publicKey" - } - }, - { - "name": "helioFee", - "type": { - "option": "publicKey" - } - }, - { - "name": "dexFee", - "type": { - "option": "publicKey" - } - }, - { - "name": "feeBps", - "type": { - "option": "u16" - } - }, - { - "name": "dexFeeShare", - "type": { - "option": "u8" - } - }, - { - "name": "migrationFee", - "type": { - "option": "u64" - } - }, - { - "name": "marketcapThreshold", - "type": { - "option": "u64" - } - }, - { - "name": "marketcapCurrency", - "type": { - "option": "u8" - } - }, - { - "name": "minSupportedDecimalPlaces", - "type": { - "option": "u8" - } - }, - { - "name": "maxSupportedDecimalPlaces", - "type": { - "option": "u8" - } - }, - { - "name": "minSupportedTokenSupply", - "type": { - "option": "u64" - } - }, - { - "name": "maxSupportedTokenSupply", - "type": { - "option": "u64" - } - }, - { - "name": "coefB", - "type": { - "option": "u32" - } - } - ] - } - }, - { - "name": "Currency", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Sol" - } - ] - } - }, - { - "name": "CurveType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "LinearV1" - }, - { - "name": "ConstantProductV1" - } - ] - } - }, - { - "name": "MigrationTarget", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Raydium" - }, - { - "name": "Meteora" - } - ] - } - }, - { - "name": "TradeType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Buy" - }, - { - "name": "Sell" - } - ] - } - }, - { - "name": "FixedSide", - "type": { - "kind": "enum", - "variants": [ - { - "name": "ExactIn" - }, - { - "name": "ExactOut" - } - ] - } - } - ], - "events": [ - { - "name": "TradeEvent", - "fields": [ - { - "name": "amount", - "type": "u64", - "index": false - }, - { - "name": "collateralAmount", - "type": "u64", - "index": false - }, - { - "name": "dexFee", - "type": "u64", - "index": false - }, - { - "name": "helioFee", - "type": "u64", - "index": false - }, - { - "name": "allocation", - "type": "u64", - "index": false - }, - { - "name": "curve", - "type": "publicKey", - "index": false - }, - { - "name": "costToken", - "type": "publicKey", - "index": false - }, - { - "name": "sender", - "type": "publicKey", - "index": false - }, - { - "name": "type", - "type": { - "defined": "TradeType" - }, - "index": false - }, - { - "name": "label", - "type": "string", - "index": true - } - ] - }, - { - "name": "MigrationEvent", - "fields": [ - { - "name": "tokensMigrated", - "type": "u64", - "index": false - }, - { - "name": "tokensBurned", - "type": "u64", - "index": false - }, - { - "name": "collateralMigrated", - "type": "u64", - "index": false - }, - { - "name": "fee", - "type": "u64", - "index": false - }, - { - "name": "label", - "type": "string", - "index": true - } - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "InsufficientBalance", - "msg": "Insufficient SOL to pay for the transaction." - }, - { - "code": 6001, - "name": "InvalidAmount", - "msg": "The amount must be available in the curve ." - }, - { - "code": 6002, - "name": "InvalidSlippage", - "msg": "The slippage must be under 100 percent." - }, - { - "code": 6003, - "name": "SlippageOverflow", - "msg": "The cost amount is not in the allowed slippage interval." - }, - { - "code": 6004, - "name": "ThresholdReached", - "msg": "Threshold limit exceeded." - }, - { - "code": 6005, - "name": "InvalidTokenAccount", - "msg": "Trade disabled, market cap threshold reached." - }, - { - "code": 6006, - "name": "InvalidCurveAccount", - "msg": "Invalid curve account." - }, - { - "code": 6007, - "name": "InvalidFeeAccount", - "msg": "Invalid fee account address." - }, - { - "code": 6008, - "name": "CurveLimit", - "msg": "Curve limit exceeded." - }, - { - "code": 6009, - "name": "InvalidCurveType", - "msg": "Invalid curve type." - }, - { - "code": 6010, - "name": "InvalidCurrency", - "msg": "Invalid currency." - }, - { - "code": 6011, - "name": "Arithmetics", - "msg": "Artithmetics error" - }, - { - "code": 6012, - "name": "ThresholdNotHit", - "msg": "Market Cap threshold not hit, cannot migrate funds yet" - }, - { - "code": 6013, - "name": "InvalidAuthority", - "msg": "Invalid Authority provided." - }, - { - "code": 6014, - "name": "TradeAmountTooLow", - "msg": "Trade amount too low , resulting in 0 costs" - }, - { - "code": 6015, - "name": "ConfigFieldMissing", - "msg": "Config field needs to be present during initialization" - }, - { - "code": 6016, - "name": "DifferentCurrencies", - "msg": "Unsupported different currency types" - }, - { - "code": 6017, - "name": "BasisPointTooHigh", - "msg": "Basis points too high" - }, - { - "code": 6018, - "name": "FeeShareTooHigh", - "msg": "Fee share too High" - }, - { - "code": 6019, - "name": "TokenDecimalsOutOfRange", - "msg": "Token decimals are not within the supported range" - }, - { - "code": 6020, - "name": "TokenNameTooLong", - "msg": "Token Name too long, max supported length is 32 bytes" - }, - { - "code": 6021, - "name": "TokenSymbolTooLong", - "msg": "Token Symbol too long, max supported length is 10 bytes" - }, - { - "code": 6022, - "name": "TokenURITooLong", - "msg": "Token URI too long, max supported length is 200 bytes" - }, - { - "code": 6023, - "name": "IncorrectDecimalPlacesBounds", - "msg": "Minimum Decimal Places cannot be lower than Maximum Decimal Places" - }, - { - "code": 6024, - "name": "IncorrectTokenSupplyBounds", - "msg": "Minimum Token Supply cannot be lower than Maximum Token Supply" - }, - { - "code": 6025, - "name": "TotalSupplyOutOfBounds", - "msg": "Token Total Supply out of bounds" - }, - { - "code": 6026, - "name": "FinalCollateralTooLow", - "msg": "This setup will produce final collateral amount less than the migration fee" - }, - { - "code": 6027, - "name": "CoefficientZero", - "msg": "One of the Coefficients is equal to ZERO" - }, - { - "code": 6028, - "name": "MarketCapThresholdTooLow", - "msg": "Market cap Threshold under the Hard lower bound limits" - }, - { - "code": 6029, - "name": "CoefBOutofBounds", - "msg": "Default coef_b set out of hard limit bounds" - }, - { - "code": 6030, - "name": "IncorrectMarketCap", - "msg": "For Constant Product the Market Cap threshold cannot be higher than 325 SOL" - }, - { - "code": 6031, - "name": "IncorrectDecimals", - "msg": "For Constant Product the Decimal places cannot be other than 9" - }, - { - "code": 6032, - "name": "IncorrectMaxSupply", - "msg": "For Constant Product the Maximal Token Supply cannot be other than 1_000_000_000" - }, - { - "code": 6033, - "name": "MarketCapTooHigh", - "msg": "Market Cap Threshold set too high, will not be hit even if Curve Hard Limit reached" - }, - { - "code": 6034, - "name": "InvalidMigrationTarget", - "msg": "This Migration Target is not supported!" - }, - { - "code": 6035, - "name": "General", - "msg": "General error" - } - ] -} \ No newline at end of file diff --git a/crates/moonshot-parser/proto/moonshot.proto b/crates/moonshot-parser/proto/moonshot.proto deleted file mode 100644 index 0d11c7fc..00000000 --- a/crates/moonshot-parser/proto/moonshot.proto +++ /dev/null @@ -1,241 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.moonshot; - -message TokenMintIx { - TokenMintIxAccounts accounts = 1; - TokenMintIxData data = 2; -} - -message BuyIx { - BuyIxAccounts accounts = 1; - BuyIxData data = 2; -} - -message SellIx { - SellIxAccounts accounts = 1; - SellIxData data = 2; -} - -message MigrateFundsIx { - MigrateFundsIxAccounts accounts = 1; -} - -message ConfigInitIx { - ConfigInitIxAccounts accounts = 1; - ConfigInitIxData data = 2; -} - -message ConfigUpdateIx { - ConfigUpdateIxAccounts accounts = 1; - ConfigUpdateIxData data = 2; -} - - -message TradeParams { - uint64 token_amount = 1; - uint64 collateral_amount = 2; - uint32 fixed_side = 3; - uint64 slippage_bps = 4; -} - -message ConfigParams { - optional string migration_authority = 1; - optional string backend_authority = 2; - optional string config_authority = 3; - optional string helio_fee = 4; - optional string dex_fee = 5; - optional uint32 fee_bps = 6; - optional uint32 dex_fee_share = 7; - optional uint64 migration_fee = 8; - optional uint64 marketcap_threshold = 9; - optional uint32 marketcap_currency = 10; - optional uint32 min_supported_decimal_places = 11; - optional uint32 max_supported_decimal_places = 12; - optional uint64 min_supported_token_supply = 13; - optional uint64 max_supported_token_supply = 14; - optional uint32 coef_b = 15; -} - -enum Currency { - CurrencySol = 0; -} - -enum CurveType { - CurveTypeLinearV1 = 0; - CurveTypeConstantProductV1 = 1; -} - -enum MigrationTarget { - MigrationTargetRaydium = 0; - MigrationTargetMeteora = 1; -} - -enum TradeType { - TradeTypeBuy = 0; - TradeTypeSell = 1; -} - -enum FixedSide { - FixedSideExactIn = 0; - FixedSideExactOut = 1; -} - - -message ConfigAccount { - string migration_authority = 1; - string backend_authority = 2; - string config_authority = 3; - string helio_fee = 4; - string dex_fee = 5; - uint32 fee_bps = 6; - uint32 dex_fee_share = 7; - uint64 migration_fee = 8; - uint64 marketcap_threshold = 9; - Currency marketcap_currency = 10; - uint32 min_supported_decimal_places = 11; - uint32 max_supported_decimal_places = 12; - uint64 min_supported_token_supply = 13; - uint64 max_supported_token_supply = 14; - uint32 bump = 15; - uint32 coef_b = 16; -} - -message CurveAccount { - uint64 total_supply = 1; - uint64 curve_amount = 2; - string mint = 3; - uint32 decimals = 4; - Currency collateral_currency = 5; - CurveType curve_type = 6; - uint64 marketcap_threshold = 7; - Currency marketcap_currency = 8; - uint64 migration_fee = 9; - uint32 coef_b = 10; - uint32 bump = 11; - MigrationTarget migration_target = 12; - uint32 price_increase = 13; -} - - -message TokenMintIxAccounts { - string sender = 1; - string backend_authority = 2; - string curve_account = 3; - string mint = 4; - string mint_metadata = 5; - string curve_token_account = 6; - string config_account = 7; - string token_program = 8; - string associated_token_program = 9; - string mpl_token_metadata = 10; - string system_program = 11; -} - -message TokenMintIxData { - string name = 1; - string symbol = 2; - string uri = 3; - uint32 decimals = 4; - uint32 collateral_currency = 5; - uint64 amount = 6; - uint32 curve_type = 7; - uint32 migration_target = 8; -} - -message BuyIxAccounts { - string sender = 1; - string sender_token_account = 2; - string curve_account = 3; - string curve_token_account = 4; - string dex_fee = 5; - string helio_fee = 6; - string mint = 7; - string config_account = 8; - string token_program = 9; - string associated_token_program = 10; - string system_program = 11; -} - -message BuyIxData { - TradeParams data = 1; -} - -message SellIxAccounts { - string sender = 1; - string sender_token_account = 2; - string curve_account = 3; - string curve_token_account = 4; - string dex_fee = 5; - string helio_fee = 6; - string mint = 7; - string config_account = 8; - string token_program = 9; - string associated_token_program = 10; - string system_program = 11; -} - -message SellIxData { - TradeParams data = 1; -} - -message MigrateFundsIxAccounts { - string backend_authority = 1; - string migration_authority = 2; - string curve_account = 3; - string curve_token_account = 4; - string migration_authority_token_account = 5; - string mint = 6; - string dex_fee_account = 7; - string helio_fee_account = 8; - string config_account = 9; - string system_program = 10; - string token_program = 11; - string associated_token_program = 12; -} - - -message ConfigInitIxAccounts { - string config_authority = 1; - string config_account = 2; - string system_program = 3; -} - -message ConfigInitIxData { - ConfigParams data = 1; -} - -message ConfigUpdateIxAccounts { - string config_authority = 1; - string config_account = 2; -} - -message ConfigUpdateIxData { - ConfigParams data = 1; -} - - -message ProgramState { - oneof state_oneof { - ConfigAccount config_account = 1; - CurveAccount curve_account = 2; - } -} - -message ProgramIxs { - oneof ix_oneof { - TokenMintIx token_mint = 1; - BuyIx buy = 2; - SellIx sell = 3; - MigrateFundsIx migrate_funds = 4; - ConfigInitIx config_init = 5; - ConfigUpdateIx config_update = 6; - } -} - diff --git a/crates/moonshot-parser/src/generated_parser/accounts_parser.rs b/crates/moonshot-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index a2738083..00000000 --- a/crates/moonshot-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,182 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{ConfigAccount, CurveAccount}, - deserialize_checked, ID, -}; - -/// TokenLaunchpad Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum TokenLaunchpadProgramState { - ConfigAccount(ConfigAccount), - CurveAccount(CurveAccount), -} - -impl TokenLaunchpadProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [189, 255, 97, 70, 186, 189, 24, 102] => Ok(TokenLaunchpadProgramState::ConfigAccount( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [8, 91, 83, 28, 132, 216, 248, 22] => Ok(TokenLaunchpadProgramState::CurveAccount( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = TokenLaunchpadProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "token_launchpad::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = TokenLaunchpadProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, ConfigAccount, TokenLaunchpadProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for ConfigAccount { - fn into_proto(self) -> proto_def::ConfigAccount { - proto_def::ConfigAccount { - migration_authority: self.migration_authority.to_string(), - backend_authority: self.backend_authority.to_string(), - config_authority: self.config_authority.to_string(), - helio_fee: self.helio_fee.to_string(), - dex_fee: self.dex_fee.to_string(), - fee_bps: self.fee_bps.into(), - dex_fee_share: self.dex_fee_share.into(), - migration_fee: self.migration_fee, - marketcap_threshold: self.marketcap_threshold, - marketcap_currency: self.marketcap_currency as i32, - min_supported_decimal_places: self.min_supported_decimal_places.into(), - max_supported_decimal_places: self.max_supported_decimal_places.into(), - min_supported_token_supply: self.min_supported_token_supply, - max_supported_token_supply: self.max_supported_token_supply, - bump: self.bump.into(), - coef_b: self.coef_b, - } - } - } - use super::CurveAccount; - impl IntoProto for CurveAccount { - fn into_proto(self) -> proto_def::CurveAccount { - proto_def::CurveAccount { - total_supply: self.total_supply, - curve_amount: self.curve_amount, - mint: self.mint.to_string(), - decimals: self.decimals.into(), - collateral_currency: self.collateral_currency as i32, - curve_type: self.curve_type as i32, - marketcap_threshold: self.marketcap_threshold, - marketcap_currency: self.marketcap_currency as i32, - migration_fee: self.migration_fee, - coef_b: self.coef_b, - bump: self.bump.into(), - migration_target: self.migration_target as i32, - price_increase: self.price_increase.into(), - } - } - } - - impl IntoProto for TokenLaunchpadProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - TokenLaunchpadProgramState::ConfigAccount(data) => { - proto_def::program_state::StateOneof::ConfigAccount(data.into_proto()) - }, - TokenLaunchpadProgramState::CurveAccount(data) => { - proto_def::program_state::StateOneof::CurveAccount(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/moonshot-parser/src/generated_parser/instructions_parser.rs b/crates/moonshot-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index ecc583bf..00000000 --- a/crates/moonshot-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,506 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - Buy as BuyIxAccounts, BuyInstructionArgs as BuyIxData, ConfigInit as ConfigInitIxAccounts, - ConfigInitInstructionArgs as ConfigInitIxData, ConfigUpdate as ConfigUpdateIxAccounts, - ConfigUpdateInstructionArgs as ConfigUpdateIxData, MigrateFunds as MigrateFundsIxAccounts, - Sell as SellIxAccounts, SellInstructionArgs as SellIxData, - TokenMint as TokenMintIxAccounts, TokenMintInstructionArgs as TokenMintIxData, - }, - ID, -}; - -/// TokenLaunchpad Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum TokenLaunchpadProgramIx { - TokenMint(TokenMintIxAccounts, TokenMintIxData), - Buy(BuyIxAccounts, BuyIxData), - Sell(SellIxAccounts, SellIxData), - MigrateFunds(MigrateFundsIxAccounts), - ConfigInit(ConfigInitIxAccounts, ConfigInitIxData), - ConfigUpdate(ConfigUpdateIxAccounts, ConfigUpdateIxData), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = TokenLaunchpadProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "TokenLaunchpad::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [3, 44, 164, 184, 123, 13, 245, 179] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = TokenMintIxAccounts { - sender: next_account(accounts)?, - backend_authority: next_account(accounts)?, - curve_account: next_account(accounts)?, - mint: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - curve_token_account: next_account(accounts)?, - config_account: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - mpl_token_metadata: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: TokenMintIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(TokenLaunchpadProgramIx::TokenMint(ix_accounts, de_ix_data)) - }, - [102, 6, 61, 18, 1, 218, 235, 234] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = BuyIxAccounts { - sender: next_account(accounts)?, - sender_token_account: next_account(accounts)?, - curve_account: next_account(accounts)?, - curve_token_account: next_account(accounts)?, - dex_fee: next_account(accounts)?, - helio_fee: next_account(accounts)?, - mint: next_account(accounts)?, - config_account: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: BuyIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(TokenLaunchpadProgramIx::Buy(ix_accounts, de_ix_data)) - }, - [51, 230, 133, 164, 1, 127, 131, 173] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SellIxAccounts { - sender: next_account(accounts)?, - sender_token_account: next_account(accounts)?, - curve_account: next_account(accounts)?, - curve_token_account: next_account(accounts)?, - dex_fee: next_account(accounts)?, - helio_fee: next_account(accounts)?, - mint: next_account(accounts)?, - config_account: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: SellIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(TokenLaunchpadProgramIx::Sell(ix_accounts, de_ix_data)) - }, - [42, 229, 10, 231, 189, 62, 193, 174] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrateFundsIxAccounts { - backend_authority: next_account(accounts)?, - migration_authority: next_account(accounts)?, - curve_account: next_account(accounts)?, - curve_token_account: next_account(accounts)?, - migration_authority_token_account: next_account(accounts)?, - mint: next_account(accounts)?, - dex_fee_account: next_account(accounts)?, - helio_fee_account: next_account(accounts)?, - config_account: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - Ok(TokenLaunchpadProgramIx::MigrateFunds(ix_accounts)) - }, - [13, 236, 164, 173, 106, 253, 164, 185] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ConfigInitIxAccounts { - config_authority: next_account(accounts)?, - config_account: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: ConfigInitIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(TokenLaunchpadProgramIx::ConfigInit(ix_accounts, de_ix_data)) - }, - [80, 37, 109, 136, 82, 135, 89, 241] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ConfigUpdateIxAccounts { - config_authority: next_account(accounts)?, - config_account: next_account(accounts)?, - }; - let de_ix_data: ConfigUpdateIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(TokenLaunchpadProgramIx::ConfigUpdate( - ix_accounts, - de_ix_data, - )) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{InstructionParser, TokenLaunchpadProgramIx, TokenMintIxAccounts}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for TokenMintIxAccounts { - fn into_proto(self) -> proto_def::TokenMintIxAccounts { - proto_def::TokenMintIxAccounts { - sender: self.sender.to_string(), - backend_authority: self.backend_authority.to_string(), - curve_account: self.curve_account.to_string(), - mint: self.mint.to_string(), - mint_metadata: self.mint_metadata.to_string(), - curve_token_account: self.curve_token_account.to_string(), - config_account: self.config_account.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - mpl_token_metadata: self.mpl_token_metadata.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::TokenMintIxData; - impl IntoProto for TokenMintIxData { - fn into_proto(self) -> proto_def::TokenMintIxData { - proto_def::TokenMintIxData { - name: self.name, - symbol: self.symbol, - uri: self.uri, - decimals: self.decimals.into(), - collateral_currency: self.collateral_currency.into(), - amount: self.amount, - curve_type: self.curve_type.into(), - migration_target: self.migration_target.into(), - } - } - } - use super::BuyIxAccounts; - impl IntoProto for BuyIxAccounts { - fn into_proto(self) -> proto_def::BuyIxAccounts { - proto_def::BuyIxAccounts { - sender: self.sender.to_string(), - sender_token_account: self.sender_token_account.to_string(), - curve_account: self.curve_account.to_string(), - curve_token_account: self.curve_token_account.to_string(), - dex_fee: self.dex_fee.to_string(), - helio_fee: self.helio_fee.to_string(), - mint: self.mint.to_string(), - config_account: self.config_account.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::BuyIxData; - impl IntoProto for BuyIxData { - fn into_proto(self) -> proto_def::BuyIxData { - proto_def::BuyIxData { - data: Some(self.data.into_proto()), - } - } - } - use super::SellIxAccounts; - impl IntoProto for SellIxAccounts { - fn into_proto(self) -> proto_def::SellIxAccounts { - proto_def::SellIxAccounts { - sender: self.sender.to_string(), - sender_token_account: self.sender_token_account.to_string(), - curve_account: self.curve_account.to_string(), - curve_token_account: self.curve_token_account.to_string(), - dex_fee: self.dex_fee.to_string(), - helio_fee: self.helio_fee.to_string(), - mint: self.mint.to_string(), - config_account: self.config_account.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::SellIxData; - impl IntoProto for SellIxData { - fn into_proto(self) -> proto_def::SellIxData { - proto_def::SellIxData { - data: Some(self.data.into_proto()), - } - } - } - use super::MigrateFundsIxAccounts; - impl IntoProto for MigrateFundsIxAccounts { - fn into_proto(self) -> proto_def::MigrateFundsIxAccounts { - proto_def::MigrateFundsIxAccounts { - backend_authority: self.backend_authority.to_string(), - migration_authority: self.migration_authority.to_string(), - curve_account: self.curve_account.to_string(), - curve_token_account: self.curve_token_account.to_string(), - migration_authority_token_account: self - .migration_authority_token_account - .to_string(), - mint: self.mint.to_string(), - dex_fee_account: self.dex_fee_account.to_string(), - helio_fee_account: self.helio_fee_account.to_string(), - config_account: self.config_account.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::ConfigInitIxAccounts; - impl IntoProto for ConfigInitIxAccounts { - fn into_proto(self) -> proto_def::ConfigInitIxAccounts { - proto_def::ConfigInitIxAccounts { - config_authority: self.config_authority.to_string(), - config_account: self.config_account.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::ConfigInitIxData; - impl IntoProto for ConfigInitIxData { - fn into_proto(self) -> proto_def::ConfigInitIxData { - proto_def::ConfigInitIxData { - data: Some(self.data.into_proto()), - } - } - } - use super::ConfigUpdateIxAccounts; - impl IntoProto for ConfigUpdateIxAccounts { - fn into_proto(self) -> proto_def::ConfigUpdateIxAccounts { - proto_def::ConfigUpdateIxAccounts { - config_authority: self.config_authority.to_string(), - config_account: self.config_account.to_string(), - } - } - } - use super::ConfigUpdateIxData; - impl IntoProto for ConfigUpdateIxData { - fn into_proto(self) -> proto_def::ConfigUpdateIxData { - proto_def::ConfigUpdateIxData { - data: Some(self.data.into_proto()), - } - } - } - - impl IntoProto for TokenLaunchpadProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - TokenLaunchpadProgramIx::TokenMint(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::TokenMint( - proto_def::TokenMintIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - TokenLaunchpadProgramIx::Buy(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Buy(proto_def::BuyIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - TokenLaunchpadProgramIx::Sell(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Sell(proto_def::SellIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - TokenLaunchpadProgramIx::MigrateFunds(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::MigrateFunds( - proto_def::MigrateFundsIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - TokenLaunchpadProgramIx::ConfigInit(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ConfigInit( - proto_def::ConfigInitIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - TokenLaunchpadProgramIx::ConfigUpdate(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ConfigUpdate( - proto_def::ConfigUpdateIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/moonshot-parser/src/generated_parser/mod.rs b/crates/moonshot-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/moonshot-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/moonshot-parser/src/generated_parser/proto_helpers.rs b/crates/moonshot-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index d0f7f303..00000000 --- a/crates/moonshot-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::TradeParams}; - impl IntoProto for TradeParams { - fn into_proto(self) -> proto_def::TradeParams { - proto_def::TradeParams { - token_amount: self.token_amount, - collateral_amount: self.collateral_amount, - fixed_side: self.fixed_side.into(), - slippage_bps: self.slippage_bps, - } - } - } - use crate::types::ConfigParams; - impl IntoProto for ConfigParams { - fn into_proto(self) -> proto_def::ConfigParams { - proto_def::ConfigParams { - migration_authority: self.migration_authority.map(|x| x.to_string()), - backend_authority: self.backend_authority.map(|x| x.to_string()), - config_authority: self.config_authority.map(|x| x.to_string()), - helio_fee: self.helio_fee.map(|x| x.to_string()), - dex_fee: self.dex_fee.map(|x| x.to_string()), - fee_bps: self.fee_bps.map(|x| x.into()), - dex_fee_share: self.dex_fee_share.map(|x| x.into()), - migration_fee: self.migration_fee, - marketcap_threshold: self.marketcap_threshold, - marketcap_currency: self.marketcap_currency.map(|x| x.into()), - min_supported_decimal_places: self.min_supported_decimal_places.map(|x| x.into()), - max_supported_decimal_places: self.max_supported_decimal_places.map(|x| x.into()), - min_supported_token_supply: self.min_supported_token_supply, - max_supported_token_supply: self.max_supported_token_supply, - coef_b: self.coef_b, - } - } - } -} diff --git a/crates/moonshot-parser/src/generated_sdk/accounts/config_account.rs b/crates/moonshot-parser/src/generated_sdk/accounts/config_account.rs deleted file mode 100644 index 32a267c4..00000000 --- a/crates/moonshot-parser/src/generated_sdk/accounts/config_account.rs +++ /dev/null @@ -1,165 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::Currency; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ConfigAccount { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub migration_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub backend_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub helio_fee: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub dex_fee: Pubkey, - pub fee_bps: u16, - pub dex_fee_share: u8, - pub migration_fee: u64, - pub marketcap_threshold: u64, - pub marketcap_currency: Currency, - pub min_supported_decimal_places: u8, - pub max_supported_decimal_places: u8, - pub min_supported_token_supply: u64, - pub max_supported_token_supply: u64, - pub bump: u8, - pub coef_b: u32, -} - -impl ConfigAccount { - pub const LEN: usize = 211; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for ConfigAccount { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_config_account( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_config_account(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_config_account( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = ConfigAccount::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_config_account( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_config_account(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_config_account( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = ConfigAccount::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for ConfigAccount { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for ConfigAccount {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for ConfigAccount { - fn owner() -> Pubkey { crate::TOKEN_LAUNCHPAD_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for ConfigAccount {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for ConfigAccount { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/moonshot-parser/src/generated_sdk/accounts/curve_account.rs b/crates/moonshot-parser/src/generated_sdk/accounts/curve_account.rs deleted file mode 100644 index 65d52c7a..00000000 --- a/crates/moonshot-parser/src/generated_sdk/accounts/curve_account.rs +++ /dev/null @@ -1,146 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{Currency, CurveType, MigrationTarget}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CurveAccount { - pub discriminator: [u8; 8], - pub total_supply: u64, - pub curve_amount: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub decimals: u8, - pub collateral_currency: Currency, - pub curve_type: CurveType, - pub marketcap_threshold: u64, - pub marketcap_currency: Currency, - pub migration_fee: u64, - pub coef_b: u32, - pub bump: u8, - pub migration_target: MigrationTarget, - pub price_increase: u16, -} - -impl CurveAccount { - pub const LEN: usize = 82; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for CurveAccount { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_curve_account( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_curve_account(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_curve_account( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = CurveAccount::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_curve_account( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_curve_account(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_curve_account( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = CurveAccount::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for CurveAccount { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for CurveAccount {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for CurveAccount { - fn owner() -> Pubkey { crate::TOKEN_LAUNCHPAD_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for CurveAccount {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for CurveAccount { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/moonshot-parser/src/generated_sdk/accounts/mod.rs b/crates/moonshot-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index e4c49c13..00000000 --- a/crates/moonshot-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#config_account; -pub(crate) mod r#curve_account; - -pub use self::{r#config_account::*, r#curve_account::*}; diff --git a/crates/moonshot-parser/src/generated_sdk/errors/mod.rs b/crates/moonshot-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index c08830c4..00000000 --- a/crates/moonshot-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod token_launchpad; - -pub use self::token_launchpad::TokenLaunchpadError; diff --git a/crates/moonshot-parser/src/generated_sdk/errors/token_launchpad.rs b/crates/moonshot-parser/src/generated_sdk/errors/token_launchpad.rs deleted file mode 100644 index dcd924f0..00000000 --- a/crates/moonshot-parser/src/generated_sdk/errors/token_launchpad.rs +++ /dev/null @@ -1,133 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum TokenLaunchpadError { - /// 6000 - Insufficient SOL to pay for the transaction. - #[error("Insufficient SOL to pay for the transaction.")] - InsufficientBalance = 0x1770, - /// 6001 - The amount must be available in the curve . - #[error("The amount must be available in the curve .")] - InvalidAmount = 0x1771, - /// 6002 - The slippage must be under 100 percent. - #[error("The slippage must be under 100 percent.")] - InvalidSlippage = 0x1772, - /// 6003 - The cost amount is not in the allowed slippage interval. - #[error("The cost amount is not in the allowed slippage interval.")] - SlippageOverflow = 0x1773, - /// 6004 - Threshold limit exceeded. - #[error("Threshold limit exceeded.")] - ThresholdReached = 0x1774, - /// 6005 - Trade disabled, market cap threshold reached. - #[error("Trade disabled, market cap threshold reached.")] - InvalidTokenAccount = 0x1775, - /// 6006 - Invalid curve account. - #[error("Invalid curve account.")] - InvalidCurveAccount = 0x1776, - /// 6007 - Invalid fee account address. - #[error("Invalid fee account address.")] - InvalidFeeAccount = 0x1777, - /// 6008 - Curve limit exceeded. - #[error("Curve limit exceeded.")] - CurveLimit = 0x1778, - /// 6009 - Invalid curve type. - #[error("Invalid curve type.")] - InvalidCurveType = 0x1779, - /// 6010 - Invalid currency. - #[error("Invalid currency.")] - InvalidCurrency = 0x177a, - /// 6011 - Artithmetics error - #[error("Artithmetics error")] - Arithmetics = 0x177b, - /// 6012 - Market Cap threshold not hit, cannot migrate funds yet - #[error("Market Cap threshold not hit, cannot migrate funds yet")] - ThresholdNotHit = 0x177c, - /// 6013 - Invalid Authority provided. - #[error("Invalid Authority provided.")] - InvalidAuthority = 0x177d, - /// 6014 - Trade amount too low , resulting in 0 costs - #[error("Trade amount too low , resulting in 0 costs")] - TradeAmountTooLow = 0x177e, - /// 6015 - Config field needs to be present during initialization - #[error("Config field needs to be present during initialization")] - ConfigFieldMissing = 0x177f, - /// 6016 - Unsupported different currency types - #[error("Unsupported different currency types")] - DifferentCurrencies = 0x1780, - /// 6017 - Basis points too high - #[error("Basis points too high")] - BasisPointTooHigh = 0x1781, - /// 6018 - Fee share too High - #[error("Fee share too High")] - FeeShareTooHigh = 0x1782, - /// 6019 - Token decimals are not within the supported range - #[error("Token decimals are not within the supported range")] - TokenDecimalsOutOfRange = 0x1783, - /// 6020 - Token Name too long, max supported length is 32 bytes - #[error("Token Name too long, max supported length is 32 bytes")] - TokenNameTooLong = 0x1784, - /// 6021 - Token Symbol too long, max supported length is 10 bytes - #[error("Token Symbol too long, max supported length is 10 bytes")] - TokenSymbolTooLong = 0x1785, - /// 6022 - Token URI too long, max supported length is 200 bytes - #[error("Token URI too long, max supported length is 200 bytes")] - TokenURITooLong = 0x1786, - /// 6023 - Minimum Decimal Places cannot be lower than Maximum Decimal Places - #[error("Minimum Decimal Places cannot be lower than Maximum Decimal Places")] - IncorrectDecimalPlacesBounds = 0x1787, - /// 6024 - Minimum Token Supply cannot be lower than Maximum Token Supply - #[error("Minimum Token Supply cannot be lower than Maximum Token Supply")] - IncorrectTokenSupplyBounds = 0x1788, - /// 6025 - Token Total Supply out of bounds - #[error("Token Total Supply out of bounds")] - TotalSupplyOutOfBounds = 0x1789, - /// 6026 - This setup will produce final collateral amount less than the migration fee - #[error("This setup will produce final collateral amount less than the migration fee")] - FinalCollateralTooLow = 0x178a, - /// 6027 - One of the Coefficients is equal to ZERO - #[error("One of the Coefficients is equal to ZERO")] - CoefficientZero = 0x178b, - /// 6028 - Market cap Threshold under the Hard lower bound limits - #[error("Market cap Threshold under the Hard lower bound limits")] - MarketCapThresholdTooLow = 0x178c, - /// 6029 - Default coef_b set out of hard limit bounds - #[error("Default coef_b set out of hard limit bounds")] - CoefBOutofBounds = 0x178d, - /// 6030 - For Constant Product the Market Cap threshold cannot be higher than 325 SOL - #[error("For Constant Product the Market Cap threshold cannot be higher than 325 SOL")] - IncorrectMarketCap = 0x178e, - /// 6031 - For Constant Product the Decimal places cannot be other than 9 - #[error("For Constant Product the Decimal places cannot be other than 9")] - IncorrectDecimals = 0x178f, - /// 6032 - For Constant Product the Maximal Token Supply cannot be other than 1_000_000_000 - #[error("For Constant Product the Maximal Token Supply cannot be other than 1_000_000_000")] - IncorrectMaxSupply = 0x1790, - /// 6033 - Market Cap Threshold set too high, will not be hit even if Curve Hard Limit reached - #[error("Market Cap Threshold set too high, will not be hit even if Curve Hard Limit reached")] - MarketCapTooHigh = 0x1791, - /// 6034 - This Migration Target is not supported! - #[error("This Migration Target is not supported!")] - InvalidMigrationTarget = 0x1792, - /// 6035 - General error - #[error("General error")] - General = 0x1793, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for TokenLaunchpadError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for TokenLaunchpadError { - fn type_of() -> &'static str { "TokenLaunchpadError" } -} diff --git a/crates/moonshot-parser/src/generated_sdk/instructions/buy.rs b/crates/moonshot-parser/src/generated_sdk/instructions/buy.rs deleted file mode 100644 index 6f2172bc..00000000 --- a/crates/moonshot-parser/src/generated_sdk/instructions/buy.rs +++ /dev/null @@ -1,723 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::TradeParams; - -/// Accounts. -#[derive(Debug)] -pub struct Buy { - pub sender: solana_pubkey::Pubkey, - - pub sender_token_account: solana_pubkey::Pubkey, - - pub curve_account: solana_pubkey::Pubkey, - - pub curve_token_account: solana_pubkey::Pubkey, - - pub dex_fee: solana_pubkey::Pubkey, - - pub helio_fee: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub config_account: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl Buy { - pub fn instruction(&self, args: BuyInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: BuyInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.sender, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.sender_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.curve_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.curve_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.dex_fee, false)); - accounts.push(solana_instruction::AccountMeta::new(self.helio_fee, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&BuyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyInstructionData { - discriminator: [u8; 8], -} - -impl BuyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [102, 6, 61, 18, 1, 218, 235, 234], - } - } -} - -impl Default for BuyInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyInstructionArgs { - pub data: TradeParams, -} - -/// Instruction builder for `Buy`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` sender -/// 1. `[writable]` sender_token_account -/// 2. `[writable]` curve_account -/// 3. `[writable]` curve_token_account -/// 4. `[writable]` dex_fee -/// 5. `[writable]` helio_fee -/// 6. `[]` mint -/// 7. `[]` config_account -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[]` associated_token_program -/// 10. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct BuyBuilder { - sender: Option, - sender_token_account: Option, - curve_account: Option, - curve_token_account: Option, - dex_fee: Option, - helio_fee: Option, - mint: Option, - config_account: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - data: Option, - __remaining_accounts: Vec, -} - -impl BuyBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn sender_token_account( - &mut self, - sender_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.sender_token_account = Some(sender_token_account); - self - } - - #[inline(always)] - pub fn curve_account(&mut self, curve_account: solana_pubkey::Pubkey) -> &mut Self { - self.curve_account = Some(curve_account); - self - } - - #[inline(always)] - pub fn curve_token_account(&mut self, curve_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.curve_token_account = Some(curve_token_account); - self - } - - #[inline(always)] - pub fn dex_fee(&mut self, dex_fee: solana_pubkey::Pubkey) -> &mut Self { - self.dex_fee = Some(dex_fee); - self - } - - #[inline(always)] - pub fn helio_fee(&mut self, helio_fee: solana_pubkey::Pubkey) -> &mut Self { - self.helio_fee = Some(helio_fee); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn config_account(&mut self, config_account: solana_pubkey::Pubkey) -> &mut Self { - self.config_account = Some(config_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn data(&mut self, data: TradeParams) -> &mut Self { - self.data = Some(data); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Buy { - sender: self.sender.expect("sender is not set"), - sender_token_account: self - .sender_token_account - .expect("sender_token_account is not set"), - curve_account: self.curve_account.expect("curve_account is not set"), - curve_token_account: self - .curve_token_account - .expect("curve_token_account is not set"), - dex_fee: self.dex_fee.expect("dex_fee is not set"), - helio_fee: self.helio_fee.expect("helio_fee is not set"), - mint: self.mint.expect("mint is not set"), - config_account: self.config_account.expect("config_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = BuyInstructionArgs { - data: self.data.clone().expect("data is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `buy` CPI accounts. -pub struct BuyCpiAccounts<'a, 'b> { - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub sender_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub curve_account: &'b solana_account_info::AccountInfo<'a>, - - pub curve_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub dex_fee: &'b solana_account_info::AccountInfo<'a>, - - pub helio_fee: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `buy` CPI instruction. -pub struct BuyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub sender_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub curve_account: &'b solana_account_info::AccountInfo<'a>, - - pub curve_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub dex_fee: &'b solana_account_info::AccountInfo<'a>, - - pub helio_fee: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: BuyInstructionArgs, -} - -impl<'a, 'b> BuyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: BuyCpiAccounts<'a, 'b>, - args: BuyInstructionArgs, - ) -> Self { - Self { - __program: program, - sender: accounts.sender, - sender_token_account: accounts.sender_token_account, - curve_account: accounts.curve_account, - curve_token_account: accounts.curve_token_account, - dex_fee: accounts.dex_fee, - helio_fee: accounts.helio_fee, - mint: accounts.mint, - config_account: accounts.config_account, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.sender.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.sender_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.curve_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.curve_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.dex_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.helio_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&BuyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.sender_token_account.clone()); - account_infos.push(self.curve_account.clone()); - account_infos.push(self.curve_token_account.clone()); - account_infos.push(self.dex_fee.clone()); - account_infos.push(self.helio_fee.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.config_account.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Buy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` sender -/// 1. `[writable]` sender_token_account -/// 2. `[writable]` curve_account -/// 3. `[writable]` curve_token_account -/// 4. `[writable]` dex_fee -/// 5. `[writable]` helio_fee -/// 6. `[]` mint -/// 7. `[]` config_account -/// 8. `[]` token_program -/// 9. `[]` associated_token_program -/// 10. `[]` system_program -#[derive(Clone, Debug)] -pub struct BuyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> BuyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(BuyCpiBuilderInstruction { - __program: program, - sender: None, - sender_token_account: None, - curve_account: None, - curve_token_account: None, - dex_fee: None, - helio_fee: None, - mint: None, - config_account: None, - token_program: None, - associated_token_program: None, - system_program: None, - data: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn sender_token_account( - &mut self, - sender_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.sender_token_account = Some(sender_token_account); - self - } - - #[inline(always)] - pub fn curve_account( - &mut self, - curve_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.curve_account = Some(curve_account); - self - } - - #[inline(always)] - pub fn curve_token_account( - &mut self, - curve_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.curve_token_account = Some(curve_token_account); - self - } - - #[inline(always)] - pub fn dex_fee(&mut self, dex_fee: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.dex_fee = Some(dex_fee); - self - } - - #[inline(always)] - pub fn helio_fee(&mut self, helio_fee: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.helio_fee = Some(helio_fee); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn config_account( - &mut self, - config_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_account = Some(config_account); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn data(&mut self, data: TradeParams) -> &mut Self { - self.instruction.data = Some(data); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = BuyInstructionArgs { - data: self.instruction.data.clone().expect("data is not set"), - }; - let instruction = BuyCpi { - __program: self.instruction.__program, - - sender: self.instruction.sender.expect("sender is not set"), - - sender_token_account: self - .instruction - .sender_token_account - .expect("sender_token_account is not set"), - - curve_account: self - .instruction - .curve_account - .expect("curve_account is not set"), - - curve_token_account: self - .instruction - .curve_token_account - .expect("curve_token_account is not set"), - - dex_fee: self.instruction.dex_fee.expect("dex_fee is not set"), - - helio_fee: self.instruction.helio_fee.expect("helio_fee is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - config_account: self - .instruction - .config_account - .expect("config_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct BuyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - sender_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_account: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - dex_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - helio_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - config_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - data: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/moonshot-parser/src/generated_sdk/instructions/config_init.rs b/crates/moonshot-parser/src/generated_sdk/instructions/config_init.rs deleted file mode 100644 index 114b810e..00000000 --- a/crates/moonshot-parser/src/generated_sdk/instructions/config_init.rs +++ /dev/null @@ -1,409 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::ConfigParams; - -/// Accounts. -#[derive(Debug)] -pub struct ConfigInit { - pub config_authority: solana_pubkey::Pubkey, - - pub config_account: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl ConfigInit { - pub fn instruction(&self, args: ConfigInitInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ConfigInitInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.config_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.config_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ConfigInitInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ConfigInitInstructionData { - discriminator: [u8; 8], -} - -impl ConfigInitInstructionData { - pub fn new() -> Self { - Self { - discriminator: [13, 236, 164, 173, 106, 253, 164, 185], - } - } -} - -impl Default for ConfigInitInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ConfigInitInstructionArgs { - pub data: ConfigParams, -} - -/// Instruction builder for `ConfigInit`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` config_authority -/// 1. `[writable]` config_account -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct ConfigInitBuilder { - config_authority: Option, - config_account: Option, - system_program: Option, - data: Option, - __remaining_accounts: Vec, -} - -impl ConfigInitBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config_authority(&mut self, config_authority: solana_pubkey::Pubkey) -> &mut Self { - self.config_authority = Some(config_authority); - self - } - - #[inline(always)] - pub fn config_account(&mut self, config_account: solana_pubkey::Pubkey) -> &mut Self { - self.config_account = Some(config_account); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn data(&mut self, data: ConfigParams) -> &mut Self { - self.data = Some(data); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ConfigInit { - config_authority: self.config_authority.expect("config_authority is not set"), - config_account: self.config_account.expect("config_account is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = ConfigInitInstructionArgs { - data: self.data.clone().expect("data is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `config_init` CPI accounts. -pub struct ConfigInitCpiAccounts<'a, 'b> { - pub config_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `config_init` CPI instruction. -pub struct ConfigInitCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ConfigInitInstructionArgs, -} - -impl<'a, 'b> ConfigInitCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ConfigInitCpiAccounts<'a, 'b>, - args: ConfigInitInstructionArgs, - ) -> Self { - Self { - __program: program, - config_authority: accounts.config_authority, - config_account: accounts.config_account, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.config_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.config_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ConfigInitInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config_authority.clone()); - account_infos.push(self.config_account.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ConfigInit` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` config_authority -/// 1. `[writable]` config_account -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct ConfigInitCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ConfigInitCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ConfigInitCpiBuilderInstruction { - __program: program, - config_authority: None, - config_account: None, - system_program: None, - data: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config_authority( - &mut self, - config_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_authority = Some(config_authority); - self - } - - #[inline(always)] - pub fn config_account( - &mut self, - config_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_account = Some(config_account); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn data(&mut self, data: ConfigParams) -> &mut Self { - self.instruction.data = Some(data); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ConfigInitInstructionArgs { - data: self.instruction.data.clone().expect("data is not set"), - }; - let instruction = ConfigInitCpi { - __program: self.instruction.__program, - - config_authority: self - .instruction - .config_authority - .expect("config_authority is not set"), - - config_account: self - .instruction - .config_account - .expect("config_account is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ConfigInitCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config_account: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - data: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/moonshot-parser/src/generated_sdk/instructions/config_update.rs b/crates/moonshot-parser/src/generated_sdk/instructions/config_update.rs deleted file mode 100644 index 55eb4647..00000000 --- a/crates/moonshot-parser/src/generated_sdk/instructions/config_update.rs +++ /dev/null @@ -1,367 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::ConfigParams; - -/// Accounts. -#[derive(Debug)] -pub struct ConfigUpdate { - pub config_authority: solana_pubkey::Pubkey, - - pub config_account: solana_pubkey::Pubkey, -} - -impl ConfigUpdate { - pub fn instruction( - &self, - args: ConfigUpdateInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ConfigUpdateInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.config_account, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ConfigUpdateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ConfigUpdateInstructionData { - discriminator: [u8; 8], -} - -impl ConfigUpdateInstructionData { - pub fn new() -> Self { - Self { - discriminator: [80, 37, 109, 136, 82, 135, 89, 241], - } - } -} - -impl Default for ConfigUpdateInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ConfigUpdateInstructionArgs { - pub data: ConfigParams, -} - -/// Instruction builder for `ConfigUpdate`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` config_authority -/// 1. `[writable]` config_account -#[derive(Clone, Debug, Default)] -pub struct ConfigUpdateBuilder { - config_authority: Option, - config_account: Option, - data: Option, - __remaining_accounts: Vec, -} - -impl ConfigUpdateBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config_authority(&mut self, config_authority: solana_pubkey::Pubkey) -> &mut Self { - self.config_authority = Some(config_authority); - self - } - - #[inline(always)] - pub fn config_account(&mut self, config_account: solana_pubkey::Pubkey) -> &mut Self { - self.config_account = Some(config_account); - self - } - - #[inline(always)] - pub fn data(&mut self, data: ConfigParams) -> &mut Self { - self.data = Some(data); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ConfigUpdate { - config_authority: self.config_authority.expect("config_authority is not set"), - config_account: self.config_account.expect("config_account is not set"), - }; - let args = ConfigUpdateInstructionArgs { - data: self.data.clone().expect("data is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `config_update` CPI accounts. -pub struct ConfigUpdateCpiAccounts<'a, 'b> { - pub config_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, -} - -/// `config_update` CPI instruction. -pub struct ConfigUpdateCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config_authority: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ConfigUpdateInstructionArgs, -} - -impl<'a, 'b> ConfigUpdateCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ConfigUpdateCpiAccounts<'a, 'b>, - args: ConfigUpdateInstructionArgs, - ) -> Self { - Self { - __program: program, - config_authority: accounts.config_authority, - config_account: accounts.config_account, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.config_account.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ConfigUpdateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config_authority.clone()); - account_infos.push(self.config_account.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ConfigUpdate` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` config_authority -/// 1. `[writable]` config_account -#[derive(Clone, Debug)] -pub struct ConfigUpdateCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ConfigUpdateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ConfigUpdateCpiBuilderInstruction { - __program: program, - config_authority: None, - config_account: None, - data: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config_authority( - &mut self, - config_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_authority = Some(config_authority); - self - } - - #[inline(always)] - pub fn config_account( - &mut self, - config_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_account = Some(config_account); - self - } - - #[inline(always)] - pub fn data(&mut self, data: ConfigParams) -> &mut Self { - self.instruction.data = Some(data); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ConfigUpdateInstructionArgs { - data: self.instruction.data.clone().expect("data is not set"), - }; - let instruction = ConfigUpdateCpi { - __program: self.instruction.__program, - - config_authority: self - .instruction - .config_authority - .expect("config_authority is not set"), - - config_account: self - .instruction - .config_account - .expect("config_account is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ConfigUpdateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - config_account: Option<&'b solana_account_info::AccountInfo<'a>>, - data: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/moonshot-parser/src/generated_sdk/instructions/migrate_funds.rs b/crates/moonshot-parser/src/generated_sdk/instructions/migrate_funds.rs deleted file mode 100644 index b7dc29ff..00000000 --- a/crates/moonshot-parser/src/generated_sdk/instructions/migrate_funds.rs +++ /dev/null @@ -1,792 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MigrateFunds { - /// BE Authority - pub backend_authority: solana_pubkey::Pubkey, - /// Migration Authority - /// Owner and Payer over Token Accounts, needs to be mutable - pub migration_authority: solana_pubkey::Pubkey, - /// Curve Account - /// The account is closed after this instruction - pub curve_account: solana_pubkey::Pubkey, - /// Curve Token Account - /// The account is closed after this instruction - pub curve_token_account: solana_pubkey::Pubkey, - /// Authority token Account - /// Init on demand - pub migration_authority_token_account: solana_pubkey::Pubkey, - /// InterfaceAccount: checks program ownership + deserialize into Mint - pub mint: solana_pubkey::Pubkey, - - pub dex_fee_account: solana_pubkey::Pubkey, - - pub helio_fee_account: solana_pubkey::Pubkey, - - pub config_account: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl MigrateFunds { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.backend_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.migration_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.curve_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.curve_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.migration_authority_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.dex_fee_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.helio_fee_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigrateFundsInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateFundsInstructionData { - discriminator: [u8; 8], -} - -impl MigrateFundsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [42, 229, 10, 231, 189, 62, 193, 174], - } - } -} - -impl Default for MigrateFundsInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigrateFunds`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` backend_authority -/// 1. `[writable, signer]` migration_authority -/// 2. `[writable]` curve_account -/// 3. `[writable]` curve_token_account -/// 4. `[writable]` migration_authority_token_account -/// 5. `[writable]` mint -/// 6. `[writable]` dex_fee_account -/// 7. `[writable]` helio_fee_account -/// 8. `[]` config_account -/// 9. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 10. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 11. `[]` associated_token_program -#[derive(Clone, Debug, Default)] -pub struct MigrateFundsBuilder { - backend_authority: Option, - migration_authority: Option, - curve_account: Option, - curve_token_account: Option, - migration_authority_token_account: Option, - mint: Option, - dex_fee_account: Option, - helio_fee_account: Option, - config_account: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - __remaining_accounts: Vec, -} - -impl MigrateFundsBuilder { - pub fn new() -> Self { Self::default() } - - /// BE Authority - #[inline(always)] - pub fn backend_authority(&mut self, backend_authority: solana_pubkey::Pubkey) -> &mut Self { - self.backend_authority = Some(backend_authority); - self - } - - /// Migration Authority - /// Owner and Payer over Token Accounts, needs to be mutable - #[inline(always)] - pub fn migration_authority(&mut self, migration_authority: solana_pubkey::Pubkey) -> &mut Self { - self.migration_authority = Some(migration_authority); - self - } - - /// Curve Account - /// The account is closed after this instruction - #[inline(always)] - pub fn curve_account(&mut self, curve_account: solana_pubkey::Pubkey) -> &mut Self { - self.curve_account = Some(curve_account); - self - } - - /// Curve Token Account - /// The account is closed after this instruction - #[inline(always)] - pub fn curve_token_account(&mut self, curve_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.curve_token_account = Some(curve_token_account); - self - } - - /// Authority token Account - /// Init on demand - #[inline(always)] - pub fn migration_authority_token_account( - &mut self, - migration_authority_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.migration_authority_token_account = Some(migration_authority_token_account); - self - } - - /// InterfaceAccount: checks program ownership + deserialize into Mint - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn dex_fee_account(&mut self, dex_fee_account: solana_pubkey::Pubkey) -> &mut Self { - self.dex_fee_account = Some(dex_fee_account); - self - } - - #[inline(always)] - pub fn helio_fee_account(&mut self, helio_fee_account: solana_pubkey::Pubkey) -> &mut Self { - self.helio_fee_account = Some(helio_fee_account); - self - } - - #[inline(always)] - pub fn config_account(&mut self, config_account: solana_pubkey::Pubkey) -> &mut Self { - self.config_account = Some(config_account); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrateFunds { - backend_authority: self - .backend_authority - .expect("backend_authority is not set"), - migration_authority: self - .migration_authority - .expect("migration_authority is not set"), - curve_account: self.curve_account.expect("curve_account is not set"), - curve_token_account: self - .curve_token_account - .expect("curve_token_account is not set"), - migration_authority_token_account: self - .migration_authority_token_account - .expect("migration_authority_token_account is not set"), - mint: self.mint.expect("mint is not set"), - dex_fee_account: self.dex_fee_account.expect("dex_fee_account is not set"), - helio_fee_account: self - .helio_fee_account - .expect("helio_fee_account is not set"), - config_account: self.config_account.expect("config_account is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migrate_funds` CPI accounts. -pub struct MigrateFundsCpiAccounts<'a, 'b> { - /// BE Authority - pub backend_authority: &'b solana_account_info::AccountInfo<'a>, - /// Migration Authority - /// Owner and Payer over Token Accounts, needs to be mutable - pub migration_authority: &'b solana_account_info::AccountInfo<'a>, - /// Curve Account - /// The account is closed after this instruction - pub curve_account: &'b solana_account_info::AccountInfo<'a>, - /// Curve Token Account - /// The account is closed after this instruction - pub curve_token_account: &'b solana_account_info::AccountInfo<'a>, - /// Authority token Account - /// Init on demand - pub migration_authority_token_account: &'b solana_account_info::AccountInfo<'a>, - /// InterfaceAccount: checks program ownership + deserialize into Mint - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub dex_fee_account: &'b solana_account_info::AccountInfo<'a>, - - pub helio_fee_account: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migrate_funds` CPI instruction. -pub struct MigrateFundsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// BE Authority - pub backend_authority: &'b solana_account_info::AccountInfo<'a>, - /// Migration Authority - /// Owner and Payer over Token Accounts, needs to be mutable - pub migration_authority: &'b solana_account_info::AccountInfo<'a>, - /// Curve Account - /// The account is closed after this instruction - pub curve_account: &'b solana_account_info::AccountInfo<'a>, - /// Curve Token Account - /// The account is closed after this instruction - pub curve_token_account: &'b solana_account_info::AccountInfo<'a>, - /// Authority token Account - /// Init on demand - pub migration_authority_token_account: &'b solana_account_info::AccountInfo<'a>, - /// InterfaceAccount: checks program ownership + deserialize into Mint - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub dex_fee_account: &'b solana_account_info::AccountInfo<'a>, - - pub helio_fee_account: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrateFundsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrateFundsCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - backend_authority: accounts.backend_authority, - migration_authority: accounts.migration_authority, - curve_account: accounts.curve_account, - curve_token_account: accounts.curve_token_account, - migration_authority_token_account: accounts.migration_authority_token_account, - mint: accounts.mint, - dex_fee_account: accounts.dex_fee_account, - helio_fee_account: accounts.helio_fee_account, - config_account: accounts.config_account, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.backend_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.migration_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.curve_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.curve_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.migration_authority_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.mint.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.dex_fee_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.helio_fee_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigrateFundsInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.backend_authority.clone()); - account_infos.push(self.migration_authority.clone()); - account_infos.push(self.curve_account.clone()); - account_infos.push(self.curve_token_account.clone()); - account_infos.push(self.migration_authority_token_account.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.dex_fee_account.clone()); - account_infos.push(self.helio_fee_account.clone()); - account_infos.push(self.config_account.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrateFunds` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` backend_authority -/// 1. `[writable, signer]` migration_authority -/// 2. `[writable]` curve_account -/// 3. `[writable]` curve_token_account -/// 4. `[writable]` migration_authority_token_account -/// 5. `[writable]` mint -/// 6. `[writable]` dex_fee_account -/// 7. `[writable]` helio_fee_account -/// 8. `[]` config_account -/// 9. `[]` system_program -/// 10. `[]` token_program -/// 11. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct MigrateFundsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrateFundsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrateFundsCpiBuilderInstruction { - __program: program, - backend_authority: None, - migration_authority: None, - curve_account: None, - curve_token_account: None, - migration_authority_token_account: None, - mint: None, - dex_fee_account: None, - helio_fee_account: None, - config_account: None, - system_program: None, - token_program: None, - associated_token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// BE Authority - #[inline(always)] - pub fn backend_authority( - &mut self, - backend_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.backend_authority = Some(backend_authority); - self - } - - /// Migration Authority - /// Owner and Payer over Token Accounts, needs to be mutable - #[inline(always)] - pub fn migration_authority( - &mut self, - migration_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migration_authority = Some(migration_authority); - self - } - - /// Curve Account - /// The account is closed after this instruction - #[inline(always)] - pub fn curve_account( - &mut self, - curve_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.curve_account = Some(curve_account); - self - } - - /// Curve Token Account - /// The account is closed after this instruction - #[inline(always)] - pub fn curve_token_account( - &mut self, - curve_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.curve_token_account = Some(curve_token_account); - self - } - - /// Authority token Account - /// Init on demand - #[inline(always)] - pub fn migration_authority_token_account( - &mut self, - migration_authority_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migration_authority_token_account = - Some(migration_authority_token_account); - self - } - - /// InterfaceAccount: checks program ownership + deserialize into Mint - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn dex_fee_account( - &mut self, - dex_fee_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.dex_fee_account = Some(dex_fee_account); - self - } - - #[inline(always)] - pub fn helio_fee_account( - &mut self, - helio_fee_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.helio_fee_account = Some(helio_fee_account); - self - } - - #[inline(always)] - pub fn config_account( - &mut self, - config_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_account = Some(config_account); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrateFundsCpi { - __program: self.instruction.__program, - - backend_authority: self - .instruction - .backend_authority - .expect("backend_authority is not set"), - - migration_authority: self - .instruction - .migration_authority - .expect("migration_authority is not set"), - - curve_account: self - .instruction - .curve_account - .expect("curve_account is not set"), - - curve_token_account: self - .instruction - .curve_token_account - .expect("curve_token_account is not set"), - - migration_authority_token_account: self - .instruction - .migration_authority_token_account - .expect("migration_authority_token_account is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - dex_fee_account: self - .instruction - .dex_fee_account - .expect("dex_fee_account is not set"), - - helio_fee_account: self - .instruction - .helio_fee_account - .expect("helio_fee_account is not set"), - - config_account: self - .instruction - .config_account - .expect("config_account is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrateFundsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - backend_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - migration_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_account: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - migration_authority_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - dex_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - helio_fee_account: Option<&'b solana_account_info::AccountInfo<'a>>, - config_account: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/moonshot-parser/src/generated_sdk/instructions/mod.rs b/crates/moonshot-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index 2373db10..00000000 --- a/crates/moonshot-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#buy; -pub(crate) mod r#config_init; -pub(crate) mod r#config_update; -pub(crate) mod r#migrate_funds; -pub(crate) mod r#sell; -pub(crate) mod r#token_mint; - -pub use self::{ - r#buy::*, r#config_init::*, r#config_update::*, r#migrate_funds::*, r#sell::*, r#token_mint::*, -}; diff --git a/crates/moonshot-parser/src/generated_sdk/instructions/sell.rs b/crates/moonshot-parser/src/generated_sdk/instructions/sell.rs deleted file mode 100644 index 1a92508e..00000000 --- a/crates/moonshot-parser/src/generated_sdk/instructions/sell.rs +++ /dev/null @@ -1,723 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::TradeParams; - -/// Accounts. -#[derive(Debug)] -pub struct Sell { - pub sender: solana_pubkey::Pubkey, - - pub sender_token_account: solana_pubkey::Pubkey, - - pub curve_account: solana_pubkey::Pubkey, - - pub curve_token_account: solana_pubkey::Pubkey, - - pub dex_fee: solana_pubkey::Pubkey, - - pub helio_fee: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub config_account: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl Sell { - pub fn instruction(&self, args: SellInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SellInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.sender, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.sender_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.curve_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.curve_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.dex_fee, false)); - accounts.push(solana_instruction::AccountMeta::new(self.helio_fee, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SellInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellInstructionData { - discriminator: [u8; 8], -} - -impl SellInstructionData { - pub fn new() -> Self { - Self { - discriminator: [51, 230, 133, 164, 1, 127, 131, 173], - } - } -} - -impl Default for SellInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellInstructionArgs { - pub data: TradeParams, -} - -/// Instruction builder for `Sell`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` sender -/// 1. `[writable]` sender_token_account -/// 2. `[writable]` curve_account -/// 3. `[writable]` curve_token_account -/// 4. `[writable]` dex_fee -/// 5. `[writable]` helio_fee -/// 6. `[]` mint -/// 7. `[]` config_account -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[]` associated_token_program -/// 10. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct SellBuilder { - sender: Option, - sender_token_account: Option, - curve_account: Option, - curve_token_account: Option, - dex_fee: Option, - helio_fee: Option, - mint: Option, - config_account: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - data: Option, - __remaining_accounts: Vec, -} - -impl SellBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn sender_token_account( - &mut self, - sender_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.sender_token_account = Some(sender_token_account); - self - } - - #[inline(always)] - pub fn curve_account(&mut self, curve_account: solana_pubkey::Pubkey) -> &mut Self { - self.curve_account = Some(curve_account); - self - } - - #[inline(always)] - pub fn curve_token_account(&mut self, curve_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.curve_token_account = Some(curve_token_account); - self - } - - #[inline(always)] - pub fn dex_fee(&mut self, dex_fee: solana_pubkey::Pubkey) -> &mut Self { - self.dex_fee = Some(dex_fee); - self - } - - #[inline(always)] - pub fn helio_fee(&mut self, helio_fee: solana_pubkey::Pubkey) -> &mut Self { - self.helio_fee = Some(helio_fee); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn config_account(&mut self, config_account: solana_pubkey::Pubkey) -> &mut Self { - self.config_account = Some(config_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn data(&mut self, data: TradeParams) -> &mut Self { - self.data = Some(data); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Sell { - sender: self.sender.expect("sender is not set"), - sender_token_account: self - .sender_token_account - .expect("sender_token_account is not set"), - curve_account: self.curve_account.expect("curve_account is not set"), - curve_token_account: self - .curve_token_account - .expect("curve_token_account is not set"), - dex_fee: self.dex_fee.expect("dex_fee is not set"), - helio_fee: self.helio_fee.expect("helio_fee is not set"), - mint: self.mint.expect("mint is not set"), - config_account: self.config_account.expect("config_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = SellInstructionArgs { - data: self.data.clone().expect("data is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `sell` CPI accounts. -pub struct SellCpiAccounts<'a, 'b> { - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub sender_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub curve_account: &'b solana_account_info::AccountInfo<'a>, - - pub curve_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub dex_fee: &'b solana_account_info::AccountInfo<'a>, - - pub helio_fee: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `sell` CPI instruction. -pub struct SellCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub sender_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub curve_account: &'b solana_account_info::AccountInfo<'a>, - - pub curve_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub dex_fee: &'b solana_account_info::AccountInfo<'a>, - - pub helio_fee: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SellInstructionArgs, -} - -impl<'a, 'b> SellCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SellCpiAccounts<'a, 'b>, - args: SellInstructionArgs, - ) -> Self { - Self { - __program: program, - sender: accounts.sender, - sender_token_account: accounts.sender_token_account, - curve_account: accounts.curve_account, - curve_token_account: accounts.curve_token_account, - dex_fee: accounts.dex_fee, - helio_fee: accounts.helio_fee, - mint: accounts.mint, - config_account: accounts.config_account, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.sender.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.sender_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.curve_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.curve_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.dex_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.helio_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SellInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.sender_token_account.clone()); - account_infos.push(self.curve_account.clone()); - account_infos.push(self.curve_token_account.clone()); - account_infos.push(self.dex_fee.clone()); - account_infos.push(self.helio_fee.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.config_account.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Sell` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` sender -/// 1. `[writable]` sender_token_account -/// 2. `[writable]` curve_account -/// 3. `[writable]` curve_token_account -/// 4. `[writable]` dex_fee -/// 5. `[writable]` helio_fee -/// 6. `[]` mint -/// 7. `[]` config_account -/// 8. `[]` token_program -/// 9. `[]` associated_token_program -/// 10. `[]` system_program -#[derive(Clone, Debug)] -pub struct SellCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SellCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SellCpiBuilderInstruction { - __program: program, - sender: None, - sender_token_account: None, - curve_account: None, - curve_token_account: None, - dex_fee: None, - helio_fee: None, - mint: None, - config_account: None, - token_program: None, - associated_token_program: None, - system_program: None, - data: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn sender_token_account( - &mut self, - sender_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.sender_token_account = Some(sender_token_account); - self - } - - #[inline(always)] - pub fn curve_account( - &mut self, - curve_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.curve_account = Some(curve_account); - self - } - - #[inline(always)] - pub fn curve_token_account( - &mut self, - curve_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.curve_token_account = Some(curve_token_account); - self - } - - #[inline(always)] - pub fn dex_fee(&mut self, dex_fee: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.dex_fee = Some(dex_fee); - self - } - - #[inline(always)] - pub fn helio_fee(&mut self, helio_fee: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.helio_fee = Some(helio_fee); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn config_account( - &mut self, - config_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_account = Some(config_account); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn data(&mut self, data: TradeParams) -> &mut Self { - self.instruction.data = Some(data); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SellInstructionArgs { - data: self.instruction.data.clone().expect("data is not set"), - }; - let instruction = SellCpi { - __program: self.instruction.__program, - - sender: self.instruction.sender.expect("sender is not set"), - - sender_token_account: self - .instruction - .sender_token_account - .expect("sender_token_account is not set"), - - curve_account: self - .instruction - .curve_account - .expect("curve_account is not set"), - - curve_token_account: self - .instruction - .curve_token_account - .expect("curve_token_account is not set"), - - dex_fee: self.instruction.dex_fee.expect("dex_fee is not set"), - - helio_fee: self.instruction.helio_fee.expect("helio_fee is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - config_account: self - .instruction - .config_account - .expect("config_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SellCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - sender_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_account: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - dex_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - helio_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - config_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - data: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/moonshot-parser/src/generated_sdk/instructions/token_mint.rs b/crates/moonshot-parser/src/generated_sdk/instructions/token_mint.rs deleted file mode 100644 index 71d3dbdc..00000000 --- a/crates/moonshot-parser/src/generated_sdk/instructions/token_mint.rs +++ /dev/null @@ -1,888 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct TokenMint { - pub sender: solana_pubkey::Pubkey, - - pub backend_authority: solana_pubkey::Pubkey, - - pub curve_account: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - /// Type validating that the account is owned by the System Program = uninitialized - /// seeds should ensure that the address is correct - pub mint_metadata: solana_pubkey::Pubkey, - - pub curve_token_account: solana_pubkey::Pubkey, - - pub config_account: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub mpl_token_metadata: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl TokenMint { - pub fn instruction(&self, args: TokenMintInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: TokenMintInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.sender, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.backend_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.curve_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.mint, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.curve_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mpl_token_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&TokenMintInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenMintInstructionData { - discriminator: [u8; 8], -} - -impl TokenMintInstructionData { - pub fn new() -> Self { - Self { - discriminator: [3, 44, 164, 184, 123, 13, 245, 179], - } - } -} - -impl Default for TokenMintInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenMintInstructionArgs { - pub name: String, - pub symbol: String, - pub uri: String, - pub decimals: u8, - pub collateral_currency: u8, - pub amount: u64, - pub curve_type: u8, - pub migration_target: u8, -} - -/// Instruction builder for `TokenMint`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` sender -/// 1. `[signer]` backend_authority -/// 2. `[writable]` curve_account -/// 3. `[writable, signer]` mint -/// 4. `[writable]` mint_metadata -/// 5. `[writable]` curve_token_account -/// 6. `[]` config_account -/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 8. `[]` associated_token_program -/// 9. `[]` mpl_token_metadata -/// 10. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct TokenMintBuilder { - sender: Option, - backend_authority: Option, - curve_account: Option, - mint: Option, - mint_metadata: Option, - curve_token_account: Option, - config_account: Option, - token_program: Option, - associated_token_program: Option, - mpl_token_metadata: Option, - system_program: Option, - name: Option, - symbol: Option, - uri: Option, - decimals: Option, - collateral_currency: Option, - amount: Option, - curve_type: Option, - migration_target: Option, - __remaining_accounts: Vec, -} - -impl TokenMintBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self { - self.sender = Some(sender); - self - } - - #[inline(always)] - pub fn backend_authority(&mut self, backend_authority: solana_pubkey::Pubkey) -> &mut Self { - self.backend_authority = Some(backend_authority); - self - } - - #[inline(always)] - pub fn curve_account(&mut self, curve_account: solana_pubkey::Pubkey) -> &mut Self { - self.curve_account = Some(curve_account); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - /// Type validating that the account is owned by the System Program = uninitialized - /// seeds should ensure that the address is correct - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn curve_token_account(&mut self, curve_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.curve_token_account = Some(curve_token_account); - self - } - - #[inline(always)] - pub fn config_account(&mut self, config_account: solana_pubkey::Pubkey) -> &mut Self { - self.config_account = Some(config_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn mpl_token_metadata(&mut self, mpl_token_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mpl_token_metadata = Some(mpl_token_metadata); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.name = Some(name); - self - } - - #[inline(always)] - pub fn symbol(&mut self, symbol: String) -> &mut Self { - self.symbol = Some(symbol); - self - } - - #[inline(always)] - pub fn uri(&mut self, uri: String) -> &mut Self { - self.uri = Some(uri); - self - } - - #[inline(always)] - pub fn decimals(&mut self, decimals: u8) -> &mut Self { - self.decimals = Some(decimals); - self - } - - #[inline(always)] - pub fn collateral_currency(&mut self, collateral_currency: u8) -> &mut Self { - self.collateral_currency = Some(collateral_currency); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: u8) -> &mut Self { - self.curve_type = Some(curve_type); - self - } - - #[inline(always)] - pub fn migration_target(&mut self, migration_target: u8) -> &mut Self { - self.migration_target = Some(migration_target); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = TokenMint { - sender: self.sender.expect("sender is not set"), - backend_authority: self - .backend_authority - .expect("backend_authority is not set"), - curve_account: self.curve_account.expect("curve_account is not set"), - mint: self.mint.expect("mint is not set"), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - curve_token_account: self - .curve_token_account - .expect("curve_token_account is not set"), - config_account: self.config_account.expect("config_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - mpl_token_metadata: self - .mpl_token_metadata - .expect("mpl_token_metadata is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = TokenMintInstructionArgs { - name: self.name.clone().expect("name is not set"), - symbol: self.symbol.clone().expect("symbol is not set"), - uri: self.uri.clone().expect("uri is not set"), - decimals: self.decimals.clone().expect("decimals is not set"), - collateral_currency: self - .collateral_currency - .clone() - .expect("collateral_currency is not set"), - amount: self.amount.clone().expect("amount is not set"), - curve_type: self.curve_type.clone().expect("curve_type is not set"), - migration_target: self - .migration_target - .clone() - .expect("migration_target is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `token_mint` CPI accounts. -pub struct TokenMintCpiAccounts<'a, 'b> { - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub backend_authority: &'b solana_account_info::AccountInfo<'a>, - - pub curve_account: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - /// Type validating that the account is owned by the System Program = uninitialized - /// seeds should ensure that the address is correct - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub curve_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub mpl_token_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `token_mint` CPI instruction. -pub struct TokenMintCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub sender: &'b solana_account_info::AccountInfo<'a>, - - pub backend_authority: &'b solana_account_info::AccountInfo<'a>, - - pub curve_account: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - /// Type validating that the account is owned by the System Program = uninitialized - /// seeds should ensure that the address is correct - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub curve_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub config_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub mpl_token_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: TokenMintInstructionArgs, -} - -impl<'a, 'b> TokenMintCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: TokenMintCpiAccounts<'a, 'b>, - args: TokenMintInstructionArgs, - ) -> Self { - Self { - __program: program, - sender: accounts.sender, - backend_authority: accounts.backend_authority, - curve_account: accounts.curve_account, - mint: accounts.mint, - mint_metadata: accounts.mint_metadata, - curve_token_account: accounts.curve_token_account, - config_account: accounts.config_account, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - mpl_token_metadata: accounts.mpl_token_metadata, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.sender.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.backend_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.curve_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.mint.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.curve_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mpl_token_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&TokenMintInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::TOKEN_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.sender.clone()); - account_infos.push(self.backend_authority.clone()); - account_infos.push(self.curve_account.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.curve_token_account.clone()); - account_infos.push(self.config_account.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.mpl_token_metadata.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `TokenMint` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` sender -/// 1. `[signer]` backend_authority -/// 2. `[writable]` curve_account -/// 3. `[writable, signer]` mint -/// 4. `[writable]` mint_metadata -/// 5. `[writable]` curve_token_account -/// 6. `[]` config_account -/// 7. `[]` token_program -/// 8. `[]` associated_token_program -/// 9. `[]` mpl_token_metadata -/// 10. `[]` system_program -#[derive(Clone, Debug)] -pub struct TokenMintCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> TokenMintCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(TokenMintCpiBuilderInstruction { - __program: program, - sender: None, - backend_authority: None, - curve_account: None, - mint: None, - mint_metadata: None, - curve_token_account: None, - config_account: None, - token_program: None, - associated_token_program: None, - mpl_token_metadata: None, - system_program: None, - name: None, - symbol: None, - uri: None, - decimals: None, - collateral_currency: None, - amount: None, - curve_type: None, - migration_target: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.sender = Some(sender); - self - } - - #[inline(always)] - pub fn backend_authority( - &mut self, - backend_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.backend_authority = Some(backend_authority); - self - } - - #[inline(always)] - pub fn curve_account( - &mut self, - curve_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.curve_account = Some(curve_account); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - /// Type validating that the account is owned by the System Program = uninitialized - /// seeds should ensure that the address is correct - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn curve_token_account( - &mut self, - curve_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.curve_token_account = Some(curve_token_account); - self - } - - #[inline(always)] - pub fn config_account( - &mut self, - config_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_account = Some(config_account); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn mpl_token_metadata( - &mut self, - mpl_token_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mpl_token_metadata = Some(mpl_token_metadata); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.instruction.name = Some(name); - self - } - - #[inline(always)] - pub fn symbol(&mut self, symbol: String) -> &mut Self { - self.instruction.symbol = Some(symbol); - self - } - - #[inline(always)] - pub fn uri(&mut self, uri: String) -> &mut Self { - self.instruction.uri = Some(uri); - self - } - - #[inline(always)] - pub fn decimals(&mut self, decimals: u8) -> &mut Self { - self.instruction.decimals = Some(decimals); - self - } - - #[inline(always)] - pub fn collateral_currency(&mut self, collateral_currency: u8) -> &mut Self { - self.instruction.collateral_currency = Some(collateral_currency); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: u8) -> &mut Self { - self.instruction.curve_type = Some(curve_type); - self - } - - #[inline(always)] - pub fn migration_target(&mut self, migration_target: u8) -> &mut Self { - self.instruction.migration_target = Some(migration_target); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = TokenMintInstructionArgs { - name: self.instruction.name.clone().expect("name is not set"), - symbol: self.instruction.symbol.clone().expect("symbol is not set"), - uri: self.instruction.uri.clone().expect("uri is not set"), - decimals: self - .instruction - .decimals - .clone() - .expect("decimals is not set"), - collateral_currency: self - .instruction - .collateral_currency - .clone() - .expect("collateral_currency is not set"), - amount: self.instruction.amount.clone().expect("amount is not set"), - curve_type: self - .instruction - .curve_type - .clone() - .expect("curve_type is not set"), - migration_target: self - .instruction - .migration_target - .clone() - .expect("migration_target is not set"), - }; - let instruction = TokenMintCpi { - __program: self.instruction.__program, - - sender: self.instruction.sender.expect("sender is not set"), - - backend_authority: self - .instruction - .backend_authority - .expect("backend_authority is not set"), - - curve_account: self - .instruction - .curve_account - .expect("curve_account is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - curve_token_account: self - .instruction - .curve_token_account - .expect("curve_token_account is not set"), - - config_account: self - .instruction - .config_account - .expect("config_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - mpl_token_metadata: self - .instruction - .mpl_token_metadata - .expect("mpl_token_metadata is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct TokenMintCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - sender: Option<&'b solana_account_info::AccountInfo<'a>>, - backend_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_account: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - config_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - mpl_token_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - name: Option, - symbol: Option, - uri: Option, - decimals: Option, - collateral_currency: Option, - amount: Option, - curve_type: Option, - migration_target: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/moonshot-parser/src/generated_sdk/mod.rs b/crates/moonshot-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/moonshot-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/moonshot-parser/src/generated_sdk/programs.rs b/crates/moonshot-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 1a9cae76..00000000 --- a/crates/moonshot-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `token_launchpad` program ID. -pub const TOKEN_LAUNCHPAD_ID: Pubkey = pubkey!("MoonCVVNZFSYkqNXP6bxHLPL6QQJiMagDL3qcqUQTrG"); diff --git a/crates/moonshot-parser/src/generated_sdk/shared.rs b/crates/moonshot-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/moonshot-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/moonshot-parser/src/generated_sdk/types/config_params.rs b/crates/moonshot-parser/src/generated_sdk/types/config_params.rs deleted file mode 100644 index 13110543..00000000 --- a/crates/moonshot-parser/src/generated_sdk/types/config_params.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ConfigParams { - pub migration_authority: Option, - pub backend_authority: Option, - pub config_authority: Option, - pub helio_fee: Option, - pub dex_fee: Option, - pub fee_bps: Option, - pub dex_fee_share: Option, - pub migration_fee: Option, - pub marketcap_threshold: Option, - pub marketcap_currency: Option, - pub min_supported_decimal_places: Option, - pub max_supported_decimal_places: Option, - pub min_supported_token_supply: Option, - pub max_supported_token_supply: Option, - pub coef_b: Option, -} diff --git a/crates/moonshot-parser/src/generated_sdk/types/currency.rs b/crates/moonshot-parser/src/generated_sdk/types/currency.rs deleted file mode 100644 index d11fc32f..00000000 --- a/crates/moonshot-parser/src/generated_sdk/types/currency.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum Currency { - Sol, -} diff --git a/crates/moonshot-parser/src/generated_sdk/types/curve_type.rs b/crates/moonshot-parser/src/generated_sdk/types/curve_type.rs deleted file mode 100644 index 801c695f..00000000 --- a/crates/moonshot-parser/src/generated_sdk/types/curve_type.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum CurveType { - LinearV1, - ConstantProductV1, -} diff --git a/crates/moonshot-parser/src/generated_sdk/types/fixed_side.rs b/crates/moonshot-parser/src/generated_sdk/types/fixed_side.rs deleted file mode 100644 index 560b9650..00000000 --- a/crates/moonshot-parser/src/generated_sdk/types/fixed_side.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum FixedSide { - ExactIn, - ExactOut, -} diff --git a/crates/moonshot-parser/src/generated_sdk/types/migration_target.rs b/crates/moonshot-parser/src/generated_sdk/types/migration_target.rs deleted file mode 100644 index dcacf760..00000000 --- a/crates/moonshot-parser/src/generated_sdk/types/migration_target.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum MigrationTarget { - Raydium, - Meteora, -} diff --git a/crates/moonshot-parser/src/generated_sdk/types/mod.rs b/crates/moonshot-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index 5c697fe2..00000000 --- a/crates/moonshot-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#config_params; -pub(crate) mod r#currency; -pub(crate) mod r#curve_type; -pub(crate) mod r#fixed_side; -pub(crate) mod r#migration_target; -pub(crate) mod r#trade_params; -pub(crate) mod r#trade_type; - -pub use self::{ - r#config_params::*, r#currency::*, r#curve_type::*, r#fixed_side::*, r#migration_target::*, - r#trade_params::*, r#trade_type::*, -}; diff --git a/crates/moonshot-parser/src/generated_sdk/types/trade_params.rs b/crates/moonshot-parser/src/generated_sdk/types/trade_params.rs deleted file mode 100644 index 9d6a004e..00000000 --- a/crates/moonshot-parser/src/generated_sdk/types/trade_params.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TradeParams { - pub token_amount: u64, - pub collateral_amount: u64, - pub fixed_side: u8, - pub slippage_bps: u64, -} diff --git a/crates/moonshot-parser/src/generated_sdk/types/trade_type.rs b/crates/moonshot-parser/src/generated_sdk/types/trade_type.rs deleted file mode 100644 index 3dbc4870..00000000 --- a/crates/moonshot-parser/src/generated_sdk/types/trade_type.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TradeType { - Buy, - Sell, -} diff --git a/crates/moonshot-parser/src/lib.rs b/crates/moonshot-parser/src/lib.rs deleted file mode 100644 index 35c6e779..00000000 --- a/crates/moonshot-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = TOKEN_LAUNCHPAD_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.moonshot"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/orca-whirlpool-parser/Cargo.toml b/crates/orca-whirlpool-parser/Cargo.toml deleted file mode 100644 index 061b87a7..00000000 --- a/crates/orca-whirlpool-parser/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "yellowstone-vixen-orca-whirlpool-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Orca Whirlpool program" -license.workspace = true -repository.workspace = true -authors.workspace = true - - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info.workspace = true -solana-cpi.workspace = true -solana-decode-error.workspace = true -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction.workspace = true -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true \ No newline at end of file diff --git a/crates/orca-whirlpool-parser/build.rs b/crates/orca-whirlpool-parser/build.rs deleted file mode 100644 index e385300c..00000000 --- a/crates/orca-whirlpool-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/orca_whirlpool.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/orca-whirlpool-parser/idl.json b/crates/orca-whirlpool-parser/idl.json deleted file mode 100644 index eac7c9bb..00000000 --- a/crates/orca-whirlpool-parser/idl.json +++ /dev/null @@ -1,5160 +0,0 @@ -{ - "version": "0.5.0", - "name": "whirlpool", - "instructions": [ - { - "name": "initializeConfig", - "docs": [ - "Initializes a WhirlpoolsConfig account that hosts info & authorities", - "required to govern a set of Whirlpools.", - "", - "### Parameters", - "- `fee_authority` - Authority authorized to initialize fee-tiers and set customs fees.", - "- `collect_protocol_fees_authority` - Authority authorized to collect protocol fees.", - "- `reward_emissions_super_authority` - Authority authorized to set reward authorities in pools." - ], - "accounts": [ - { - "name": "config", - "isMut": true, - "isSigner": true - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "feeAuthority", - "type": "publicKey" - }, - { - "name": "collectProtocolFeesAuthority", - "type": "publicKey" - }, - { - "name": "rewardEmissionsSuperAuthority", - "type": "publicKey" - }, - { - "name": "defaultProtocolFeeRate", - "type": "u16" - } - ] - }, - { - "name": "initializePool", - "docs": [ - "Initializes a Whirlpool account.", - "Fee rate is set to the default values on the config and supplied fee_tier.", - "", - "### Parameters", - "- `bumps` - The bump value when deriving the PDA of the Whirlpool address.", - "- `tick_spacing` - The desired tick spacing for this pool.", - "- `initial_sqrt_price` - The desired initial sqrt-price for this pool", - "", - "#### Special Errors", - "`InvalidTokenMintOrder` - The order of mints have to be ordered by", - "`SqrtPriceOutOfBounds` - provided initial_sqrt_price is not between 2^-64 to 2^64", - "" - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintB", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": true - }, - { - "name": "feeTier", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "bumps", - "type": { - "defined": "WhirlpoolBumps" - } - }, - { - "name": "tickSpacing", - "type": "u16" - }, - { - "name": "initialSqrtPrice", - "type": "u128" - } - ] - }, - { - "name": "initializeTickArray", - "docs": [ - "Initializes a fixed-length tick_array account to represent a tick-range in a Whirlpool.", - "", - "### Parameters", - "- `start_tick_index` - The starting tick index for this tick-array.", - "Has to be a multiple of TickArray size & the tick spacing of this pool.", - "", - "#### Special Errors", - "- `InvalidStartTick` - if the provided start tick is out of bounds or is not a multiple of", - "TICK_ARRAY_SIZE * tick spacing." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "tickArray", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "startTickIndex", - "type": "i32" - } - ] - }, - { - "name": "initializeDynamicTickArray", - "docs": [ - "Initialize a variable-length tick array for a Whirlpool.", - "", - "### Parameters", - "- `start_tick_index` - The starting tick index for this tick-array.", - "Has to be a multiple of TickArray size & the tick spacing of this pool.", - "- `idempotent` - If true, the instruction will not fail if the tick array already exists.", - "Note: The idempotent option exits successfully if a FixedTickArray is present as well as a DynamicTickArray.", - "", - "#### Special Errors", - "- `InvalidStartTick` - if the provided start tick is out of bounds or is not a multiple of", - "TICK_ARRAY_SIZE * tick spacing." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "tickArray", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "startTickIndex", - "type": "i32" - }, - { - "name": "idempotent", - "type": "bool" - } - ] - }, - { - "name": "initializeFeeTier", - "docs": [ - "Initializes a fee_tier account usable by Whirlpools in a WhirlpoolConfig space.", - "", - "### Authority", - "- \"fee_authority\" - Set authority in the WhirlpoolConfig", - "", - "### Parameters", - "- `tick_spacing` - The tick-spacing that this fee-tier suggests the default_fee_rate for.", - "- `default_fee_rate` - The default fee rate that a pool will use if the pool uses this", - "fee tier during initialization.", - "", - "#### Special Errors", - "- `InvalidTickSpacing` - If the provided tick_spacing is 0.", - "- `FeeRateMaxExceeded` - If the provided default_fee_rate exceeds MAX_FEE_RATE." - ], - "accounts": [ - { - "name": "config", - "isMut": false, - "isSigner": false - }, - { - "name": "feeTier", - "isMut": true, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tickSpacing", - "type": "u16" - }, - { - "name": "defaultFeeRate", - "type": "u16" - } - ] - }, - { - "name": "initializeReward", - "docs": [ - "Initialize reward for a Whirlpool. A pool can only support up to a set number of rewards.", - "", - "### Authority", - "- \"reward_authority\" - assigned authority by the reward_super_authority for the specified", - "reward-index in this Whirlpool", - "", - "### Parameters", - "- `reward_index` - The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS)", - "", - "#### Special Errors", - "- `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized", - "index in this pool, or exceeds NUM_REWARDS, or", - "all reward slots for this pool has been initialized." - ], - "accounts": [ - { - "name": "rewardAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardMint", - "isMut": false, - "isSigner": false - }, - { - "name": "rewardVault", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u8" - } - ] - }, - { - "name": "setRewardEmissions", - "docs": [ - "Set the reward emissions for a reward in a Whirlpool.", - "", - "### Authority", - "- \"reward_authority\" - assigned authority by the reward_super_authority for the specified", - "reward-index in this Whirlpool", - "", - "### Parameters", - "- `reward_index` - The reward index (0 <= index <= NUM_REWARDS) that we'd like to modify.", - "- `emissions_per_second_x64` - The amount of rewards emitted in this pool.", - "", - "#### Special Errors", - "- `RewardVaultAmountInsufficient` - The amount of rewards in the reward vault cannot emit", - "more than a day of desired emissions.", - "- `InvalidTimestamp` - Provided timestamp is not in order with the previous timestamp.", - "- `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized", - "index in this pool, or exceeds NUM_REWARDS, or", - "all reward slots for this pool has been initialized." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "rewardVault", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u8" - }, - { - "name": "emissionsPerSecondX64", - "type": "u128" - } - ] - }, - { - "name": "openPosition", - "docs": [ - "Open a position in a Whirlpool. A unique token will be minted to represent the position", - "in the users wallet. The position will start off with 0 liquidity.", - "", - "### Parameters", - "- `tick_lower_index` - The tick specifying the lower end of the position range.", - "- `tick_upper_index` - The tick specifying the upper end of the position range.", - "", - "#### Special Errors", - "- `InvalidTickIndex` - If a provided tick is out of bounds, out of order or not a multiple of", - "the tick-spacing in this pool." - ], - "accounts": [ - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "owner", - "isMut": false, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionMint", - "isMut": true, - "isSigner": true - }, - { - "name": "positionTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "bumps", - "type": { - "defined": "OpenPositionBumps" - } - }, - { - "name": "tickLowerIndex", - "type": "i32" - }, - { - "name": "tickUpperIndex", - "type": "i32" - } - ] - }, - { - "name": "openPositionWithMetadata", - "docs": [ - "Open a position in a Whirlpool. A unique token will be minted to represent the position", - "in the users wallet. Additional Metaplex metadata is appended to identify the token.", - "The position will start off with 0 liquidity.", - "", - "### Parameters", - "- `tick_lower_index` - The tick specifying the lower end of the position range.", - "- `tick_upper_index` - The tick specifying the upper end of the position range.", - "", - "#### Special Errors", - "- `InvalidTickIndex` - If a provided tick is out of bounds, out of order or not a multiple of", - "the tick-spacing in this pool." - ], - "accounts": [ - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "owner", - "isMut": false, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionMint", - "isMut": true, - "isSigner": true - }, - { - "name": "positionMetadataAccount", - "isMut": true, - "isSigner": false, - "docs": [ - "https://github.com/metaplex-foundation/mpl-token-metadata/blob/master/programs/token-metadata/program/src/utils/metadata.rs#L78" - ] - }, - { - "name": "positionTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "metadataUpdateAuth", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "bumps", - "type": { - "defined": "OpenPositionWithMetadataBumps" - } - }, - { - "name": "tickLowerIndex", - "type": "i32" - }, - { - "name": "tickUpperIndex", - "type": "i32" - } - ] - }, - { - "name": "increaseLiquidity", - "docs": [ - "Add liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards.", - "", - "### Authority", - "- `position_authority` - authority that owns the token corresponding to this desired position.", - "", - "### Parameters", - "- `liquidity_amount` - The total amount of Liquidity the user is willing to deposit.", - "- `token_max_a` - The maximum amount of tokenA the user is willing to deposit.", - "- `token_max_b` - The maximum amount of tokenB the user is willing to deposit.", - "", - "#### Special Errors", - "- `LiquidityZero` - Provided liquidity amount is zero.", - "- `LiquidityTooHigh` - Provided liquidity exceeds u128::max.", - "- `TokenMaxExceeded` - The required token to perform this operation exceeds the user defined amount." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenOwnerAccountA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityAmount", - "type": "u128" - }, - { - "name": "tokenMaxA", - "type": "u64" - }, - { - "name": "tokenMaxB", - "type": "u64" - } - ] - }, - { - "name": "decreaseLiquidity", - "docs": [ - "Withdraw liquidity from a position in the Whirlpool. This call also updates the position's accrued fees and rewards.", - "", - "### Authority", - "- `position_authority` - authority that owns the token corresponding to this desired position.", - "", - "### Parameters", - "- `liquidity_amount` - The total amount of Liquidity the user desires to withdraw.", - "- `token_min_a` - The minimum amount of tokenA the user is willing to withdraw.", - "- `token_min_b` - The minimum amount of tokenB the user is willing to withdraw.", - "", - "#### Special Errors", - "- `LiquidityZero` - Provided liquidity amount is zero.", - "- `LiquidityTooHigh` - Provided liquidity exceeds u128::max.", - "- `TokenMinSubceeded` - The required token to perform this operation subceeds the user defined amount." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenOwnerAccountA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityAmount", - "type": "u128" - }, - { - "name": "tokenMinA", - "type": "u64" - }, - { - "name": "tokenMinB", - "type": "u64" - } - ] - }, - { - "name": "updateFeesAndRewards", - "docs": [ - "Update the accrued fees and rewards for a position.", - "", - "#### Special Errors", - "- `TickNotFound` - Provided tick array account does not contain the tick for this position.", - "- `LiquidityZero` - Position has zero liquidity and therefore already has the most updated fees and reward values." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": false, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "collectFees", - "docs": [ - "Collect fees accrued for this position.", - "", - "### Authority", - "- `position_authority` - authority that owns the token corresponding to this desired position." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenOwnerAccountA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "collectReward", - "docs": [ - "Collect rewards accrued for this position.", - "", - "### Authority", - "- `position_authority` - authority that owns the token corresponding to this desired position." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "rewardOwnerAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardVault", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u8" - } - ] - }, - { - "name": "collectProtocolFees", - "docs": [ - "Collect the protocol fees accrued in this Whirlpool", - "", - "### Authority", - "- `collect_protocol_fees_authority` - assigned authority in the WhirlpoolConfig that can collect protocol fees" - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "collectProtocolFeesAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenDestinationA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenDestinationB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "swap", - "docs": [ - "Perform a swap in this Whirlpool", - "", - "### Authority", - "- \"token_authority\" - The authority to withdraw tokens from the input token account.", - "", - "### Parameters", - "- `amount` - The amount of input or output token to swap from (depending on amount_specified_is_input).", - "- `other_amount_threshold` - The maximum/minimum of input/output token to swap into (depending on amount_specified_is_input).", - "- `sqrt_price_limit` - The maximum/minimum price the swap will swap to.", - "- `amount_specified_is_input` - Specifies the token the parameter `amount`represents. If true, the amount represents the input token of the swap.", - "- `a_to_b` - The direction of the swap. True if swapping from A to B. False if swapping from B to A.", - "", - "#### Special Errors", - "- `ZeroTradableAmount` - User provided parameter `amount` is 0.", - "- `InvalidSqrtPriceLimitDirection` - User provided parameter `sqrt_price_limit` does not match the direction of the trade.", - "- `SqrtPriceOutOfBounds` - User provided parameter `sqrt_price_limit` is over Whirlppool's max/min bounds for sqrt-price.", - "- `InvalidTickArraySequence` - User provided tick-arrays are not in sequential order required to proceed in this trade direction.", - "- `TickArraySequenceInvalidIndex` - The swap loop attempted to access an invalid array index during the query of the next initialized tick.", - "- `TickArrayIndexOutofBounds` - The swap loop attempted to access an invalid array index during tick crossing.", - "- `LiquidityOverflow` - Liquidity value overflowed 128bits during tick crossing.", - "- `InvalidTickSpacing` - The swap pool was initialized with tick-spacing of 0." - ], - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArray0", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArray1", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArray2", - "isMut": true, - "isSigner": false - }, - { - "name": "oracle", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "otherAmountThreshold", - "type": "u64" - }, - { - "name": "sqrtPriceLimit", - "type": "u128" - }, - { - "name": "amountSpecifiedIsInput", - "type": "bool" - }, - { - "name": "aToB", - "type": "bool" - } - ] - }, - { - "name": "closePosition", - "docs": [ - "Close a position in a Whirlpool. Burns the position token in the owner's wallet.", - "", - "### Authority", - "- \"position_authority\" - The authority that owns the position token.", - "", - "#### Special Errors", - "- `ClosePositionNotEmpty` - The provided position account is not empty." - ], - "accounts": [ - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "receiver", - "isMut": true, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionMint", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "setDefaultFeeRate", - "docs": [ - "Set the default_fee_rate for a FeeTier", - "Only the current fee authority has permission to invoke this instruction.", - "", - "### Authority", - "- \"fee_authority\" - Set authority in the WhirlpoolConfig", - "", - "### Parameters", - "- `default_fee_rate` - The default fee rate that a pool will use if the pool uses this", - "fee tier during initialization.", - "", - "#### Special Errors", - "- `FeeRateMaxExceeded` - If the provided default_fee_rate exceeds MAX_FEE_RATE." - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "feeTier", - "isMut": true, - "isSigner": false - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "defaultFeeRate", - "type": "u16" - } - ] - }, - { - "name": "setDefaultProtocolFeeRate", - "docs": [ - "Sets the default protocol fee rate for a WhirlpoolConfig", - "Protocol fee rate is represented as a basis point.", - "Only the current fee authority has permission to invoke this instruction.", - "", - "### Authority", - "- \"fee_authority\" - Set authority that can modify pool fees in the WhirlpoolConfig", - "", - "### Parameters", - "- `default_protocol_fee_rate` - Rate that is referenced during the initialization of a Whirlpool using this config.", - "", - "#### Special Errors", - "- `ProtocolFeeRateMaxExceeded` - If the provided default_protocol_fee_rate exceeds MAX_PROTOCOL_FEE_RATE." - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "defaultProtocolFeeRate", - "type": "u16" - } - ] - }, - { - "name": "setFeeRate", - "docs": [ - "Sets the fee rate for a Whirlpool.", - "Fee rate is represented as hundredths of a basis point.", - "Only the current fee authority has permission to invoke this instruction.", - "", - "### Authority", - "- \"fee_authority\" - Set authority that can modify pool fees in the WhirlpoolConfig", - "", - "### Parameters", - "- `fee_rate` - The rate that the pool will use to calculate fees going onwards.", - "", - "#### Special Errors", - "- `FeeRateMaxExceeded` - If the provided fee_rate exceeds MAX_FEE_RATE." - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "feeRate", - "type": "u16" - } - ] - }, - { - "name": "setProtocolFeeRate", - "docs": [ - "Sets the protocol fee rate for a Whirlpool.", - "Protocol fee rate is represented as a basis point.", - "Only the current fee authority has permission to invoke this instruction.", - "", - "### Authority", - "- \"fee_authority\" - Set authority that can modify pool fees in the WhirlpoolConfig", - "", - "### Parameters", - "- `protocol_fee_rate` - The rate that the pool will use to calculate protocol fees going onwards.", - "", - "#### Special Errors", - "- `ProtocolFeeRateMaxExceeded` - If the provided default_protocol_fee_rate exceeds MAX_PROTOCOL_FEE_RATE." - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "protocolFeeRate", - "type": "u16" - } - ] - }, - { - "name": "setFeeAuthority", - "docs": [ - "Sets the fee authority for a WhirlpoolConfig.", - "The fee authority can set the fee & protocol fee rate for individual pools or", - "set the default fee rate for newly minted pools.", - "Only the current fee authority has permission to invoke this instruction.", - "", - "### Authority", - "- \"fee_authority\" - Set authority that can modify pool fees in the WhirlpoolConfig" - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "newFeeAuthority", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "setCollectProtocolFeesAuthority", - "docs": [ - "Sets the fee authority to collect protocol fees for a WhirlpoolConfig.", - "Only the current collect protocol fee authority has permission to invoke this instruction.", - "", - "### Authority", - "- \"fee_authority\" - Set authority that can collect protocol fees in the WhirlpoolConfig" - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "collectProtocolFeesAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "newCollectProtocolFeesAuthority", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "setRewardAuthority", - "docs": [ - "Set the whirlpool reward authority at the provided `reward_index`.", - "Only the current reward authority for this reward index has permission to invoke this instruction.", - "", - "### Authority", - "- \"reward_authority\" - Set authority that can control reward emission for this particular reward.", - "", - "#### Special Errors", - "- `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized", - "index in this pool, or exceeds NUM_REWARDS, or", - "all reward slots for this pool has been initialized." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "newRewardAuthority", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u8" - } - ] - }, - { - "name": "setRewardAuthorityBySuperAuthority", - "docs": [ - "Set the whirlpool reward authority at the provided `reward_index`.", - "Only the current reward super authority has permission to invoke this instruction.", - "", - "### Authority", - "- \"reward_authority\" - Set authority that can control reward emission for this particular reward.", - "", - "#### Special Errors", - "- `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized", - "index in this pool, or exceeds NUM_REWARDS, or", - "all reward slots for this pool has been initialized." - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardEmissionsSuperAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "newRewardAuthority", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u8" - } - ] - }, - { - "name": "setRewardEmissionsSuperAuthority", - "docs": [ - "Set the whirlpool reward super authority for a WhirlpoolConfig", - "Only the current reward super authority has permission to invoke this instruction.", - "This instruction will not change the authority on any `WhirlpoolRewardInfo` whirlpool rewards.", - "", - "### Authority", - "- \"reward_emissions_super_authority\" - Set authority that can control reward authorities for all pools in this config space." - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardEmissionsSuperAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "newRewardEmissionsSuperAuthority", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "twoHopSwap", - "docs": [ - "Perform a two-hop swap in this Whirlpool", - "", - "### Authority", - "- \"token_authority\" - The authority to withdraw tokens from the input token account.", - "", - "### Parameters", - "- `amount` - The amount of input or output token to swap from (depending on amount_specified_is_input).", - "- `other_amount_threshold` - The maximum/minimum of input/output token to swap into (depending on amount_specified_is_input).", - "- `amount_specified_is_input` - Specifies the token the parameter `amount`represents. If true, the amount represents the input token of the swap.", - "- `a_to_b_one` - The direction of the swap of hop one. True if swapping from A to B. False if swapping from B to A.", - "- `a_to_b_two` - The direction of the swap of hop two. True if swapping from A to B. False if swapping from B to A.", - "- `sqrt_price_limit_one` - The maximum/minimum price the swap will swap to in the first hop.", - "- `sqrt_price_limit_two` - The maximum/minimum price the swap will swap to in the second hop.", - "", - "#### Special Errors", - "- `ZeroTradableAmount` - User provided parameter `amount` is 0.", - "- `InvalidSqrtPriceLimitDirection` - User provided parameter `sqrt_price_limit` does not match the direction of the trade.", - "- `SqrtPriceOutOfBounds` - User provided parameter `sqrt_price_limit` is over Whirlppool's max/min bounds for sqrt-price.", - "- `InvalidTickArraySequence` - User provided tick-arrays are not in sequential order required to proceed in this trade direction.", - "- `TickArraySequenceInvalidIndex` - The swap loop attempted to access an invalid array index during the query of the next initialized tick.", - "- `TickArrayIndexOutofBounds` - The swap loop attempted to access an invalid array index during tick crossing.", - "- `LiquidityOverflow` - Liquidity value overflowed 128bits during tick crossing.", - "- `InvalidTickSpacing` - The swap pool was initialized with tick-spacing of 0.", - "- `InvalidIntermediaryMint` - Error if the intermediary mint between hop one and two do not equal.", - "- `DuplicateTwoHopPool` - Error if whirlpool one & two are the same pool." - ], - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "whirlpoolOne", - "isMut": true, - "isSigner": false - }, - { - "name": "whirlpoolTwo", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountOneA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultOneA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountOneB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultOneB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountTwoA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultTwoA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountTwoB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultTwoB", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayOne0", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayOne1", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayOne2", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayTwo0", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayTwo1", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayTwo2", - "isMut": true, - "isSigner": false - }, - { - "name": "oracleOne", - "isMut": false, - "isSigner": false - }, - { - "name": "oracleTwo", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "otherAmountThreshold", - "type": "u64" - }, - { - "name": "amountSpecifiedIsInput", - "type": "bool" - }, - { - "name": "aToBOne", - "type": "bool" - }, - { - "name": "aToBTwo", - "type": "bool" - }, - { - "name": "sqrtPriceLimitOne", - "type": "u128" - }, - { - "name": "sqrtPriceLimitTwo", - "type": "u128" - } - ] - }, - { - "name": "initializePositionBundle", - "docs": [ - "Initializes a PositionBundle account that bundles several positions.", - "A unique token will be minted to represent the position bundle in the users wallet." - ], - "accounts": [ - { - "name": "positionBundle", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundleMint", - "isMut": true, - "isSigner": true - }, - { - "name": "positionBundleTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundleOwner", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "initializePositionBundleWithMetadata", - "docs": [ - "Initializes a PositionBundle account that bundles several positions.", - "A unique token will be minted to represent the position bundle in the users wallet.", - "Additional Metaplex metadata is appended to identify the token." - ], - "accounts": [ - { - "name": "positionBundle", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundleMint", - "isMut": true, - "isSigner": true - }, - { - "name": "positionBundleMetadata", - "isMut": true, - "isSigner": false, - "docs": [ - "https://github.com/metaplex-foundation/metaplex-program-library/blob/773a574c4b34e5b9f248a81306ec24db064e255f/token-metadata/program/src/utils/metadata.rs#L100" - ] - }, - { - "name": "positionBundleTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundleOwner", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "metadataUpdateAuth", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "deletePositionBundle", - "docs": [ - "Delete a PositionBundle account. Burns the position bundle token in the owner's wallet.", - "", - "### Authority", - "- `position_bundle_owner` - The owner that owns the position bundle token.", - "", - "### Special Errors", - "- `PositionBundleNotDeletable` - The provided position bundle has open positions." - ], - "accounts": [ - { - "name": "positionBundle", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundleMint", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundleTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundleOwner", - "isMut": false, - "isSigner": true - }, - { - "name": "receiver", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "openBundledPosition", - "docs": [ - "Open a bundled position in a Whirlpool. No new tokens are issued", - "because the owner of the position bundle becomes the owner of the position.", - "The position will start off with 0 liquidity.", - "", - "### Authority", - "- `position_bundle_authority` - authority that owns the token corresponding to this desired position bundle.", - "", - "### Parameters", - "- `bundle_index` - The bundle index that we'd like to open.", - "- `tick_lower_index` - The tick specifying the lower end of the position range.", - "- `tick_upper_index` - The tick specifying the upper end of the position range.", - "", - "#### Special Errors", - "- `InvalidBundleIndex` - If the provided bundle index is out of bounds.", - "- `InvalidTickIndex` - If a provided tick is out of bounds, out of order or not a multiple of", - "the tick-spacing in this pool." - ], - "accounts": [ - { - "name": "bundledPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundle", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundleTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "positionBundleAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "bundleIndex", - "type": "u16" - }, - { - "name": "tickLowerIndex", - "type": "i32" - }, - { - "name": "tickUpperIndex", - "type": "i32" - } - ] - }, - { - "name": "closeBundledPosition", - "docs": [ - "Close a bundled position in a Whirlpool.", - "", - "### Authority", - "- `position_bundle_authority` - authority that owns the token corresponding to this desired position bundle.", - "", - "### Parameters", - "- `bundle_index` - The bundle index that we'd like to close.", - "", - "#### Special Errors", - "- `InvalidBundleIndex` - If the provided bundle index is out of bounds.", - "- `ClosePositionNotEmpty` - The provided position account is not empty." - ], - "accounts": [ - { - "name": "bundledPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundle", - "isMut": true, - "isSigner": false - }, - { - "name": "positionBundleTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "positionBundleAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "receiver", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "bundleIndex", - "type": "u16" - } - ] - }, - { - "name": "openPositionWithTokenExtensions", - "docs": [ - "Open a position in a Whirlpool. A unique token will be minted to represent the position", - "in the users wallet. Additional TokenMetadata extension is initialized to identify the token.", - "Mint and TokenAccount are based on Token-2022.", - "The position will start off with 0 liquidity.", - "", - "### Parameters", - "- `tick_lower_index` - The tick specifying the lower end of the position range.", - "- `tick_upper_index` - The tick specifying the upper end of the position range.", - "- `with_token_metadata_extension` - If true, the token metadata extension will be initialized.", - "", - "#### Special Errors", - "- `InvalidTickIndex` - If a provided tick is out of bounds, out of order or not a multiple of", - "the tick-spacing in this pool." - ], - "accounts": [ - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "owner", - "isMut": false, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionMint", - "isMut": true, - "isSigner": true - }, - { - "name": "positionTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "token2022Program", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "metadataUpdateAuth", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tickLowerIndex", - "type": "i32" - }, - { - "name": "tickUpperIndex", - "type": "i32" - }, - { - "name": "withTokenMetadataExtension", - "type": "bool" - } - ] - }, - { - "name": "closePositionWithTokenExtensions", - "docs": [ - "Close a position in a Whirlpool. Burns the position token in the owner's wallet.", - "Mint and TokenAccount are based on Token-2022. And Mint accout will be also closed.", - "", - "### Authority", - "- \"position_authority\" - The authority that owns the position token.", - "", - "#### Special Errors", - "- `ClosePositionNotEmpty` - The provided position account is not empty." - ], - "accounts": [ - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "receiver", - "isMut": true, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionMint", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "token2022Program", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "lockPosition", - "docs": [ - "Lock the position to prevent any liquidity changes.", - "", - "### Authority", - "- `position_authority` - The authority that owns the position token.", - "", - "#### Special Errors", - "- `PositionAlreadyLocked` - The provided position is already locked.", - "- `PositionNotLockable` - The provided position is not lockable (e.g. An empty position)." - ], - "accounts": [ - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": false, - "isSigner": false - }, - { - "name": "positionMint", - "isMut": false, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "lockConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "token2022Program", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "lockType", - "type": { - "defined": "LockType" - } - } - ] - }, - { - "name": "resetPositionRange", - "docs": [ - "Reset the position range to a new range.", - "", - "### Authority", - "- `position_authority` - The authority that owns the position token.", - "", - "### Parameters", - "- `new_tick_lower_index` - The new tick specifying the lower end of the position range.", - "- `new_tick_upper_index` - The new tick specifying the upper end of the position range.", - "", - "#### Special Errors", - "- `InvalidTickIndex` - If a provided tick is out of bounds, out of order or not a multiple of", - "the tick-spacing in this pool.", - "- `ClosePositionNotEmpty` - The provided position account is not empty.", - "- `SameTickRangeNotAllowed` - The provided tick range is the same as the current tick range." - ], - "accounts": [ - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "newTickLowerIndex", - "type": "i32" - }, - { - "name": "newTickUpperIndex", - "type": "i32" - } - ] - }, - { - "name": "transferLockedPosition", - "docs": [ - "Transfer a locked position to to a different token account.", - "", - "### Authority", - "- `position_authority` - The authority that owns the position token." - ], - "accounts": [ - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "receiver", - "isMut": true, - "isSigner": false - }, - { - "name": "position", - "isMut": false, - "isSigner": false - }, - { - "name": "positionMint", - "isMut": false, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "destinationTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "lockConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "token2022Program", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "initializeAdaptiveFeeTier", - "docs": [ - "Initializes an adaptive_fee_tier account usable by Whirlpools in a WhirlpoolConfig space.", - "", - "### Authority", - "- \"fee_authority\" - Set authority in the WhirlpoolConfig", - "", - "### Parameters", - "- `fee_tier_index` - The index of the fee-tier that this adaptive fee tier will be initialized.", - "- `tick_spacing` - The tick-spacing that this fee-tier suggests the default_fee_rate for.", - "- `initialize_pool_authority` - The authority that can initialize pools with this adaptive fee-tier.", - "- `delegated_fee_authority` - The authority that can set the base fee rate for pools using this adaptive fee-tier.", - "- `default_fee_rate` - The default fee rate that a pool will use if the pool uses this", - "fee tier during initialization.", - "- `filter_period` - Period determine high frequency trading time window. (seconds)", - "- `decay_period` - Period determine when the adaptive fee start decrease. (seconds)", - "- `reduction_factor` - Adaptive fee rate decrement rate.", - "- `adaptive_fee_control_factor` - Adaptive fee control factor.", - "- `max_volatility_accumulator` - Max volatility accumulator.", - "- `tick_group_size` - Tick group size to define tick group index.", - "- `major_swap_threshold_ticks` - Major swap threshold ticks to define major swap.", - "", - "#### Special Errors", - "- `InvalidTickSpacing` - If the provided tick_spacing is 0.", - "- `InvalidFeeTierIndex` - If the provided fee_tier_index is same to tick_spacing.", - "- `FeeRateMaxExceeded` - If the provided default_fee_rate exceeds MAX_FEE_RATE.", - "- `InvalidAdaptiveFeeConstants` - If the provided adaptive fee constants are invalid." - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "adaptiveFeeTier", - "isMut": true, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "feeTierIndex", - "type": "u16" - }, - { - "name": "tickSpacing", - "type": "u16" - }, - { - "name": "initializePoolAuthority", - "type": "publicKey" - }, - { - "name": "delegatedFeeAuthority", - "type": "publicKey" - }, - { - "name": "defaultBaseFeeRate", - "type": "u16" - }, - { - "name": "filterPeriod", - "type": "u16" - }, - { - "name": "decayPeriod", - "type": "u16" - }, - { - "name": "reductionFactor", - "type": "u16" - }, - { - "name": "adaptiveFeeControlFactor", - "type": "u32" - }, - { - "name": "maxVolatilityAccumulator", - "type": "u32" - }, - { - "name": "tickGroupSize", - "type": "u16" - }, - { - "name": "majorSwapThresholdTicks", - "type": "u16" - } - ] - }, - { - "name": "setDefaultBaseFeeRate", - "docs": [ - "Set the default_base_fee_rate for an AdaptiveFeeTier", - "Only the current fee authority in WhirlpoolsConfig has permission to invoke this instruction.", - "", - "### Authority", - "- \"fee_authority\" - Set authority in the WhirlpoolConfig", - "", - "### Parameters", - "- `default_base_fee_rate` - The default base fee rate that a pool will use if the pool uses this", - "adaptive fee-tier during initialization.", - "", - "#### Special Errors", - "- `FeeRateMaxExceeded` - If the provided default_fee_rate exceeds MAX_FEE_RATE." - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "adaptiveFeeTier", - "isMut": true, - "isSigner": false - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "defaultBaseFeeRate", - "type": "u16" - } - ] - }, - { - "name": "setDelegatedFeeAuthority", - "docs": [ - "Sets the delegated fee authority for an AdaptiveFeeTier.", - "The delegated fee authority can set the fee rate for individual pools initialized with the adaptive fee-tier.", - "Only the current fee authority in WhirlpoolsConfig has permission to invoke this instruction.", - "", - "### Authority", - "- \"fee_authority\" - Set authority in the WhirlpoolConfig" - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "adaptiveFeeTier", - "isMut": true, - "isSigner": false - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "newDelegatedFeeAuthority", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "setInitializePoolAuthority", - "docs": [ - "Sets the initialize pool authority for an AdaptiveFeeTier.", - "Only the initialize pool authority can initialize pools with the adaptive fee-tier.", - "Only the current fee authority in WhirlpoolsConfig has permission to invoke this instruction.", - "", - "### Authority", - "- \"fee_authority\" - Set authority in the WhirlpoolConfig" - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "adaptiveFeeTier", - "isMut": true, - "isSigner": false - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "newInitializePoolAuthority", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "setPresetAdaptiveFeeConstants", - "docs": [ - "Sets the adaptive fee constants for an AdaptiveFeeTier.", - "Only the current fee authority in WhirlpoolsConfig has permission to invoke this instruction.", - "", - "### Authority", - "- \"fee_authority\" - Set authority in the WhirlpoolConfig", - "", - "### Parameters", - "- `filter_period` - Period determine high frequency trading time window. (seconds)", - "- `decay_period` - Period determine when the adaptive fee start decrease. (seconds)", - "- `reduction_factor` - Adaptive fee rate decrement rate.", - "- `adaptive_fee_control_factor` - Adaptive fee control factor.", - "- `max_volatility_accumulator` - Max volatility accumulator.", - "- `tick_group_size` - Tick group size to define tick group index.", - "- `major_swap_threshold_ticks` - Major swap threshold ticks to define major swap." - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "adaptiveFeeTier", - "isMut": true, - "isSigner": false - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "filterPeriod", - "type": "u16" - }, - { - "name": "decayPeriod", - "type": "u16" - }, - { - "name": "reductionFactor", - "type": "u16" - }, - { - "name": "adaptiveFeeControlFactor", - "type": "u32" - }, - { - "name": "maxVolatilityAccumulator", - "type": "u32" - }, - { - "name": "tickGroupSize", - "type": "u16" - }, - { - "name": "majorSwapThresholdTicks", - "type": "u16" - } - ] - }, - { - "name": "initializePoolWithAdaptiveFee", - "docs": [ - "Initializes a Whirlpool account and Oracle account with adaptive fee.", - "", - "### Parameters", - "- `initial_sqrt_price` - The desired initial sqrt-price for this pool", - "- `trade_enable_timestamp` - The timestamp when trading is enabled for this pool (within 72 hours)", - "", - "#### Special Errors", - "`InvalidTokenMintOrder` - The order of mints have to be ordered by", - "`SqrtPriceOutOfBounds` - provided initial_sqrt_price is not between 2^-64 to 2^64", - "`InvalidTradeEnableTimestamp` - provided trade_enable_timestamp is not within 72 hours or the adaptive fee-tier is permission-less", - "`UnsupportedTokenMint` - The provided token mint is not supported by the program (e.g. it has risky token extensions)", - "" - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintB", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenBadgeA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenBadgeB", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "initializePoolAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": true - }, - { - "name": "adaptiveFeeTier", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramB", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "initialSqrtPrice", - "type": "u128" - }, - { - "name": "tradeEnableTimestamp", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "setFeeRateByDelegatedFeeAuthority", - "docs": [ - "Sets the fee rate for a Whirlpool by the delegated fee authority in AdaptiveFeeTier.", - "Fee rate is represented as hundredths of a basis point.", - "", - "### Authority", - "- \"delegated_fee_authority\" - Set authority that can modify pool fees in the AdaptiveFeeTier", - "", - "### Parameters", - "- `fee_rate` - The rate that the pool will use to calculate fees going onwards.", - "", - "#### Special Errors", - "- `FeeRateMaxExceeded` - If the provided fee_rate exceeds MAX_FEE_RATE." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "adaptiveFeeTier", - "isMut": false, - "isSigner": false - }, - { - "name": "delegatedFeeAuthority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "feeRate", - "type": "u16" - } - ] - }, - { - "name": "collectFeesV2", - "docs": [ - "Collect fees accrued for this position.", - "", - "### Authority", - "- `position_authority` - authority that owns the token corresponding to this desired position." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintB", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenOwnerAccountA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgramA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramB", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "remainingAccountsInfo", - "type": { - "option": { - "defined": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "collectProtocolFeesV2", - "docs": [ - "Collect the protocol fees accrued in this Whirlpool", - "", - "### Authority", - "- `collect_protocol_fees_authority` - assigned authority in the WhirlpoolConfig that can collect protocol fees" - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "collectProtocolFeesAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenMintA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintB", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenDestinationA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenDestinationB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgramA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramB", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "remainingAccountsInfo", - "type": { - "option": { - "defined": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "collectRewardV2", - "docs": [ - "Collect rewards accrued for this position.", - "", - "### Authority", - "- `position_authority` - authority that owns the token corresponding to this desired position." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": false, - "isSigner": false - }, - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "rewardOwnerAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardMint", - "isMut": false, - "isSigner": false - }, - { - "name": "rewardVault", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u8" - }, - { - "name": "remainingAccountsInfo", - "type": { - "option": { - "defined": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "decreaseLiquidityV2", - "docs": [ - "Withdraw liquidity from a position in the Whirlpool. This call also updates the position's accrued fees and rewards.", - "", - "### Authority", - "- `position_authority` - authority that owns the token corresponding to this desired position.", - "", - "### Parameters", - "- `liquidity_amount` - The total amount of Liquidity the user desires to withdraw.", - "- `token_min_a` - The minimum amount of tokenA the user is willing to withdraw.", - "- `token_min_b` - The minimum amount of tokenB the user is willing to withdraw.", - "", - "#### Special Errors", - "- `LiquidityZero` - Provided liquidity amount is zero.", - "- `LiquidityTooHigh` - Provided liquidity exceeds u128::max.", - "- `TokenMinSubceeded` - The required token to perform this operation subceeds the user defined amount." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgramA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramB", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintB", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenOwnerAccountA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityAmount", - "type": "u128" - }, - { - "name": "tokenMinA", - "type": "u64" - }, - { - "name": "tokenMinB", - "type": "u64" - }, - { - "name": "remainingAccountsInfo", - "type": { - "option": { - "defined": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "increaseLiquidityV2", - "docs": [ - "Add liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards.", - "", - "### Authority", - "- `position_authority` - authority that owns the token corresponding to this desired position.", - "", - "### Parameters", - "- `liquidity_amount` - The total amount of Liquidity the user is willing to deposit.", - "- `token_max_a` - The maximum amount of tokenA the user is willing to deposit.", - "- `token_max_b` - The maximum amount of tokenB the user is willing to deposit.", - "", - "#### Special Errors", - "- `LiquidityZero` - Provided liquidity amount is zero.", - "- `LiquidityTooHigh` - Provided liquidity exceeds u128::max.", - "- `TokenMaxExceeded` - The required token to perform this operation exceeds the user defined amount." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgramA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramB", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "positionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "position", - "isMut": true, - "isSigner": false - }, - { - "name": "positionTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintB", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenOwnerAccountA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidityAmount", - "type": "u128" - }, - { - "name": "tokenMaxA", - "type": "u64" - }, - { - "name": "tokenMaxB", - "type": "u64" - }, - { - "name": "remainingAccountsInfo", - "type": { - "option": { - "defined": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "initializePoolV2", - "docs": [ - "Initializes a Whirlpool account.", - "Fee rate is set to the default values on the config and supplied fee_tier.", - "", - "### Parameters", - "- `bumps` - The bump value when deriving the PDA of the Whirlpool address.", - "- `tick_spacing` - The desired tick spacing for this pool.", - "- `initial_sqrt_price` - The desired initial sqrt-price for this pool", - "", - "#### Special Errors", - "`InvalidTokenMintOrder` - The order of mints have to be ordered by", - "`SqrtPriceOutOfBounds` - provided initial_sqrt_price is not between 2^-64 to 2^64", - "" - ], - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintB", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenBadgeA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenBadgeB", - "isMut": false, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": true - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": true - }, - { - "name": "feeTier", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramB", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tickSpacing", - "type": "u16" - }, - { - "name": "initialSqrtPrice", - "type": "u128" - } - ] - }, - { - "name": "initializeRewardV2", - "docs": [ - "Initialize reward for a Whirlpool. A pool can only support up to a set number of rewards.", - "", - "### Authority", - "- \"reward_authority\" - assigned authority by the reward_super_authority for the specified", - "reward-index in this Whirlpool", - "", - "### Parameters", - "- `reward_index` - The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS)", - "", - "#### Special Errors", - "- `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized", - "index in this pool, or exceeds NUM_REWARDS, or", - "all reward slots for this pool has been initialized." - ], - "accounts": [ - { - "name": "rewardAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardMint", - "isMut": false, - "isSigner": false - }, - { - "name": "rewardTokenBadge", - "isMut": false, - "isSigner": false - }, - { - "name": "rewardVault", - "isMut": true, - "isSigner": true - }, - { - "name": "rewardTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u8" - } - ] - }, - { - "name": "setRewardEmissionsV2", - "docs": [ - "Set the reward emissions for a reward in a Whirlpool.", - "", - "### Authority", - "- \"reward_authority\" - assigned authority by the reward_super_authority for the specified", - "reward-index in this Whirlpool", - "", - "### Parameters", - "- `reward_index` - The reward index (0 <= index <= NUM_REWARDS) that we'd like to modify.", - "- `emissions_per_second_x64` - The amount of rewards emitted in this pool.", - "", - "#### Special Errors", - "- `RewardVaultAmountInsufficient` - The amount of rewards in the reward vault cannot emit", - "more than a day of desired emissions.", - "- `InvalidTimestamp` - Provided timestamp is not in order with the previous timestamp.", - "- `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized", - "index in this pool, or exceeds NUM_REWARDS, or", - "all reward slots for this pool has been initialized." - ], - "accounts": [ - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "rewardVault", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u8" - }, - { - "name": "emissionsPerSecondX64", - "type": "u128" - } - ] - }, - { - "name": "swapV2", - "docs": [ - "Perform a swap in this Whirlpool", - "", - "### Authority", - "- \"token_authority\" - The authority to withdraw tokens from the input token account.", - "", - "### Parameters", - "- `amount` - The amount of input or output token to swap from (depending on amount_specified_is_input).", - "- `other_amount_threshold` - The maximum/minimum of input/output token to swap into (depending on amount_specified_is_input).", - "- `sqrt_price_limit` - The maximum/minimum price the swap will swap to.", - "- `amount_specified_is_input` - Specifies the token the parameter `amount`represents. If true, the amount represents the input token of the swap.", - "- `a_to_b` - The direction of the swap. True if swapping from A to B. False if swapping from B to A.", - "", - "#### Special Errors", - "- `ZeroTradableAmount` - User provided parameter `amount` is 0.", - "- `InvalidSqrtPriceLimitDirection` - User provided parameter `sqrt_price_limit` does not match the direction of the trade.", - "- `SqrtPriceOutOfBounds` - User provided parameter `sqrt_price_limit` is over Whirlppool's max/min bounds for sqrt-price.", - "- `InvalidTickArraySequence` - User provided tick-arrays are not in sequential order required to proceed in this trade direction.", - "- `TickArraySequenceInvalidIndex` - The swap loop attempted to access an invalid array index during the query of the next initialized tick.", - "- `TickArrayIndexOutofBounds` - The swap loop attempted to access an invalid array index during tick crossing.", - "- `LiquidityOverflow` - Liquidity value overflowed 128bits during tick crossing.", - "- `InvalidTickSpacing` - The swap pool was initialized with tick-spacing of 0." - ], - "accounts": [ - { - "name": "tokenProgramA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramB", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "whirlpool", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMintA", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintB", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenOwnerAccountA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultA", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountB", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultB", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArray0", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArray1", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArray2", - "isMut": true, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "otherAmountThreshold", - "type": "u64" - }, - { - "name": "sqrtPriceLimit", - "type": "u128" - }, - { - "name": "amountSpecifiedIsInput", - "type": "bool" - }, - { - "name": "aToB", - "type": "bool" - }, - { - "name": "remainingAccountsInfo", - "type": { - "option": { - "defined": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "twoHopSwapV2", - "docs": [ - "Perform a two-hop swap in this Whirlpool", - "", - "### Authority", - "- \"token_authority\" - The authority to withdraw tokens from the input token account.", - "", - "### Parameters", - "- `amount` - The amount of input or output token to swap from (depending on amount_specified_is_input).", - "- `other_amount_threshold` - The maximum/minimum of input/output token to swap into (depending on amount_specified_is_input).", - "- `amount_specified_is_input` - Specifies the token the parameter `amount`represents. If true, the amount represents the input token of the swap.", - "- `a_to_b_one` - The direction of the swap of hop one. True if swapping from A to B. False if swapping from B to A.", - "- `a_to_b_two` - The direction of the swap of hop two. True if swapping from A to B. False if swapping from B to A.", - "- `sqrt_price_limit_one` - The maximum/minimum price the swap will swap to in the first hop.", - "- `sqrt_price_limit_two` - The maximum/minimum price the swap will swap to in the second hop.", - "", - "#### Special Errors", - "- `ZeroTradableAmount` - User provided parameter `amount` is 0.", - "- `InvalidSqrtPriceLimitDirection` - User provided parameter `sqrt_price_limit` does not match the direction of the trade.", - "- `SqrtPriceOutOfBounds` - User provided parameter `sqrt_price_limit` is over Whirlppool's max/min bounds for sqrt-price.", - "- `InvalidTickArraySequence` - User provided tick-arrays are not in sequential order required to proceed in this trade direction.", - "- `TickArraySequenceInvalidIndex` - The swap loop attempted to access an invalid array index during the query of the next initialized tick.", - "- `TickArrayIndexOutofBounds` - The swap loop attempted to access an invalid array index during tick crossing.", - "- `LiquidityOverflow` - Liquidity value overflowed 128bits during tick crossing.", - "- `InvalidTickSpacing` - The swap pool was initialized with tick-spacing of 0.", - "- `InvalidIntermediaryMint` - Error if the intermediary mint between hop one and two do not equal.", - "- `DuplicateTwoHopPool` - Error if whirlpool one & two are the same pool." - ], - "accounts": [ - { - "name": "whirlpoolOne", - "isMut": true, - "isSigner": false - }, - { - "name": "whirlpoolTwo", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMintInput", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintIntermediate", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMintOutput", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramInput", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramIntermediate", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgramOutput", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenOwnerAccountInput", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultOneInput", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultOneIntermediate", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultTwoIntermediate", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVaultTwoOutput", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenOwnerAccountOutput", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "tickArrayOne0", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayOne1", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayOne2", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayTwo0", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayTwo1", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayTwo2", - "isMut": true, - "isSigner": false - }, - { - "name": "oracleOne", - "isMut": true, - "isSigner": false - }, - { - "name": "oracleTwo", - "isMut": true, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "otherAmountThreshold", - "type": "u64" - }, - { - "name": "amountSpecifiedIsInput", - "type": "bool" - }, - { - "name": "aToBOne", - "type": "bool" - }, - { - "name": "aToBTwo", - "type": "bool" - }, - { - "name": "sqrtPriceLimitOne", - "type": "u128" - }, - { - "name": "sqrtPriceLimitTwo", - "type": "u128" - }, - { - "name": "remainingAccountsInfo", - "type": { - "option": { - "defined": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "initializeConfigExtension", - "accounts": [ - { - "name": "config", - "isMut": false, - "isSigner": false - }, - { - "name": "configExtension", - "isMut": true, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "feeAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "setConfigExtensionAuthority", - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "whirlpoolsConfigExtension", - "isMut": true, - "isSigner": false - }, - { - "name": "configExtensionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "newConfigExtensionAuthority", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "setTokenBadgeAuthority", - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "whirlpoolsConfigExtension", - "isMut": true, - "isSigner": false - }, - { - "name": "configExtensionAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "newTokenBadgeAuthority", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "initializeTokenBadge", - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "whirlpoolsConfigExtension", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenBadgeAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenBadge", - "isMut": true, - "isSigner": false - }, - { - "name": "funder", - "isMut": true, - "isSigner": true - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "deleteTokenBadge", - "accounts": [ - { - "name": "whirlpoolsConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "whirlpoolsConfigExtension", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenBadgeAuthority", - "isMut": false, - "isSigner": true - }, - { - "name": "tokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenBadge", - "isMut": true, - "isSigner": false - }, - { - "name": "receiver", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "idlInclude", - "accounts": [ - { - "name": "tickArray", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - } - ], - "accounts": [ - { - "name": "AdaptiveFeeTier", - "type": { - "kind": "struct", - "fields": [ - { - "name": "whirlpoolsConfig", - "type": "publicKey" - }, - { - "name": "feeTierIndex", - "type": "u16" - }, - { - "name": "tickSpacing", - "type": "u16" - }, - { - "name": "initializePoolAuthority", - "type": "publicKey" - }, - { - "name": "delegatedFeeAuthority", - "type": "publicKey" - }, - { - "name": "defaultBaseFeeRate", - "type": "u16" - }, - { - "name": "filterPeriod", - "type": "u16" - }, - { - "name": "decayPeriod", - "type": "u16" - }, - { - "name": "reductionFactor", - "type": "u16" - }, - { - "name": "adaptiveFeeControlFactor", - "type": "u32" - }, - { - "name": "maxVolatilityAccumulator", - "type": "u32" - }, - { - "name": "tickGroupSize", - "type": "u16" - }, - { - "name": "majorSwapThresholdTicks", - "type": "u16" - } - ] - } - }, - { - "name": "WhirlpoolsConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "feeAuthority", - "type": "publicKey" - }, - { - "name": "collectProtocolFeesAuthority", - "type": "publicKey" - }, - { - "name": "rewardEmissionsSuperAuthority", - "type": "publicKey" - }, - { - "name": "defaultProtocolFeeRate", - "type": "u16" - } - ] - } - }, - { - "name": "WhirlpoolsConfigExtension", - "type": { - "kind": "struct", - "fields": [ - { - "name": "whirlpoolsConfig", - "type": "publicKey" - }, - { - "name": "configExtensionAuthority", - "type": "publicKey" - }, - { - "name": "tokenBadgeAuthority", - "type": "publicKey" - } - ] - } - }, - { - "name": "DynamicTickArray", - "type": { - "kind": "struct", - "fields": [ - { - "name": "startTickIndex", - "type": "i32" - }, - { - "name": "whirlpool", - "type": "publicKey" - }, - { - "name": "tickBitmap", - "type": "u128" - }, - { - "name": "ticks", - "type": { - "array": [ - { - "defined": "DynamicTick" - }, - 88 - ] - } - } - ] - } - }, - { - "name": "FeeTier", - "type": { - "kind": "struct", - "fields": [ - { - "name": "whirlpoolsConfig", - "type": "publicKey" - }, - { - "name": "tickSpacing", - "type": "u16" - }, - { - "name": "defaultFeeRate", - "type": "u16" - } - ] - } - }, - { - "name": "TickArray", - "type": { - "kind": "struct", - "fields": [ - { - "name": "startTickIndex", - "type": "i32" - }, - { - "name": "ticks", - "type": { - "array": [ - { - "defined": "Tick" - }, - 88 - ] - } - }, - { - "name": "whirlpool", - "type": "publicKey" - } - ] - } - }, - { - "name": "LockConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "position", - "type": "publicKey" - }, - { - "name": "positionOwner", - "type": "publicKey" - }, - { - "name": "whirlpool", - "type": "publicKey" - }, - { - "name": "lockedTimestamp", - "type": "u64" - }, - { - "name": "lockType", - "type": { - "defined": "LockTypeLabel" - } - } - ] - } - }, - { - "name": "Oracle", - "type": { - "kind": "struct", - "fields": [ - { - "name": "whirlpool", - "type": "publicKey" - }, - { - "name": "tradeEnableTimestamp", - "type": "u64" - }, - { - "name": "adaptiveFeeConstants", - "type": { - "defined": "AdaptiveFeeConstants" - } - }, - { - "name": "adaptiveFeeVariables", - "type": { - "defined": "AdaptiveFeeVariables" - } - }, - { - "name": "reserved", - "type": { - "array": ["u8", 128] - } - } - ] - } - }, - { - "name": "Position", - "type": { - "kind": "struct", - "fields": [ - { - "name": "whirlpool", - "type": "publicKey" - }, - { - "name": "positionMint", - "type": "publicKey" - }, - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "tickLowerIndex", - "type": "i32" - }, - { - "name": "tickUpperIndex", - "type": "i32" - }, - { - "name": "feeGrowthCheckpointA", - "type": "u128" - }, - { - "name": "feeOwedA", - "type": "u64" - }, - { - "name": "feeGrowthCheckpointB", - "type": "u128" - }, - { - "name": "feeOwedB", - "type": "u64" - }, - { - "name": "rewardInfos", - "type": { - "array": [ - { - "defined": "PositionRewardInfo" - }, - 3 - ] - } - } - ] - } - }, - { - "name": "PositionBundle", - "type": { - "kind": "struct", - "fields": [ - { - "name": "positionBundleMint", - "type": "publicKey" - }, - { - "name": "positionBitmap", - "type": { - "array": ["u8", 32] - } - } - ] - } - }, - { - "name": "TokenBadge", - "type": { - "kind": "struct", - "fields": [ - { - "name": "whirlpoolsConfig", - "type": "publicKey" - }, - { - "name": "tokenMint", - "type": "publicKey" - } - ] - } - }, - { - "name": "Whirlpool", - "type": { - "kind": "struct", - "fields": [ - { - "name": "whirlpoolsConfig", - "type": "publicKey" - }, - { - "name": "whirlpoolBump", - "type": { - "array": ["u8", 1] - } - }, - { - "name": "tickSpacing", - "type": "u16" - }, - { - "name": "feeTierIndexSeed", - "type": { - "array": ["u8", 2] - } - }, - { - "name": "feeRate", - "type": "u16" - }, - { - "name": "protocolFeeRate", - "type": "u16" - }, - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "sqrtPrice", - "type": "u128" - }, - { - "name": "tickCurrentIndex", - "type": "i32" - }, - { - "name": "protocolFeeOwedA", - "type": "u64" - }, - { - "name": "protocolFeeOwedB", - "type": "u64" - }, - { - "name": "tokenMintA", - "type": "publicKey" - }, - { - "name": "tokenVaultA", - "type": "publicKey" - }, - { - "name": "feeGrowthGlobalA", - "type": "u128" - }, - { - "name": "tokenMintB", - "type": "publicKey" - }, - { - "name": "tokenVaultB", - "type": "publicKey" - }, - { - "name": "feeGrowthGlobalB", - "type": "u128" - }, - { - "name": "rewardLastUpdatedTimestamp", - "type": "u64" - }, - { - "name": "rewardInfos", - "type": { - "array": [ - { - "defined": "WhirlpoolRewardInfo" - }, - 3 - ] - } - } - ] - } - } - ], - "types": [ - { - "name": "DynamicTick", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Uninitialized" - }, - { - "name": "Initialized", - "fields": [ - { - "defined": "DynamicTickData" - } - ] - } - ] - } - }, - { - "name": "DynamicTickData", - "type": { - "kind": "struct", - "fields": [ - { - "name": "liquidityNet", - "type": "i128" - }, - { - "name": "liquidityGross", - "type": "u128" - }, - { - "name": "feeGrowthOutsideA", - "type": "u128" - }, - { - "name": "feeGrowthOutsideB", - "type": "u128" - }, - { - "name": "rewardGrowthsOutside", - "type": { - "array": ["u128", 3] - } - } - ] - } - }, - { - "name": "LockType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Permanent" - } - ] - } - }, - { - "name": "LockTypeLabel", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Permanent" - } - ] - } - }, - { - "name": "AdaptiveFeeConstants", - "type": { - "kind": "struct", - "fields": [ - { - "name": "filterPeriod", - "type": "u16" - }, - { - "name": "decayPeriod", - "type": "u16" - }, - { - "name": "reductionFactor", - "type": "u16" - }, - { - "name": "adaptiveFeeControlFactor", - "type": "u32" - }, - { - "name": "maxVolatilityAccumulator", - "type": "u32" - }, - { - "name": "tickGroupSize", - "type": "u16" - }, - { - "name": "majorSwapThresholdTicks", - "type": "u16" - }, - { - "name": "reserved", - "type": { - "array": ["u8", 16] - } - } - ] - } - }, - { - "name": "AdaptiveFeeVariables", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lastReferenceUpdateTimestamp", - "type": "u64" - }, - { - "name": "lastMajorSwapTimestamp", - "type": "u64" - }, - { - "name": "volatilityReference", - "type": "u32" - }, - { - "name": "tickGroupIndexReference", - "type": "i32" - }, - { - "name": "volatilityAccumulator", - "type": "u32" - }, - { - "name": "reserved", - "type": { - "array": ["u8", 16] - } - } - ] - } - }, - { - "name": "OpenPositionBumps", - "type": { - "kind": "struct", - "fields": [ - { - "name": "positionBump", - "type": "u8" - } - ] - } - }, - { - "name": "OpenPositionWithMetadataBumps", - "type": { - "kind": "struct", - "fields": [ - { - "name": "positionBump", - "type": "u8" - }, - { - "name": "metadataBump", - "type": "u8" - } - ] - } - }, - { - "name": "PositionRewardInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "growthInsideCheckpoint", - "type": "u128" - }, - { - "name": "amountOwed", - "type": "u64" - } - ] - } - }, - { - "name": "Tick", - "type": { - "kind": "struct", - "fields": [ - { - "name": "initialized", - "type": "bool" - }, - { - "name": "liquidityNet", - "type": "i128" - }, - { - "name": "liquidityGross", - "type": "u128" - }, - { - "name": "feeGrowthOutsideA", - "type": "u128" - }, - { - "name": "feeGrowthOutsideB", - "type": "u128" - }, - { - "name": "rewardGrowthsOutside", - "type": { - "array": ["u128", 3] - } - } - ] - } - }, - { - "name": "WhirlpoolBumps", - "type": { - "kind": "struct", - "fields": [ - { - "name": "whirlpoolBump", - "type": "u8" - } - ] - } - }, - { - "name": "WhirlpoolRewardInfo", - "docs": [ - "Stores the state relevant for tracking liquidity mining rewards at the `Whirlpool` level.", - "These values are used in conjunction with `PositionRewardInfo`, `Tick.reward_growths_outside`,", - "and `Whirlpool.reward_last_updated_timestamp` to determine how many rewards are earned by open", - "positions." - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint", - "docs": ["Reward token mint."], - "type": "publicKey" - }, - { - "name": "vault", - "docs": ["Reward vault token account."], - "type": "publicKey" - }, - { - "name": "authority", - "docs": [ - "Authority account that has permission to initialize the reward and set emissions." - ], - "type": "publicKey" - }, - { - "name": "emissionsPerSecondX64", - "docs": [ - "Q64.64 number that indicates how many tokens per second are earned per unit of liquidity." - ], - "type": "u128" - }, - { - "name": "growthGlobalX64", - "docs": [ - "Q64.64 number that tracks the total tokens earned per unit of liquidity since the reward", - "emissions were turned on." - ], - "type": "u128" - } - ] - } - }, - { - "name": "AccountsType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "TransferHookA" - }, - { - "name": "TransferHookB" - }, - { - "name": "TransferHookReward" - }, - { - "name": "TransferHookInput" - }, - { - "name": "TransferHookIntermediate" - }, - { - "name": "TransferHookOutput" - }, - { - "name": "SupplementalTickArrays" - }, - { - "name": "SupplementalTickArraysOne" - }, - { - "name": "SupplementalTickArraysTwo" - } - ] - } - }, - { - "name": "RemainingAccountsInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "slices", - "type": { - "vec": { - "defined": "RemainingAccountsSlice" - } - } - } - ] - } - }, - { - "name": "RemainingAccountsSlice", - "type": { - "kind": "struct", - "fields": [ - { - "name": "accountsType", - "type": { - "defined": "AccountsType" - } - }, - { - "name": "length", - "type": "u8" - } - ] - } - } - ], - "events": [ - { - "name": "LiquidityDecreased", - "fields": [ - { - "name": "whirlpool", - "type": "publicKey", - "index": false - }, - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "tickLowerIndex", - "type": "i32", - "index": false - }, - { - "name": "tickUpperIndex", - "type": "i32", - "index": false - }, - { - "name": "liquidity", - "type": "u128", - "index": false - }, - { - "name": "tokenAAmount", - "type": "u64", - "index": false - }, - { - "name": "tokenBAmount", - "type": "u64", - "index": false - }, - { - "name": "tokenATransferFee", - "type": "u64", - "index": false - }, - { - "name": "tokenBTransferFee", - "type": "u64", - "index": false - } - ] - }, - { - "name": "LiquidityIncreased", - "fields": [ - { - "name": "whirlpool", - "type": "publicKey", - "index": false - }, - { - "name": "position", - "type": "publicKey", - "index": false - }, - { - "name": "tickLowerIndex", - "type": "i32", - "index": false - }, - { - "name": "tickUpperIndex", - "type": "i32", - "index": false - }, - { - "name": "liquidity", - "type": "u128", - "index": false - }, - { - "name": "tokenAAmount", - "type": "u64", - "index": false - }, - { - "name": "tokenBAmount", - "type": "u64", - "index": false - }, - { - "name": "tokenATransferFee", - "type": "u64", - "index": false - }, - { - "name": "tokenBTransferFee", - "type": "u64", - "index": false - } - ] - }, - { - "name": "PoolInitialized", - "fields": [ - { - "name": "whirlpool", - "type": "publicKey", - "index": false - }, - { - "name": "whirlpoolsConfig", - "type": "publicKey", - "index": false - }, - { - "name": "tokenMintA", - "type": "publicKey", - "index": false - }, - { - "name": "tokenMintB", - "type": "publicKey", - "index": false - }, - { - "name": "tickSpacing", - "type": "u16", - "index": false - }, - { - "name": "tokenProgramA", - "type": "publicKey", - "index": false - }, - { - "name": "tokenProgramB", - "type": "publicKey", - "index": false - }, - { - "name": "decimalsA", - "type": "u8", - "index": false - }, - { - "name": "decimalsB", - "type": "u8", - "index": false - }, - { - "name": "initialSqrtPrice", - "type": "u128", - "index": false - } - ] - }, - { - "name": "Traded", - "fields": [ - { - "name": "whirlpool", - "type": "publicKey", - "index": false - }, - { - "name": "aToB", - "type": "bool", - "index": false - }, - { - "name": "preSqrtPrice", - "type": "u128", - "index": false - }, - { - "name": "postSqrtPrice", - "type": "u128", - "index": false - }, - { - "name": "inputAmount", - "type": "u64", - "index": false - }, - { - "name": "outputAmount", - "type": "u64", - "index": false - }, - { - "name": "inputTransferFee", - "type": "u64", - "index": false - }, - { - "name": "outputTransferFee", - "type": "u64", - "index": false - }, - { - "name": "lpFee", - "type": "u64", - "index": false - }, - { - "name": "protocolFee", - "type": "u64", - "index": false - } - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "InvalidEnum", - "msg": "Enum value could not be converted" - }, - { - "code": 6001, - "name": "InvalidStartTick", - "msg": "Invalid start tick index provided." - }, - { - "code": 6002, - "name": "TickArrayExistInPool", - "msg": "Tick-array already exists in this whirlpool" - }, - { - "code": 6003, - "name": "TickArrayIndexOutofBounds", - "msg": "Attempt to search for a tick-array failed" - }, - { - "code": 6004, - "name": "InvalidTickSpacing", - "msg": "Tick-spacing is not supported" - }, - { - "code": 6005, - "name": "ClosePositionNotEmpty", - "msg": "Position is not empty It cannot be closed" - }, - { - "code": 6006, - "name": "DivideByZero", - "msg": "Unable to divide by zero" - }, - { - "code": 6007, - "name": "NumberCastError", - "msg": "Unable to cast number into BigInt" - }, - { - "code": 6008, - "name": "NumberDownCastError", - "msg": "Unable to down cast number" - }, - { - "code": 6009, - "name": "TickNotFound", - "msg": "Tick not found within tick array" - }, - { - "code": 6010, - "name": "InvalidTickIndex", - "msg": "Provided tick index is either out of bounds or uninitializable" - }, - { - "code": 6011, - "name": "SqrtPriceOutOfBounds", - "msg": "Provided sqrt price out of bounds" - }, - { - "code": 6012, - "name": "LiquidityZero", - "msg": "Liquidity amount must be greater than zero" - }, - { - "code": 6013, - "name": "LiquidityTooHigh", - "msg": "Liquidity amount must be less than i64::MAX" - }, - { - "code": 6014, - "name": "LiquidityOverflow", - "msg": "Liquidity overflow" - }, - { - "code": 6015, - "name": "LiquidityUnderflow", - "msg": "Liquidity underflow" - }, - { - "code": 6016, - "name": "LiquidityNetError", - "msg": "Tick liquidity net underflowed or overflowed" - }, - { - "code": 6017, - "name": "TokenMaxExceeded", - "msg": "Exceeded token max" - }, - { - "code": 6018, - "name": "TokenMinSubceeded", - "msg": "Did not meet token min" - }, - { - "code": 6019, - "name": "MissingOrInvalidDelegate", - "msg": "Position token account has a missing or invalid delegate" - }, - { - "code": 6020, - "name": "InvalidPositionTokenAmount", - "msg": "Position token amount must be 1" - }, - { - "code": 6021, - "name": "InvalidTimestampConversion", - "msg": "Timestamp should be convertible from i64 to u64" - }, - { - "code": 6022, - "name": "InvalidTimestamp", - "msg": "Timestamp should be greater than the last updated timestamp" - }, - { - "code": 6023, - "name": "InvalidTickArraySequence", - "msg": "Invalid tick array sequence provided for instruction." - }, - { - "code": 6024, - "name": "InvalidTokenMintOrder", - "msg": "Token Mint in wrong order" - }, - { - "code": 6025, - "name": "RewardNotInitialized", - "msg": "Reward not initialized" - }, - { - "code": 6026, - "name": "InvalidRewardIndex", - "msg": "Invalid reward index" - }, - { - "code": 6027, - "name": "RewardVaultAmountInsufficient", - "msg": "Reward vault requires amount to support emissions for at least one day" - }, - { - "code": 6028, - "name": "FeeRateMaxExceeded", - "msg": "Exceeded max fee rate" - }, - { - "code": 6029, - "name": "ProtocolFeeRateMaxExceeded", - "msg": "Exceeded max protocol fee rate" - }, - { - "code": 6030, - "name": "MultiplicationShiftRightOverflow", - "msg": "Multiplication with shift right overflow" - }, - { - "code": 6031, - "name": "MulDivOverflow", - "msg": "Muldiv overflow" - }, - { - "code": 6032, - "name": "MulDivInvalidInput", - "msg": "Invalid div_u256 input" - }, - { - "code": 6033, - "name": "MultiplicationOverflow", - "msg": "Multiplication overflow" - }, - { - "code": 6034, - "name": "InvalidSqrtPriceLimitDirection", - "msg": "Provided SqrtPriceLimit not in the same direction as the swap." - }, - { - "code": 6035, - "name": "ZeroTradableAmount", - "msg": "There are no tradable amount to swap." - }, - { - "code": 6036, - "name": "AmountOutBelowMinimum", - "msg": "Amount out below minimum threshold" - }, - { - "code": 6037, - "name": "AmountInAboveMaximum", - "msg": "Amount in above maximum threshold" - }, - { - "code": 6038, - "name": "TickArraySequenceInvalidIndex", - "msg": "Invalid index for tick array sequence" - }, - { - "code": 6039, - "name": "AmountCalcOverflow", - "msg": "Amount calculated overflows" - }, - { - "code": 6040, - "name": "AmountRemainingOverflow", - "msg": "Amount remaining overflows" - }, - { - "code": 6041, - "name": "InvalidIntermediaryMint", - "msg": "Invalid intermediary mint" - }, - { - "code": 6042, - "name": "DuplicateTwoHopPool", - "msg": "Duplicate two hop pool" - }, - { - "code": 6043, - "name": "InvalidBundleIndex", - "msg": "Bundle index is out of bounds" - }, - { - "code": 6044, - "name": "BundledPositionAlreadyOpened", - "msg": "Position has already been opened" - }, - { - "code": 6045, - "name": "BundledPositionAlreadyClosed", - "msg": "Position has already been closed" - }, - { - "code": 6046, - "name": "PositionBundleNotDeletable", - "msg": "Unable to delete PositionBundle with open positions" - }, - { - "code": 6047, - "name": "UnsupportedTokenMint", - "msg": "Token mint has unsupported attributes" - }, - { - "code": 6048, - "name": "RemainingAccountsInvalidSlice", - "msg": "Invalid remaining accounts" - }, - { - "code": 6049, - "name": "RemainingAccountsInsufficient", - "msg": "Insufficient remaining accounts" - }, - { - "code": 6050, - "name": "NoExtraAccountsForTransferHook", - "msg": "Unable to call transfer hook without extra accounts" - }, - { - "code": 6051, - "name": "IntermediateTokenAmountMismatch", - "msg": "Output and input amount mismatch" - }, - { - "code": 6052, - "name": "TransferFeeCalculationError", - "msg": "Transfer fee calculation failed" - }, - { - "code": 6053, - "name": "RemainingAccountsDuplicatedAccountsType", - "msg": "Same accounts type is provided more than once" - }, - { - "code": 6054, - "name": "FullRangeOnlyPool", - "msg": "This whirlpool only supports full-range positions" - }, - { - "code": 6055, - "name": "TooManySupplementalTickArrays", - "msg": "Too many supplemental tick arrays provided" - }, - { - "code": 6056, - "name": "DifferentWhirlpoolTickArrayAccount", - "msg": "TickArray account for different whirlpool provided" - }, - { - "code": 6057, - "name": "PartialFillError", - "msg": "Trade resulted in partial fill" - }, - { - "code": 6058, - "name": "PositionNotLockable", - "msg": "Position is not lockable" - }, - { - "code": 6059, - "name": "OperationNotAllowedOnLockedPosition", - "msg": "Operation not allowed on locked position" - }, - { - "code": 6060, - "name": "SameTickRangeNotAllowed", - "msg": "Cannot reset position range with same tick range" - }, - { - "code": 6061, - "name": "InvalidAdaptiveFeeConstants", - "msg": "Invalid adaptive fee constants" - }, - { - "code": 6062, - "name": "InvalidFeeTierIndex", - "msg": "Invalid fee tier index" - }, - { - "code": 6063, - "name": "InvalidTradeEnableTimestamp", - "msg": "Invalid trade enable timestamp" - }, - { - "code": 6064, - "name": "TradeIsNotEnabled", - "msg": "Trade is not enabled yet" - }, - { - "code": 6065, - "name": "RentCalculationError", - "msg": "Rent calculation error" - } - ] -} diff --git a/crates/orca-whirlpool-parser/proto/orca_whirlpool.proto b/crates/orca-whirlpool-parser/proto/orca_whirlpool.proto deleted file mode 100644 index 000bfa5d..00000000 --- a/crates/orca-whirlpool-parser/proto/orca_whirlpool.proto +++ /dev/null @@ -1,1457 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.orca_whirlpool; - -message DynamicTickUninitialized { } - -message DynamicTickInitialized { - DynamicTickData field_0 = 1; -} - -message InitializeConfigIx { - InitializeConfigIxAccounts accounts = 1; - InitializeConfigIxData data = 2; -} - -message InitializePoolIx { - InitializePoolIxAccounts accounts = 1; - InitializePoolIxData data = 2; -} - -message InitializeTickArrayIx { - InitializeTickArrayIxAccounts accounts = 1; - InitializeTickArrayIxData data = 2; -} - -message InitializeDynamicTickArrayIx { - InitializeDynamicTickArrayIxAccounts accounts = 1; - InitializeDynamicTickArrayIxData data = 2; -} - -message InitializeFeeTierIx { - InitializeFeeTierIxAccounts accounts = 1; - InitializeFeeTierIxData data = 2; -} - -message InitializeRewardIx { - InitializeRewardIxAccounts accounts = 1; - InitializeRewardIxData data = 2; -} - -message SetRewardEmissionsIx { - SetRewardEmissionsIxAccounts accounts = 1; - SetRewardEmissionsIxData data = 2; -} - -message OpenPositionIx { - OpenPositionIxAccounts accounts = 1; - OpenPositionIxData data = 2; -} - -message OpenPositionWithMetadataIx { - OpenPositionWithMetadataIxAccounts accounts = 1; - OpenPositionWithMetadataIxData data = 2; -} - -message IncreaseLiquidityIx { - IncreaseLiquidityIxAccounts accounts = 1; - IncreaseLiquidityIxData data = 2; -} - -message DecreaseLiquidityIx { - DecreaseLiquidityIxAccounts accounts = 1; - DecreaseLiquidityIxData data = 2; -} - -message UpdateFeesAndRewardsIx { - UpdateFeesAndRewardsIxAccounts accounts = 1; -} - -message CollectFeesIx { - CollectFeesIxAccounts accounts = 1; -} - -message CollectRewardIx { - CollectRewardIxAccounts accounts = 1; - CollectRewardIxData data = 2; -} - -message CollectProtocolFeesIx { - CollectProtocolFeesIxAccounts accounts = 1; -} - -message SwapIx { - SwapIxAccounts accounts = 1; - SwapIxData data = 2; -} - -message ClosePositionIx { - ClosePositionIxAccounts accounts = 1; -} - -message SetDefaultFeeRateIx { - SetDefaultFeeRateIxAccounts accounts = 1; - SetDefaultFeeRateIxData data = 2; -} - -message SetDefaultProtocolFeeRateIx { - SetDefaultProtocolFeeRateIxAccounts accounts = 1; - SetDefaultProtocolFeeRateIxData data = 2; -} - -message SetFeeRateIx { - SetFeeRateIxAccounts accounts = 1; - SetFeeRateIxData data = 2; -} - -message SetProtocolFeeRateIx { - SetProtocolFeeRateIxAccounts accounts = 1; - SetProtocolFeeRateIxData data = 2; -} - -message SetFeeAuthorityIx { - SetFeeAuthorityIxAccounts accounts = 1; -} - -message SetCollectProtocolFeesAuthorityIx { - SetCollectProtocolFeesAuthorityIxAccounts accounts = 1; -} - -message SetRewardAuthorityIx { - SetRewardAuthorityIxAccounts accounts = 1; - SetRewardAuthorityIxData data = 2; -} - -message SetRewardAuthorityBySuperAuthorityIx { - SetRewardAuthorityBySuperAuthorityIxAccounts accounts = 1; - SetRewardAuthorityBySuperAuthorityIxData data = 2; -} - -message SetRewardEmissionsSuperAuthorityIx { - SetRewardEmissionsSuperAuthorityIxAccounts accounts = 1; -} - -message TwoHopSwapIx { - TwoHopSwapIxAccounts accounts = 1; - TwoHopSwapIxData data = 2; -} - -message InitializePositionBundleIx { - InitializePositionBundleIxAccounts accounts = 1; -} - -message InitializePositionBundleWithMetadataIx { - InitializePositionBundleWithMetadataIxAccounts accounts = 1; -} - -message DeletePositionBundleIx { - DeletePositionBundleIxAccounts accounts = 1; -} - -message OpenBundledPositionIx { - OpenBundledPositionIxAccounts accounts = 1; - OpenBundledPositionIxData data = 2; -} - -message CloseBundledPositionIx { - CloseBundledPositionIxAccounts accounts = 1; - CloseBundledPositionIxData data = 2; -} - -message OpenPositionWithTokenExtensionsIx { - OpenPositionWithTokenExtensionsIxAccounts accounts = 1; - OpenPositionWithTokenExtensionsIxData data = 2; -} - -message ClosePositionWithTokenExtensionsIx { - ClosePositionWithTokenExtensionsIxAccounts accounts = 1; -} - -message LockPositionIx { - LockPositionIxAccounts accounts = 1; - LockPositionIxData data = 2; -} - -message ResetPositionRangeIx { - ResetPositionRangeIxAccounts accounts = 1; - ResetPositionRangeIxData data = 2; -} - -message TransferLockedPositionIx { - TransferLockedPositionIxAccounts accounts = 1; -} - -message InitializeAdaptiveFeeTierIx { - InitializeAdaptiveFeeTierIxAccounts accounts = 1; - InitializeAdaptiveFeeTierIxData data = 2; -} - -message SetDefaultBaseFeeRateIx { - SetDefaultBaseFeeRateIxAccounts accounts = 1; - SetDefaultBaseFeeRateIxData data = 2; -} - -message SetDelegatedFeeAuthorityIx { - SetDelegatedFeeAuthorityIxAccounts accounts = 1; -} - -message SetInitializePoolAuthorityIx { - SetInitializePoolAuthorityIxAccounts accounts = 1; -} - -message SetPresetAdaptiveFeeConstantsIx { - SetPresetAdaptiveFeeConstantsIxAccounts accounts = 1; - SetPresetAdaptiveFeeConstantsIxData data = 2; -} - -message InitializePoolWithAdaptiveFeeIx { - InitializePoolWithAdaptiveFeeIxAccounts accounts = 1; - InitializePoolWithAdaptiveFeeIxData data = 2; -} - -message SetFeeRateByDelegatedFeeAuthorityIx { - SetFeeRateByDelegatedFeeAuthorityIxAccounts accounts = 1; - SetFeeRateByDelegatedFeeAuthorityIxData data = 2; -} - -message CollectFeesV2Ix { - CollectFeesV2IxAccounts accounts = 1; - CollectFeesV2IxData data = 2; -} - -message CollectProtocolFeesV2Ix { - CollectProtocolFeesV2IxAccounts accounts = 1; - CollectProtocolFeesV2IxData data = 2; -} - -message CollectRewardV2Ix { - CollectRewardV2IxAccounts accounts = 1; - CollectRewardV2IxData data = 2; -} - -message DecreaseLiquidityV2Ix { - DecreaseLiquidityV2IxAccounts accounts = 1; - DecreaseLiquidityV2IxData data = 2; -} - -message IncreaseLiquidityV2Ix { - IncreaseLiquidityV2IxAccounts accounts = 1; - IncreaseLiquidityV2IxData data = 2; -} - -message InitializePoolV2Ix { - InitializePoolV2IxAccounts accounts = 1; - InitializePoolV2IxData data = 2; -} - -message InitializeRewardV2Ix { - InitializeRewardV2IxAccounts accounts = 1; - InitializeRewardV2IxData data = 2; -} - -message SetRewardEmissionsV2Ix { - SetRewardEmissionsV2IxAccounts accounts = 1; - SetRewardEmissionsV2IxData data = 2; -} - -message SwapV2Ix { - SwapV2IxAccounts accounts = 1; - SwapV2IxData data = 2; -} - -message TwoHopSwapV2Ix { - TwoHopSwapV2IxAccounts accounts = 1; - TwoHopSwapV2IxData data = 2; -} - -message InitializeConfigExtensionIx { - InitializeConfigExtensionIxAccounts accounts = 1; -} - -message SetConfigExtensionAuthorityIx { - SetConfigExtensionAuthorityIxAccounts accounts = 1; -} - -message SetTokenBadgeAuthorityIx { - SetTokenBadgeAuthorityIxAccounts accounts = 1; -} - -message InitializeTokenBadgeIx { - InitializeTokenBadgeIxAccounts accounts = 1; -} - -message DeleteTokenBadgeIx { - DeleteTokenBadgeIxAccounts accounts = 1; -} - -message IdlIncludeIx { - IdlIncludeIxAccounts accounts = 1; -} - - -message DynamicTick { - oneof variant{ - DynamicTickUninitialized uninitialized = 1; - DynamicTickInitialized initialized = 2; - } -} - -message DynamicTickData { - string liquidity_net = 1; - string liquidity_gross = 2; - string fee_growth_outside_a = 3; - string fee_growth_outside_b = 4; - repeated string reward_growths_outside = 5; -} - -enum LockType { - LockTypePermanent = 0; -} - -enum LockTypeLabel { - LockTypeLabelPermanent = 0; -} - -message AdaptiveFeeConstants { - uint32 filter_period = 1; - uint32 decay_period = 2; - uint32 reduction_factor = 3; - uint32 adaptive_fee_control_factor = 4; - uint32 max_volatility_accumulator = 5; - uint32 tick_group_size = 6; - uint32 major_swap_threshold_ticks = 7; - repeated uint32 reserved = 8; -} - -message AdaptiveFeeVariables { - uint64 last_reference_update_timestamp = 1; - uint64 last_major_swap_timestamp = 2; - uint32 volatility_reference = 3; - int32 tick_group_index_reference = 4; - uint32 volatility_accumulator = 5; - repeated uint32 reserved = 6; -} - -message PositionRewardInfo { - string growth_inside_checkpoint = 1; - uint64 amount_owed = 2; -} - -message Tick { - bool initialized = 1; - string liquidity_net = 2; - string liquidity_gross = 3; - string fee_growth_outside_a = 4; - string fee_growth_outside_b = 5; - repeated string reward_growths_outside = 6; -} - -message WhirlpoolRewardInfo { - string mint = 1; - string vault = 2; - string authority = 3; - string emissions_per_second_x64 = 4; - string growth_global_x64 = 5; -} - -enum AccountsType { - AccountsTypeTransferHookA = 0; - AccountsTypeTransferHookB = 1; - AccountsTypeTransferHookReward = 2; - AccountsTypeTransferHookInput = 3; - AccountsTypeTransferHookIntermediate = 4; - AccountsTypeTransferHookOutput = 5; - AccountsTypeSupplementalTickArrays = 6; - AccountsTypeSupplementalTickArraysOne = 7; - AccountsTypeSupplementalTickArraysTwo = 8; -} - -message RemainingAccountsInfo { - repeated RemainingAccountsSlice slices = 1; -} - -message RemainingAccountsSlice { - AccountsType accounts_type = 1; - uint32 length = 2; -} - - -message AdaptiveFeeTier { - string whirlpools_config = 1; - uint32 fee_tier_index = 2; - uint32 tick_spacing = 3; - string initialize_pool_authority = 4; - string delegated_fee_authority = 5; - uint32 default_base_fee_rate = 6; - uint32 filter_period = 7; - uint32 decay_period = 8; - uint32 reduction_factor = 9; - uint32 adaptive_fee_control_factor = 10; - uint32 max_volatility_accumulator = 11; - uint32 tick_group_size = 12; - uint32 major_swap_threshold_ticks = 13; -} - -message WhirlpoolsConfig { - string fee_authority = 1; - string collect_protocol_fees_authority = 2; - string reward_emissions_super_authority = 3; - uint32 default_protocol_fee_rate = 4; -} - -message WhirlpoolsConfigExtension { - string whirlpools_config = 1; - string config_extension_authority = 2; - string token_badge_authority = 3; -} - -message DynamicTickArray { - int32 start_tick_index = 1; - string whirlpool = 2; - string tick_bitmap = 3; - repeated DynamicTick ticks = 4; -} - -message FeeTier { - string whirlpools_config = 1; - uint32 tick_spacing = 2; - uint32 default_fee_rate = 3; -} - -message TickArray { - int32 start_tick_index = 1; - repeated Tick ticks = 2; - string whirlpool = 3; -} - -message LockConfig { - string position = 1; - string position_owner = 2; - string whirlpool = 3; - uint64 locked_timestamp = 4; - LockTypeLabel lock_type = 5; -} - -message Oracle { - string whirlpool = 1; - uint64 trade_enable_timestamp = 2; - AdaptiveFeeConstants adaptive_fee_constants = 3; - AdaptiveFeeVariables adaptive_fee_variables = 4; - repeated uint32 reserved = 5; -} - -message Position { - string whirlpool = 1; - string position_mint = 2; - string liquidity = 3; - int32 tick_lower_index = 4; - int32 tick_upper_index = 5; - string fee_growth_checkpoint_a = 6; - uint64 fee_owed_a = 7; - string fee_growth_checkpoint_b = 8; - uint64 fee_owed_b = 9; - repeated PositionRewardInfo reward_infos = 10; -} - -message PositionBundle { - string position_bundle_mint = 1; - repeated uint32 position_bitmap = 2; -} - -message TokenBadge { - string whirlpools_config = 1; - string token_mint = 2; -} - -message Whirlpool { - string whirlpools_config = 1; - repeated uint32 whirlpool_bump = 2; - uint32 tick_spacing = 3; - repeated uint32 fee_tier_index_seed = 4; - uint32 fee_rate = 5; - uint32 protocol_fee_rate = 6; - string liquidity = 7; - string sqrt_price = 8; - int32 tick_current_index = 9; - uint64 protocol_fee_owed_a = 10; - uint64 protocol_fee_owed_b = 11; - string token_mint_a = 12; - string token_vault_a = 13; - string fee_growth_global_a = 14; - string token_mint_b = 15; - string token_vault_b = 16; - string fee_growth_global_b = 17; - uint64 reward_last_updated_timestamp = 18; - repeated WhirlpoolRewardInfo reward_infos = 19; -} - - -message InitializeConfigIxAccounts { - string config = 1; - string funder = 2; - string system_program = 3; -} - -message InitializeConfigIxData { - string fee_authority = 1; - string collect_protocol_fees_authority = 2; - string reward_emissions_super_authority = 3; - uint32 default_protocol_fee_rate = 4; -} - -message InitializePoolIxAccounts { - string whirlpools_config = 1; - string token_mint_a = 2; - string token_mint_b = 3; - string funder = 4; - string whirlpool = 5; - string token_vault_a = 6; - string token_vault_b = 7; - string fee_tier = 8; - string token_program = 9; - string system_program = 10; - string rent = 11; -} - -message InitializePoolIxData { - uint32 whirlpool_bump = 1; - uint32 tick_spacing = 2; - string initial_sqrt_price = 3; -} - -message InitializeTickArrayIxAccounts { - string whirlpool = 1; - string funder = 2; - string tick_array = 3; - string system_program = 4; -} - -message InitializeTickArrayIxData { - int32 start_tick_index = 1; -} - -message InitializeDynamicTickArrayIxAccounts { - string whirlpool = 1; - string funder = 2; - string tick_array = 3; - string system_program = 4; -} - -message InitializeDynamicTickArrayIxData { - int32 start_tick_index = 1; - bool idempotent = 2; -} - -message InitializeFeeTierIxAccounts { - string config = 1; - string fee_tier = 2; - string funder = 3; - string fee_authority = 4; - string system_program = 5; -} - -message InitializeFeeTierIxData { - uint32 tick_spacing = 1; - uint32 default_fee_rate = 2; -} - -message InitializeRewardIxAccounts { - string reward_authority = 1; - string funder = 2; - string whirlpool = 3; - string reward_mint = 4; - string reward_vault = 5; - string token_program = 6; - string system_program = 7; - string rent = 8; -} - -message InitializeRewardIxData { - uint32 reward_index = 1; -} - -message SetRewardEmissionsIxAccounts { - string whirlpool = 1; - string reward_authority = 2; - string reward_vault = 3; -} - -message SetRewardEmissionsIxData { - uint32 reward_index = 1; - string emissions_per_second_x64 = 2; -} - -message OpenPositionIxAccounts { - string funder = 1; - string owner = 2; - string position = 3; - string position_mint = 4; - string position_token_account = 5; - string whirlpool = 6; - string token_program = 7; - string system_program = 8; - string rent = 9; - string associated_token_program = 10; -} - -message OpenPositionIxData { - uint32 position_bump = 1; - int32 tick_lower_index = 2; - int32 tick_upper_index = 3; -} - -message OpenPositionWithMetadataIxAccounts { - string funder = 1; - string owner = 2; - string position = 3; - string position_mint = 4; - string position_metadata_account = 5; - string position_token_account = 6; - string whirlpool = 7; - string token_program = 8; - string system_program = 9; - string rent = 10; - string associated_token_program = 11; - string metadata_program = 12; - string metadata_update_auth = 13; -} - -message OpenPositionWithMetadataIxData { - uint32 position_bump = 1; - uint32 metadata_bump = 2; - int32 tick_lower_index = 3; - int32 tick_upper_index = 4; -} - -message IncreaseLiquidityIxAccounts { - string whirlpool = 1; - string token_program = 2; - string position_authority = 3; - string position = 4; - string position_token_account = 5; - string token_owner_account_a = 6; - string token_owner_account_b = 7; - string token_vault_a = 8; - string token_vault_b = 9; - string tick_array_lower = 10; - string tick_array_upper = 11; -} - -message IncreaseLiquidityIxData { - string liquidity_amount = 1; - uint64 token_max_a = 2; - uint64 token_max_b = 3; -} - -message DecreaseLiquidityIxAccounts { - string whirlpool = 1; - string token_program = 2; - string position_authority = 3; - string position = 4; - string position_token_account = 5; - string token_owner_account_a = 6; - string token_owner_account_b = 7; - string token_vault_a = 8; - string token_vault_b = 9; - string tick_array_lower = 10; - string tick_array_upper = 11; -} - -message DecreaseLiquidityIxData { - string liquidity_amount = 1; - uint64 token_min_a = 2; - uint64 token_min_b = 3; -} - -message UpdateFeesAndRewardsIxAccounts { - string whirlpool = 1; - string position = 2; - string tick_array_lower = 3; - string tick_array_upper = 4; -} - - -message CollectFeesIxAccounts { - string whirlpool = 1; - string position_authority = 2; - string position = 3; - string position_token_account = 4; - string token_owner_account_a = 5; - string token_vault_a = 6; - string token_owner_account_b = 7; - string token_vault_b = 8; - string token_program = 9; -} - - -message CollectRewardIxAccounts { - string whirlpool = 1; - string position_authority = 2; - string position = 3; - string position_token_account = 4; - string reward_owner_account = 5; - string reward_vault = 6; - string token_program = 7; -} - -message CollectRewardIxData { - uint32 reward_index = 1; -} - -message CollectProtocolFeesIxAccounts { - string whirlpools_config = 1; - string whirlpool = 2; - string collect_protocol_fees_authority = 3; - string token_vault_a = 4; - string token_vault_b = 5; - string token_destination_a = 6; - string token_destination_b = 7; - string token_program = 8; -} - - -message SwapIxAccounts { - string token_program = 1; - string token_authority = 2; - string whirlpool = 3; - string token_owner_account_a = 4; - string token_vault_a = 5; - string token_owner_account_b = 6; - string token_vault_b = 7; - string tick_array0 = 8; - string tick_array1 = 9; - string tick_array2 = 10; - string oracle = 11; -} - -message SwapIxData { - uint64 amount = 1; - uint64 other_amount_threshold = 2; - string sqrt_price_limit = 3; - bool amount_specified_is_input = 4; - bool a_to_b = 5; -} - -message ClosePositionIxAccounts { - string position_authority = 1; - string receiver = 2; - string position = 3; - string position_mint = 4; - string position_token_account = 5; - string token_program = 6; -} - - -message SetDefaultFeeRateIxAccounts { - string whirlpools_config = 1; - string fee_tier = 2; - string fee_authority = 3; -} - -message SetDefaultFeeRateIxData { - uint32 default_fee_rate = 1; -} - -message SetDefaultProtocolFeeRateIxAccounts { - string whirlpools_config = 1; - string fee_authority = 2; -} - -message SetDefaultProtocolFeeRateIxData { - uint32 default_protocol_fee_rate = 1; -} - -message SetFeeRateIxAccounts { - string whirlpools_config = 1; - string whirlpool = 2; - string fee_authority = 3; -} - -message SetFeeRateIxData { - uint32 fee_rate = 1; -} - -message SetProtocolFeeRateIxAccounts { - string whirlpools_config = 1; - string whirlpool = 2; - string fee_authority = 3; -} - -message SetProtocolFeeRateIxData { - uint32 protocol_fee_rate = 1; -} - -message SetFeeAuthorityIxAccounts { - string whirlpools_config = 1; - string fee_authority = 2; - string new_fee_authority = 3; -} - - -message SetCollectProtocolFeesAuthorityIxAccounts { - string whirlpools_config = 1; - string collect_protocol_fees_authority = 2; - string new_collect_protocol_fees_authority = 3; -} - - -message SetRewardAuthorityIxAccounts { - string whirlpool = 1; - string reward_authority = 2; - string new_reward_authority = 3; -} - -message SetRewardAuthorityIxData { - uint32 reward_index = 1; -} - -message SetRewardAuthorityBySuperAuthorityIxAccounts { - string whirlpools_config = 1; - string whirlpool = 2; - string reward_emissions_super_authority = 3; - string new_reward_authority = 4; -} - -message SetRewardAuthorityBySuperAuthorityIxData { - uint32 reward_index = 1; -} - -message SetRewardEmissionsSuperAuthorityIxAccounts { - string whirlpools_config = 1; - string reward_emissions_super_authority = 2; - string new_reward_emissions_super_authority = 3; -} - - -message TwoHopSwapIxAccounts { - string token_program = 1; - string token_authority = 2; - string whirlpool_one = 3; - string whirlpool_two = 4; - string token_owner_account_one_a = 5; - string token_vault_one_a = 6; - string token_owner_account_one_b = 7; - string token_vault_one_b = 8; - string token_owner_account_two_a = 9; - string token_vault_two_a = 10; - string token_owner_account_two_b = 11; - string token_vault_two_b = 12; - string tick_array_one0 = 13; - string tick_array_one1 = 14; - string tick_array_one2 = 15; - string tick_array_two0 = 16; - string tick_array_two1 = 17; - string tick_array_two2 = 18; - string oracle_one = 19; - string oracle_two = 20; -} - -message TwoHopSwapIxData { - uint64 amount = 1; - uint64 other_amount_threshold = 2; - bool amount_specified_is_input = 3; - bool a_to_b_one = 4; - bool a_to_b_two = 5; - string sqrt_price_limit_one = 6; - string sqrt_price_limit_two = 7; -} - -message InitializePositionBundleIxAccounts { - string position_bundle = 1; - string position_bundle_mint = 2; - string position_bundle_token_account = 3; - string position_bundle_owner = 4; - string funder = 5; - string token_program = 6; - string system_program = 7; - string rent = 8; - string associated_token_program = 9; -} - - -message InitializePositionBundleWithMetadataIxAccounts { - string position_bundle = 1; - string position_bundle_mint = 2; - string position_bundle_metadata = 3; - string position_bundle_token_account = 4; - string position_bundle_owner = 5; - string funder = 6; - string metadata_update_auth = 7; - string token_program = 8; - string system_program = 9; - string rent = 10; - string associated_token_program = 11; - string metadata_program = 12; -} - - -message DeletePositionBundleIxAccounts { - string position_bundle = 1; - string position_bundle_mint = 2; - string position_bundle_token_account = 3; - string position_bundle_owner = 4; - string receiver = 5; - string token_program = 6; -} - - -message OpenBundledPositionIxAccounts { - string bundled_position = 1; - string position_bundle = 2; - string position_bundle_token_account = 3; - string position_bundle_authority = 4; - string whirlpool = 5; - string funder = 6; - string system_program = 7; - string rent = 8; -} - -message OpenBundledPositionIxData { - uint32 bundle_index = 1; - int32 tick_lower_index = 2; - int32 tick_upper_index = 3; -} - -message CloseBundledPositionIxAccounts { - string bundled_position = 1; - string position_bundle = 2; - string position_bundle_token_account = 3; - string position_bundle_authority = 4; - string receiver = 5; -} - -message CloseBundledPositionIxData { - uint32 bundle_index = 1; -} - -message OpenPositionWithTokenExtensionsIxAccounts { - string funder = 1; - string owner = 2; - string position = 3; - string position_mint = 4; - string position_token_account = 5; - string whirlpool = 6; - string token2022_program = 7; - string system_program = 8; - string associated_token_program = 9; - string metadata_update_auth = 10; -} - -message OpenPositionWithTokenExtensionsIxData { - int32 tick_lower_index = 1; - int32 tick_upper_index = 2; - bool with_token_metadata_extension = 3; -} - -message ClosePositionWithTokenExtensionsIxAccounts { - string position_authority = 1; - string receiver = 2; - string position = 3; - string position_mint = 4; - string position_token_account = 5; - string token2022_program = 6; -} - - -message LockPositionIxAccounts { - string funder = 1; - string position_authority = 2; - string position = 3; - string position_mint = 4; - string position_token_account = 5; - string lock_config = 6; - string whirlpool = 7; - string token2022_program = 8; - string system_program = 9; -} - -message LockPositionIxData { - LockType lock_type = 1; -} - -message ResetPositionRangeIxAccounts { - string funder = 1; - string position_authority = 2; - string whirlpool = 3; - string position = 4; - string position_token_account = 5; - string system_program = 6; -} - -message ResetPositionRangeIxData { - int32 new_tick_lower_index = 1; - int32 new_tick_upper_index = 2; -} - -message TransferLockedPositionIxAccounts { - string position_authority = 1; - string receiver = 2; - string position = 3; - string position_mint = 4; - string position_token_account = 5; - string destination_token_account = 6; - string lock_config = 7; - string token2022_program = 8; -} - - -message InitializeAdaptiveFeeTierIxAccounts { - string whirlpools_config = 1; - string adaptive_fee_tier = 2; - string funder = 3; - string fee_authority = 4; - string system_program = 5; -} - -message InitializeAdaptiveFeeTierIxData { - uint32 fee_tier_index = 1; - uint32 tick_spacing = 2; - string initialize_pool_authority = 3; - string delegated_fee_authority = 4; - uint32 default_base_fee_rate = 5; - uint32 filter_period = 6; - uint32 decay_period = 7; - uint32 reduction_factor = 8; - uint32 adaptive_fee_control_factor = 9; - uint32 max_volatility_accumulator = 10; - uint32 tick_group_size = 11; - uint32 major_swap_threshold_ticks = 12; -} - -message SetDefaultBaseFeeRateIxAccounts { - string whirlpools_config = 1; - string adaptive_fee_tier = 2; - string fee_authority = 3; -} - -message SetDefaultBaseFeeRateIxData { - uint32 default_base_fee_rate = 1; -} - -message SetDelegatedFeeAuthorityIxAccounts { - string whirlpools_config = 1; - string adaptive_fee_tier = 2; - string fee_authority = 3; - string new_delegated_fee_authority = 4; -} - - -message SetInitializePoolAuthorityIxAccounts { - string whirlpools_config = 1; - string adaptive_fee_tier = 2; - string fee_authority = 3; - string new_initialize_pool_authority = 4; -} - - -message SetPresetAdaptiveFeeConstantsIxAccounts { - string whirlpools_config = 1; - string adaptive_fee_tier = 2; - string fee_authority = 3; -} - -message SetPresetAdaptiveFeeConstantsIxData { - uint32 filter_period = 1; - uint32 decay_period = 2; - uint32 reduction_factor = 3; - uint32 adaptive_fee_control_factor = 4; - uint32 max_volatility_accumulator = 5; - uint32 tick_group_size = 6; - uint32 major_swap_threshold_ticks = 7; -} - -message InitializePoolWithAdaptiveFeeIxAccounts { - string whirlpools_config = 1; - string token_mint_a = 2; - string token_mint_b = 3; - string token_badge_a = 4; - string token_badge_b = 5; - string funder = 6; - string initialize_pool_authority = 7; - string whirlpool = 8; - string oracle = 9; - string token_vault_a = 10; - string token_vault_b = 11; - string adaptive_fee_tier = 12; - string token_program_a = 13; - string token_program_b = 14; - string system_program = 15; - string rent = 16; -} - -message InitializePoolWithAdaptiveFeeIxData { - string initial_sqrt_price = 1; - optional uint64 trade_enable_timestamp = 2; -} - -message SetFeeRateByDelegatedFeeAuthorityIxAccounts { - string whirlpool = 1; - string adaptive_fee_tier = 2; - string delegated_fee_authority = 3; -} - -message SetFeeRateByDelegatedFeeAuthorityIxData { - uint32 fee_rate = 1; -} - -message CollectFeesV2IxAccounts { - string whirlpool = 1; - string position_authority = 2; - string position = 3; - string position_token_account = 4; - string token_mint_a = 5; - string token_mint_b = 6; - string token_owner_account_a = 7; - string token_vault_a = 8; - string token_owner_account_b = 9; - string token_vault_b = 10; - string token_program_a = 11; - string token_program_b = 12; - string memo_program = 13; -} - -message CollectFeesV2IxData { - optional RemainingAccountsInfo remaining_accounts_info = 1; -} - -message CollectProtocolFeesV2IxAccounts { - string whirlpools_config = 1; - string whirlpool = 2; - string collect_protocol_fees_authority = 3; - string token_mint_a = 4; - string token_mint_b = 5; - string token_vault_a = 6; - string token_vault_b = 7; - string token_destination_a = 8; - string token_destination_b = 9; - string token_program_a = 10; - string token_program_b = 11; - string memo_program = 12; -} - -message CollectProtocolFeesV2IxData { - optional RemainingAccountsInfo remaining_accounts_info = 1; -} - -message CollectRewardV2IxAccounts { - string whirlpool = 1; - string position_authority = 2; - string position = 3; - string position_token_account = 4; - string reward_owner_account = 5; - string reward_mint = 6; - string reward_vault = 7; - string reward_token_program = 8; - string memo_program = 9; -} - -message CollectRewardV2IxData { - uint32 reward_index = 1; - optional RemainingAccountsInfo remaining_accounts_info = 2; -} - -message DecreaseLiquidityV2IxAccounts { - string whirlpool = 1; - string token_program_a = 2; - string token_program_b = 3; - string memo_program = 4; - string position_authority = 5; - string position = 6; - string position_token_account = 7; - string token_mint_a = 8; - string token_mint_b = 9; - string token_owner_account_a = 10; - string token_owner_account_b = 11; - string token_vault_a = 12; - string token_vault_b = 13; - string tick_array_lower = 14; - string tick_array_upper = 15; -} - -message DecreaseLiquidityV2IxData { - string liquidity_amount = 1; - uint64 token_min_a = 2; - uint64 token_min_b = 3; - optional RemainingAccountsInfo remaining_accounts_info = 4; -} - -message IncreaseLiquidityV2IxAccounts { - string whirlpool = 1; - string token_program_a = 2; - string token_program_b = 3; - string memo_program = 4; - string position_authority = 5; - string position = 6; - string position_token_account = 7; - string token_mint_a = 8; - string token_mint_b = 9; - string token_owner_account_a = 10; - string token_owner_account_b = 11; - string token_vault_a = 12; - string token_vault_b = 13; - string tick_array_lower = 14; - string tick_array_upper = 15; -} - -message IncreaseLiquidityV2IxData { - string liquidity_amount = 1; - uint64 token_max_a = 2; - uint64 token_max_b = 3; - optional RemainingAccountsInfo remaining_accounts_info = 4; -} - -message InitializePoolV2IxAccounts { - string whirlpools_config = 1; - string token_mint_a = 2; - string token_mint_b = 3; - string token_badge_a = 4; - string token_badge_b = 5; - string funder = 6; - string whirlpool = 7; - string token_vault_a = 8; - string token_vault_b = 9; - string fee_tier = 10; - string token_program_a = 11; - string token_program_b = 12; - string system_program = 13; - string rent = 14; -} - -message InitializePoolV2IxData { - uint32 tick_spacing = 1; - string initial_sqrt_price = 2; -} - -message InitializeRewardV2IxAccounts { - string reward_authority = 1; - string funder = 2; - string whirlpool = 3; - string reward_mint = 4; - string reward_token_badge = 5; - string reward_vault = 6; - string reward_token_program = 7; - string system_program = 8; - string rent = 9; -} - -message InitializeRewardV2IxData { - uint32 reward_index = 1; -} - -message SetRewardEmissionsV2IxAccounts { - string whirlpool = 1; - string reward_authority = 2; - string reward_vault = 3; -} - -message SetRewardEmissionsV2IxData { - uint32 reward_index = 1; - string emissions_per_second_x64 = 2; -} - -message SwapV2IxAccounts { - string token_program_a = 1; - string token_program_b = 2; - string memo_program = 3; - string token_authority = 4; - string whirlpool = 5; - string token_mint_a = 6; - string token_mint_b = 7; - string token_owner_account_a = 8; - string token_vault_a = 9; - string token_owner_account_b = 10; - string token_vault_b = 11; - string tick_array0 = 12; - string tick_array1 = 13; - string tick_array2 = 14; - string oracle = 15; -} - -message SwapV2IxData { - uint64 amount = 1; - uint64 other_amount_threshold = 2; - string sqrt_price_limit = 3; - bool amount_specified_is_input = 4; - bool a_to_b = 5; - optional RemainingAccountsInfo remaining_accounts_info = 6; -} - -message TwoHopSwapV2IxAccounts { - string whirlpool_one = 1; - string whirlpool_two = 2; - string token_mint_input = 3; - string token_mint_intermediate = 4; - string token_mint_output = 5; - string token_program_input = 6; - string token_program_intermediate = 7; - string token_program_output = 8; - string token_owner_account_input = 9; - string token_vault_one_input = 10; - string token_vault_one_intermediate = 11; - string token_vault_two_intermediate = 12; - string token_vault_two_output = 13; - string token_owner_account_output = 14; - string token_authority = 15; - string tick_array_one0 = 16; - string tick_array_one1 = 17; - string tick_array_one2 = 18; - string tick_array_two0 = 19; - string tick_array_two1 = 20; - string tick_array_two2 = 21; - string oracle_one = 22; - string oracle_two = 23; - string memo_program = 24; -} - -message TwoHopSwapV2IxData { - uint64 amount = 1; - uint64 other_amount_threshold = 2; - bool amount_specified_is_input = 3; - bool a_to_b_one = 4; - bool a_to_b_two = 5; - string sqrt_price_limit_one = 6; - string sqrt_price_limit_two = 7; - optional RemainingAccountsInfo remaining_accounts_info = 8; -} - -message InitializeConfigExtensionIxAccounts { - string config = 1; - string config_extension = 2; - string funder = 3; - string fee_authority = 4; - string system_program = 5; -} - - -message SetConfigExtensionAuthorityIxAccounts { - string whirlpools_config = 1; - string whirlpools_config_extension = 2; - string config_extension_authority = 3; - string new_config_extension_authority = 4; -} - - -message SetTokenBadgeAuthorityIxAccounts { - string whirlpools_config = 1; - string whirlpools_config_extension = 2; - string config_extension_authority = 3; - string new_token_badge_authority = 4; -} - - -message InitializeTokenBadgeIxAccounts { - string whirlpools_config = 1; - string whirlpools_config_extension = 2; - string token_badge_authority = 3; - string token_mint = 4; - string token_badge = 5; - string funder = 6; - string system_program = 7; -} - - -message DeleteTokenBadgeIxAccounts { - string whirlpools_config = 1; - string whirlpools_config_extension = 2; - string token_badge_authority = 3; - string token_mint = 4; - string token_badge = 5; - string receiver = 6; -} - - -message IdlIncludeIxAccounts { - string tick_array = 1; - string system_program = 2; -} - - - -message ProgramState { - oneof state_oneof { - AdaptiveFeeTier adaptive_fee_tier = 1; - WhirlpoolsConfig whirlpools_config = 2; - WhirlpoolsConfigExtension whirlpools_config_extension = 3; - DynamicTickArray dynamic_tick_array = 4; - FeeTier fee_tier = 5; - TickArray tick_array = 6; - LockConfig lock_config = 7; - Oracle oracle = 8; - Position position = 9; - PositionBundle position_bundle = 10; - TokenBadge token_badge = 11; - Whirlpool whirlpool = 12; - } -} - -message ProgramIxs { - oneof ix_oneof { - InitializeConfigIx initialize_config = 1; - InitializePoolIx initialize_pool = 2; - InitializeTickArrayIx initialize_tick_array = 3; - InitializeDynamicTickArrayIx initialize_dynamic_tick_array = 4; - InitializeFeeTierIx initialize_fee_tier = 5; - InitializeRewardIx initialize_reward = 6; - SetRewardEmissionsIx set_reward_emissions = 7; - OpenPositionIx open_position = 8; - OpenPositionWithMetadataIx open_position_with_metadata = 9; - IncreaseLiquidityIx increase_liquidity = 10; - DecreaseLiquidityIx decrease_liquidity = 11; - UpdateFeesAndRewardsIx update_fees_and_rewards = 12; - CollectFeesIx collect_fees = 13; - CollectRewardIx collect_reward = 14; - CollectProtocolFeesIx collect_protocol_fees = 15; - SwapIx swap = 16; - ClosePositionIx close_position = 17; - SetDefaultFeeRateIx set_default_fee_rate = 18; - SetDefaultProtocolFeeRateIx set_default_protocol_fee_rate = 19; - SetFeeRateIx set_fee_rate = 20; - SetProtocolFeeRateIx set_protocol_fee_rate = 21; - SetFeeAuthorityIx set_fee_authority = 22; - SetCollectProtocolFeesAuthorityIx set_collect_protocol_fees_authority = 23; - SetRewardAuthorityIx set_reward_authority = 24; - SetRewardAuthorityBySuperAuthorityIx set_reward_authority_by_super_authority = 25; - SetRewardEmissionsSuperAuthorityIx set_reward_emissions_super_authority = 26; - TwoHopSwapIx two_hop_swap = 27; - InitializePositionBundleIx initialize_position_bundle = 28; - InitializePositionBundleWithMetadataIx initialize_position_bundle_with_metadata = 29; - DeletePositionBundleIx delete_position_bundle = 30; - OpenBundledPositionIx open_bundled_position = 31; - CloseBundledPositionIx close_bundled_position = 32; - OpenPositionWithTokenExtensionsIx open_position_with_token_extensions = 33; - ClosePositionWithTokenExtensionsIx close_position_with_token_extensions = 34; - LockPositionIx lock_position = 35; - ResetPositionRangeIx reset_position_range = 36; - TransferLockedPositionIx transfer_locked_position = 37; - InitializeAdaptiveFeeTierIx initialize_adaptive_fee_tier = 38; - SetDefaultBaseFeeRateIx set_default_base_fee_rate = 39; - SetDelegatedFeeAuthorityIx set_delegated_fee_authority = 40; - SetInitializePoolAuthorityIx set_initialize_pool_authority = 41; - SetPresetAdaptiveFeeConstantsIx set_preset_adaptive_fee_constants = 42; - InitializePoolWithAdaptiveFeeIx initialize_pool_with_adaptive_fee = 43; - SetFeeRateByDelegatedFeeAuthorityIx set_fee_rate_by_delegated_fee_authority = 44; - CollectFeesV2Ix collect_fees_v2 = 45; - CollectProtocolFeesV2Ix collect_protocol_fees_v2 = 46; - CollectRewardV2Ix collect_reward_v2 = 47; - DecreaseLiquidityV2Ix decrease_liquidity_v2 = 48; - IncreaseLiquidityV2Ix increase_liquidity_v2 = 49; - InitializePoolV2Ix initialize_pool_v2 = 50; - InitializeRewardV2Ix initialize_reward_v2 = 51; - SetRewardEmissionsV2Ix set_reward_emissions_v2 = 52; - SwapV2Ix swap_v2 = 53; - TwoHopSwapV2Ix two_hop_swap_v2 = 54; - InitializeConfigExtensionIx initialize_config_extension = 55; - SetConfigExtensionAuthorityIx set_config_extension_authority = 56; - SetTokenBadgeAuthorityIx set_token_badge_authority = 57; - InitializeTokenBadgeIx initialize_token_badge = 58; - DeleteTokenBadgeIx delete_token_badge = 59; - IdlIncludeIx idl_include = 60; - } -} - diff --git a/crates/orca-whirlpool-parser/src/custom_impl/mod.rs b/crates/orca-whirlpool-parser/src/custom_impl/mod.rs deleted file mode 100644 index e9f09b9f..00000000 --- a/crates/orca-whirlpool-parser/src/custom_impl/mod.rs +++ /dev/null @@ -1 +0,0 @@ -//! Placeholder for custom impls that are not overriden by the generated code. diff --git a/crates/orca-whirlpool-parser/src/generated_parser/accounts_parser.rs b/crates/orca-whirlpool-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index 9dbde991..00000000 --- a/crates/orca-whirlpool-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,385 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{ - AdaptiveFeeTier, DynamicTickArray, FeeTier, LockConfig, Oracle, Position, PositionBundle, - TickArray, TokenBadge, Whirlpool, WhirlpoolsConfig, WhirlpoolsConfigExtension, - }, - deserialize_checked, ID, -}; - -/// Whirlpool Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum WhirlpoolProgramState { - AdaptiveFeeTier(AdaptiveFeeTier), - WhirlpoolsConfig(WhirlpoolsConfig), - WhirlpoolsConfigExtension(WhirlpoolsConfigExtension), - DynamicTickArray(DynamicTickArray), - FeeTier(FeeTier), - TickArray(TickArray), - LockConfig(LockConfig), - Oracle(Oracle), - Position(Position), - PositionBundle(PositionBundle), - TokenBadge(TokenBadge), - Whirlpool(Whirlpool), -} - -impl WhirlpoolProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [147, 16, 144, 116, 47, 146, 149, 46] => Ok(WhirlpoolProgramState::AdaptiveFeeTier( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [157, 20, 49, 224, 217, 87, 193, 254] => Ok(WhirlpoolProgramState::WhirlpoolsConfig( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [2, 99, 215, 163, 240, 26, 153, 58] => { - Ok(WhirlpoolProgramState::WhirlpoolsConfigExtension( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [17, 216, 246, 142, 225, 199, 218, 56] => Ok(WhirlpoolProgramState::DynamicTickArray( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [56, 75, 159, 76, 142, 68, 190, 105] => Ok(WhirlpoolProgramState::FeeTier( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [69, 97, 189, 190, 110, 7, 66, 187] => Ok(WhirlpoolProgramState::TickArray( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [106, 47, 238, 159, 124, 12, 160, 192] => Ok(WhirlpoolProgramState::LockConfig( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [139, 194, 131, 179, 140, 179, 229, 244] => Ok(WhirlpoolProgramState::Oracle( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [170, 188, 143, 228, 122, 64, 247, 208] => Ok(WhirlpoolProgramState::Position( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [129, 169, 175, 65, 185, 95, 32, 100] => Ok(WhirlpoolProgramState::PositionBundle( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [116, 219, 204, 229, 249, 116, 255, 150] => Ok(WhirlpoolProgramState::TokenBadge( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [63, 149, 209, 12, 225, 128, 99, 9] => Ok(WhirlpoolProgramState::Whirlpool( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = WhirlpoolProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "whirlpool::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = WhirlpoolProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, AdaptiveFeeTier, WhirlpoolProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for AdaptiveFeeTier { - fn into_proto(self) -> proto_def::AdaptiveFeeTier { - proto_def::AdaptiveFeeTier { - whirlpools_config: self.whirlpools_config.to_string(), - fee_tier_index: self.fee_tier_index.into(), - tick_spacing: self.tick_spacing.into(), - initialize_pool_authority: self.initialize_pool_authority.to_string(), - delegated_fee_authority: self.delegated_fee_authority.to_string(), - default_base_fee_rate: self.default_base_fee_rate.into(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - adaptive_fee_control_factor: self.adaptive_fee_control_factor, - max_volatility_accumulator: self.max_volatility_accumulator, - tick_group_size: self.tick_group_size.into(), - major_swap_threshold_ticks: self.major_swap_threshold_ticks.into(), - } - } - } - use super::WhirlpoolsConfig; - impl IntoProto for WhirlpoolsConfig { - fn into_proto(self) -> proto_def::WhirlpoolsConfig { - proto_def::WhirlpoolsConfig { - fee_authority: self.fee_authority.to_string(), - collect_protocol_fees_authority: self.collect_protocol_fees_authority.to_string(), - reward_emissions_super_authority: self.reward_emissions_super_authority.to_string(), - default_protocol_fee_rate: self.default_protocol_fee_rate.into(), - } - } - } - use super::WhirlpoolsConfigExtension; - impl IntoProto for WhirlpoolsConfigExtension { - fn into_proto(self) -> proto_def::WhirlpoolsConfigExtension { - proto_def::WhirlpoolsConfigExtension { - whirlpools_config: self.whirlpools_config.to_string(), - config_extension_authority: self.config_extension_authority.to_string(), - token_badge_authority: self.token_badge_authority.to_string(), - } - } - } - use super::DynamicTickArray; - impl IntoProto for DynamicTickArray { - fn into_proto(self) -> proto_def::DynamicTickArray { - proto_def::DynamicTickArray { - start_tick_index: self.start_tick_index, - whirlpool: self.whirlpool.to_string(), - tick_bitmap: self.tick_bitmap.to_string(), - ticks: self.ticks.into_iter().map(|x| x.into_proto()).collect(), - } - } - } - use super::FeeTier; - impl IntoProto for FeeTier { - fn into_proto(self) -> proto_def::FeeTier { - proto_def::FeeTier { - whirlpools_config: self.whirlpools_config.to_string(), - tick_spacing: self.tick_spacing.into(), - default_fee_rate: self.default_fee_rate.into(), - } - } - } - use super::TickArray; - impl IntoProto for TickArray { - fn into_proto(self) -> proto_def::TickArray { - proto_def::TickArray { - start_tick_index: self.start_tick_index, - ticks: self.ticks.into_iter().map(|x| x.into_proto()).collect(), - whirlpool: self.whirlpool.to_string(), - } - } - } - use super::LockConfig; - impl IntoProto for LockConfig { - fn into_proto(self) -> proto_def::LockConfig { - proto_def::LockConfig { - position: self.position.to_string(), - position_owner: self.position_owner.to_string(), - whirlpool: self.whirlpool.to_string(), - locked_timestamp: self.locked_timestamp, - lock_type: self.lock_type as i32, - } - } - } - use super::Oracle; - impl IntoProto for Oracle { - fn into_proto(self) -> proto_def::Oracle { - proto_def::Oracle { - whirlpool: self.whirlpool.to_string(), - trade_enable_timestamp: self.trade_enable_timestamp, - adaptive_fee_constants: Some(self.adaptive_fee_constants.into_proto()), - adaptive_fee_variables: Some(self.adaptive_fee_variables.into_proto()), - reserved: self.reserved.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::Position; - impl IntoProto for Position { - fn into_proto(self) -> proto_def::Position { - proto_def::Position { - whirlpool: self.whirlpool.to_string(), - position_mint: self.position_mint.to_string(), - liquidity: self.liquidity.to_string(), - tick_lower_index: self.tick_lower_index, - tick_upper_index: self.tick_upper_index, - fee_growth_checkpoint_a: self.fee_growth_checkpoint_a.to_string(), - fee_owed_a: self.fee_owed_a, - fee_growth_checkpoint_b: self.fee_growth_checkpoint_b.to_string(), - fee_owed_b: self.fee_owed_b, - reward_infos: self - .reward_infos - .into_iter() - .map(|x| x.into_proto()) - .collect(), - } - } - } - use super::PositionBundle; - impl IntoProto for PositionBundle { - fn into_proto(self) -> proto_def::PositionBundle { - proto_def::PositionBundle { - position_bundle_mint: self.position_bundle_mint.to_string(), - position_bitmap: self.position_bitmap.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::TokenBadge; - impl IntoProto for TokenBadge { - fn into_proto(self) -> proto_def::TokenBadge { - proto_def::TokenBadge { - whirlpools_config: self.whirlpools_config.to_string(), - token_mint: self.token_mint.to_string(), - } - } - } - use super::Whirlpool; - impl IntoProto for Whirlpool { - fn into_proto(self) -> proto_def::Whirlpool { - proto_def::Whirlpool { - whirlpools_config: self.whirlpools_config.to_string(), - whirlpool_bump: self.whirlpool_bump.into_iter().map(|x| x.into()).collect(), - tick_spacing: self.tick_spacing.into(), - fee_tier_index_seed: self - .fee_tier_index_seed - .into_iter() - .map(|x| x.into()) - .collect(), - fee_rate: self.fee_rate.into(), - protocol_fee_rate: self.protocol_fee_rate.into(), - liquidity: self.liquidity.to_string(), - sqrt_price: self.sqrt_price.to_string(), - tick_current_index: self.tick_current_index, - protocol_fee_owed_a: self.protocol_fee_owed_a, - protocol_fee_owed_b: self.protocol_fee_owed_b, - token_mint_a: self.token_mint_a.to_string(), - token_vault_a: self.token_vault_a.to_string(), - fee_growth_global_a: self.fee_growth_global_a.to_string(), - token_mint_b: self.token_mint_b.to_string(), - token_vault_b: self.token_vault_b.to_string(), - fee_growth_global_b: self.fee_growth_global_b.to_string(), - reward_last_updated_timestamp: self.reward_last_updated_timestamp, - reward_infos: self - .reward_infos - .into_iter() - .map(|x| x.into_proto()) - .collect(), - } - } - } - - impl IntoProto for WhirlpoolProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - WhirlpoolProgramState::AdaptiveFeeTier(data) => { - proto_def::program_state::StateOneof::AdaptiveFeeTier(data.into_proto()) - }, - WhirlpoolProgramState::WhirlpoolsConfig(data) => { - proto_def::program_state::StateOneof::WhirlpoolsConfig(data.into_proto()) - }, - WhirlpoolProgramState::WhirlpoolsConfigExtension(data) => { - proto_def::program_state::StateOneof::WhirlpoolsConfigExtension( - data.into_proto(), - ) - }, - WhirlpoolProgramState::DynamicTickArray(data) => { - proto_def::program_state::StateOneof::DynamicTickArray(data.into_proto()) - }, - WhirlpoolProgramState::FeeTier(data) => { - proto_def::program_state::StateOneof::FeeTier(data.into_proto()) - }, - WhirlpoolProgramState::TickArray(data) => { - proto_def::program_state::StateOneof::TickArray(data.into_proto()) - }, - WhirlpoolProgramState::LockConfig(data) => { - proto_def::program_state::StateOneof::LockConfig(data.into_proto()) - }, - WhirlpoolProgramState::Oracle(data) => { - proto_def::program_state::StateOneof::Oracle(data.into_proto()) - }, - WhirlpoolProgramState::Position(data) => { - proto_def::program_state::StateOneof::Position(data.into_proto()) - }, - WhirlpoolProgramState::PositionBundle(data) => { - proto_def::program_state::StateOneof::PositionBundle(data.into_proto()) - }, - WhirlpoolProgramState::TokenBadge(data) => { - proto_def::program_state::StateOneof::TokenBadge(data.into_proto()) - }, - WhirlpoolProgramState::Whirlpool(data) => { - proto_def::program_state::StateOneof::Whirlpool(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/orca-whirlpool-parser/src/generated_parser/instructions_parser.rs b/crates/orca-whirlpool-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index bef50249..00000000 --- a/crates/orca-whirlpool-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,3236 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - CloseBundledPosition as CloseBundledPositionIxAccounts, - CloseBundledPositionInstructionArgs as CloseBundledPositionIxData, - ClosePosition as ClosePositionIxAccounts, - ClosePositionWithTokenExtensions as ClosePositionWithTokenExtensionsIxAccounts, - CollectFees as CollectFeesIxAccounts, CollectFeesV2 as CollectFeesV2IxAccounts, - CollectFeesV2InstructionArgs as CollectFeesV2IxData, - CollectProtocolFees as CollectProtocolFeesIxAccounts, - CollectProtocolFeesV2 as CollectProtocolFeesV2IxAccounts, - CollectProtocolFeesV2InstructionArgs as CollectProtocolFeesV2IxData, - CollectReward as CollectRewardIxAccounts, - CollectRewardInstructionArgs as CollectRewardIxData, - CollectRewardV2 as CollectRewardV2IxAccounts, - CollectRewardV2InstructionArgs as CollectRewardV2IxData, - DecreaseLiquidity as DecreaseLiquidityIxAccounts, - DecreaseLiquidityInstructionArgs as DecreaseLiquidityIxData, - DecreaseLiquidityV2 as DecreaseLiquidityV2IxAccounts, - DecreaseLiquidityV2InstructionArgs as DecreaseLiquidityV2IxData, - DeletePositionBundle as DeletePositionBundleIxAccounts, - DeleteTokenBadge as DeleteTokenBadgeIxAccounts, IdlInclude as IdlIncludeIxAccounts, - IncreaseLiquidity as IncreaseLiquidityIxAccounts, - IncreaseLiquidityInstructionArgs as IncreaseLiquidityIxData, - IncreaseLiquidityV2 as IncreaseLiquidityV2IxAccounts, - IncreaseLiquidityV2InstructionArgs as IncreaseLiquidityV2IxData, - InitializeAdaptiveFeeTier as InitializeAdaptiveFeeTierIxAccounts, - InitializeAdaptiveFeeTierInstructionArgs as InitializeAdaptiveFeeTierIxData, - InitializeConfig as InitializeConfigIxAccounts, - InitializeConfigExtension as InitializeConfigExtensionIxAccounts, - InitializeConfigInstructionArgs as InitializeConfigIxData, - InitializeDynamicTickArray as InitializeDynamicTickArrayIxAccounts, - InitializeDynamicTickArrayInstructionArgs as InitializeDynamicTickArrayIxData, - InitializeFeeTier as InitializeFeeTierIxAccounts, - InitializeFeeTierInstructionArgs as InitializeFeeTierIxData, - InitializePool as InitializePoolIxAccounts, - InitializePoolInstructionArgs as InitializePoolIxData, - InitializePoolV2 as InitializePoolV2IxAccounts, - InitializePoolV2InstructionArgs as InitializePoolV2IxData, - InitializePoolWithAdaptiveFee as InitializePoolWithAdaptiveFeeIxAccounts, - InitializePoolWithAdaptiveFeeInstructionArgs as InitializePoolWithAdaptiveFeeIxData, - InitializePositionBundle as InitializePositionBundleIxAccounts, - InitializePositionBundleWithMetadata as InitializePositionBundleWithMetadataIxAccounts, - InitializeReward as InitializeRewardIxAccounts, - InitializeRewardInstructionArgs as InitializeRewardIxData, - InitializeRewardV2 as InitializeRewardV2IxAccounts, - InitializeRewardV2InstructionArgs as InitializeRewardV2IxData, - InitializeTickArray as InitializeTickArrayIxAccounts, - InitializeTickArrayInstructionArgs as InitializeTickArrayIxData, - InitializeTokenBadge as InitializeTokenBadgeIxAccounts, - LockPosition as LockPositionIxAccounts, LockPositionInstructionArgs as LockPositionIxData, - OpenBundledPosition as OpenBundledPositionIxAccounts, - OpenBundledPositionInstructionArgs as OpenBundledPositionIxData, - OpenPosition as OpenPositionIxAccounts, OpenPositionInstructionArgs as OpenPositionIxData, - OpenPositionWithMetadata as OpenPositionWithMetadataIxAccounts, - OpenPositionWithMetadataInstructionArgs as OpenPositionWithMetadataIxData, - OpenPositionWithTokenExtensions as OpenPositionWithTokenExtensionsIxAccounts, - OpenPositionWithTokenExtensionsInstructionArgs as OpenPositionWithTokenExtensionsIxData, - ResetPositionRange as ResetPositionRangeIxAccounts, - ResetPositionRangeInstructionArgs as ResetPositionRangeIxData, - SetCollectProtocolFeesAuthority as SetCollectProtocolFeesAuthorityIxAccounts, - SetConfigExtensionAuthority as SetConfigExtensionAuthorityIxAccounts, - SetDefaultBaseFeeRate as SetDefaultBaseFeeRateIxAccounts, - SetDefaultBaseFeeRateInstructionArgs as SetDefaultBaseFeeRateIxData, - SetDefaultFeeRate as SetDefaultFeeRateIxAccounts, - SetDefaultFeeRateInstructionArgs as SetDefaultFeeRateIxData, - SetDefaultProtocolFeeRate as SetDefaultProtocolFeeRateIxAccounts, - SetDefaultProtocolFeeRateInstructionArgs as SetDefaultProtocolFeeRateIxData, - SetDelegatedFeeAuthority as SetDelegatedFeeAuthorityIxAccounts, - SetFeeAuthority as SetFeeAuthorityIxAccounts, SetFeeRate as SetFeeRateIxAccounts, - SetFeeRateByDelegatedFeeAuthority as SetFeeRateByDelegatedFeeAuthorityIxAccounts, - SetFeeRateByDelegatedFeeAuthorityInstructionArgs as SetFeeRateByDelegatedFeeAuthorityIxData, - SetFeeRateInstructionArgs as SetFeeRateIxData, - SetInitializePoolAuthority as SetInitializePoolAuthorityIxAccounts, - SetPresetAdaptiveFeeConstants as SetPresetAdaptiveFeeConstantsIxAccounts, - SetPresetAdaptiveFeeConstantsInstructionArgs as SetPresetAdaptiveFeeConstantsIxData, - SetProtocolFeeRate as SetProtocolFeeRateIxAccounts, - SetProtocolFeeRateInstructionArgs as SetProtocolFeeRateIxData, - SetRewardAuthority as SetRewardAuthorityIxAccounts, - SetRewardAuthorityBySuperAuthority as SetRewardAuthorityBySuperAuthorityIxAccounts, - SetRewardAuthorityBySuperAuthorityInstructionArgs as SetRewardAuthorityBySuperAuthorityIxData, - SetRewardAuthorityInstructionArgs as SetRewardAuthorityIxData, - SetRewardEmissions as SetRewardEmissionsIxAccounts, - SetRewardEmissionsInstructionArgs as SetRewardEmissionsIxData, - SetRewardEmissionsSuperAuthority as SetRewardEmissionsSuperAuthorityIxAccounts, - SetRewardEmissionsV2 as SetRewardEmissionsV2IxAccounts, - SetRewardEmissionsV2InstructionArgs as SetRewardEmissionsV2IxData, - SetTokenBadgeAuthority as SetTokenBadgeAuthorityIxAccounts, Swap as SwapIxAccounts, - SwapInstructionArgs as SwapIxData, SwapV2 as SwapV2IxAccounts, - SwapV2InstructionArgs as SwapV2IxData, - TransferLockedPosition as TransferLockedPositionIxAccounts, - TwoHopSwap as TwoHopSwapIxAccounts, TwoHopSwapInstructionArgs as TwoHopSwapIxData, - TwoHopSwapV2 as TwoHopSwapV2IxAccounts, TwoHopSwapV2InstructionArgs as TwoHopSwapV2IxData, - UpdateFeesAndRewards as UpdateFeesAndRewardsIxAccounts, - }, - ID, -}; - -/// Whirlpool Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum WhirlpoolProgramIx { - InitializeConfig(InitializeConfigIxAccounts, InitializeConfigIxData), - InitializePool(InitializePoolIxAccounts, InitializePoolIxData), - InitializeTickArray(InitializeTickArrayIxAccounts, InitializeTickArrayIxData), - InitializeDynamicTickArray( - InitializeDynamicTickArrayIxAccounts, - InitializeDynamicTickArrayIxData, - ), - InitializeFeeTier(InitializeFeeTierIxAccounts, InitializeFeeTierIxData), - InitializeReward(InitializeRewardIxAccounts, InitializeRewardIxData), - SetRewardEmissions(SetRewardEmissionsIxAccounts, SetRewardEmissionsIxData), - OpenPosition(OpenPositionIxAccounts, OpenPositionIxData), - OpenPositionWithMetadata( - OpenPositionWithMetadataIxAccounts, - OpenPositionWithMetadataIxData, - ), - IncreaseLiquidity(IncreaseLiquidityIxAccounts, IncreaseLiquidityIxData), - DecreaseLiquidity(DecreaseLiquidityIxAccounts, DecreaseLiquidityIxData), - UpdateFeesAndRewards(UpdateFeesAndRewardsIxAccounts), - CollectFees(CollectFeesIxAccounts), - CollectReward(CollectRewardIxAccounts, CollectRewardIxData), - CollectProtocolFees(CollectProtocolFeesIxAccounts), - Swap(SwapIxAccounts, SwapIxData), - ClosePosition(ClosePositionIxAccounts), - SetDefaultFeeRate(SetDefaultFeeRateIxAccounts, SetDefaultFeeRateIxData), - SetDefaultProtocolFeeRate( - SetDefaultProtocolFeeRateIxAccounts, - SetDefaultProtocolFeeRateIxData, - ), - SetFeeRate(SetFeeRateIxAccounts, SetFeeRateIxData), - SetProtocolFeeRate(SetProtocolFeeRateIxAccounts, SetProtocolFeeRateIxData), - SetFeeAuthority(SetFeeAuthorityIxAccounts), - SetCollectProtocolFeesAuthority(SetCollectProtocolFeesAuthorityIxAccounts), - SetRewardAuthority(SetRewardAuthorityIxAccounts, SetRewardAuthorityIxData), - SetRewardAuthorityBySuperAuthority( - SetRewardAuthorityBySuperAuthorityIxAccounts, - SetRewardAuthorityBySuperAuthorityIxData, - ), - SetRewardEmissionsSuperAuthority(SetRewardEmissionsSuperAuthorityIxAccounts), - TwoHopSwap(TwoHopSwapIxAccounts, TwoHopSwapIxData), - InitializePositionBundle(InitializePositionBundleIxAccounts), - InitializePositionBundleWithMetadata(InitializePositionBundleWithMetadataIxAccounts), - DeletePositionBundle(DeletePositionBundleIxAccounts), - OpenBundledPosition(OpenBundledPositionIxAccounts, OpenBundledPositionIxData), - CloseBundledPosition(CloseBundledPositionIxAccounts, CloseBundledPositionIxData), - OpenPositionWithTokenExtensions( - OpenPositionWithTokenExtensionsIxAccounts, - OpenPositionWithTokenExtensionsIxData, - ), - ClosePositionWithTokenExtensions(ClosePositionWithTokenExtensionsIxAccounts), - LockPosition(LockPositionIxAccounts, LockPositionIxData), - ResetPositionRange(ResetPositionRangeIxAccounts, ResetPositionRangeIxData), - TransferLockedPosition(TransferLockedPositionIxAccounts), - InitializeAdaptiveFeeTier( - InitializeAdaptiveFeeTierIxAccounts, - InitializeAdaptiveFeeTierIxData, - ), - SetDefaultBaseFeeRate(SetDefaultBaseFeeRateIxAccounts, SetDefaultBaseFeeRateIxData), - SetDelegatedFeeAuthority(SetDelegatedFeeAuthorityIxAccounts), - SetInitializePoolAuthority(SetInitializePoolAuthorityIxAccounts), - SetPresetAdaptiveFeeConstants( - SetPresetAdaptiveFeeConstantsIxAccounts, - SetPresetAdaptiveFeeConstantsIxData, - ), - InitializePoolWithAdaptiveFee( - InitializePoolWithAdaptiveFeeIxAccounts, - InitializePoolWithAdaptiveFeeIxData, - ), - SetFeeRateByDelegatedFeeAuthority( - SetFeeRateByDelegatedFeeAuthorityIxAccounts, - SetFeeRateByDelegatedFeeAuthorityIxData, - ), - CollectFeesV2(CollectFeesV2IxAccounts, CollectFeesV2IxData), - CollectProtocolFeesV2(CollectProtocolFeesV2IxAccounts, CollectProtocolFeesV2IxData), - CollectRewardV2(CollectRewardV2IxAccounts, CollectRewardV2IxData), - DecreaseLiquidityV2(DecreaseLiquidityV2IxAccounts, DecreaseLiquidityV2IxData), - IncreaseLiquidityV2(IncreaseLiquidityV2IxAccounts, IncreaseLiquidityV2IxData), - InitializePoolV2(InitializePoolV2IxAccounts, InitializePoolV2IxData), - InitializeRewardV2(InitializeRewardV2IxAccounts, InitializeRewardV2IxData), - SetRewardEmissionsV2(SetRewardEmissionsV2IxAccounts, SetRewardEmissionsV2IxData), - SwapV2(SwapV2IxAccounts, SwapV2IxData), - TwoHopSwapV2(TwoHopSwapV2IxAccounts, TwoHopSwapV2IxData), - InitializeConfigExtension(InitializeConfigExtensionIxAccounts), - SetConfigExtensionAuthority(SetConfigExtensionAuthorityIxAccounts), - SetTokenBadgeAuthority(SetTokenBadgeAuthorityIxAccounts), - InitializeTokenBadge(InitializeTokenBadgeIxAccounts), - DeleteTokenBadge(DeleteTokenBadgeIxAccounts), - IdlInclude(IdlIncludeIxAccounts), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = WhirlpoolProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "Whirlpool::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [208, 127, 21, 1, 194, 190, 196, 70] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeConfigIxAccounts { - config: next_account(accounts)?, - funder: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializeConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::InitializeConfig( - ix_accounts, - de_ix_data, - )) - }, - [95, 180, 10, 172, 84, 174, 232, 40] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePoolIxAccounts { - whirlpools_config: next_account(accounts)?, - token_mint_a: next_account(accounts)?, - token_mint_b: next_account(accounts)?, - funder: next_account(accounts)?, - whirlpool: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - fee_tier: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: InitializePoolIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::InitializePool(ix_accounts, de_ix_data)) - }, - [11, 188, 193, 214, 141, 91, 149, 184] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeTickArrayIxAccounts { - whirlpool: next_account(accounts)?, - funder: next_account(accounts)?, - tick_array: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializeTickArrayIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::InitializeTickArray( - ix_accounts, - de_ix_data, - )) - }, - [41, 33, 165, 200, 120, 231, 142, 50] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeDynamicTickArrayIxAccounts { - whirlpool: next_account(accounts)?, - funder: next_account(accounts)?, - tick_array: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializeDynamicTickArrayIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::InitializeDynamicTickArray( - ix_accounts, - de_ix_data, - )) - }, - [183, 74, 156, 160, 112, 2, 42, 30] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeFeeTierIxAccounts { - config: next_account(accounts)?, - fee_tier: next_account(accounts)?, - funder: next_account(accounts)?, - fee_authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializeFeeTierIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::InitializeFeeTier( - ix_accounts, - de_ix_data, - )) - }, - [95, 135, 192, 196, 242, 129, 230, 68] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeRewardIxAccounts { - reward_authority: next_account(accounts)?, - funder: next_account(accounts)?, - whirlpool: next_account(accounts)?, - reward_mint: next_account(accounts)?, - reward_vault: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: InitializeRewardIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::InitializeReward( - ix_accounts, - de_ix_data, - )) - }, - [13, 197, 86, 168, 109, 176, 27, 244] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetRewardEmissionsIxAccounts { - whirlpool: next_account(accounts)?, - reward_authority: next_account(accounts)?, - reward_vault: next_account(accounts)?, - }; - let de_ix_data: SetRewardEmissionsIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetRewardEmissions( - ix_accounts, - de_ix_data, - )) - }, - [135, 128, 47, 77, 15, 152, 240, 49] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = OpenPositionIxAccounts { - funder: next_account(accounts)?, - owner: next_account(accounts)?, - position: next_account(accounts)?, - position_mint: next_account(accounts)?, - position_token_account: next_account(accounts)?, - whirlpool: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - let de_ix_data: OpenPositionIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::OpenPosition(ix_accounts, de_ix_data)) - }, - [242, 29, 134, 48, 58, 110, 14, 60] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = OpenPositionWithMetadataIxAccounts { - funder: next_account(accounts)?, - owner: next_account(accounts)?, - position: next_account(accounts)?, - position_mint: next_account(accounts)?, - position_metadata_account: next_account(accounts)?, - position_token_account: next_account(accounts)?, - whirlpool: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - metadata_program: next_account(accounts)?, - metadata_update_auth: next_account(accounts)?, - }; - let de_ix_data: OpenPositionWithMetadataIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::OpenPositionWithMetadata( - ix_accounts, - de_ix_data, - )) - }, - [46, 156, 243, 118, 13, 205, 251, 178] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = IncreaseLiquidityIxAccounts { - whirlpool: next_account(accounts)?, - token_program: next_account(accounts)?, - position_authority: next_account(accounts)?, - position: next_account(accounts)?, - position_token_account: next_account(accounts)?, - token_owner_account_a: next_account(accounts)?, - token_owner_account_b: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - }; - let de_ix_data: IncreaseLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::IncreaseLiquidity( - ix_accounts, - de_ix_data, - )) - }, - [160, 38, 208, 111, 104, 91, 44, 1] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DecreaseLiquidityIxAccounts { - whirlpool: next_account(accounts)?, - token_program: next_account(accounts)?, - position_authority: next_account(accounts)?, - position: next_account(accounts)?, - position_token_account: next_account(accounts)?, - token_owner_account_a: next_account(accounts)?, - token_owner_account_b: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - }; - let de_ix_data: DecreaseLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::DecreaseLiquidity( - ix_accounts, - de_ix_data, - )) - }, - [154, 230, 250, 13, 236, 209, 75, 223] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateFeesAndRewardsIxAccounts { - whirlpool: next_account(accounts)?, - position: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::UpdateFeesAndRewards(ix_accounts)) - }, - [164, 152, 207, 99, 30, 186, 19, 182] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectFeesIxAccounts { - whirlpool: next_account(accounts)?, - position_authority: next_account(accounts)?, - position: next_account(accounts)?, - position_token_account: next_account(accounts)?, - token_owner_account_a: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_owner_account_b: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::CollectFees(ix_accounts)) - }, - [70, 5, 132, 87, 86, 235, 177, 34] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectRewardIxAccounts { - whirlpool: next_account(accounts)?, - position_authority: next_account(accounts)?, - position: next_account(accounts)?, - position_token_account: next_account(accounts)?, - reward_owner_account: next_account(accounts)?, - reward_vault: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: CollectRewardIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::CollectReward(ix_accounts, de_ix_data)) - }, - [22, 67, 23, 98, 150, 178, 70, 220] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectProtocolFeesIxAccounts { - whirlpools_config: next_account(accounts)?, - whirlpool: next_account(accounts)?, - collect_protocol_fees_authority: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - token_destination_a: next_account(accounts)?, - token_destination_b: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::CollectProtocolFees(ix_accounts)) - }, - [248, 198, 158, 145, 225, 117, 135, 200] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapIxAccounts { - token_program: next_account(accounts)?, - token_authority: next_account(accounts)?, - whirlpool: next_account(accounts)?, - token_owner_account_a: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_owner_account_b: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - tick_array0: next_account(accounts)?, - tick_array1: next_account(accounts)?, - tick_array2: next_account(accounts)?, - oracle: next_account(accounts)?, - }; - let de_ix_data: SwapIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::Swap(ix_accounts, de_ix_data)) - }, - [123, 134, 81, 0, 49, 68, 98, 98] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClosePositionIxAccounts { - position_authority: next_account(accounts)?, - receiver: next_account(accounts)?, - position: next_account(accounts)?, - position_mint: next_account(accounts)?, - position_token_account: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::ClosePosition(ix_accounts)) - }, - [118, 215, 214, 157, 182, 229, 208, 228] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetDefaultFeeRateIxAccounts { - whirlpools_config: next_account(accounts)?, - fee_tier: next_account(accounts)?, - fee_authority: next_account(accounts)?, - }; - let de_ix_data: SetDefaultFeeRateIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetDefaultFeeRate( - ix_accounts, - de_ix_data, - )) - }, - [107, 205, 249, 226, 151, 35, 86, 0] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetDefaultProtocolFeeRateIxAccounts { - whirlpools_config: next_account(accounts)?, - fee_authority: next_account(accounts)?, - }; - let de_ix_data: SetDefaultProtocolFeeRateIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetDefaultProtocolFeeRate( - ix_accounts, - de_ix_data, - )) - }, - [53, 243, 137, 65, 8, 140, 158, 6] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetFeeRateIxAccounts { - whirlpools_config: next_account(accounts)?, - whirlpool: next_account(accounts)?, - fee_authority: next_account(accounts)?, - }; - let de_ix_data: SetFeeRateIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetFeeRate(ix_accounts, de_ix_data)) - }, - [95, 7, 4, 50, 154, 79, 156, 131] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetProtocolFeeRateIxAccounts { - whirlpools_config: next_account(accounts)?, - whirlpool: next_account(accounts)?, - fee_authority: next_account(accounts)?, - }; - let de_ix_data: SetProtocolFeeRateIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetProtocolFeeRate( - ix_accounts, - de_ix_data, - )) - }, - [31, 1, 50, 87, 237, 101, 97, 132] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetFeeAuthorityIxAccounts { - whirlpools_config: next_account(accounts)?, - fee_authority: next_account(accounts)?, - new_fee_authority: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::SetFeeAuthority(ix_accounts)) - }, - [34, 150, 93, 244, 139, 225, 233, 67] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetCollectProtocolFeesAuthorityIxAccounts { - whirlpools_config: next_account(accounts)?, - collect_protocol_fees_authority: next_account(accounts)?, - new_collect_protocol_fees_authority: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::SetCollectProtocolFeesAuthority( - ix_accounts, - )) - }, - [34, 39, 183, 252, 83, 28, 85, 127] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetRewardAuthorityIxAccounts { - whirlpool: next_account(accounts)?, - reward_authority: next_account(accounts)?, - new_reward_authority: next_account(accounts)?, - }; - let de_ix_data: SetRewardAuthorityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetRewardAuthority( - ix_accounts, - de_ix_data, - )) - }, - [240, 154, 201, 198, 148, 93, 56, 25] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetRewardAuthorityBySuperAuthorityIxAccounts { - whirlpools_config: next_account(accounts)?, - whirlpool: next_account(accounts)?, - reward_emissions_super_authority: next_account(accounts)?, - new_reward_authority: next_account(accounts)?, - }; - let de_ix_data: SetRewardAuthorityBySuperAuthorityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetRewardAuthorityBySuperAuthority( - ix_accounts, - de_ix_data, - )) - }, - [207, 5, 200, 209, 122, 56, 82, 183] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetRewardEmissionsSuperAuthorityIxAccounts { - whirlpools_config: next_account(accounts)?, - reward_emissions_super_authority: next_account(accounts)?, - new_reward_emissions_super_authority: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::SetRewardEmissionsSuperAuthority( - ix_accounts, - )) - }, - [195, 96, 237, 108, 68, 162, 219, 230] => { - let expected_accounts_len = 20; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = TwoHopSwapIxAccounts { - token_program: next_account(accounts)?, - token_authority: next_account(accounts)?, - whirlpool_one: next_account(accounts)?, - whirlpool_two: next_account(accounts)?, - token_owner_account_one_a: next_account(accounts)?, - token_vault_one_a: next_account(accounts)?, - token_owner_account_one_b: next_account(accounts)?, - token_vault_one_b: next_account(accounts)?, - token_owner_account_two_a: next_account(accounts)?, - token_vault_two_a: next_account(accounts)?, - token_owner_account_two_b: next_account(accounts)?, - token_vault_two_b: next_account(accounts)?, - tick_array_one0: next_account(accounts)?, - tick_array_one1: next_account(accounts)?, - tick_array_one2: next_account(accounts)?, - tick_array_two0: next_account(accounts)?, - tick_array_two1: next_account(accounts)?, - tick_array_two2: next_account(accounts)?, - oracle_one: next_account(accounts)?, - oracle_two: next_account(accounts)?, - }; - let de_ix_data: TwoHopSwapIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::TwoHopSwap(ix_accounts, de_ix_data)) - }, - [117, 45, 241, 149, 24, 18, 194, 65] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePositionBundleIxAccounts { - position_bundle: next_account(accounts)?, - position_bundle_mint: next_account(accounts)?, - position_bundle_token_account: next_account(accounts)?, - position_bundle_owner: next_account(accounts)?, - funder: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::InitializePositionBundle(ix_accounts)) - }, - [93, 124, 16, 179, 249, 131, 115, 245] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePositionBundleWithMetadataIxAccounts { - position_bundle: next_account(accounts)?, - position_bundle_mint: next_account(accounts)?, - position_bundle_metadata: next_account(accounts)?, - position_bundle_token_account: next_account(accounts)?, - position_bundle_owner: next_account(accounts)?, - funder: next_account(accounts)?, - metadata_update_auth: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - metadata_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::InitializePositionBundleWithMetadata( - ix_accounts, - )) - }, - [100, 25, 99, 2, 217, 239, 124, 173] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DeletePositionBundleIxAccounts { - position_bundle: next_account(accounts)?, - position_bundle_mint: next_account(accounts)?, - position_bundle_token_account: next_account(accounts)?, - position_bundle_owner: next_account(accounts)?, - receiver: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::DeletePositionBundle(ix_accounts)) - }, - [169, 113, 126, 171, 213, 172, 212, 49] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = OpenBundledPositionIxAccounts { - bundled_position: next_account(accounts)?, - position_bundle: next_account(accounts)?, - position_bundle_token_account: next_account(accounts)?, - position_bundle_authority: next_account(accounts)?, - whirlpool: next_account(accounts)?, - funder: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: OpenBundledPositionIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::OpenBundledPosition( - ix_accounts, - de_ix_data, - )) - }, - [41, 36, 216, 245, 27, 85, 103, 67] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CloseBundledPositionIxAccounts { - bundled_position: next_account(accounts)?, - position_bundle: next_account(accounts)?, - position_bundle_token_account: next_account(accounts)?, - position_bundle_authority: next_account(accounts)?, - receiver: next_account(accounts)?, - }; - let de_ix_data: CloseBundledPositionIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::CloseBundledPosition( - ix_accounts, - de_ix_data, - )) - }, - [212, 47, 95, 92, 114, 102, 131, 250] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = OpenPositionWithTokenExtensionsIxAccounts { - funder: next_account(accounts)?, - owner: next_account(accounts)?, - position: next_account(accounts)?, - position_mint: next_account(accounts)?, - position_token_account: next_account(accounts)?, - whirlpool: next_account(accounts)?, - token2022_program: next_account(accounts)?, - system_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - metadata_update_auth: next_account(accounts)?, - }; - let de_ix_data: OpenPositionWithTokenExtensionsIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::OpenPositionWithTokenExtensions( - ix_accounts, - de_ix_data, - )) - }, - [1, 182, 135, 59, 155, 25, 99, 223] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClosePositionWithTokenExtensionsIxAccounts { - position_authority: next_account(accounts)?, - receiver: next_account(accounts)?, - position: next_account(accounts)?, - position_mint: next_account(accounts)?, - position_token_account: next_account(accounts)?, - token2022_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::ClosePositionWithTokenExtensions( - ix_accounts, - )) - }, - [227, 62, 2, 252, 247, 10, 171, 185] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = LockPositionIxAccounts { - funder: next_account(accounts)?, - position_authority: next_account(accounts)?, - position: next_account(accounts)?, - position_mint: next_account(accounts)?, - position_token_account: next_account(accounts)?, - lock_config: next_account(accounts)?, - whirlpool: next_account(accounts)?, - token2022_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: LockPositionIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::LockPosition(ix_accounts, de_ix_data)) - }, - [164, 123, 180, 141, 194, 100, 160, 175] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ResetPositionRangeIxAccounts { - funder: next_account(accounts)?, - position_authority: next_account(accounts)?, - whirlpool: next_account(accounts)?, - position: next_account(accounts)?, - position_token_account: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: ResetPositionRangeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::ResetPositionRange( - ix_accounts, - de_ix_data, - )) - }, - [179, 121, 229, 46, 67, 138, 194, 138] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = TransferLockedPositionIxAccounts { - position_authority: next_account(accounts)?, - receiver: next_account(accounts)?, - position: next_account(accounts)?, - position_mint: next_account(accounts)?, - position_token_account: next_account(accounts)?, - destination_token_account: next_account(accounts)?, - lock_config: next_account(accounts)?, - token2022_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::TransferLockedPosition(ix_accounts)) - }, - [77, 99, 208, 200, 141, 123, 117, 48] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeAdaptiveFeeTierIxAccounts { - whirlpools_config: next_account(accounts)?, - adaptive_fee_tier: next_account(accounts)?, - funder: next_account(accounts)?, - fee_authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializeAdaptiveFeeTierIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::InitializeAdaptiveFeeTier( - ix_accounts, - de_ix_data, - )) - }, - [229, 66, 84, 251, 164, 134, 183, 7] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetDefaultBaseFeeRateIxAccounts { - whirlpools_config: next_account(accounts)?, - adaptive_fee_tier: next_account(accounts)?, - fee_authority: next_account(accounts)?, - }; - let de_ix_data: SetDefaultBaseFeeRateIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetDefaultBaseFeeRate( - ix_accounts, - de_ix_data, - )) - }, - [193, 234, 231, 147, 138, 57, 3, 122] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetDelegatedFeeAuthorityIxAccounts { - whirlpools_config: next_account(accounts)?, - adaptive_fee_tier: next_account(accounts)?, - fee_authority: next_account(accounts)?, - new_delegated_fee_authority: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::SetDelegatedFeeAuthority(ix_accounts)) - }, - [125, 43, 127, 235, 149, 26, 106, 236] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetInitializePoolAuthorityIxAccounts { - whirlpools_config: next_account(accounts)?, - adaptive_fee_tier: next_account(accounts)?, - fee_authority: next_account(accounts)?, - new_initialize_pool_authority: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::SetInitializePoolAuthority(ix_accounts)) - }, - [132, 185, 66, 148, 83, 88, 134, 198] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetPresetAdaptiveFeeConstantsIxAccounts { - whirlpools_config: next_account(accounts)?, - adaptive_fee_tier: next_account(accounts)?, - fee_authority: next_account(accounts)?, - }; - let de_ix_data: SetPresetAdaptiveFeeConstantsIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetPresetAdaptiveFeeConstants( - ix_accounts, - de_ix_data, - )) - }, - [143, 94, 96, 76, 172, 124, 119, 199] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePoolWithAdaptiveFeeIxAccounts { - whirlpools_config: next_account(accounts)?, - token_mint_a: next_account(accounts)?, - token_mint_b: next_account(accounts)?, - token_badge_a: next_account(accounts)?, - token_badge_b: next_account(accounts)?, - funder: next_account(accounts)?, - initialize_pool_authority: next_account(accounts)?, - whirlpool: next_account(accounts)?, - oracle: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - adaptive_fee_tier: next_account(accounts)?, - token_program_a: next_account(accounts)?, - token_program_b: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: InitializePoolWithAdaptiveFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::InitializePoolWithAdaptiveFee( - ix_accounts, - de_ix_data, - )) - }, - [121, 121, 54, 114, 131, 230, 162, 104] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetFeeRateByDelegatedFeeAuthorityIxAccounts { - whirlpool: next_account(accounts)?, - adaptive_fee_tier: next_account(accounts)?, - delegated_fee_authority: next_account(accounts)?, - }; - let de_ix_data: SetFeeRateByDelegatedFeeAuthorityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetFeeRateByDelegatedFeeAuthority( - ix_accounts, - de_ix_data, - )) - }, - [207, 117, 95, 191, 229, 180, 226, 15] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectFeesV2IxAccounts { - whirlpool: next_account(accounts)?, - position_authority: next_account(accounts)?, - position: next_account(accounts)?, - position_token_account: next_account(accounts)?, - token_mint_a: next_account(accounts)?, - token_mint_b: next_account(accounts)?, - token_owner_account_a: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_owner_account_b: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - token_program_a: next_account(accounts)?, - token_program_b: next_account(accounts)?, - memo_program: next_account(accounts)?, - }; - let de_ix_data: CollectFeesV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::CollectFeesV2(ix_accounts, de_ix_data)) - }, - [103, 128, 222, 134, 114, 200, 22, 200] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectProtocolFeesV2IxAccounts { - whirlpools_config: next_account(accounts)?, - whirlpool: next_account(accounts)?, - collect_protocol_fees_authority: next_account(accounts)?, - token_mint_a: next_account(accounts)?, - token_mint_b: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - token_destination_a: next_account(accounts)?, - token_destination_b: next_account(accounts)?, - token_program_a: next_account(accounts)?, - token_program_b: next_account(accounts)?, - memo_program: next_account(accounts)?, - }; - let de_ix_data: CollectProtocolFeesV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::CollectProtocolFeesV2( - ix_accounts, - de_ix_data, - )) - }, - [177, 107, 37, 180, 160, 19, 49, 209] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectRewardV2IxAccounts { - whirlpool: next_account(accounts)?, - position_authority: next_account(accounts)?, - position: next_account(accounts)?, - position_token_account: next_account(accounts)?, - reward_owner_account: next_account(accounts)?, - reward_mint: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_token_program: next_account(accounts)?, - memo_program: next_account(accounts)?, - }; - let de_ix_data: CollectRewardV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::CollectRewardV2(ix_accounts, de_ix_data)) - }, - [58, 127, 188, 62, 79, 82, 196, 96] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DecreaseLiquidityV2IxAccounts { - whirlpool: next_account(accounts)?, - token_program_a: next_account(accounts)?, - token_program_b: next_account(accounts)?, - memo_program: next_account(accounts)?, - position_authority: next_account(accounts)?, - position: next_account(accounts)?, - position_token_account: next_account(accounts)?, - token_mint_a: next_account(accounts)?, - token_mint_b: next_account(accounts)?, - token_owner_account_a: next_account(accounts)?, - token_owner_account_b: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - }; - let de_ix_data: DecreaseLiquidityV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::DecreaseLiquidityV2( - ix_accounts, - de_ix_data, - )) - }, - [133, 29, 89, 223, 69, 238, 176, 10] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = IncreaseLiquidityV2IxAccounts { - whirlpool: next_account(accounts)?, - token_program_a: next_account(accounts)?, - token_program_b: next_account(accounts)?, - memo_program: next_account(accounts)?, - position_authority: next_account(accounts)?, - position: next_account(accounts)?, - position_token_account: next_account(accounts)?, - token_mint_a: next_account(accounts)?, - token_mint_b: next_account(accounts)?, - token_owner_account_a: next_account(accounts)?, - token_owner_account_b: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - }; - let de_ix_data: IncreaseLiquidityV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::IncreaseLiquidityV2( - ix_accounts, - de_ix_data, - )) - }, - [207, 45, 87, 242, 27, 63, 204, 67] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializePoolV2IxAccounts { - whirlpools_config: next_account(accounts)?, - token_mint_a: next_account(accounts)?, - token_mint_b: next_account(accounts)?, - token_badge_a: next_account(accounts)?, - token_badge_b: next_account(accounts)?, - funder: next_account(accounts)?, - whirlpool: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - fee_tier: next_account(accounts)?, - token_program_a: next_account(accounts)?, - token_program_b: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: InitializePoolV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::InitializePoolV2( - ix_accounts, - de_ix_data, - )) - }, - [91, 1, 77, 50, 235, 229, 133, 49] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeRewardV2IxAccounts { - reward_authority: next_account(accounts)?, - funder: next_account(accounts)?, - whirlpool: next_account(accounts)?, - reward_mint: next_account(accounts)?, - reward_token_badge: next_account(accounts)?, - reward_vault: next_account(accounts)?, - reward_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: InitializeRewardV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::InitializeRewardV2( - ix_accounts, - de_ix_data, - )) - }, - [114, 228, 72, 32, 193, 48, 160, 102] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetRewardEmissionsV2IxAccounts { - whirlpool: next_account(accounts)?, - reward_authority: next_account(accounts)?, - reward_vault: next_account(accounts)?, - }; - let de_ix_data: SetRewardEmissionsV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SetRewardEmissionsV2( - ix_accounts, - de_ix_data, - )) - }, - [43, 4, 237, 11, 26, 201, 30, 98] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapV2IxAccounts { - token_program_a: next_account(accounts)?, - token_program_b: next_account(accounts)?, - memo_program: next_account(accounts)?, - token_authority: next_account(accounts)?, - whirlpool: next_account(accounts)?, - token_mint_a: next_account(accounts)?, - token_mint_b: next_account(accounts)?, - token_owner_account_a: next_account(accounts)?, - token_vault_a: next_account(accounts)?, - token_owner_account_b: next_account(accounts)?, - token_vault_b: next_account(accounts)?, - tick_array0: next_account(accounts)?, - tick_array1: next_account(accounts)?, - tick_array2: next_account(accounts)?, - oracle: next_account(accounts)?, - }; - let de_ix_data: SwapV2IxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::SwapV2(ix_accounts, de_ix_data)) - }, - [186, 143, 209, 29, 254, 2, 194, 117] => { - let expected_accounts_len = 24; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = TwoHopSwapV2IxAccounts { - whirlpool_one: next_account(accounts)?, - whirlpool_two: next_account(accounts)?, - token_mint_input: next_account(accounts)?, - token_mint_intermediate: next_account(accounts)?, - token_mint_output: next_account(accounts)?, - token_program_input: next_account(accounts)?, - token_program_intermediate: next_account(accounts)?, - token_program_output: next_account(accounts)?, - token_owner_account_input: next_account(accounts)?, - token_vault_one_input: next_account(accounts)?, - token_vault_one_intermediate: next_account(accounts)?, - token_vault_two_intermediate: next_account(accounts)?, - token_vault_two_output: next_account(accounts)?, - token_owner_account_output: next_account(accounts)?, - token_authority: next_account(accounts)?, - tick_array_one0: next_account(accounts)?, - tick_array_one1: next_account(accounts)?, - tick_array_one2: next_account(accounts)?, - tick_array_two0: next_account(accounts)?, - tick_array_two1: next_account(accounts)?, - tick_array_two2: next_account(accounts)?, - oracle_one: next_account(accounts)?, - oracle_two: next_account(accounts)?, - memo_program: next_account(accounts)?, - }; - let de_ix_data: TwoHopSwapV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(WhirlpoolProgramIx::TwoHopSwapV2(ix_accounts, de_ix_data)) - }, - [55, 9, 53, 9, 114, 57, 209, 52] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeConfigExtensionIxAccounts { - config: next_account(accounts)?, - config_extension: next_account(accounts)?, - funder: next_account(accounts)?, - fee_authority: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::InitializeConfigExtension(ix_accounts)) - }, - [44, 94, 241, 116, 24, 188, 60, 143] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetConfigExtensionAuthorityIxAccounts { - whirlpools_config: next_account(accounts)?, - whirlpools_config_extension: next_account(accounts)?, - config_extension_authority: next_account(accounts)?, - new_config_extension_authority: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::SetConfigExtensionAuthority(ix_accounts)) - }, - [207, 202, 4, 32, 205, 79, 13, 178] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetTokenBadgeAuthorityIxAccounts { - whirlpools_config: next_account(accounts)?, - whirlpools_config_extension: next_account(accounts)?, - config_extension_authority: next_account(accounts)?, - new_token_badge_authority: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::SetTokenBadgeAuthority(ix_accounts)) - }, - [253, 77, 205, 95, 27, 224, 89, 223] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeTokenBadgeIxAccounts { - whirlpools_config: next_account(accounts)?, - whirlpools_config_extension: next_account(accounts)?, - token_badge_authority: next_account(accounts)?, - token_mint: next_account(accounts)?, - token_badge: next_account(accounts)?, - funder: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::InitializeTokenBadge(ix_accounts)) - }, - [53, 146, 68, 8, 18, 117, 17, 185] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DeleteTokenBadgeIxAccounts { - whirlpools_config: next_account(accounts)?, - whirlpools_config_extension: next_account(accounts)?, - token_badge_authority: next_account(accounts)?, - token_mint: next_account(accounts)?, - token_badge: next_account(accounts)?, - receiver: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::DeleteTokenBadge(ix_accounts)) - }, - [223, 253, 121, 121, 60, 193, 129, 31] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = IdlIncludeIxAccounts { - tick_array: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(WhirlpoolProgramIx::IdlInclude(ix_accounts)) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{InitializeConfigIxAccounts, InstructionParser, WhirlpoolProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for InitializeConfigIxAccounts { - fn into_proto(self) -> proto_def::InitializeConfigIxAccounts { - proto_def::InitializeConfigIxAccounts { - config: self.config.to_string(), - funder: self.funder.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializeConfigIxData; - impl IntoProto for InitializeConfigIxData { - fn into_proto(self) -> proto_def::InitializeConfigIxData { - proto_def::InitializeConfigIxData { - fee_authority: self.fee_authority.to_string(), - collect_protocol_fees_authority: self.collect_protocol_fees_authority.to_string(), - reward_emissions_super_authority: self.reward_emissions_super_authority.to_string(), - default_protocol_fee_rate: self.default_protocol_fee_rate.into(), - } - } - } - use super::InitializePoolIxAccounts; - impl IntoProto for InitializePoolIxAccounts { - fn into_proto(self) -> proto_def::InitializePoolIxAccounts { - proto_def::InitializePoolIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - token_mint_a: self.token_mint_a.to_string(), - token_mint_b: self.token_mint_b.to_string(), - funder: self.funder.to_string(), - whirlpool: self.whirlpool.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_vault_b: self.token_vault_b.to_string(), - fee_tier: self.fee_tier.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::InitializePoolIxData; - impl IntoProto for InitializePoolIxData { - fn into_proto(self) -> proto_def::InitializePoolIxData { - proto_def::InitializePoolIxData { - whirlpool_bump: self.whirlpool_bump.into(), - tick_spacing: self.tick_spacing.into(), - initial_sqrt_price: self.initial_sqrt_price.to_string(), - } - } - } - use super::InitializeTickArrayIxAccounts; - impl IntoProto for InitializeTickArrayIxAccounts { - fn into_proto(self) -> proto_def::InitializeTickArrayIxAccounts { - proto_def::InitializeTickArrayIxAccounts { - whirlpool: self.whirlpool.to_string(), - funder: self.funder.to_string(), - tick_array: self.tick_array.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializeTickArrayIxData; - impl IntoProto for InitializeTickArrayIxData { - fn into_proto(self) -> proto_def::InitializeTickArrayIxData { - proto_def::InitializeTickArrayIxData { - start_tick_index: self.start_tick_index, - } - } - } - use super::InitializeDynamicTickArrayIxAccounts; - impl IntoProto - for InitializeDynamicTickArrayIxAccounts - { - fn into_proto(self) -> proto_def::InitializeDynamicTickArrayIxAccounts { - proto_def::InitializeDynamicTickArrayIxAccounts { - whirlpool: self.whirlpool.to_string(), - funder: self.funder.to_string(), - tick_array: self.tick_array.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializeDynamicTickArrayIxData; - impl IntoProto for InitializeDynamicTickArrayIxData { - fn into_proto(self) -> proto_def::InitializeDynamicTickArrayIxData { - proto_def::InitializeDynamicTickArrayIxData { - start_tick_index: self.start_tick_index, - idempotent: self.idempotent, - } - } - } - use super::InitializeFeeTierIxAccounts; - impl IntoProto for InitializeFeeTierIxAccounts { - fn into_proto(self) -> proto_def::InitializeFeeTierIxAccounts { - proto_def::InitializeFeeTierIxAccounts { - config: self.config.to_string(), - fee_tier: self.fee_tier.to_string(), - funder: self.funder.to_string(), - fee_authority: self.fee_authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializeFeeTierIxData; - impl IntoProto for InitializeFeeTierIxData { - fn into_proto(self) -> proto_def::InitializeFeeTierIxData { - proto_def::InitializeFeeTierIxData { - tick_spacing: self.tick_spacing.into(), - default_fee_rate: self.default_fee_rate.into(), - } - } - } - use super::InitializeRewardIxAccounts; - impl IntoProto for InitializeRewardIxAccounts { - fn into_proto(self) -> proto_def::InitializeRewardIxAccounts { - proto_def::InitializeRewardIxAccounts { - reward_authority: self.reward_authority.to_string(), - funder: self.funder.to_string(), - whirlpool: self.whirlpool.to_string(), - reward_mint: self.reward_mint.to_string(), - reward_vault: self.reward_vault.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::InitializeRewardIxData; - impl IntoProto for InitializeRewardIxData { - fn into_proto(self) -> proto_def::InitializeRewardIxData { - proto_def::InitializeRewardIxData { - reward_index: self.reward_index.into(), - } - } - } - use super::SetRewardEmissionsIxAccounts; - impl IntoProto for SetRewardEmissionsIxAccounts { - fn into_proto(self) -> proto_def::SetRewardEmissionsIxAccounts { - proto_def::SetRewardEmissionsIxAccounts { - whirlpool: self.whirlpool.to_string(), - reward_authority: self.reward_authority.to_string(), - reward_vault: self.reward_vault.to_string(), - } - } - } - use super::SetRewardEmissionsIxData; - impl IntoProto for SetRewardEmissionsIxData { - fn into_proto(self) -> proto_def::SetRewardEmissionsIxData { - proto_def::SetRewardEmissionsIxData { - reward_index: self.reward_index.into(), - emissions_per_second_x64: self.emissions_per_second_x64.to_string(), - } - } - } - use super::OpenPositionIxAccounts; - impl IntoProto for OpenPositionIxAccounts { - fn into_proto(self) -> proto_def::OpenPositionIxAccounts { - proto_def::OpenPositionIxAccounts { - funder: self.funder.to_string(), - owner: self.owner.to_string(), - position: self.position.to_string(), - position_mint: self.position_mint.to_string(), - position_token_account: self.position_token_account.to_string(), - whirlpool: self.whirlpool.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::OpenPositionIxData; - impl IntoProto for OpenPositionIxData { - fn into_proto(self) -> proto_def::OpenPositionIxData { - proto_def::OpenPositionIxData { - position_bump: self.position_bump.into(), - tick_lower_index: self.tick_lower_index, - tick_upper_index: self.tick_upper_index, - } - } - } - use super::OpenPositionWithMetadataIxAccounts; - impl IntoProto - for OpenPositionWithMetadataIxAccounts - { - fn into_proto(self) -> proto_def::OpenPositionWithMetadataIxAccounts { - proto_def::OpenPositionWithMetadataIxAccounts { - funder: self.funder.to_string(), - owner: self.owner.to_string(), - position: self.position.to_string(), - position_mint: self.position_mint.to_string(), - position_metadata_account: self.position_metadata_account.to_string(), - position_token_account: self.position_token_account.to_string(), - whirlpool: self.whirlpool.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - associated_token_program: self.associated_token_program.to_string(), - metadata_program: self.metadata_program.to_string(), - metadata_update_auth: self.metadata_update_auth.to_string(), - } - } - } - use super::OpenPositionWithMetadataIxData; - impl IntoProto for OpenPositionWithMetadataIxData { - fn into_proto(self) -> proto_def::OpenPositionWithMetadataIxData { - proto_def::OpenPositionWithMetadataIxData { - position_bump: self.position_bump.into(), - metadata_bump: self.metadata_bump.into(), - tick_lower_index: self.tick_lower_index, - tick_upper_index: self.tick_upper_index, - } - } - } - use super::IncreaseLiquidityIxAccounts; - impl IntoProto for IncreaseLiquidityIxAccounts { - fn into_proto(self) -> proto_def::IncreaseLiquidityIxAccounts { - proto_def::IncreaseLiquidityIxAccounts { - whirlpool: self.whirlpool.to_string(), - token_program: self.token_program.to_string(), - position_authority: self.position_authority.to_string(), - position: self.position.to_string(), - position_token_account: self.position_token_account.to_string(), - token_owner_account_a: self.token_owner_account_a.to_string(), - token_owner_account_b: self.token_owner_account_b.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_vault_b: self.token_vault_b.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - } - } - } - use super::IncreaseLiquidityIxData; - impl IntoProto for IncreaseLiquidityIxData { - fn into_proto(self) -> proto_def::IncreaseLiquidityIxData { - proto_def::IncreaseLiquidityIxData { - liquidity_amount: self.liquidity_amount.to_string(), - token_max_a: self.token_max_a, - token_max_b: self.token_max_b, - } - } - } - use super::DecreaseLiquidityIxAccounts; - impl IntoProto for DecreaseLiquidityIxAccounts { - fn into_proto(self) -> proto_def::DecreaseLiquidityIxAccounts { - proto_def::DecreaseLiquidityIxAccounts { - whirlpool: self.whirlpool.to_string(), - token_program: self.token_program.to_string(), - position_authority: self.position_authority.to_string(), - position: self.position.to_string(), - position_token_account: self.position_token_account.to_string(), - token_owner_account_a: self.token_owner_account_a.to_string(), - token_owner_account_b: self.token_owner_account_b.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_vault_b: self.token_vault_b.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - } - } - } - use super::DecreaseLiquidityIxData; - impl IntoProto for DecreaseLiquidityIxData { - fn into_proto(self) -> proto_def::DecreaseLiquidityIxData { - proto_def::DecreaseLiquidityIxData { - liquidity_amount: self.liquidity_amount.to_string(), - token_min_a: self.token_min_a, - token_min_b: self.token_min_b, - } - } - } - use super::UpdateFeesAndRewardsIxAccounts; - impl IntoProto for UpdateFeesAndRewardsIxAccounts { - fn into_proto(self) -> proto_def::UpdateFeesAndRewardsIxAccounts { - proto_def::UpdateFeesAndRewardsIxAccounts { - whirlpool: self.whirlpool.to_string(), - position: self.position.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - } - } - } - use super::CollectFeesIxAccounts; - impl IntoProto for CollectFeesIxAccounts { - fn into_proto(self) -> proto_def::CollectFeesIxAccounts { - proto_def::CollectFeesIxAccounts { - whirlpool: self.whirlpool.to_string(), - position_authority: self.position_authority.to_string(), - position: self.position.to_string(), - position_token_account: self.position_token_account.to_string(), - token_owner_account_a: self.token_owner_account_a.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_owner_account_b: self.token_owner_account_b.to_string(), - token_vault_b: self.token_vault_b.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::CollectRewardIxAccounts; - impl IntoProto for CollectRewardIxAccounts { - fn into_proto(self) -> proto_def::CollectRewardIxAccounts { - proto_def::CollectRewardIxAccounts { - whirlpool: self.whirlpool.to_string(), - position_authority: self.position_authority.to_string(), - position: self.position.to_string(), - position_token_account: self.position_token_account.to_string(), - reward_owner_account: self.reward_owner_account.to_string(), - reward_vault: self.reward_vault.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::CollectRewardIxData; - impl IntoProto for CollectRewardIxData { - fn into_proto(self) -> proto_def::CollectRewardIxData { - proto_def::CollectRewardIxData { - reward_index: self.reward_index.into(), - } - } - } - use super::CollectProtocolFeesIxAccounts; - impl IntoProto for CollectProtocolFeesIxAccounts { - fn into_proto(self) -> proto_def::CollectProtocolFeesIxAccounts { - proto_def::CollectProtocolFeesIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - whirlpool: self.whirlpool.to_string(), - collect_protocol_fees_authority: self.collect_protocol_fees_authority.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_vault_b: self.token_vault_b.to_string(), - token_destination_a: self.token_destination_a.to_string(), - token_destination_b: self.token_destination_b.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::SwapIxAccounts; - impl IntoProto for SwapIxAccounts { - fn into_proto(self) -> proto_def::SwapIxAccounts { - proto_def::SwapIxAccounts { - token_program: self.token_program.to_string(), - token_authority: self.token_authority.to_string(), - whirlpool: self.whirlpool.to_string(), - token_owner_account_a: self.token_owner_account_a.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_owner_account_b: self.token_owner_account_b.to_string(), - token_vault_b: self.token_vault_b.to_string(), - tick_array0: self.tick_array0.to_string(), - tick_array1: self.tick_array1.to_string(), - tick_array2: self.tick_array2.to_string(), - oracle: self.oracle.to_string(), - } - } - } - use super::SwapIxData; - impl IntoProto for SwapIxData { - fn into_proto(self) -> proto_def::SwapIxData { - proto_def::SwapIxData { - amount: self.amount, - other_amount_threshold: self.other_amount_threshold, - sqrt_price_limit: self.sqrt_price_limit.to_string(), - amount_specified_is_input: self.amount_specified_is_input, - a_to_b: self.a_to_b, - } - } - } - use super::ClosePositionIxAccounts; - impl IntoProto for ClosePositionIxAccounts { - fn into_proto(self) -> proto_def::ClosePositionIxAccounts { - proto_def::ClosePositionIxAccounts { - position_authority: self.position_authority.to_string(), - receiver: self.receiver.to_string(), - position: self.position.to_string(), - position_mint: self.position_mint.to_string(), - position_token_account: self.position_token_account.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::SetDefaultFeeRateIxAccounts; - impl IntoProto for SetDefaultFeeRateIxAccounts { - fn into_proto(self) -> proto_def::SetDefaultFeeRateIxAccounts { - proto_def::SetDefaultFeeRateIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - fee_tier: self.fee_tier.to_string(), - fee_authority: self.fee_authority.to_string(), - } - } - } - use super::SetDefaultFeeRateIxData; - impl IntoProto for SetDefaultFeeRateIxData { - fn into_proto(self) -> proto_def::SetDefaultFeeRateIxData { - proto_def::SetDefaultFeeRateIxData { - default_fee_rate: self.default_fee_rate.into(), - } - } - } - use super::SetDefaultProtocolFeeRateIxAccounts; - impl IntoProto - for SetDefaultProtocolFeeRateIxAccounts - { - fn into_proto(self) -> proto_def::SetDefaultProtocolFeeRateIxAccounts { - proto_def::SetDefaultProtocolFeeRateIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - fee_authority: self.fee_authority.to_string(), - } - } - } - use super::SetDefaultProtocolFeeRateIxData; - impl IntoProto for SetDefaultProtocolFeeRateIxData { - fn into_proto(self) -> proto_def::SetDefaultProtocolFeeRateIxData { - proto_def::SetDefaultProtocolFeeRateIxData { - default_protocol_fee_rate: self.default_protocol_fee_rate.into(), - } - } - } - use super::SetFeeRateIxAccounts; - impl IntoProto for SetFeeRateIxAccounts { - fn into_proto(self) -> proto_def::SetFeeRateIxAccounts { - proto_def::SetFeeRateIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - whirlpool: self.whirlpool.to_string(), - fee_authority: self.fee_authority.to_string(), - } - } - } - use super::SetFeeRateIxData; - impl IntoProto for SetFeeRateIxData { - fn into_proto(self) -> proto_def::SetFeeRateIxData { - proto_def::SetFeeRateIxData { - fee_rate: self.fee_rate.into(), - } - } - } - use super::SetProtocolFeeRateIxAccounts; - impl IntoProto for SetProtocolFeeRateIxAccounts { - fn into_proto(self) -> proto_def::SetProtocolFeeRateIxAccounts { - proto_def::SetProtocolFeeRateIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - whirlpool: self.whirlpool.to_string(), - fee_authority: self.fee_authority.to_string(), - } - } - } - use super::SetProtocolFeeRateIxData; - impl IntoProto for SetProtocolFeeRateIxData { - fn into_proto(self) -> proto_def::SetProtocolFeeRateIxData { - proto_def::SetProtocolFeeRateIxData { - protocol_fee_rate: self.protocol_fee_rate.into(), - } - } - } - use super::SetFeeAuthorityIxAccounts; - impl IntoProto for SetFeeAuthorityIxAccounts { - fn into_proto(self) -> proto_def::SetFeeAuthorityIxAccounts { - proto_def::SetFeeAuthorityIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - fee_authority: self.fee_authority.to_string(), - new_fee_authority: self.new_fee_authority.to_string(), - } - } - } - use super::SetCollectProtocolFeesAuthorityIxAccounts; - impl IntoProto - for SetCollectProtocolFeesAuthorityIxAccounts - { - fn into_proto(self) -> proto_def::SetCollectProtocolFeesAuthorityIxAccounts { - proto_def::SetCollectProtocolFeesAuthorityIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - collect_protocol_fees_authority: self.collect_protocol_fees_authority.to_string(), - new_collect_protocol_fees_authority: self - .new_collect_protocol_fees_authority - .to_string(), - } - } - } - use super::SetRewardAuthorityIxAccounts; - impl IntoProto for SetRewardAuthorityIxAccounts { - fn into_proto(self) -> proto_def::SetRewardAuthorityIxAccounts { - proto_def::SetRewardAuthorityIxAccounts { - whirlpool: self.whirlpool.to_string(), - reward_authority: self.reward_authority.to_string(), - new_reward_authority: self.new_reward_authority.to_string(), - } - } - } - use super::SetRewardAuthorityIxData; - impl IntoProto for SetRewardAuthorityIxData { - fn into_proto(self) -> proto_def::SetRewardAuthorityIxData { - proto_def::SetRewardAuthorityIxData { - reward_index: self.reward_index.into(), - } - } - } - use super::SetRewardAuthorityBySuperAuthorityIxAccounts; - impl IntoProto - for SetRewardAuthorityBySuperAuthorityIxAccounts - { - fn into_proto(self) -> proto_def::SetRewardAuthorityBySuperAuthorityIxAccounts { - proto_def::SetRewardAuthorityBySuperAuthorityIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - whirlpool: self.whirlpool.to_string(), - reward_emissions_super_authority: self.reward_emissions_super_authority.to_string(), - new_reward_authority: self.new_reward_authority.to_string(), - } - } - } - use super::SetRewardAuthorityBySuperAuthorityIxData; - impl IntoProto - for SetRewardAuthorityBySuperAuthorityIxData - { - fn into_proto(self) -> proto_def::SetRewardAuthorityBySuperAuthorityIxData { - proto_def::SetRewardAuthorityBySuperAuthorityIxData { - reward_index: self.reward_index.into(), - } - } - } - use super::SetRewardEmissionsSuperAuthorityIxAccounts; - impl IntoProto - for SetRewardEmissionsSuperAuthorityIxAccounts - { - fn into_proto(self) -> proto_def::SetRewardEmissionsSuperAuthorityIxAccounts { - proto_def::SetRewardEmissionsSuperAuthorityIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - reward_emissions_super_authority: self.reward_emissions_super_authority.to_string(), - new_reward_emissions_super_authority: self - .new_reward_emissions_super_authority - .to_string(), - } - } - } - use super::TwoHopSwapIxAccounts; - impl IntoProto for TwoHopSwapIxAccounts { - fn into_proto(self) -> proto_def::TwoHopSwapIxAccounts { - proto_def::TwoHopSwapIxAccounts { - token_program: self.token_program.to_string(), - token_authority: self.token_authority.to_string(), - whirlpool_one: self.whirlpool_one.to_string(), - whirlpool_two: self.whirlpool_two.to_string(), - token_owner_account_one_a: self.token_owner_account_one_a.to_string(), - token_vault_one_a: self.token_vault_one_a.to_string(), - token_owner_account_one_b: self.token_owner_account_one_b.to_string(), - token_vault_one_b: self.token_vault_one_b.to_string(), - token_owner_account_two_a: self.token_owner_account_two_a.to_string(), - token_vault_two_a: self.token_vault_two_a.to_string(), - token_owner_account_two_b: self.token_owner_account_two_b.to_string(), - token_vault_two_b: self.token_vault_two_b.to_string(), - tick_array_one0: self.tick_array_one0.to_string(), - tick_array_one1: self.tick_array_one1.to_string(), - tick_array_one2: self.tick_array_one2.to_string(), - tick_array_two0: self.tick_array_two0.to_string(), - tick_array_two1: self.tick_array_two1.to_string(), - tick_array_two2: self.tick_array_two2.to_string(), - oracle_one: self.oracle_one.to_string(), - oracle_two: self.oracle_two.to_string(), - } - } - } - use super::TwoHopSwapIxData; - impl IntoProto for TwoHopSwapIxData { - fn into_proto(self) -> proto_def::TwoHopSwapIxData { - proto_def::TwoHopSwapIxData { - amount: self.amount, - other_amount_threshold: self.other_amount_threshold, - amount_specified_is_input: self.amount_specified_is_input, - a_to_b_one: self.a_to_b_one, - a_to_b_two: self.a_to_b_two, - sqrt_price_limit_one: self.sqrt_price_limit_one.to_string(), - sqrt_price_limit_two: self.sqrt_price_limit_two.to_string(), - } - } - } - use super::InitializePositionBundleIxAccounts; - impl IntoProto - for InitializePositionBundleIxAccounts - { - fn into_proto(self) -> proto_def::InitializePositionBundleIxAccounts { - proto_def::InitializePositionBundleIxAccounts { - position_bundle: self.position_bundle.to_string(), - position_bundle_mint: self.position_bundle_mint.to_string(), - position_bundle_token_account: self.position_bundle_token_account.to_string(), - position_bundle_owner: self.position_bundle_owner.to_string(), - funder: self.funder.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::InitializePositionBundleWithMetadataIxAccounts; - impl IntoProto - for InitializePositionBundleWithMetadataIxAccounts - { - fn into_proto(self) -> proto_def::InitializePositionBundleWithMetadataIxAccounts { - proto_def::InitializePositionBundleWithMetadataIxAccounts { - position_bundle: self.position_bundle.to_string(), - position_bundle_mint: self.position_bundle_mint.to_string(), - position_bundle_metadata: self.position_bundle_metadata.to_string(), - position_bundle_token_account: self.position_bundle_token_account.to_string(), - position_bundle_owner: self.position_bundle_owner.to_string(), - funder: self.funder.to_string(), - metadata_update_auth: self.metadata_update_auth.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - associated_token_program: self.associated_token_program.to_string(), - metadata_program: self.metadata_program.to_string(), - } - } - } - use super::DeletePositionBundleIxAccounts; - impl IntoProto for DeletePositionBundleIxAccounts { - fn into_proto(self) -> proto_def::DeletePositionBundleIxAccounts { - proto_def::DeletePositionBundleIxAccounts { - position_bundle: self.position_bundle.to_string(), - position_bundle_mint: self.position_bundle_mint.to_string(), - position_bundle_token_account: self.position_bundle_token_account.to_string(), - position_bundle_owner: self.position_bundle_owner.to_string(), - receiver: self.receiver.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::OpenBundledPositionIxAccounts; - impl IntoProto for OpenBundledPositionIxAccounts { - fn into_proto(self) -> proto_def::OpenBundledPositionIxAccounts { - proto_def::OpenBundledPositionIxAccounts { - bundled_position: self.bundled_position.to_string(), - position_bundle: self.position_bundle.to_string(), - position_bundle_token_account: self.position_bundle_token_account.to_string(), - position_bundle_authority: self.position_bundle_authority.to_string(), - whirlpool: self.whirlpool.to_string(), - funder: self.funder.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::OpenBundledPositionIxData; - impl IntoProto for OpenBundledPositionIxData { - fn into_proto(self) -> proto_def::OpenBundledPositionIxData { - proto_def::OpenBundledPositionIxData { - bundle_index: self.bundle_index.into(), - tick_lower_index: self.tick_lower_index, - tick_upper_index: self.tick_upper_index, - } - } - } - use super::CloseBundledPositionIxAccounts; - impl IntoProto for CloseBundledPositionIxAccounts { - fn into_proto(self) -> proto_def::CloseBundledPositionIxAccounts { - proto_def::CloseBundledPositionIxAccounts { - bundled_position: self.bundled_position.to_string(), - position_bundle: self.position_bundle.to_string(), - position_bundle_token_account: self.position_bundle_token_account.to_string(), - position_bundle_authority: self.position_bundle_authority.to_string(), - receiver: self.receiver.to_string(), - } - } - } - use super::CloseBundledPositionIxData; - impl IntoProto for CloseBundledPositionIxData { - fn into_proto(self) -> proto_def::CloseBundledPositionIxData { - proto_def::CloseBundledPositionIxData { - bundle_index: self.bundle_index.into(), - } - } - } - use super::OpenPositionWithTokenExtensionsIxAccounts; - impl IntoProto - for OpenPositionWithTokenExtensionsIxAccounts - { - fn into_proto(self) -> proto_def::OpenPositionWithTokenExtensionsIxAccounts { - proto_def::OpenPositionWithTokenExtensionsIxAccounts { - funder: self.funder.to_string(), - owner: self.owner.to_string(), - position: self.position.to_string(), - position_mint: self.position_mint.to_string(), - position_token_account: self.position_token_account.to_string(), - whirlpool: self.whirlpool.to_string(), - token2022_program: self.token2022_program.to_string(), - system_program: self.system_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - metadata_update_auth: self.metadata_update_auth.to_string(), - } - } - } - use super::OpenPositionWithTokenExtensionsIxData; - impl IntoProto - for OpenPositionWithTokenExtensionsIxData - { - fn into_proto(self) -> proto_def::OpenPositionWithTokenExtensionsIxData { - proto_def::OpenPositionWithTokenExtensionsIxData { - tick_lower_index: self.tick_lower_index, - tick_upper_index: self.tick_upper_index, - with_token_metadata_extension: self.with_token_metadata_extension, - } - } - } - use super::ClosePositionWithTokenExtensionsIxAccounts; - impl IntoProto - for ClosePositionWithTokenExtensionsIxAccounts - { - fn into_proto(self) -> proto_def::ClosePositionWithTokenExtensionsIxAccounts { - proto_def::ClosePositionWithTokenExtensionsIxAccounts { - position_authority: self.position_authority.to_string(), - receiver: self.receiver.to_string(), - position: self.position.to_string(), - position_mint: self.position_mint.to_string(), - position_token_account: self.position_token_account.to_string(), - token2022_program: self.token2022_program.to_string(), - } - } - } - use super::LockPositionIxAccounts; - impl IntoProto for LockPositionIxAccounts { - fn into_proto(self) -> proto_def::LockPositionIxAccounts { - proto_def::LockPositionIxAccounts { - funder: self.funder.to_string(), - position_authority: self.position_authority.to_string(), - position: self.position.to_string(), - position_mint: self.position_mint.to_string(), - position_token_account: self.position_token_account.to_string(), - lock_config: self.lock_config.to_string(), - whirlpool: self.whirlpool.to_string(), - token2022_program: self.token2022_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::LockPositionIxData; - impl IntoProto for LockPositionIxData { - fn into_proto(self) -> proto_def::LockPositionIxData { - proto_def::LockPositionIxData { - lock_type: self.lock_type as i32, - } - } - } - use super::ResetPositionRangeIxAccounts; - impl IntoProto for ResetPositionRangeIxAccounts { - fn into_proto(self) -> proto_def::ResetPositionRangeIxAccounts { - proto_def::ResetPositionRangeIxAccounts { - funder: self.funder.to_string(), - position_authority: self.position_authority.to_string(), - whirlpool: self.whirlpool.to_string(), - position: self.position.to_string(), - position_token_account: self.position_token_account.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::ResetPositionRangeIxData; - impl IntoProto for ResetPositionRangeIxData { - fn into_proto(self) -> proto_def::ResetPositionRangeIxData { - proto_def::ResetPositionRangeIxData { - new_tick_lower_index: self.new_tick_lower_index, - new_tick_upper_index: self.new_tick_upper_index, - } - } - } - use super::TransferLockedPositionIxAccounts; - impl IntoProto for TransferLockedPositionIxAccounts { - fn into_proto(self) -> proto_def::TransferLockedPositionIxAccounts { - proto_def::TransferLockedPositionIxAccounts { - position_authority: self.position_authority.to_string(), - receiver: self.receiver.to_string(), - position: self.position.to_string(), - position_mint: self.position_mint.to_string(), - position_token_account: self.position_token_account.to_string(), - destination_token_account: self.destination_token_account.to_string(), - lock_config: self.lock_config.to_string(), - token2022_program: self.token2022_program.to_string(), - } - } - } - use super::InitializeAdaptiveFeeTierIxAccounts; - impl IntoProto - for InitializeAdaptiveFeeTierIxAccounts - { - fn into_proto(self) -> proto_def::InitializeAdaptiveFeeTierIxAccounts { - proto_def::InitializeAdaptiveFeeTierIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - adaptive_fee_tier: self.adaptive_fee_tier.to_string(), - funder: self.funder.to_string(), - fee_authority: self.fee_authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializeAdaptiveFeeTierIxData; - impl IntoProto for InitializeAdaptiveFeeTierIxData { - fn into_proto(self) -> proto_def::InitializeAdaptiveFeeTierIxData { - proto_def::InitializeAdaptiveFeeTierIxData { - fee_tier_index: self.fee_tier_index.into(), - tick_spacing: self.tick_spacing.into(), - initialize_pool_authority: self.initialize_pool_authority.to_string(), - delegated_fee_authority: self.delegated_fee_authority.to_string(), - default_base_fee_rate: self.default_base_fee_rate.into(), - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - adaptive_fee_control_factor: self.adaptive_fee_control_factor, - max_volatility_accumulator: self.max_volatility_accumulator, - tick_group_size: self.tick_group_size.into(), - major_swap_threshold_ticks: self.major_swap_threshold_ticks.into(), - } - } - } - use super::SetDefaultBaseFeeRateIxAccounts; - impl IntoProto for SetDefaultBaseFeeRateIxAccounts { - fn into_proto(self) -> proto_def::SetDefaultBaseFeeRateIxAccounts { - proto_def::SetDefaultBaseFeeRateIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - adaptive_fee_tier: self.adaptive_fee_tier.to_string(), - fee_authority: self.fee_authority.to_string(), - } - } - } - use super::SetDefaultBaseFeeRateIxData; - impl IntoProto for SetDefaultBaseFeeRateIxData { - fn into_proto(self) -> proto_def::SetDefaultBaseFeeRateIxData { - proto_def::SetDefaultBaseFeeRateIxData { - default_base_fee_rate: self.default_base_fee_rate.into(), - } - } - } - use super::SetDelegatedFeeAuthorityIxAccounts; - impl IntoProto - for SetDelegatedFeeAuthorityIxAccounts - { - fn into_proto(self) -> proto_def::SetDelegatedFeeAuthorityIxAccounts { - proto_def::SetDelegatedFeeAuthorityIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - adaptive_fee_tier: self.adaptive_fee_tier.to_string(), - fee_authority: self.fee_authority.to_string(), - new_delegated_fee_authority: self.new_delegated_fee_authority.to_string(), - } - } - } - use super::SetInitializePoolAuthorityIxAccounts; - impl IntoProto - for SetInitializePoolAuthorityIxAccounts - { - fn into_proto(self) -> proto_def::SetInitializePoolAuthorityIxAccounts { - proto_def::SetInitializePoolAuthorityIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - adaptive_fee_tier: self.adaptive_fee_tier.to_string(), - fee_authority: self.fee_authority.to_string(), - new_initialize_pool_authority: self.new_initialize_pool_authority.to_string(), - } - } - } - use super::SetPresetAdaptiveFeeConstantsIxAccounts; - impl IntoProto - for SetPresetAdaptiveFeeConstantsIxAccounts - { - fn into_proto(self) -> proto_def::SetPresetAdaptiveFeeConstantsIxAccounts { - proto_def::SetPresetAdaptiveFeeConstantsIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - adaptive_fee_tier: self.adaptive_fee_tier.to_string(), - fee_authority: self.fee_authority.to_string(), - } - } - } - use super::SetPresetAdaptiveFeeConstantsIxData; - impl IntoProto - for SetPresetAdaptiveFeeConstantsIxData - { - fn into_proto(self) -> proto_def::SetPresetAdaptiveFeeConstantsIxData { - proto_def::SetPresetAdaptiveFeeConstantsIxData { - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - adaptive_fee_control_factor: self.adaptive_fee_control_factor, - max_volatility_accumulator: self.max_volatility_accumulator, - tick_group_size: self.tick_group_size.into(), - major_swap_threshold_ticks: self.major_swap_threshold_ticks.into(), - } - } - } - use super::InitializePoolWithAdaptiveFeeIxAccounts; - impl IntoProto - for InitializePoolWithAdaptiveFeeIxAccounts - { - fn into_proto(self) -> proto_def::InitializePoolWithAdaptiveFeeIxAccounts { - proto_def::InitializePoolWithAdaptiveFeeIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - token_mint_a: self.token_mint_a.to_string(), - token_mint_b: self.token_mint_b.to_string(), - token_badge_a: self.token_badge_a.to_string(), - token_badge_b: self.token_badge_b.to_string(), - funder: self.funder.to_string(), - initialize_pool_authority: self.initialize_pool_authority.to_string(), - whirlpool: self.whirlpool.to_string(), - oracle: self.oracle.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_vault_b: self.token_vault_b.to_string(), - adaptive_fee_tier: self.adaptive_fee_tier.to_string(), - token_program_a: self.token_program_a.to_string(), - token_program_b: self.token_program_b.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::InitializePoolWithAdaptiveFeeIxData; - impl IntoProto - for InitializePoolWithAdaptiveFeeIxData - { - fn into_proto(self) -> proto_def::InitializePoolWithAdaptiveFeeIxData { - proto_def::InitializePoolWithAdaptiveFeeIxData { - initial_sqrt_price: self.initial_sqrt_price.to_string(), - trade_enable_timestamp: self.trade_enable_timestamp, - } - } - } - use super::SetFeeRateByDelegatedFeeAuthorityIxAccounts; - impl IntoProto - for SetFeeRateByDelegatedFeeAuthorityIxAccounts - { - fn into_proto(self) -> proto_def::SetFeeRateByDelegatedFeeAuthorityIxAccounts { - proto_def::SetFeeRateByDelegatedFeeAuthorityIxAccounts { - whirlpool: self.whirlpool.to_string(), - adaptive_fee_tier: self.adaptive_fee_tier.to_string(), - delegated_fee_authority: self.delegated_fee_authority.to_string(), - } - } - } - use super::SetFeeRateByDelegatedFeeAuthorityIxData; - impl IntoProto - for SetFeeRateByDelegatedFeeAuthorityIxData - { - fn into_proto(self) -> proto_def::SetFeeRateByDelegatedFeeAuthorityIxData { - proto_def::SetFeeRateByDelegatedFeeAuthorityIxData { - fee_rate: self.fee_rate.into(), - } - } - } - use super::CollectFeesV2IxAccounts; - impl IntoProto for CollectFeesV2IxAccounts { - fn into_proto(self) -> proto_def::CollectFeesV2IxAccounts { - proto_def::CollectFeesV2IxAccounts { - whirlpool: self.whirlpool.to_string(), - position_authority: self.position_authority.to_string(), - position: self.position.to_string(), - position_token_account: self.position_token_account.to_string(), - token_mint_a: self.token_mint_a.to_string(), - token_mint_b: self.token_mint_b.to_string(), - token_owner_account_a: self.token_owner_account_a.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_owner_account_b: self.token_owner_account_b.to_string(), - token_vault_b: self.token_vault_b.to_string(), - token_program_a: self.token_program_a.to_string(), - token_program_b: self.token_program_b.to_string(), - memo_program: self.memo_program.to_string(), - } - } - } - use super::CollectFeesV2IxData; - impl IntoProto for CollectFeesV2IxData { - fn into_proto(self) -> proto_def::CollectFeesV2IxData { - proto_def::CollectFeesV2IxData { - remaining_accounts_info: self.remaining_accounts_info.map(|x| x.into_proto()), - } - } - } - use super::CollectProtocolFeesV2IxAccounts; - impl IntoProto for CollectProtocolFeesV2IxAccounts { - fn into_proto(self) -> proto_def::CollectProtocolFeesV2IxAccounts { - proto_def::CollectProtocolFeesV2IxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - whirlpool: self.whirlpool.to_string(), - collect_protocol_fees_authority: self.collect_protocol_fees_authority.to_string(), - token_mint_a: self.token_mint_a.to_string(), - token_mint_b: self.token_mint_b.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_vault_b: self.token_vault_b.to_string(), - token_destination_a: self.token_destination_a.to_string(), - token_destination_b: self.token_destination_b.to_string(), - token_program_a: self.token_program_a.to_string(), - token_program_b: self.token_program_b.to_string(), - memo_program: self.memo_program.to_string(), - } - } - } - use super::CollectProtocolFeesV2IxData; - impl IntoProto for CollectProtocolFeesV2IxData { - fn into_proto(self) -> proto_def::CollectProtocolFeesV2IxData { - proto_def::CollectProtocolFeesV2IxData { - remaining_accounts_info: self.remaining_accounts_info.map(|x| x.into_proto()), - } - } - } - use super::CollectRewardV2IxAccounts; - impl IntoProto for CollectRewardV2IxAccounts { - fn into_proto(self) -> proto_def::CollectRewardV2IxAccounts { - proto_def::CollectRewardV2IxAccounts { - whirlpool: self.whirlpool.to_string(), - position_authority: self.position_authority.to_string(), - position: self.position.to_string(), - position_token_account: self.position_token_account.to_string(), - reward_owner_account: self.reward_owner_account.to_string(), - reward_mint: self.reward_mint.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_token_program: self.reward_token_program.to_string(), - memo_program: self.memo_program.to_string(), - } - } - } - use super::CollectRewardV2IxData; - impl IntoProto for CollectRewardV2IxData { - fn into_proto(self) -> proto_def::CollectRewardV2IxData { - proto_def::CollectRewardV2IxData { - reward_index: self.reward_index.into(), - remaining_accounts_info: self.remaining_accounts_info.map(|x| x.into_proto()), - } - } - } - use super::DecreaseLiquidityV2IxAccounts; - impl IntoProto for DecreaseLiquidityV2IxAccounts { - fn into_proto(self) -> proto_def::DecreaseLiquidityV2IxAccounts { - proto_def::DecreaseLiquidityV2IxAccounts { - whirlpool: self.whirlpool.to_string(), - token_program_a: self.token_program_a.to_string(), - token_program_b: self.token_program_b.to_string(), - memo_program: self.memo_program.to_string(), - position_authority: self.position_authority.to_string(), - position: self.position.to_string(), - position_token_account: self.position_token_account.to_string(), - token_mint_a: self.token_mint_a.to_string(), - token_mint_b: self.token_mint_b.to_string(), - token_owner_account_a: self.token_owner_account_a.to_string(), - token_owner_account_b: self.token_owner_account_b.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_vault_b: self.token_vault_b.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - } - } - } - use super::DecreaseLiquidityV2IxData; - impl IntoProto for DecreaseLiquidityV2IxData { - fn into_proto(self) -> proto_def::DecreaseLiquidityV2IxData { - proto_def::DecreaseLiquidityV2IxData { - liquidity_amount: self.liquidity_amount.to_string(), - token_min_a: self.token_min_a, - token_min_b: self.token_min_b, - remaining_accounts_info: self.remaining_accounts_info.map(|x| x.into_proto()), - } - } - } - use super::IncreaseLiquidityV2IxAccounts; - impl IntoProto for IncreaseLiquidityV2IxAccounts { - fn into_proto(self) -> proto_def::IncreaseLiquidityV2IxAccounts { - proto_def::IncreaseLiquidityV2IxAccounts { - whirlpool: self.whirlpool.to_string(), - token_program_a: self.token_program_a.to_string(), - token_program_b: self.token_program_b.to_string(), - memo_program: self.memo_program.to_string(), - position_authority: self.position_authority.to_string(), - position: self.position.to_string(), - position_token_account: self.position_token_account.to_string(), - token_mint_a: self.token_mint_a.to_string(), - token_mint_b: self.token_mint_b.to_string(), - token_owner_account_a: self.token_owner_account_a.to_string(), - token_owner_account_b: self.token_owner_account_b.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_vault_b: self.token_vault_b.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - } - } - } - use super::IncreaseLiquidityV2IxData; - impl IntoProto for IncreaseLiquidityV2IxData { - fn into_proto(self) -> proto_def::IncreaseLiquidityV2IxData { - proto_def::IncreaseLiquidityV2IxData { - liquidity_amount: self.liquidity_amount.to_string(), - token_max_a: self.token_max_a, - token_max_b: self.token_max_b, - remaining_accounts_info: self.remaining_accounts_info.map(|x| x.into_proto()), - } - } - } - use super::InitializePoolV2IxAccounts; - impl IntoProto for InitializePoolV2IxAccounts { - fn into_proto(self) -> proto_def::InitializePoolV2IxAccounts { - proto_def::InitializePoolV2IxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - token_mint_a: self.token_mint_a.to_string(), - token_mint_b: self.token_mint_b.to_string(), - token_badge_a: self.token_badge_a.to_string(), - token_badge_b: self.token_badge_b.to_string(), - funder: self.funder.to_string(), - whirlpool: self.whirlpool.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_vault_b: self.token_vault_b.to_string(), - fee_tier: self.fee_tier.to_string(), - token_program_a: self.token_program_a.to_string(), - token_program_b: self.token_program_b.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::InitializePoolV2IxData; - impl IntoProto for InitializePoolV2IxData { - fn into_proto(self) -> proto_def::InitializePoolV2IxData { - proto_def::InitializePoolV2IxData { - tick_spacing: self.tick_spacing.into(), - initial_sqrt_price: self.initial_sqrt_price.to_string(), - } - } - } - use super::InitializeRewardV2IxAccounts; - impl IntoProto for InitializeRewardV2IxAccounts { - fn into_proto(self) -> proto_def::InitializeRewardV2IxAccounts { - proto_def::InitializeRewardV2IxAccounts { - reward_authority: self.reward_authority.to_string(), - funder: self.funder.to_string(), - whirlpool: self.whirlpool.to_string(), - reward_mint: self.reward_mint.to_string(), - reward_token_badge: self.reward_token_badge.to_string(), - reward_vault: self.reward_vault.to_string(), - reward_token_program: self.reward_token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::InitializeRewardV2IxData; - impl IntoProto for InitializeRewardV2IxData { - fn into_proto(self) -> proto_def::InitializeRewardV2IxData { - proto_def::InitializeRewardV2IxData { - reward_index: self.reward_index.into(), - } - } - } - use super::SetRewardEmissionsV2IxAccounts; - impl IntoProto for SetRewardEmissionsV2IxAccounts { - fn into_proto(self) -> proto_def::SetRewardEmissionsV2IxAccounts { - proto_def::SetRewardEmissionsV2IxAccounts { - whirlpool: self.whirlpool.to_string(), - reward_authority: self.reward_authority.to_string(), - reward_vault: self.reward_vault.to_string(), - } - } - } - use super::SetRewardEmissionsV2IxData; - impl IntoProto for SetRewardEmissionsV2IxData { - fn into_proto(self) -> proto_def::SetRewardEmissionsV2IxData { - proto_def::SetRewardEmissionsV2IxData { - reward_index: self.reward_index.into(), - emissions_per_second_x64: self.emissions_per_second_x64.to_string(), - } - } - } - use super::SwapV2IxAccounts; - impl IntoProto for SwapV2IxAccounts { - fn into_proto(self) -> proto_def::SwapV2IxAccounts { - proto_def::SwapV2IxAccounts { - token_program_a: self.token_program_a.to_string(), - token_program_b: self.token_program_b.to_string(), - memo_program: self.memo_program.to_string(), - token_authority: self.token_authority.to_string(), - whirlpool: self.whirlpool.to_string(), - token_mint_a: self.token_mint_a.to_string(), - token_mint_b: self.token_mint_b.to_string(), - token_owner_account_a: self.token_owner_account_a.to_string(), - token_vault_a: self.token_vault_a.to_string(), - token_owner_account_b: self.token_owner_account_b.to_string(), - token_vault_b: self.token_vault_b.to_string(), - tick_array0: self.tick_array0.to_string(), - tick_array1: self.tick_array1.to_string(), - tick_array2: self.tick_array2.to_string(), - oracle: self.oracle.to_string(), - } - } - } - use super::SwapV2IxData; - impl IntoProto for SwapV2IxData { - fn into_proto(self) -> proto_def::SwapV2IxData { - proto_def::SwapV2IxData { - amount: self.amount, - other_amount_threshold: self.other_amount_threshold, - sqrt_price_limit: self.sqrt_price_limit.to_string(), - amount_specified_is_input: self.amount_specified_is_input, - a_to_b: self.a_to_b, - remaining_accounts_info: self.remaining_accounts_info.map(|x| x.into_proto()), - } - } - } - use super::TwoHopSwapV2IxAccounts; - impl IntoProto for TwoHopSwapV2IxAccounts { - fn into_proto(self) -> proto_def::TwoHopSwapV2IxAccounts { - proto_def::TwoHopSwapV2IxAccounts { - whirlpool_one: self.whirlpool_one.to_string(), - whirlpool_two: self.whirlpool_two.to_string(), - token_mint_input: self.token_mint_input.to_string(), - token_mint_intermediate: self.token_mint_intermediate.to_string(), - token_mint_output: self.token_mint_output.to_string(), - token_program_input: self.token_program_input.to_string(), - token_program_intermediate: self.token_program_intermediate.to_string(), - token_program_output: self.token_program_output.to_string(), - token_owner_account_input: self.token_owner_account_input.to_string(), - token_vault_one_input: self.token_vault_one_input.to_string(), - token_vault_one_intermediate: self.token_vault_one_intermediate.to_string(), - token_vault_two_intermediate: self.token_vault_two_intermediate.to_string(), - token_vault_two_output: self.token_vault_two_output.to_string(), - token_owner_account_output: self.token_owner_account_output.to_string(), - token_authority: self.token_authority.to_string(), - tick_array_one0: self.tick_array_one0.to_string(), - tick_array_one1: self.tick_array_one1.to_string(), - tick_array_one2: self.tick_array_one2.to_string(), - tick_array_two0: self.tick_array_two0.to_string(), - tick_array_two1: self.tick_array_two1.to_string(), - tick_array_two2: self.tick_array_two2.to_string(), - oracle_one: self.oracle_one.to_string(), - oracle_two: self.oracle_two.to_string(), - memo_program: self.memo_program.to_string(), - } - } - } - use super::TwoHopSwapV2IxData; - impl IntoProto for TwoHopSwapV2IxData { - fn into_proto(self) -> proto_def::TwoHopSwapV2IxData { - proto_def::TwoHopSwapV2IxData { - amount: self.amount, - other_amount_threshold: self.other_amount_threshold, - amount_specified_is_input: self.amount_specified_is_input, - a_to_b_one: self.a_to_b_one, - a_to_b_two: self.a_to_b_two, - sqrt_price_limit_one: self.sqrt_price_limit_one.to_string(), - sqrt_price_limit_two: self.sqrt_price_limit_two.to_string(), - remaining_accounts_info: self.remaining_accounts_info.map(|x| x.into_proto()), - } - } - } - use super::InitializeConfigExtensionIxAccounts; - impl IntoProto - for InitializeConfigExtensionIxAccounts - { - fn into_proto(self) -> proto_def::InitializeConfigExtensionIxAccounts { - proto_def::InitializeConfigExtensionIxAccounts { - config: self.config.to_string(), - config_extension: self.config_extension.to_string(), - funder: self.funder.to_string(), - fee_authority: self.fee_authority.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::SetConfigExtensionAuthorityIxAccounts; - impl IntoProto - for SetConfigExtensionAuthorityIxAccounts - { - fn into_proto(self) -> proto_def::SetConfigExtensionAuthorityIxAccounts { - proto_def::SetConfigExtensionAuthorityIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - whirlpools_config_extension: self.whirlpools_config_extension.to_string(), - config_extension_authority: self.config_extension_authority.to_string(), - new_config_extension_authority: self.new_config_extension_authority.to_string(), - } - } - } - use super::SetTokenBadgeAuthorityIxAccounts; - impl IntoProto for SetTokenBadgeAuthorityIxAccounts { - fn into_proto(self) -> proto_def::SetTokenBadgeAuthorityIxAccounts { - proto_def::SetTokenBadgeAuthorityIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - whirlpools_config_extension: self.whirlpools_config_extension.to_string(), - config_extension_authority: self.config_extension_authority.to_string(), - new_token_badge_authority: self.new_token_badge_authority.to_string(), - } - } - } - use super::InitializeTokenBadgeIxAccounts; - impl IntoProto for InitializeTokenBadgeIxAccounts { - fn into_proto(self) -> proto_def::InitializeTokenBadgeIxAccounts { - proto_def::InitializeTokenBadgeIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - whirlpools_config_extension: self.whirlpools_config_extension.to_string(), - token_badge_authority: self.token_badge_authority.to_string(), - token_mint: self.token_mint.to_string(), - token_badge: self.token_badge.to_string(), - funder: self.funder.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::DeleteTokenBadgeIxAccounts; - impl IntoProto for DeleteTokenBadgeIxAccounts { - fn into_proto(self) -> proto_def::DeleteTokenBadgeIxAccounts { - proto_def::DeleteTokenBadgeIxAccounts { - whirlpools_config: self.whirlpools_config.to_string(), - whirlpools_config_extension: self.whirlpools_config_extension.to_string(), - token_badge_authority: self.token_badge_authority.to_string(), - token_mint: self.token_mint.to_string(), - token_badge: self.token_badge.to_string(), - receiver: self.receiver.to_string(), - } - } - } - use super::IdlIncludeIxAccounts; - impl IntoProto for IdlIncludeIxAccounts { - fn into_proto(self) -> proto_def::IdlIncludeIxAccounts { - proto_def::IdlIncludeIxAccounts { - tick_array: self.tick_array.to_string(), - system_program: self.system_program.to_string(), - } - } - } - - impl IntoProto for WhirlpoolProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - WhirlpoolProgramIx::InitializeConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeConfig( - proto_def::InitializeConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializePool(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePool( - proto_def::InitializePoolIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializeTickArray(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeTickArray( - proto_def::InitializeTickArrayIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializeDynamicTickArray(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::InitializeDynamicTickArray( - proto_def::InitializeDynamicTickArrayIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - WhirlpoolProgramIx::InitializeFeeTier(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeFeeTier( - proto_def::InitializeFeeTierIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializeReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeReward( - proto_def::InitializeRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetRewardEmissions(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetRewardEmissions( - proto_def::SetRewardEmissionsIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::OpenPosition(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::OpenPosition( - proto_def::OpenPositionIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::OpenPositionWithMetadata(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::OpenPositionWithMetadata( - proto_def::OpenPositionWithMetadataIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::IncreaseLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::IncreaseLiquidity( - proto_def::IncreaseLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::DecreaseLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::DecreaseLiquidity( - proto_def::DecreaseLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::UpdateFeesAndRewards(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateFeesAndRewards( - proto_def::UpdateFeesAndRewardsIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::CollectFees(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectFees( - proto_def::CollectFeesIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::CollectReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectReward( - proto_def::CollectRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::CollectProtocolFees(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectProtocolFees( - proto_def::CollectProtocolFeesIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::Swap(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Swap(proto_def::SwapIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - WhirlpoolProgramIx::ClosePosition(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClosePosition( - proto_def::ClosePositionIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetDefaultFeeRate(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetDefaultFeeRate( - proto_def::SetDefaultFeeRateIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetDefaultProtocolFeeRate(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetDefaultProtocolFeeRate( - proto_def::SetDefaultProtocolFeeRateIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetFeeRate(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetFeeRate( - proto_def::SetFeeRateIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetProtocolFeeRate(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetProtocolFeeRate( - proto_def::SetProtocolFeeRateIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetFeeAuthority(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetFeeAuthority( - proto_def::SetFeeAuthorityIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetCollectProtocolFeesAuthority(acc) => proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::SetCollectProtocolFeesAuthority( - proto_def::SetCollectProtocolFeesAuthorityIx { - accounts: Some(acc.into_proto()), - }, - ), - ), - }, - WhirlpoolProgramIx::SetRewardAuthority(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetRewardAuthority( - proto_def::SetRewardAuthorityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetRewardAuthorityBySuperAuthority(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::SetRewardAuthorityBySuperAuthority( - proto_def::SetRewardAuthorityBySuperAuthorityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - WhirlpoolProgramIx::SetRewardEmissionsSuperAuthority(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::SetRewardEmissionsSuperAuthority( - proto_def::SetRewardEmissionsSuperAuthorityIx { - accounts: Some(acc.into_proto()), - }, - ), - ), - } - }, - WhirlpoolProgramIx::TwoHopSwap(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::TwoHopSwap( - proto_def::TwoHopSwapIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializePositionBundle(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePositionBundle( - proto_def::InitializePositionBundleIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializePositionBundleWithMetadata(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::InitializePositionBundleWithMetadata( - proto_def::InitializePositionBundleWithMetadataIx { - accounts: Some(acc.into_proto()), - }, - ), - ), - } - }, - WhirlpoolProgramIx::DeletePositionBundle(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::DeletePositionBundle( - proto_def::DeletePositionBundleIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::OpenBundledPosition(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::OpenBundledPosition( - proto_def::OpenBundledPositionIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::CloseBundledPosition(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CloseBundledPosition( - proto_def::CloseBundledPositionIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::OpenPositionWithTokenExtensions(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::OpenPositionWithTokenExtensions( - proto_def::OpenPositionWithTokenExtensionsIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - WhirlpoolProgramIx::ClosePositionWithTokenExtensions(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::ClosePositionWithTokenExtensions( - proto_def::ClosePositionWithTokenExtensionsIx { - accounts: Some(acc.into_proto()), - }, - ), - ), - } - }, - WhirlpoolProgramIx::LockPosition(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::LockPosition( - proto_def::LockPositionIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::ResetPositionRange(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ResetPositionRange( - proto_def::ResetPositionRangeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::TransferLockedPosition(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::TransferLockedPosition( - proto_def::TransferLockedPositionIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializeAdaptiveFeeTier(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeAdaptiveFeeTier( - proto_def::InitializeAdaptiveFeeTierIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetDefaultBaseFeeRate(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetDefaultBaseFeeRate( - proto_def::SetDefaultBaseFeeRateIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetDelegatedFeeAuthority(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetDelegatedFeeAuthority( - proto_def::SetDelegatedFeeAuthorityIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetInitializePoolAuthority(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetInitializePoolAuthority( - proto_def::SetInitializePoolAuthorityIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetPresetAdaptiveFeeConstants(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::SetPresetAdaptiveFeeConstants( - proto_def::SetPresetAdaptiveFeeConstantsIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - WhirlpoolProgramIx::InitializePoolWithAdaptiveFee(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::InitializePoolWithAdaptiveFee( - proto_def::InitializePoolWithAdaptiveFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - WhirlpoolProgramIx::SetFeeRateByDelegatedFeeAuthority(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::SetFeeRateByDelegatedFeeAuthority( - proto_def::SetFeeRateByDelegatedFeeAuthorityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - WhirlpoolProgramIx::CollectFeesV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectFeesV2( - proto_def::CollectFeesV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::CollectProtocolFeesV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectProtocolFeesV2( - proto_def::CollectProtocolFeesV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::CollectRewardV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectRewardV2( - proto_def::CollectRewardV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::DecreaseLiquidityV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::DecreaseLiquidityV2( - proto_def::DecreaseLiquidityV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::IncreaseLiquidityV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::IncreaseLiquidityV2( - proto_def::IncreaseLiquidityV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializePoolV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializePoolV2( - proto_def::InitializePoolV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializeRewardV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeRewardV2( - proto_def::InitializeRewardV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetRewardEmissionsV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetRewardEmissionsV2( - proto_def::SetRewardEmissionsV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SwapV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapV2( - proto_def::SwapV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::TwoHopSwapV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::TwoHopSwapV2( - proto_def::TwoHopSwapV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializeConfigExtension(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeConfigExtension( - proto_def::InitializeConfigExtensionIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::SetConfigExtensionAuthority(acc) => proto_def::ProgramIxs { - ix_oneof: Some( - proto_def::program_ixs::IxOneof::SetConfigExtensionAuthority( - proto_def::SetConfigExtensionAuthorityIx { - accounts: Some(acc.into_proto()), - }, - ), - ), - }, - WhirlpoolProgramIx::SetTokenBadgeAuthority(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetTokenBadgeAuthority( - proto_def::SetTokenBadgeAuthorityIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::InitializeTokenBadge(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeTokenBadge( - proto_def::InitializeTokenBadgeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::DeleteTokenBadge(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::DeleteTokenBadge( - proto_def::DeleteTokenBadgeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - WhirlpoolProgramIx::IdlInclude(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::IdlInclude( - proto_def::IdlIncludeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/orca-whirlpool-parser/src/generated_parser/mod.rs b/crates/orca-whirlpool-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/orca-whirlpool-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/orca-whirlpool-parser/src/generated_parser/proto_helpers.rs b/crates/orca-whirlpool-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index 5c2eb908..00000000 --- a/crates/orca-whirlpool-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,133 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::DynamicTickData}; - impl IntoProto for DynamicTickData { - fn into_proto(self) -> proto_def::DynamicTickData { - proto_def::DynamicTickData { - liquidity_net: self.liquidity_net.to_string(), - liquidity_gross: self.liquidity_gross.to_string(), - fee_growth_outside_a: self.fee_growth_outside_a.to_string(), - fee_growth_outside_b: self.fee_growth_outside_b.to_string(), - reward_growths_outside: self - .reward_growths_outside - .into_iter() - .map(|x| x.to_string()) - .collect(), - } - } - } - use crate::types::AdaptiveFeeConstants; - impl IntoProto for AdaptiveFeeConstants { - fn into_proto(self) -> proto_def::AdaptiveFeeConstants { - proto_def::AdaptiveFeeConstants { - filter_period: self.filter_period.into(), - decay_period: self.decay_period.into(), - reduction_factor: self.reduction_factor.into(), - adaptive_fee_control_factor: self.adaptive_fee_control_factor, - max_volatility_accumulator: self.max_volatility_accumulator, - tick_group_size: self.tick_group_size.into(), - major_swap_threshold_ticks: self.major_swap_threshold_ticks.into(), - reserved: self.reserved.into_iter().map(|x| x.into()).collect(), - } - } - } - use crate::types::AdaptiveFeeVariables; - impl IntoProto for AdaptiveFeeVariables { - fn into_proto(self) -> proto_def::AdaptiveFeeVariables { - proto_def::AdaptiveFeeVariables { - last_reference_update_timestamp: self.last_reference_update_timestamp, - last_major_swap_timestamp: self.last_major_swap_timestamp, - volatility_reference: self.volatility_reference, - tick_group_index_reference: self.tick_group_index_reference, - volatility_accumulator: self.volatility_accumulator, - reserved: self.reserved.into_iter().map(|x| x.into()).collect(), - } - } - } - use crate::types::PositionRewardInfo; - impl IntoProto for PositionRewardInfo { - fn into_proto(self) -> proto_def::PositionRewardInfo { - proto_def::PositionRewardInfo { - growth_inside_checkpoint: self.growth_inside_checkpoint.to_string(), - amount_owed: self.amount_owed, - } - } - } - use crate::types::Tick; - impl IntoProto for Tick { - fn into_proto(self) -> proto_def::Tick { - proto_def::Tick { - initialized: self.initialized, - liquidity_net: self.liquidity_net.to_string(), - liquidity_gross: self.liquidity_gross.to_string(), - fee_growth_outside_a: self.fee_growth_outside_a.to_string(), - fee_growth_outside_b: self.fee_growth_outside_b.to_string(), - reward_growths_outside: self - .reward_growths_outside - .into_iter() - .map(|x| x.to_string()) - .collect(), - } - } - } - use crate::types::WhirlpoolRewardInfo; - impl IntoProto for WhirlpoolRewardInfo { - fn into_proto(self) -> proto_def::WhirlpoolRewardInfo { - proto_def::WhirlpoolRewardInfo { - mint: self.mint.to_string(), - vault: self.vault.to_string(), - authority: self.authority.to_string(), - emissions_per_second_x64: self.emissions_per_second_x64.to_string(), - growth_global_x64: self.growth_global_x64.to_string(), - } - } - } - use crate::types::RemainingAccountsInfo; - impl IntoProto for RemainingAccountsInfo { - fn into_proto(self) -> proto_def::RemainingAccountsInfo { - proto_def::RemainingAccountsInfo { - slices: self.slices.into_iter().map(|x| x.into_proto()).collect(), - } - } - } - use crate::types::RemainingAccountsSlice; - impl IntoProto for RemainingAccountsSlice { - fn into_proto(self) -> proto_def::RemainingAccountsSlice { - proto_def::RemainingAccountsSlice { - accounts_type: self.accounts_type as i32, - length: self.length.into(), - } - } - } - - use proto_def::dynamic_tick; - - use crate::types::DynamicTick; - impl IntoProto for DynamicTick { - fn into_proto(self) -> proto_def::DynamicTick { - let variant = match self { - DynamicTick::Uninitialized => { - dynamic_tick::Variant::Uninitialized(proto_def::DynamicTickUninitialized {}) - }, - DynamicTick::Initialized(field_0) => { - dynamic_tick::Variant::Initialized(proto_def::DynamicTickInitialized { - field_0: Some(field_0.into_proto()), - }) - }, - }; - - proto_def::DynamicTick { - variant: Some(variant), - } - } - } -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/adaptive_fee_tier.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/adaptive_fee_tier.rs deleted file mode 100644 index 7e1350e5..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/adaptive_fee_tier.rs +++ /dev/null @@ -1,152 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AdaptiveFeeTier { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whirlpools_config: Pubkey, - pub fee_tier_index: u16, - pub tick_spacing: u16, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub initialize_pool_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub delegated_fee_authority: Pubkey, - pub default_base_fee_rate: u16, - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub adaptive_fee_control_factor: u32, - pub max_volatility_accumulator: u32, - pub tick_group_size: u16, - pub major_swap_threshold_ticks: u16, -} - -impl AdaptiveFeeTier { - pub const LEN: usize = 128; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for AdaptiveFeeTier { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_adaptive_fee_tier( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_adaptive_fee_tier(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_adaptive_fee_tier( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = AdaptiveFeeTier::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_adaptive_fee_tier( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_adaptive_fee_tier(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_adaptive_fee_tier( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = AdaptiveFeeTier::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for AdaptiveFeeTier { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for AdaptiveFeeTier {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for AdaptiveFeeTier { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for AdaptiveFeeTier {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for AdaptiveFeeTier { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/dynamic_tick_array.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/dynamic_tick_array.rs deleted file mode 100644 index 3e7b1ad2..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/dynamic_tick_array.rs +++ /dev/null @@ -1,136 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::DynamicTick; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DynamicTickArray { - pub discriminator: [u8; 8], - pub start_tick_index: i32, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whirlpool: Pubkey, - pub tick_bitmap: u128, - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub ticks: [DynamicTick; 88], -} - -impl DynamicTickArray { - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for DynamicTickArray { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_dynamic_tick_array( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_dynamic_tick_array(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_dynamic_tick_array( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = DynamicTickArray::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_dynamic_tick_array( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_dynamic_tick_array(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_dynamic_tick_array( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = DynamicTickArray::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for DynamicTickArray { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for DynamicTickArray {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for DynamicTickArray { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for DynamicTickArray {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for DynamicTickArray { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/fee_tier.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/fee_tier.rs deleted file mode 100644 index a917989c..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/fee_tier.rs +++ /dev/null @@ -1,134 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FeeTier { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whirlpools_config: Pubkey, - pub tick_spacing: u16, - pub default_fee_rate: u16, -} - -impl FeeTier { - pub const LEN: usize = 44; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for FeeTier { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_fee_tier( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_fee_tier(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_fee_tier( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = FeeTier::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_fee_tier( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_fee_tier(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_fee_tier( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = FeeTier::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for FeeTier { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for FeeTier {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for FeeTier { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for FeeTier {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for FeeTier { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/lock_config.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/lock_config.rs deleted file mode 100644 index 405072a7..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/lock_config.rs +++ /dev/null @@ -1,146 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::LockTypeLabel; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockConfig { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position_owner: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whirlpool: Pubkey, - pub locked_timestamp: u64, - pub lock_type: LockTypeLabel, -} - -impl LockConfig { - pub const LEN: usize = 113; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for LockConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_lock_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_lock_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_lock_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = LockConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_lock_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_lock_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_lock_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = LockConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for LockConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for LockConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for LockConfig { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for LockConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for LockConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/mod.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index c0d46c45..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#adaptive_fee_tier; -pub(crate) mod r#dynamic_tick_array; -pub(crate) mod r#fee_tier; -pub(crate) mod r#lock_config; -pub(crate) mod r#oracle; -pub(crate) mod r#position; -pub(crate) mod r#position_bundle; -pub(crate) mod r#tick_array; -pub(crate) mod r#token_badge; -pub(crate) mod r#whirlpool; -pub(crate) mod r#whirlpools_config; -pub(crate) mod r#whirlpools_config_extension; - -pub use self::{ - r#adaptive_fee_tier::*, r#dynamic_tick_array::*, r#fee_tier::*, r#lock_config::*, r#oracle::*, - r#position::*, r#position_bundle::*, r#tick_array::*, r#token_badge::*, r#whirlpool::*, - r#whirlpools_config::*, r#whirlpools_config_extension::*, -}; diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/oracle.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/oracle.rs deleted file mode 100644 index 4eddd776..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/oracle.rs +++ /dev/null @@ -1,139 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{AdaptiveFeeConstants, AdaptiveFeeVariables}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Oracle { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whirlpool: Pubkey, - pub trade_enable_timestamp: u64, - pub adaptive_fee_constants: AdaptiveFeeConstants, - pub adaptive_fee_variables: AdaptiveFeeVariables, - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub reserved: [u8; 128], -} - -impl Oracle { - pub const LEN: usize = 254; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Oracle { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_oracle( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_oracle(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_oracle( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Oracle::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_oracle( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_oracle(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_oracle( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Oracle::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Oracle { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Oracle {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Oracle { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Oracle {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Oracle { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/position.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/position.rs deleted file mode 100644 index 2da5ec81..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/position.rs +++ /dev/null @@ -1,147 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::PositionRewardInfo; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Position { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whirlpool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position_mint: Pubkey, - pub liquidity: u128, - pub tick_lower_index: i32, - pub tick_upper_index: i32, - pub fee_growth_checkpoint_a: u128, - pub fee_owed_a: u64, - pub fee_growth_checkpoint_b: u128, - pub fee_owed_b: u64, - pub reward_infos: [PositionRewardInfo; 3], -} - -impl Position { - pub const LEN: usize = 216; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Position { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_position( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_position(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_position( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Position::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_position( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_position(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_position( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Position::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Position { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Position {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Position { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Position {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Position { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/position_bundle.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/position_bundle.rs deleted file mode 100644 index 05706cec..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/position_bundle.rs +++ /dev/null @@ -1,133 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PositionBundle { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub position_bundle_mint: Pubkey, - pub position_bitmap: [u8; 32], -} - -impl PositionBundle { - pub const LEN: usize = 72; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PositionBundle { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_position_bundle( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_position_bundle(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_position_bundle( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PositionBundle::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_position_bundle( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_position_bundle(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_position_bundle( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PositionBundle::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PositionBundle { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PositionBundle {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PositionBundle { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PositionBundle {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PositionBundle { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/tick_array.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/tick_array.rs deleted file mode 100644 index 03521c2a..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/tick_array.rs +++ /dev/null @@ -1,137 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::Tick; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TickArray { - pub discriminator: [u8; 8], - pub start_tick_index: i32, - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub ticks: [Tick; 88], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whirlpool: Pubkey, -} - -impl TickArray { - pub const LEN: usize = 9988; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for TickArray { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_tick_array( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_tick_array(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_tick_array( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = TickArray::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_tick_array( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_tick_array(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_tick_array( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = TickArray::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for TickArray { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for TickArray {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for TickArray { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for TickArray {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for TickArray { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/token_badge.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/token_badge.rs deleted file mode 100644 index 4a59f8c4..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/token_badge.rs +++ /dev/null @@ -1,137 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenBadge { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whirlpools_config: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_mint: Pubkey, -} - -impl TokenBadge { - pub const LEN: usize = 72; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for TokenBadge { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_token_badge(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = TokenBadge::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_token_badge(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_token_badge( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = TokenBadge::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for TokenBadge { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for TokenBadge {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for TokenBadge { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for TokenBadge {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for TokenBadge { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/whirlpool.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/whirlpool.rs deleted file mode 100644 index 4dc511ab..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/whirlpool.rs +++ /dev/null @@ -1,168 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::WhirlpoolRewardInfo; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Whirlpool { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whirlpools_config: Pubkey, - pub whirlpool_bump: [u8; 1], - pub tick_spacing: u16, - pub fee_tier_index_seed: [u8; 2], - pub fee_rate: u16, - pub protocol_fee_rate: u16, - pub liquidity: u128, - pub sqrt_price: u128, - pub tick_current_index: i32, - pub protocol_fee_owed_a: u64, - pub protocol_fee_owed_b: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_mint_a: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_vault_a: Pubkey, - pub fee_growth_global_a: u128, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_mint_b: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_vault_b: Pubkey, - pub fee_growth_global_b: u128, - pub reward_last_updated_timestamp: u64, - pub reward_infos: [WhirlpoolRewardInfo; 3], -} - -impl Whirlpool { - pub const LEN: usize = 653; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Whirlpool { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_whirlpool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_whirlpool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_whirlpool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Whirlpool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_whirlpool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_whirlpool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_whirlpool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Whirlpool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Whirlpool { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Whirlpool {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Whirlpool { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Whirlpool {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Whirlpool { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/whirlpools_config.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/whirlpools_config.rs deleted file mode 100644 index 76dc151b..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/whirlpools_config.rs +++ /dev/null @@ -1,143 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WhirlpoolsConfig { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub collect_protocol_fees_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub reward_emissions_super_authority: Pubkey, - pub default_protocol_fee_rate: u16, -} - -impl WhirlpoolsConfig { - pub const LEN: usize = 106; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for WhirlpoolsConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_whirlpools_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_whirlpools_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_whirlpools_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = WhirlpoolsConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_whirlpools_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_whirlpools_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_whirlpools_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = WhirlpoolsConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for WhirlpoolsConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for WhirlpoolsConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for WhirlpoolsConfig { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for WhirlpoolsConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for WhirlpoolsConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/whirlpools_config_extension.rs b/crates/orca-whirlpool-parser/src/generated_sdk/accounts/whirlpools_config_extension.rs deleted file mode 100644 index 70c67316..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/accounts/whirlpools_config_extension.rs +++ /dev/null @@ -1,144 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WhirlpoolsConfigExtension { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub whirlpools_config: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config_extension_authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_badge_authority: Pubkey, -} - -impl WhirlpoolsConfigExtension { - pub const LEN: usize = 104; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for WhirlpoolsConfigExtension { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_whirlpools_config_extension( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_whirlpools_config_extension(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_whirlpools_config_extension( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = WhirlpoolsConfigExtension::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_whirlpools_config_extension( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_whirlpools_config_extension(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_whirlpools_config_extension( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = WhirlpoolsConfigExtension::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for WhirlpoolsConfigExtension { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for WhirlpoolsConfigExtension {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for WhirlpoolsConfigExtension { - fn owner() -> Pubkey { crate::WHIRLPOOL_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for WhirlpoolsConfigExtension {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for WhirlpoolsConfigExtension { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/errors/mod.rs b/crates/orca-whirlpool-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 19b7f9f1..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod whirlpool; - -pub use self::whirlpool::WhirlpoolError; diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/errors/whirlpool.rs b/crates/orca-whirlpool-parser/src/generated_sdk/errors/whirlpool.rs deleted file mode 100644 index bc1d3565..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/errors/whirlpool.rs +++ /dev/null @@ -1,223 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum WhirlpoolError { - /// 6000 - Enum value could not be converted - #[error("Enum value could not be converted")] - InvalidEnum = 0x1770, - /// 6001 - Invalid start tick index provided. - #[error("Invalid start tick index provided.")] - InvalidStartTick = 0x1771, - /// 6002 - Tick-array already exists in this whirlpool - #[error("Tick-array already exists in this whirlpool")] - TickArrayExistInPool = 0x1772, - /// 6003 - Attempt to search for a tick-array failed - #[error("Attempt to search for a tick-array failed")] - TickArrayIndexOutofBounds = 0x1773, - /// 6004 - Tick-spacing is not supported - #[error("Tick-spacing is not supported")] - InvalidTickSpacing = 0x1774, - /// 6005 - Position is not empty It cannot be closed - #[error("Position is not empty It cannot be closed")] - ClosePositionNotEmpty = 0x1775, - /// 6006 - Unable to divide by zero - #[error("Unable to divide by zero")] - DivideByZero = 0x1776, - /// 6007 - Unable to cast number into BigInt - #[error("Unable to cast number into BigInt")] - NumberCastError = 0x1777, - /// 6008 - Unable to down cast number - #[error("Unable to down cast number")] - NumberDownCastError = 0x1778, - /// 6009 - Tick not found within tick array - #[error("Tick not found within tick array")] - TickNotFound = 0x1779, - /// 6010 - Provided tick index is either out of bounds or uninitializable - #[error("Provided tick index is either out of bounds or uninitializable")] - InvalidTickIndex = 0x177a, - /// 6011 - Provided sqrt price out of bounds - #[error("Provided sqrt price out of bounds")] - SqrtPriceOutOfBounds = 0x177b, - /// 6012 - Liquidity amount must be greater than zero - #[error("Liquidity amount must be greater than zero")] - LiquidityZero = 0x177c, - /// 6013 - Liquidity amount must be less than i64::MAX - #[error("Liquidity amount must be less than i64::MAX")] - LiquidityTooHigh = 0x177d, - /// 6014 - Liquidity overflow - #[error("Liquidity overflow")] - LiquidityOverflow = 0x177e, - /// 6015 - Liquidity underflow - #[error("Liquidity underflow")] - LiquidityUnderflow = 0x177f, - /// 6016 - Tick liquidity net underflowed or overflowed - #[error("Tick liquidity net underflowed or overflowed")] - LiquidityNetError = 0x1780, - /// 6017 - Exceeded token max - #[error("Exceeded token max")] - TokenMaxExceeded = 0x1781, - /// 6018 - Did not meet token min - #[error("Did not meet token min")] - TokenMinSubceeded = 0x1782, - /// 6019 - Position token account has a missing or invalid delegate - #[error("Position token account has a missing or invalid delegate")] - MissingOrInvalidDelegate = 0x1783, - /// 6020 - Position token amount must be 1 - #[error("Position token amount must be 1")] - InvalidPositionTokenAmount = 0x1784, - /// 6021 - Timestamp should be convertible from i64 to u64 - #[error("Timestamp should be convertible from i64 to u64")] - InvalidTimestampConversion = 0x1785, - /// 6022 - Timestamp should be greater than the last updated timestamp - #[error("Timestamp should be greater than the last updated timestamp")] - InvalidTimestamp = 0x1786, - /// 6023 - Invalid tick array sequence provided for instruction. - #[error("Invalid tick array sequence provided for instruction.")] - InvalidTickArraySequence = 0x1787, - /// 6024 - Token Mint in wrong order - #[error("Token Mint in wrong order")] - InvalidTokenMintOrder = 0x1788, - /// 6025 - Reward not initialized - #[error("Reward not initialized")] - RewardNotInitialized = 0x1789, - /// 6026 - Invalid reward index - #[error("Invalid reward index")] - InvalidRewardIndex = 0x178a, - /// 6027 - Reward vault requires amount to support emissions for at least one day - #[error("Reward vault requires amount to support emissions for at least one day")] - RewardVaultAmountInsufficient = 0x178b, - /// 6028 - Exceeded max fee rate - #[error("Exceeded max fee rate")] - FeeRateMaxExceeded = 0x178c, - /// 6029 - Exceeded max protocol fee rate - #[error("Exceeded max protocol fee rate")] - ProtocolFeeRateMaxExceeded = 0x178d, - /// 6030 - Multiplication with shift right overflow - #[error("Multiplication with shift right overflow")] - MultiplicationShiftRightOverflow = 0x178e, - /// 6031 - Muldiv overflow - #[error("Muldiv overflow")] - MulDivOverflow = 0x178f, - /// 6032 - Invalid div_u256 input - #[error("Invalid div_u256 input")] - MulDivInvalidInput = 0x1790, - /// 6033 - Multiplication overflow - #[error("Multiplication overflow")] - MultiplicationOverflow = 0x1791, - /// 6034 - Provided SqrtPriceLimit not in the same direction as the swap. - #[error("Provided SqrtPriceLimit not in the same direction as the swap.")] - InvalidSqrtPriceLimitDirection = 0x1792, - /// 6035 - There are no tradable amount to swap. - #[error("There are no tradable amount to swap.")] - ZeroTradableAmount = 0x1793, - /// 6036 - Amount out below minimum threshold - #[error("Amount out below minimum threshold")] - AmountOutBelowMinimum = 0x1794, - /// 6037 - Amount in above maximum threshold - #[error("Amount in above maximum threshold")] - AmountInAboveMaximum = 0x1795, - /// 6038 - Invalid index for tick array sequence - #[error("Invalid index for tick array sequence")] - TickArraySequenceInvalidIndex = 0x1796, - /// 6039 - Amount calculated overflows - #[error("Amount calculated overflows")] - AmountCalcOverflow = 0x1797, - /// 6040 - Amount remaining overflows - #[error("Amount remaining overflows")] - AmountRemainingOverflow = 0x1798, - /// 6041 - Invalid intermediary mint - #[error("Invalid intermediary mint")] - InvalidIntermediaryMint = 0x1799, - /// 6042 - Duplicate two hop pool - #[error("Duplicate two hop pool")] - DuplicateTwoHopPool = 0x179a, - /// 6043 - Bundle index is out of bounds - #[error("Bundle index is out of bounds")] - InvalidBundleIndex = 0x179b, - /// 6044 - Position has already been opened - #[error("Position has already been opened")] - BundledPositionAlreadyOpened = 0x179c, - /// 6045 - Position has already been closed - #[error("Position has already been closed")] - BundledPositionAlreadyClosed = 0x179d, - /// 6046 - Unable to delete PositionBundle with open positions - #[error("Unable to delete PositionBundle with open positions")] - PositionBundleNotDeletable = 0x179e, - /// 6047 - Token mint has unsupported attributes - #[error("Token mint has unsupported attributes")] - UnsupportedTokenMint = 0x179f, - /// 6048 - Invalid remaining accounts - #[error("Invalid remaining accounts")] - RemainingAccountsInvalidSlice = 0x17a0, - /// 6049 - Insufficient remaining accounts - #[error("Insufficient remaining accounts")] - RemainingAccountsInsufficient = 0x17a1, - /// 6050 - Unable to call transfer hook without extra accounts - #[error("Unable to call transfer hook without extra accounts")] - NoExtraAccountsForTransferHook = 0x17a2, - /// 6051 - Output and input amount mismatch - #[error("Output and input amount mismatch")] - IntermediateTokenAmountMismatch = 0x17a3, - /// 6052 - Transfer fee calculation failed - #[error("Transfer fee calculation failed")] - TransferFeeCalculationError = 0x17a4, - /// 6053 - Same accounts type is provided more than once - #[error("Same accounts type is provided more than once")] - RemainingAccountsDuplicatedAccountsType = 0x17a5, - /// 6054 - This whirlpool only supports full-range positions - #[error("This whirlpool only supports full-range positions")] - FullRangeOnlyPool = 0x17a6, - /// 6055 - Too many supplemental tick arrays provided - #[error("Too many supplemental tick arrays provided")] - TooManySupplementalTickArrays = 0x17a7, - /// 6056 - TickArray account for different whirlpool provided - #[error("TickArray account for different whirlpool provided")] - DifferentWhirlpoolTickArrayAccount = 0x17a8, - /// 6057 - Trade resulted in partial fill - #[error("Trade resulted in partial fill")] - PartialFillError = 0x17a9, - /// 6058 - Position is not lockable - #[error("Position is not lockable")] - PositionNotLockable = 0x17aa, - /// 6059 - Operation not allowed on locked position - #[error("Operation not allowed on locked position")] - OperationNotAllowedOnLockedPosition = 0x17ab, - /// 6060 - Cannot reset position range with same tick range - #[error("Cannot reset position range with same tick range")] - SameTickRangeNotAllowed = 0x17ac, - /// 6061 - Invalid adaptive fee constants - #[error("Invalid adaptive fee constants")] - InvalidAdaptiveFeeConstants = 0x17ad, - /// 6062 - Invalid fee tier index - #[error("Invalid fee tier index")] - InvalidFeeTierIndex = 0x17ae, - /// 6063 - Invalid trade enable timestamp - #[error("Invalid trade enable timestamp")] - InvalidTradeEnableTimestamp = 0x17af, - /// 6064 - Trade is not enabled yet - #[error("Trade is not enabled yet")] - TradeIsNotEnabled = 0x17b0, - /// 6065 - Rent calculation error - #[error("Rent calculation error")] - RentCalculationError = 0x17b1, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for WhirlpoolError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for WhirlpoolError { - fn type_of() -> &'static str { "WhirlpoolError" } -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/close_bundled_position.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/close_bundled_position.rs deleted file mode 100644 index 351394c4..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/close_bundled_position.rs +++ /dev/null @@ -1,496 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CloseBundledPosition { - pub bundled_position: solana_pubkey::Pubkey, - - pub position_bundle: solana_pubkey::Pubkey, - - pub position_bundle_token_account: solana_pubkey::Pubkey, - - pub position_bundle_authority: solana_pubkey::Pubkey, - - pub receiver: solana_pubkey::Pubkey, -} - -impl CloseBundledPosition { - pub fn instruction( - &self, - args: CloseBundledPositionInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CloseBundledPositionInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.bundled_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_bundle_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_bundle_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.receiver, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CloseBundledPositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseBundledPositionInstructionData { - discriminator: [u8; 8], -} - -impl CloseBundledPositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [41, 36, 216, 245, 27, 85, 103, 67], - } - } -} - -impl Default for CloseBundledPositionInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CloseBundledPositionInstructionArgs { - pub bundle_index: u16, -} - -/// Instruction builder for `CloseBundledPosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` bundled_position -/// 1. `[writable]` position_bundle -/// 2. `[]` position_bundle_token_account -/// 3. `[signer]` position_bundle_authority -/// 4. `[writable]` receiver -#[derive(Clone, Debug, Default)] -pub struct CloseBundledPositionBuilder { - bundled_position: Option, - position_bundle: Option, - position_bundle_token_account: Option, - position_bundle_authority: Option, - receiver: Option, - bundle_index: Option, - __remaining_accounts: Vec, -} - -impl CloseBundledPositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn bundled_position(&mut self, bundled_position: solana_pubkey::Pubkey) -> &mut Self { - self.bundled_position = Some(bundled_position); - self - } - - #[inline(always)] - pub fn position_bundle(&mut self, position_bundle: solana_pubkey::Pubkey) -> &mut Self { - self.position_bundle = Some(position_bundle); - self - } - - #[inline(always)] - pub fn position_bundle_token_account( - &mut self, - position_bundle_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_token_account = Some(position_bundle_token_account); - self - } - - #[inline(always)] - pub fn position_bundle_authority( - &mut self, - position_bundle_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_authority = Some(position_bundle_authority); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: solana_pubkey::Pubkey) -> &mut Self { - self.receiver = Some(receiver); - self - } - - #[inline(always)] - pub fn bundle_index(&mut self, bundle_index: u16) -> &mut Self { - self.bundle_index = Some(bundle_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CloseBundledPosition { - bundled_position: self.bundled_position.expect("bundled_position is not set"), - position_bundle: self.position_bundle.expect("position_bundle is not set"), - position_bundle_token_account: self - .position_bundle_token_account - .expect("position_bundle_token_account is not set"), - position_bundle_authority: self - .position_bundle_authority - .expect("position_bundle_authority is not set"), - receiver: self.receiver.expect("receiver is not set"), - }; - let args = CloseBundledPositionInstructionArgs { - bundle_index: self.bundle_index.clone().expect("bundle_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `close_bundled_position` CPI accounts. -pub struct CloseBundledPositionCpiAccounts<'a, 'b> { - pub bundled_position: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_authority: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_bundled_position` CPI instruction. -pub struct CloseBundledPositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub bundled_position: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_authority: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CloseBundledPositionInstructionArgs, -} - -impl<'a, 'b> CloseBundledPositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CloseBundledPositionCpiAccounts<'a, 'b>, - args: CloseBundledPositionInstructionArgs, - ) -> Self { - Self { - __program: program, - bundled_position: accounts.bundled_position, - position_bundle: accounts.position_bundle, - position_bundle_token_account: accounts.position_bundle_token_account, - position_bundle_authority: accounts.position_bundle_authority, - receiver: accounts.receiver, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.bundled_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_bundle_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_bundle_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.receiver.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CloseBundledPositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.bundled_position.clone()); - account_infos.push(self.position_bundle.clone()); - account_infos.push(self.position_bundle_token_account.clone()); - account_infos.push(self.position_bundle_authority.clone()); - account_infos.push(self.receiver.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CloseBundledPosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` bundled_position -/// 1. `[writable]` position_bundle -/// 2. `[]` position_bundle_token_account -/// 3. `[signer]` position_bundle_authority -/// 4. `[writable]` receiver -#[derive(Clone, Debug)] -pub struct CloseBundledPositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CloseBundledPositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CloseBundledPositionCpiBuilderInstruction { - __program: program, - bundled_position: None, - position_bundle: None, - position_bundle_token_account: None, - position_bundle_authority: None, - receiver: None, - bundle_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn bundled_position( - &mut self, - bundled_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bundled_position = Some(bundled_position); - self - } - - #[inline(always)] - pub fn position_bundle( - &mut self, - position_bundle: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle = Some(position_bundle); - self - } - - #[inline(always)] - pub fn position_bundle_token_account( - &mut self, - position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_token_account = Some(position_bundle_token_account); - self - } - - #[inline(always)] - pub fn position_bundle_authority( - &mut self, - position_bundle_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_authority = Some(position_bundle_authority); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.receiver = Some(receiver); - self - } - - #[inline(always)] - pub fn bundle_index(&mut self, bundle_index: u16) -> &mut Self { - self.instruction.bundle_index = Some(bundle_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CloseBundledPositionInstructionArgs { - bundle_index: self - .instruction - .bundle_index - .clone() - .expect("bundle_index is not set"), - }; - let instruction = CloseBundledPositionCpi { - __program: self.instruction.__program, - - bundled_position: self - .instruction - .bundled_position - .expect("bundled_position is not set"), - - position_bundle: self - .instruction - .position_bundle - .expect("position_bundle is not set"), - - position_bundle_token_account: self - .instruction - .position_bundle_token_account - .expect("position_bundle_token_account is not set"), - - position_bundle_authority: self - .instruction - .position_bundle_authority - .expect("position_bundle_authority is not set"), - - receiver: self.instruction.receiver.expect("receiver is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CloseBundledPositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - bundled_position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - bundle_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/close_position.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/close_position.rs deleted file mode 100644 index 72a7a2be..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/close_position.rs +++ /dev/null @@ -1,485 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClosePosition { - pub position_authority: solana_pubkey::Pubkey, - - pub receiver: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_mint: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl ClosePosition { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.receiver, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.position_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClosePositionInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClosePositionInstructionData { - discriminator: [u8; 8], -} - -impl ClosePositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [123, 134, 81, 0, 49, 68, 98, 98], - } - } -} - -impl Default for ClosePositionInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClosePosition`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` position_authority -/// 1. `[writable]` receiver -/// 2. `[writable]` position -/// 3. `[writable]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct ClosePositionBuilder { - position_authority: Option, - receiver: Option, - position: Option, - position_mint: Option, - position_token_account: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl ClosePositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: solana_pubkey::Pubkey) -> &mut Self { - self.receiver = Some(receiver); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint(&mut self, position_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClosePosition { - position_authority: self - .position_authority - .expect("position_authority is not set"), - receiver: self.receiver.expect("receiver is not set"), - position: self.position.expect("position is not set"), - position_mint: self.position_mint.expect("position_mint is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_position` CPI accounts. -pub struct ClosePositionCpiAccounts<'a, 'b> { - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_position` CPI instruction. -pub struct ClosePositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClosePositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClosePositionCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position_authority: accounts.position_authority, - receiver: accounts.receiver, - position: accounts.position, - position_mint: accounts.position_mint, - position_token_account: accounts.position_token_account, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClosePositionInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.receiver.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_mint.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClosePosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` position_authority -/// 1. `[writable]` receiver -/// 2. `[writable]` position -/// 3. `[writable]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[]` token_program -#[derive(Clone, Debug)] -pub struct ClosePositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClosePositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClosePositionCpiBuilderInstruction { - __program: program, - position_authority: None, - receiver: None, - position: None, - position_mint: None, - position_token_account: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.receiver = Some(receiver); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint( - &mut self, - position_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClosePositionCpi { - __program: self.instruction.__program, - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - receiver: self.instruction.receiver.expect("receiver is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_mint: self - .instruction - .position_mint - .expect("position_mint is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClosePositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/close_position_with_token_extensions.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/close_position_with_token_extensions.rs deleted file mode 100644 index 0a41fd37..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/close_position_with_token_extensions.rs +++ /dev/null @@ -1,484 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClosePositionWithTokenExtensions { - pub position_authority: solana_pubkey::Pubkey, - - pub receiver: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_mint: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub token2022_program: solana_pubkey::Pubkey, -} - -impl ClosePositionWithTokenExtensions { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.receiver, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.position_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClosePositionWithTokenExtensionsInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClosePositionWithTokenExtensionsInstructionData { - discriminator: [u8; 8], -} - -impl ClosePositionWithTokenExtensionsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [1, 182, 135, 59, 155, 25, 99, 223], - } - } -} - -impl Default for ClosePositionWithTokenExtensionsInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClosePositionWithTokenExtensions`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` position_authority -/// 1. `[writable]` receiver -/// 2. `[writable]` position -/// 3. `[writable]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[]` token2022_program -#[derive(Clone, Debug, Default)] -pub struct ClosePositionWithTokenExtensionsBuilder { - position_authority: Option, - receiver: Option, - position: Option, - position_mint: Option, - position_token_account: Option, - token2022_program: Option, - __remaining_accounts: Vec, -} - -impl ClosePositionWithTokenExtensionsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: solana_pubkey::Pubkey) -> &mut Self { - self.receiver = Some(receiver); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint(&mut self, position_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClosePositionWithTokenExtensions { - position_authority: self - .position_authority - .expect("position_authority is not set"), - receiver: self.receiver.expect("receiver is not set"), - position: self.position.expect("position is not set"), - position_mint: self.position_mint.expect("position_mint is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - token2022_program: self - .token2022_program - .expect("token2022_program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_position_with_token_extensions` CPI accounts. -pub struct ClosePositionWithTokenExtensionsCpiAccounts<'a, 'b> { - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_position_with_token_extensions` CPI instruction. -pub struct ClosePositionWithTokenExtensionsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClosePositionWithTokenExtensionsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClosePositionWithTokenExtensionsCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position_authority: accounts.position_authority, - receiver: accounts.receiver, - position: accounts.position, - position_mint: accounts.position_mint, - position_token_account: accounts.position_token_account, - token2022_program: accounts.token2022_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClosePositionWithTokenExtensionsInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.receiver.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_mint.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.token2022_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClosePositionWithTokenExtensions` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` position_authority -/// 1. `[writable]` receiver -/// 2. `[writable]` position -/// 3. `[writable]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[]` token2022_program -#[derive(Clone, Debug)] -pub struct ClosePositionWithTokenExtensionsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClosePositionWithTokenExtensionsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClosePositionWithTokenExtensionsCpiBuilderInstruction { - __program: program, - position_authority: None, - receiver: None, - position: None, - position_mint: None, - position_token_account: None, - token2022_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.receiver = Some(receiver); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint( - &mut self, - position_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClosePositionWithTokenExtensionsCpi { - __program: self.instruction.__program, - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - receiver: self.instruction.receiver.expect("receiver is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_mint: self - .instruction - .position_mint - .expect("position_mint is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClosePositionWithTokenExtensionsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_fees.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_fees.rs deleted file mode 100644 index cd3ed1be..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_fees.rs +++ /dev/null @@ -1,624 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CollectFees { - pub whirlpool: solana_pubkey::Pubkey, - - pub position_authority: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub token_owner_account_a: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_owner_account_b: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl CollectFees { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CollectFeesInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectFeesInstructionData { - discriminator: [u8; 8], -} - -impl CollectFeesInstructionData { - pub fn new() -> Self { - Self { - discriminator: [164, 152, 207, 99, 30, 186, 19, 182], - } - } -} - -impl Default for CollectFeesInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CollectFees`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[signer]` position_authority -/// 2. `[writable]` position -/// 3. `[]` position_token_account -/// 4. `[writable]` token_owner_account_a -/// 5. `[writable]` token_vault_a -/// 6. `[writable]` token_owner_account_b -/// 7. `[writable]` token_vault_b -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct CollectFeesBuilder { - whirlpool: Option, - position_authority: Option, - position: Option, - position_token_account: Option, - token_owner_account_a: Option, - token_vault_a: Option, - token_owner_account_b: Option, - token_vault_b: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl CollectFeesBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectFees { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - position_authority: self - .position_authority - .expect("position_authority is not set"), - position: self.position.expect("position is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - token_owner_account_a: self - .token_owner_account_a - .expect("token_owner_account_a is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_owner_account_b: self - .token_owner_account_b - .expect("token_owner_account_b is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `collect_fees` CPI accounts. -pub struct CollectFeesCpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_fees` CPI instruction. -pub struct CollectFeesCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CollectFeesCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectFeesCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - position_authority: accounts.position_authority, - position: accounts.position, - position_token_account: accounts.position_token_account, - token_owner_account_a: accounts.token_owner_account_a, - token_vault_a: accounts.token_vault_a, - token_owner_account_b: accounts.token_owner_account_b, - token_vault_b: accounts.token_vault_b, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CollectFeesInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.token_owner_account_a.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_owner_account_b.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectFees` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[signer]` position_authority -/// 2. `[writable]` position -/// 3. `[]` position_token_account -/// 4. `[writable]` token_owner_account_a -/// 5. `[writable]` token_vault_a -/// 6. `[writable]` token_owner_account_b -/// 7. `[writable]` token_vault_b -/// 8. `[]` token_program -#[derive(Clone, Debug)] -pub struct CollectFeesCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectFeesCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectFeesCpiBuilderInstruction { - __program: program, - whirlpool: None, - position_authority: None, - position: None, - position_token_account: None, - token_owner_account_a: None, - token_vault_a: None, - token_owner_account_b: None, - token_vault_b: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CollectFeesCpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - token_owner_account_a: self - .instruction - .token_owner_account_a - .expect("token_owner_account_a is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_owner_account_b: self - .instruction - .token_owner_account_b - .expect("token_owner_account_b is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectFeesCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_fees_v2.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_fees_v2.rs deleted file mode 100644 index 10d9b43e..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_fees_v2.rs +++ /dev/null @@ -1,839 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct CollectFeesV2 { - pub whirlpool: solana_pubkey::Pubkey, - - pub position_authority: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub token_mint_a: solana_pubkey::Pubkey, - - pub token_mint_b: solana_pubkey::Pubkey, - - pub token_owner_account_a: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_owner_account_b: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub token_program_a: solana_pubkey::Pubkey, - - pub token_program_b: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, -} - -impl CollectFeesV2 { - pub fn instruction( - &self, - args: CollectFeesV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CollectFeesV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CollectFeesV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectFeesV2InstructionData { - discriminator: [u8; 8], -} - -impl CollectFeesV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [207, 117, 95, 191, 229, 180, 226, 15], - } - } -} - -impl Default for CollectFeesV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectFeesV2InstructionArgs { - pub remaining_accounts_info: Option, -} - -/// Instruction builder for `CollectFeesV2`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[signer]` position_authority -/// 2. `[writable]` position -/// 3. `[]` position_token_account -/// 4. `[]` token_mint_a -/// 5. `[]` token_mint_b -/// 6. `[writable]` token_owner_account_a -/// 7. `[writable]` token_vault_a -/// 8. `[writable]` token_owner_account_b -/// 9. `[writable]` token_vault_b -/// 10. `[]` token_program_a -/// 11. `[]` token_program_b -/// 12. `[]` memo_program -#[derive(Clone, Debug, Default)] -pub struct CollectFeesV2Builder { - whirlpool: Option, - position_authority: Option, - position: Option, - position_token_account: Option, - token_mint_a: Option, - token_mint_b: Option, - token_owner_account_a: Option, - token_vault_a: Option, - token_owner_account_b: Option, - token_vault_b: Option, - token_program_a: Option, - token_program_b: Option, - memo_program: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl CollectFeesV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_mint_a(&mut self, token_mint_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b(&mut self, token_mint_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn token_program_a(&mut self, token_program_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b(&mut self, token_program_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectFeesV2 { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - position_authority: self - .position_authority - .expect("position_authority is not set"), - position: self.position.expect("position is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - token_mint_a: self.token_mint_a.expect("token_mint_a is not set"), - token_mint_b: self.token_mint_b.expect("token_mint_b is not set"), - token_owner_account_a: self - .token_owner_account_a - .expect("token_owner_account_a is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_owner_account_b: self - .token_owner_account_b - .expect("token_owner_account_b is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - token_program_a: self.token_program_a.expect("token_program_a is not set"), - token_program_b: self.token_program_b.expect("token_program_b is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - }; - let args = CollectFeesV2InstructionArgs { - remaining_accounts_info: self.remaining_accounts_info.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `collect_fees_v2` CPI accounts. -pub struct CollectFeesV2CpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_fees_v2` CPI instruction. -pub struct CollectFeesV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CollectFeesV2InstructionArgs, -} - -impl<'a, 'b> CollectFeesV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectFeesV2CpiAccounts<'a, 'b>, - args: CollectFeesV2InstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - position_authority: accounts.position_authority, - position: accounts.position, - position_token_account: accounts.position_token_account, - token_mint_a: accounts.token_mint_a, - token_mint_b: accounts.token_mint_b, - token_owner_account_a: accounts.token_owner_account_a, - token_vault_a: accounts.token_vault_a, - token_owner_account_b: accounts.token_owner_account_b, - token_vault_b: accounts.token_vault_b, - token_program_a: accounts.token_program_a, - token_program_b: accounts.token_program_b, - memo_program: accounts.memo_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CollectFeesV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.token_mint_a.clone()); - account_infos.push(self.token_mint_b.clone()); - account_infos.push(self.token_owner_account_a.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_owner_account_b.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.token_program_a.clone()); - account_infos.push(self.token_program_b.clone()); - account_infos.push(self.memo_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectFeesV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[signer]` position_authority -/// 2. `[writable]` position -/// 3. `[]` position_token_account -/// 4. `[]` token_mint_a -/// 5. `[]` token_mint_b -/// 6. `[writable]` token_owner_account_a -/// 7. `[writable]` token_vault_a -/// 8. `[writable]` token_owner_account_b -/// 9. `[writable]` token_vault_b -/// 10. `[]` token_program_a -/// 11. `[]` token_program_b -/// 12. `[]` memo_program -#[derive(Clone, Debug)] -pub struct CollectFeesV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectFeesV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectFeesV2CpiBuilderInstruction { - __program: program, - whirlpool: None, - position_authority: None, - position: None, - position_token_account: None, - token_mint_a: None, - token_mint_b: None, - token_owner_account_a: None, - token_vault_a: None, - token_owner_account_b: None, - token_vault_b: None, - token_program_a: None, - token_program_b: None, - memo_program: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_mint_a( - &mut self, - token_mint_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b( - &mut self, - token_mint_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn token_program_a( - &mut self, - token_program_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b( - &mut self, - token_program_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CollectFeesV2InstructionArgs { - remaining_accounts_info: self.instruction.remaining_accounts_info.clone(), - }; - let instruction = CollectFeesV2Cpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - token_mint_a: self - .instruction - .token_mint_a - .expect("token_mint_a is not set"), - - token_mint_b: self - .instruction - .token_mint_b - .expect("token_mint_b is not set"), - - token_owner_account_a: self - .instruction - .token_owner_account_a - .expect("token_owner_account_a is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_owner_account_b: self - .instruction - .token_owner_account_b - .expect("token_owner_account_b is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - token_program_a: self - .instruction - .token_program_a - .expect("token_program_a is not set"), - - token_program_b: self - .instruction - .token_program_b - .expect("token_program_b is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectFeesV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_b: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_protocol_fees.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_protocol_fees.rs deleted file mode 100644 index 5c45f949..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_protocol_fees.rs +++ /dev/null @@ -1,582 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CollectProtocolFees { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub collect_protocol_fees_authority: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub token_destination_a: solana_pubkey::Pubkey, - - pub token_destination_b: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl CollectProtocolFees { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.collect_protocol_fees_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_destination_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_destination_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CollectProtocolFeesInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectProtocolFeesInstructionData { - discriminator: [u8; 8], -} - -impl CollectProtocolFeesInstructionData { - pub fn new() -> Self { - Self { - discriminator: [22, 67, 23, 98, 150, 178, 70, 220], - } - } -} - -impl Default for CollectProtocolFeesInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CollectProtocolFees`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpool -/// 2. `[signer]` collect_protocol_fees_authority -/// 3. `[writable]` token_vault_a -/// 4. `[writable]` token_vault_b -/// 5. `[writable]` token_destination_a -/// 6. `[writable]` token_destination_b -/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct CollectProtocolFeesBuilder { - whirlpools_config: Option, - whirlpool: Option, - collect_protocol_fees_authority: Option, - token_vault_a: Option, - token_vault_b: Option, - token_destination_a: Option, - token_destination_b: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl CollectProtocolFeesBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn collect_protocol_fees_authority( - &mut self, - collect_protocol_fees_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.collect_protocol_fees_authority = Some(collect_protocol_fees_authority); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn token_destination_a(&mut self, token_destination_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_destination_a = Some(token_destination_a); - self - } - - #[inline(always)] - pub fn token_destination_b(&mut self, token_destination_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_destination_b = Some(token_destination_b); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectProtocolFees { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - collect_protocol_fees_authority: self - .collect_protocol_fees_authority - .expect("collect_protocol_fees_authority is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - token_destination_a: self - .token_destination_a - .expect("token_destination_a is not set"), - token_destination_b: self - .token_destination_b - .expect("token_destination_b is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `collect_protocol_fees` CPI accounts. -pub struct CollectProtocolFeesCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_destination_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_destination_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_protocol_fees` CPI instruction. -pub struct CollectProtocolFeesCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_destination_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_destination_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CollectProtocolFeesCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectProtocolFeesCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - whirlpool: accounts.whirlpool, - collect_protocol_fees_authority: accounts.collect_protocol_fees_authority, - token_vault_a: accounts.token_vault_a, - token_vault_b: accounts.token_vault_b, - token_destination_a: accounts.token_destination_a, - token_destination_b: accounts.token_destination_b, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.collect_protocol_fees_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_destination_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_destination_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CollectProtocolFeesInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.collect_protocol_fees_authority.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.token_destination_a.clone()); - account_infos.push(self.token_destination_b.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectProtocolFees` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpool -/// 2. `[signer]` collect_protocol_fees_authority -/// 3. `[writable]` token_vault_a -/// 4. `[writable]` token_vault_b -/// 5. `[writable]` token_destination_a -/// 6. `[writable]` token_destination_b -/// 7. `[]` token_program -#[derive(Clone, Debug)] -pub struct CollectProtocolFeesCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectProtocolFeesCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectProtocolFeesCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - whirlpool: None, - collect_protocol_fees_authority: None, - token_vault_a: None, - token_vault_b: None, - token_destination_a: None, - token_destination_b: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn collect_protocol_fees_authority( - &mut self, - collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.collect_protocol_fees_authority = Some(collect_protocol_fees_authority); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn token_destination_a( - &mut self, - token_destination_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_destination_a = Some(token_destination_a); - self - } - - #[inline(always)] - pub fn token_destination_b( - &mut self, - token_destination_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_destination_b = Some(token_destination_b); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CollectProtocolFeesCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - collect_protocol_fees_authority: self - .instruction - .collect_protocol_fees_authority - .expect("collect_protocol_fees_authority is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - token_destination_a: self - .instruction - .token_destination_a - .expect("token_destination_a is not set"), - - token_destination_b: self - .instruction - .token_destination_b - .expect("token_destination_b is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectProtocolFeesCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - collect_protocol_fees_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_destination_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_destination_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_protocol_fees_v2.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_protocol_fees_v2.rs deleted file mode 100644 index 908ba666..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_protocol_fees_v2.rs +++ /dev/null @@ -1,797 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct CollectProtocolFeesV2 { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub collect_protocol_fees_authority: solana_pubkey::Pubkey, - - pub token_mint_a: solana_pubkey::Pubkey, - - pub token_mint_b: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub token_destination_a: solana_pubkey::Pubkey, - - pub token_destination_b: solana_pubkey::Pubkey, - - pub token_program_a: solana_pubkey::Pubkey, - - pub token_program_b: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, -} - -impl CollectProtocolFeesV2 { - pub fn instruction( - &self, - args: CollectProtocolFeesV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CollectProtocolFeesV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.collect_protocol_fees_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_destination_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_destination_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CollectProtocolFeesV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectProtocolFeesV2InstructionData { - discriminator: [u8; 8], -} - -impl CollectProtocolFeesV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [103, 128, 222, 134, 114, 200, 22, 200], - } - } -} - -impl Default for CollectProtocolFeesV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectProtocolFeesV2InstructionArgs { - pub remaining_accounts_info: Option, -} - -/// Instruction builder for `CollectProtocolFeesV2`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpool -/// 2. `[signer]` collect_protocol_fees_authority -/// 3. `[]` token_mint_a -/// 4. `[]` token_mint_b -/// 5. `[writable]` token_vault_a -/// 6. `[writable]` token_vault_b -/// 7. `[writable]` token_destination_a -/// 8. `[writable]` token_destination_b -/// 9. `[]` token_program_a -/// 10. `[]` token_program_b -/// 11. `[]` memo_program -#[derive(Clone, Debug, Default)] -pub struct CollectProtocolFeesV2Builder { - whirlpools_config: Option, - whirlpool: Option, - collect_protocol_fees_authority: Option, - token_mint_a: Option, - token_mint_b: Option, - token_vault_a: Option, - token_vault_b: Option, - token_destination_a: Option, - token_destination_b: Option, - token_program_a: Option, - token_program_b: Option, - memo_program: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl CollectProtocolFeesV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn collect_protocol_fees_authority( - &mut self, - collect_protocol_fees_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.collect_protocol_fees_authority = Some(collect_protocol_fees_authority); - self - } - - #[inline(always)] - pub fn token_mint_a(&mut self, token_mint_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b(&mut self, token_mint_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn token_destination_a(&mut self, token_destination_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_destination_a = Some(token_destination_a); - self - } - - #[inline(always)] - pub fn token_destination_b(&mut self, token_destination_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_destination_b = Some(token_destination_b); - self - } - - #[inline(always)] - pub fn token_program_a(&mut self, token_program_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b(&mut self, token_program_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectProtocolFeesV2 { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - collect_protocol_fees_authority: self - .collect_protocol_fees_authority - .expect("collect_protocol_fees_authority is not set"), - token_mint_a: self.token_mint_a.expect("token_mint_a is not set"), - token_mint_b: self.token_mint_b.expect("token_mint_b is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - token_destination_a: self - .token_destination_a - .expect("token_destination_a is not set"), - token_destination_b: self - .token_destination_b - .expect("token_destination_b is not set"), - token_program_a: self.token_program_a.expect("token_program_a is not set"), - token_program_b: self.token_program_b.expect("token_program_b is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - }; - let args = CollectProtocolFeesV2InstructionArgs { - remaining_accounts_info: self.remaining_accounts_info.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `collect_protocol_fees_v2` CPI accounts. -pub struct CollectProtocolFeesV2CpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_destination_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_destination_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_protocol_fees_v2` CPI instruction. -pub struct CollectProtocolFeesV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_destination_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_destination_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CollectProtocolFeesV2InstructionArgs, -} - -impl<'a, 'b> CollectProtocolFeesV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectProtocolFeesV2CpiAccounts<'a, 'b>, - args: CollectProtocolFeesV2InstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - whirlpool: accounts.whirlpool, - collect_protocol_fees_authority: accounts.collect_protocol_fees_authority, - token_mint_a: accounts.token_mint_a, - token_mint_b: accounts.token_mint_b, - token_vault_a: accounts.token_vault_a, - token_vault_b: accounts.token_vault_b, - token_destination_a: accounts.token_destination_a, - token_destination_b: accounts.token_destination_b, - token_program_a: accounts.token_program_a, - token_program_b: accounts.token_program_b, - memo_program: accounts.memo_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.collect_protocol_fees_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_destination_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_destination_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CollectProtocolFeesV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.collect_protocol_fees_authority.clone()); - account_infos.push(self.token_mint_a.clone()); - account_infos.push(self.token_mint_b.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.token_destination_a.clone()); - account_infos.push(self.token_destination_b.clone()); - account_infos.push(self.token_program_a.clone()); - account_infos.push(self.token_program_b.clone()); - account_infos.push(self.memo_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectProtocolFeesV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpool -/// 2. `[signer]` collect_protocol_fees_authority -/// 3. `[]` token_mint_a -/// 4. `[]` token_mint_b -/// 5. `[writable]` token_vault_a -/// 6. `[writable]` token_vault_b -/// 7. `[writable]` token_destination_a -/// 8. `[writable]` token_destination_b -/// 9. `[]` token_program_a -/// 10. `[]` token_program_b -/// 11. `[]` memo_program -#[derive(Clone, Debug)] -pub struct CollectProtocolFeesV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectProtocolFeesV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectProtocolFeesV2CpiBuilderInstruction { - __program: program, - whirlpools_config: None, - whirlpool: None, - collect_protocol_fees_authority: None, - token_mint_a: None, - token_mint_b: None, - token_vault_a: None, - token_vault_b: None, - token_destination_a: None, - token_destination_b: None, - token_program_a: None, - token_program_b: None, - memo_program: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn collect_protocol_fees_authority( - &mut self, - collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.collect_protocol_fees_authority = Some(collect_protocol_fees_authority); - self - } - - #[inline(always)] - pub fn token_mint_a( - &mut self, - token_mint_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b( - &mut self, - token_mint_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn token_destination_a( - &mut self, - token_destination_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_destination_a = Some(token_destination_a); - self - } - - #[inline(always)] - pub fn token_destination_b( - &mut self, - token_destination_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_destination_b = Some(token_destination_b); - self - } - - #[inline(always)] - pub fn token_program_a( - &mut self, - token_program_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b( - &mut self, - token_program_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CollectProtocolFeesV2InstructionArgs { - remaining_accounts_info: self.instruction.remaining_accounts_info.clone(), - }; - let instruction = CollectProtocolFeesV2Cpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - collect_protocol_fees_authority: self - .instruction - .collect_protocol_fees_authority - .expect("collect_protocol_fees_authority is not set"), - - token_mint_a: self - .instruction - .token_mint_a - .expect("token_mint_a is not set"), - - token_mint_b: self - .instruction - .token_mint_b - .expect("token_mint_b is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - token_destination_a: self - .instruction - .token_destination_a - .expect("token_destination_a is not set"), - - token_destination_b: self - .instruction - .token_destination_b - .expect("token_destination_b is not set"), - - token_program_a: self - .instruction - .token_program_a - .expect("token_program_a is not set"), - - token_program_b: self - .instruction - .token_program_b - .expect("token_program_b is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectProtocolFeesV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - collect_protocol_fees_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_destination_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_destination_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_b: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_reward.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_reward.rs deleted file mode 100644 index 92a798ef..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_reward.rs +++ /dev/null @@ -1,579 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CollectReward { - pub whirlpool: solana_pubkey::Pubkey, - - pub position_authority: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub reward_owner_account: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl CollectReward { - pub fn instruction( - &self, - args: CollectRewardInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CollectRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_owner_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CollectRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectRewardInstructionData { - discriminator: [u8; 8], -} - -impl CollectRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [70, 5, 132, 87, 86, 235, 177, 34], - } - } -} - -impl Default for CollectRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectRewardInstructionArgs { - pub reward_index: u8, -} - -/// Instruction builder for `CollectReward`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[signer]` position_authority -/// 2. `[writable]` position -/// 3. `[]` position_token_account -/// 4. `[writable]` reward_owner_account -/// 5. `[writable]` reward_vault -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct CollectRewardBuilder { - whirlpool: Option, - position_authority: Option, - position: Option, - position_token_account: Option, - reward_owner_account: Option, - reward_vault: Option, - token_program: Option, - reward_index: Option, - __remaining_accounts: Vec, -} - -impl CollectRewardBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn reward_owner_account( - &mut self, - reward_owner_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.reward_owner_account = Some(reward_owner_account); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectReward { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - position_authority: self - .position_authority - .expect("position_authority is not set"), - position: self.position.expect("position is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - reward_owner_account: self - .reward_owner_account - .expect("reward_owner_account is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = CollectRewardInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `collect_reward` CPI accounts. -pub struct CollectRewardCpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub reward_owner_account: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_reward` CPI instruction. -pub struct CollectRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub reward_owner_account: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CollectRewardInstructionArgs, -} - -impl<'a, 'b> CollectRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectRewardCpiAccounts<'a, 'b>, - args: CollectRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - position_authority: accounts.position_authority, - position: accounts.position, - position_token_account: accounts.position_token_account, - reward_owner_account: accounts.reward_owner_account, - reward_vault: accounts.reward_vault, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_owner_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CollectRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.reward_owner_account.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[signer]` position_authority -/// 2. `[writable]` position -/// 3. `[]` position_token_account -/// 4. `[writable]` reward_owner_account -/// 5. `[writable]` reward_vault -/// 6. `[]` token_program -#[derive(Clone, Debug)] -pub struct CollectRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectRewardCpiBuilderInstruction { - __program: program, - whirlpool: None, - position_authority: None, - position: None, - position_token_account: None, - reward_owner_account: None, - reward_vault: None, - token_program: None, - reward_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn reward_owner_account( - &mut self, - reward_owner_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_owner_account = Some(reward_owner_account); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CollectRewardInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - }; - let instruction = CollectRewardCpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - reward_owner_account: self - .instruction - .reward_owner_account - .expect("reward_owner_account is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_owner_account: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_reward_v2.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_reward_v2.rs deleted file mode 100644 index 84a185d8..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/collect_reward_v2.rs +++ /dev/null @@ -1,693 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct CollectRewardV2 { - pub whirlpool: solana_pubkey::Pubkey, - - pub position_authority: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub reward_owner_account: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_token_program: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, -} - -impl CollectRewardV2 { - pub fn instruction( - &self, - args: CollectRewardV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CollectRewardV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_owner_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CollectRewardV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectRewardV2InstructionData { - discriminator: [u8; 8], -} - -impl CollectRewardV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [177, 107, 37, 180, 160, 19, 49, 209], - } - } -} - -impl Default for CollectRewardV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectRewardV2InstructionArgs { - pub reward_index: u8, - pub remaining_accounts_info: Option, -} - -/// Instruction builder for `CollectRewardV2`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[signer]` position_authority -/// 2. `[writable]` position -/// 3. `[]` position_token_account -/// 4. `[writable]` reward_owner_account -/// 5. `[]` reward_mint -/// 6. `[writable]` reward_vault -/// 7. `[]` reward_token_program -/// 8. `[]` memo_program -#[derive(Clone, Debug, Default)] -pub struct CollectRewardV2Builder { - whirlpool: Option, - position_authority: Option, - position: Option, - position_token_account: Option, - reward_owner_account: Option, - reward_mint: Option, - reward_vault: Option, - reward_token_program: Option, - memo_program: Option, - reward_index: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl CollectRewardV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn reward_owner_account( - &mut self, - reward_owner_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.reward_owner_account = Some(reward_owner_account); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_token_program( - &mut self, - reward_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.reward_token_program = Some(reward_token_program); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectRewardV2 { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - position_authority: self - .position_authority - .expect("position_authority is not set"), - position: self.position.expect("position is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - reward_owner_account: self - .reward_owner_account - .expect("reward_owner_account is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_token_program: self - .reward_token_program - .expect("reward_token_program is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - }; - let args = CollectRewardV2InstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - remaining_accounts_info: self.remaining_accounts_info.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `collect_reward_v2` CPI accounts. -pub struct CollectRewardV2CpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub reward_owner_account: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_reward_v2` CPI instruction. -pub struct CollectRewardV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub reward_owner_account: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CollectRewardV2InstructionArgs, -} - -impl<'a, 'b> CollectRewardV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectRewardV2CpiAccounts<'a, 'b>, - args: CollectRewardV2InstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - position_authority: accounts.position_authority, - position: accounts.position, - position_token_account: accounts.position_token_account, - reward_owner_account: accounts.reward_owner_account, - reward_mint: accounts.reward_mint, - reward_vault: accounts.reward_vault, - reward_token_program: accounts.reward_token_program, - memo_program: accounts.memo_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_owner_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CollectRewardV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.reward_owner_account.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_token_program.clone()); - account_infos.push(self.memo_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectRewardV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[signer]` position_authority -/// 2. `[writable]` position -/// 3. `[]` position_token_account -/// 4. `[writable]` reward_owner_account -/// 5. `[]` reward_mint -/// 6. `[writable]` reward_vault -/// 7. `[]` reward_token_program -/// 8. `[]` memo_program -#[derive(Clone, Debug)] -pub struct CollectRewardV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectRewardV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectRewardV2CpiBuilderInstruction { - __program: program, - whirlpool: None, - position_authority: None, - position: None, - position_token_account: None, - reward_owner_account: None, - reward_mint: None, - reward_vault: None, - reward_token_program: None, - memo_program: None, - reward_index: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn reward_owner_account( - &mut self, - reward_owner_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_owner_account = Some(reward_owner_account); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_token_program( - &mut self, - reward_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_token_program = Some(reward_token_program); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CollectRewardV2InstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - remaining_accounts_info: self.instruction.remaining_accounts_info.clone(), - }; - let instruction = CollectRewardV2Cpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - reward_owner_account: self - .instruction - .reward_owner_account - .expect("reward_owner_account is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_token_program: self - .instruction - .reward_token_program - .expect("reward_token_program is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectRewardV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_owner_account: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/decrease_liquidity.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/decrease_liquidity.rs deleted file mode 100644 index bfaf4267..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/decrease_liquidity.rs +++ /dev/null @@ -1,796 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct DecreaseLiquidity { - pub whirlpool: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub position_authority: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub token_owner_account_a: solana_pubkey::Pubkey, - - pub token_owner_account_b: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, -} - -impl DecreaseLiquidity { - pub fn instruction( - &self, - args: DecreaseLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DecreaseLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DecreaseLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DecreaseLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl DecreaseLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [160, 38, 208, 111, 104, 91, 44, 1], - } - } -} - -impl Default for DecreaseLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DecreaseLiquidityInstructionArgs { - pub liquidity_amount: u128, - pub token_min_a: u64, - pub token_min_b: u64, -} - -/// Instruction builder for `DecreaseLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 2. `[signer]` position_authority -/// 3. `[writable]` position -/// 4. `[]` position_token_account -/// 5. `[writable]` token_owner_account_a -/// 6. `[writable]` token_owner_account_b -/// 7. `[writable]` token_vault_a -/// 8. `[writable]` token_vault_b -/// 9. `[writable]` tick_array_lower -/// 10. `[writable]` tick_array_upper -#[derive(Clone, Debug, Default)] -pub struct DecreaseLiquidityBuilder { - whirlpool: Option, - token_program: Option, - position_authority: Option, - position: Option, - position_token_account: Option, - token_owner_account_a: Option, - token_owner_account_b: Option, - token_vault_a: Option, - token_vault_b: Option, - tick_array_lower: Option, - tick_array_upper: Option, - liquidity_amount: Option, - token_min_a: Option, - token_min_b: Option, - __remaining_accounts: Vec, -} - -impl DecreaseLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn liquidity_amount(&mut self, liquidity_amount: u128) -> &mut Self { - self.liquidity_amount = Some(liquidity_amount); - self - } - - #[inline(always)] - pub fn token_min_a(&mut self, token_min_a: u64) -> &mut Self { - self.token_min_a = Some(token_min_a); - self - } - - #[inline(always)] - pub fn token_min_b(&mut self, token_min_b: u64) -> &mut Self { - self.token_min_b = Some(token_min_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = DecreaseLiquidity { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - position_authority: self - .position_authority - .expect("position_authority is not set"), - position: self.position.expect("position is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - token_owner_account_a: self - .token_owner_account_a - .expect("token_owner_account_a is not set"), - token_owner_account_b: self - .token_owner_account_b - .expect("token_owner_account_b is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - }; - let args = DecreaseLiquidityInstructionArgs { - liquidity_amount: self - .liquidity_amount - .clone() - .expect("liquidity_amount is not set"), - token_min_a: self.token_min_a.clone().expect("token_min_a is not set"), - token_min_b: self.token_min_b.clone().expect("token_min_b is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `decrease_liquidity` CPI accounts. -pub struct DecreaseLiquidityCpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, -} - -/// `decrease_liquidity` CPI instruction. -pub struct DecreaseLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DecreaseLiquidityInstructionArgs, -} - -impl<'a, 'b> DecreaseLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DecreaseLiquidityCpiAccounts<'a, 'b>, - args: DecreaseLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - token_program: accounts.token_program, - position_authority: accounts.position_authority, - position: accounts.position, - position_token_account: accounts.position_token_account, - token_owner_account_a: accounts.token_owner_account_a, - token_owner_account_b: accounts.token_owner_account_b, - token_vault_a: accounts.token_vault_a, - token_vault_b: accounts.token_vault_b, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DecreaseLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.token_owner_account_a.clone()); - account_infos.push(self.token_owner_account_b.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `DecreaseLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[]` token_program -/// 2. `[signer]` position_authority -/// 3. `[writable]` position -/// 4. `[]` position_token_account -/// 5. `[writable]` token_owner_account_a -/// 6. `[writable]` token_owner_account_b -/// 7. `[writable]` token_vault_a -/// 8. `[writable]` token_vault_b -/// 9. `[writable]` tick_array_lower -/// 10. `[writable]` tick_array_upper -#[derive(Clone, Debug)] -pub struct DecreaseLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DecreaseLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DecreaseLiquidityCpiBuilderInstruction { - __program: program, - whirlpool: None, - token_program: None, - position_authority: None, - position: None, - position_token_account: None, - token_owner_account_a: None, - token_owner_account_b: None, - token_vault_a: None, - token_vault_b: None, - tick_array_lower: None, - tick_array_upper: None, - liquidity_amount: None, - token_min_a: None, - token_min_b: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn liquidity_amount(&mut self, liquidity_amount: u128) -> &mut Self { - self.instruction.liquidity_amount = Some(liquidity_amount); - self - } - - #[inline(always)] - pub fn token_min_a(&mut self, token_min_a: u64) -> &mut Self { - self.instruction.token_min_a = Some(token_min_a); - self - } - - #[inline(always)] - pub fn token_min_b(&mut self, token_min_b: u64) -> &mut Self { - self.instruction.token_min_b = Some(token_min_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DecreaseLiquidityInstructionArgs { - liquidity_amount: self - .instruction - .liquidity_amount - .clone() - .expect("liquidity_amount is not set"), - token_min_a: self - .instruction - .token_min_a - .clone() - .expect("token_min_a is not set"), - token_min_b: self - .instruction - .token_min_b - .clone() - .expect("token_min_b is not set"), - }; - let instruction = DecreaseLiquidityCpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - token_owner_account_a: self - .instruction - .token_owner_account_a - .expect("token_owner_account_a is not set"), - - token_owner_account_b: self - .instruction - .token_owner_account_b - .expect("token_owner_account_b is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DecreaseLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity_amount: Option, - token_min_a: Option, - token_min_b: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/decrease_liquidity_v2.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/decrease_liquidity_v2.rs deleted file mode 100644 index d3ac8163..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/decrease_liquidity_v2.rs +++ /dev/null @@ -1,989 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct DecreaseLiquidityV2 { - pub whirlpool: solana_pubkey::Pubkey, - - pub token_program_a: solana_pubkey::Pubkey, - - pub token_program_b: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub position_authority: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub token_mint_a: solana_pubkey::Pubkey, - - pub token_mint_b: solana_pubkey::Pubkey, - - pub token_owner_account_a: solana_pubkey::Pubkey, - - pub token_owner_account_b: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, -} - -impl DecreaseLiquidityV2 { - pub fn instruction( - &self, - args: DecreaseLiquidityV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DecreaseLiquidityV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DecreaseLiquidityV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DecreaseLiquidityV2InstructionData { - discriminator: [u8; 8], -} - -impl DecreaseLiquidityV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [58, 127, 188, 62, 79, 82, 196, 96], - } - } -} - -impl Default for DecreaseLiquidityV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DecreaseLiquidityV2InstructionArgs { - pub liquidity_amount: u128, - pub token_min_a: u64, - pub token_min_b: u64, - pub remaining_accounts_info: Option, -} - -/// Instruction builder for `DecreaseLiquidityV2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[]` token_program_a -/// 2. `[]` token_program_b -/// 3. `[]` memo_program -/// 4. `[signer]` position_authority -/// 5. `[writable]` position -/// 6. `[]` position_token_account -/// 7. `[]` token_mint_a -/// 8. `[]` token_mint_b -/// 9. `[writable]` token_owner_account_a -/// 10. `[writable]` token_owner_account_b -/// 11. `[writable]` token_vault_a -/// 12. `[writable]` token_vault_b -/// 13. `[writable]` tick_array_lower -/// 14. `[writable]` tick_array_upper -#[derive(Clone, Debug, Default)] -pub struct DecreaseLiquidityV2Builder { - whirlpool: Option, - token_program_a: Option, - token_program_b: Option, - memo_program: Option, - position_authority: Option, - position: Option, - position_token_account: Option, - token_mint_a: Option, - token_mint_b: Option, - token_owner_account_a: Option, - token_owner_account_b: Option, - token_vault_a: Option, - token_vault_b: Option, - tick_array_lower: Option, - tick_array_upper: Option, - liquidity_amount: Option, - token_min_a: Option, - token_min_b: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl DecreaseLiquidityV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_program_a(&mut self, token_program_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b(&mut self, token_program_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_mint_a(&mut self, token_mint_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b(&mut self, token_mint_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn liquidity_amount(&mut self, liquidity_amount: u128) -> &mut Self { - self.liquidity_amount = Some(liquidity_amount); - self - } - - #[inline(always)] - pub fn token_min_a(&mut self, token_min_a: u64) -> &mut Self { - self.token_min_a = Some(token_min_a); - self - } - - #[inline(always)] - pub fn token_min_b(&mut self, token_min_b: u64) -> &mut Self { - self.token_min_b = Some(token_min_b); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = DecreaseLiquidityV2 { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token_program_a: self.token_program_a.expect("token_program_a is not set"), - token_program_b: self.token_program_b.expect("token_program_b is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - position_authority: self - .position_authority - .expect("position_authority is not set"), - position: self.position.expect("position is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - token_mint_a: self.token_mint_a.expect("token_mint_a is not set"), - token_mint_b: self.token_mint_b.expect("token_mint_b is not set"), - token_owner_account_a: self - .token_owner_account_a - .expect("token_owner_account_a is not set"), - token_owner_account_b: self - .token_owner_account_b - .expect("token_owner_account_b is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - }; - let args = DecreaseLiquidityV2InstructionArgs { - liquidity_amount: self - .liquidity_amount - .clone() - .expect("liquidity_amount is not set"), - token_min_a: self.token_min_a.clone().expect("token_min_a is not set"), - token_min_b: self.token_min_b.clone().expect("token_min_b is not set"), - remaining_accounts_info: self.remaining_accounts_info.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `decrease_liquidity_v2` CPI accounts. -pub struct DecreaseLiquidityV2CpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, -} - -/// `decrease_liquidity_v2` CPI instruction. -pub struct DecreaseLiquidityV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DecreaseLiquidityV2InstructionArgs, -} - -impl<'a, 'b> DecreaseLiquidityV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DecreaseLiquidityV2CpiAccounts<'a, 'b>, - args: DecreaseLiquidityV2InstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - token_program_a: accounts.token_program_a, - token_program_b: accounts.token_program_b, - memo_program: accounts.memo_program, - position_authority: accounts.position_authority, - position: accounts.position, - position_token_account: accounts.position_token_account, - token_mint_a: accounts.token_mint_a, - token_mint_b: accounts.token_mint_b, - token_owner_account_a: accounts.token_owner_account_a, - token_owner_account_b: accounts.token_owner_account_b, - token_vault_a: accounts.token_vault_a, - token_vault_b: accounts.token_vault_b, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DecreaseLiquidityV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token_program_a.clone()); - account_infos.push(self.token_program_b.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.token_mint_a.clone()); - account_infos.push(self.token_mint_b.clone()); - account_infos.push(self.token_owner_account_a.clone()); - account_infos.push(self.token_owner_account_b.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `DecreaseLiquidityV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[]` token_program_a -/// 2. `[]` token_program_b -/// 3. `[]` memo_program -/// 4. `[signer]` position_authority -/// 5. `[writable]` position -/// 6. `[]` position_token_account -/// 7. `[]` token_mint_a -/// 8. `[]` token_mint_b -/// 9. `[writable]` token_owner_account_a -/// 10. `[writable]` token_owner_account_b -/// 11. `[writable]` token_vault_a -/// 12. `[writable]` token_vault_b -/// 13. `[writable]` tick_array_lower -/// 14. `[writable]` tick_array_upper -#[derive(Clone, Debug)] -pub struct DecreaseLiquidityV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DecreaseLiquidityV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DecreaseLiquidityV2CpiBuilderInstruction { - __program: program, - whirlpool: None, - token_program_a: None, - token_program_b: None, - memo_program: None, - position_authority: None, - position: None, - position_token_account: None, - token_mint_a: None, - token_mint_b: None, - token_owner_account_a: None, - token_owner_account_b: None, - token_vault_a: None, - token_vault_b: None, - tick_array_lower: None, - tick_array_upper: None, - liquidity_amount: None, - token_min_a: None, - token_min_b: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_program_a( - &mut self, - token_program_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b( - &mut self, - token_program_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_mint_a( - &mut self, - token_mint_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b( - &mut self, - token_mint_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn liquidity_amount(&mut self, liquidity_amount: u128) -> &mut Self { - self.instruction.liquidity_amount = Some(liquidity_amount); - self - } - - #[inline(always)] - pub fn token_min_a(&mut self, token_min_a: u64) -> &mut Self { - self.instruction.token_min_a = Some(token_min_a); - self - } - - #[inline(always)] - pub fn token_min_b(&mut self, token_min_b: u64) -> &mut Self { - self.instruction.token_min_b = Some(token_min_b); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DecreaseLiquidityV2InstructionArgs { - liquidity_amount: self - .instruction - .liquidity_amount - .clone() - .expect("liquidity_amount is not set"), - token_min_a: self - .instruction - .token_min_a - .clone() - .expect("token_min_a is not set"), - token_min_b: self - .instruction - .token_min_b - .clone() - .expect("token_min_b is not set"), - remaining_accounts_info: self.instruction.remaining_accounts_info.clone(), - }; - let instruction = DecreaseLiquidityV2Cpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token_program_a: self - .instruction - .token_program_a - .expect("token_program_a is not set"), - - token_program_b: self - .instruction - .token_program_b - .expect("token_program_b is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - token_mint_a: self - .instruction - .token_mint_a - .expect("token_mint_a is not set"), - - token_mint_b: self - .instruction - .token_mint_b - .expect("token_mint_b is not set"), - - token_owner_account_a: self - .instruction - .token_owner_account_a - .expect("token_owner_account_a is not set"), - - token_owner_account_b: self - .instruction - .token_owner_account_b - .expect("token_owner_account_b is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DecreaseLiquidityV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_b: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity_amount: Option, - token_min_a: Option, - token_min_b: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/delete_position_bundle.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/delete_position_bundle.rs deleted file mode 100644 index a76031f0..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/delete_position_bundle.rs +++ /dev/null @@ -1,502 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct DeletePositionBundle { - pub position_bundle: solana_pubkey::Pubkey, - - pub position_bundle_mint: solana_pubkey::Pubkey, - - pub position_bundle_token_account: solana_pubkey::Pubkey, - - pub position_bundle_owner: solana_pubkey::Pubkey, - - pub receiver: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl DeletePositionBundle { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_bundle_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.receiver, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DeletePositionBundleInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DeletePositionBundleInstructionData { - discriminator: [u8; 8], -} - -impl DeletePositionBundleInstructionData { - pub fn new() -> Self { - Self { - discriminator: [100, 25, 99, 2, 217, 239, 124, 173], - } - } -} - -impl Default for DeletePositionBundleInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `DeletePositionBundle`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position_bundle -/// 1. `[writable]` position_bundle_mint -/// 2. `[writable]` position_bundle_token_account -/// 3. `[signer]` position_bundle_owner -/// 4. `[writable]` receiver -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct DeletePositionBundleBuilder { - position_bundle: Option, - position_bundle_mint: Option, - position_bundle_token_account: Option, - position_bundle_owner: Option, - receiver: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl DeletePositionBundleBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position_bundle(&mut self, position_bundle: solana_pubkey::Pubkey) -> &mut Self { - self.position_bundle = Some(position_bundle); - self - } - - #[inline(always)] - pub fn position_bundle_mint( - &mut self, - position_bundle_mint: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_mint = Some(position_bundle_mint); - self - } - - #[inline(always)] - pub fn position_bundle_token_account( - &mut self, - position_bundle_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_token_account = Some(position_bundle_token_account); - self - } - - #[inline(always)] - pub fn position_bundle_owner( - &mut self, - position_bundle_owner: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_owner = Some(position_bundle_owner); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: solana_pubkey::Pubkey) -> &mut Self { - self.receiver = Some(receiver); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = DeletePositionBundle { - position_bundle: self.position_bundle.expect("position_bundle is not set"), - position_bundle_mint: self - .position_bundle_mint - .expect("position_bundle_mint is not set"), - position_bundle_token_account: self - .position_bundle_token_account - .expect("position_bundle_token_account is not set"), - position_bundle_owner: self - .position_bundle_owner - .expect("position_bundle_owner is not set"), - receiver: self.receiver.expect("receiver is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `delete_position_bundle` CPI accounts. -pub struct DeletePositionBundleCpiAccounts<'a, 'b> { - pub position_bundle: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_owner: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `delete_position_bundle` CPI instruction. -pub struct DeletePositionBundleCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_owner: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> DeletePositionBundleCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DeletePositionBundleCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position_bundle: accounts.position_bundle, - position_bundle_mint: accounts.position_bundle_mint, - position_bundle_token_account: accounts.position_bundle_token_account, - position_bundle_owner: accounts.position_bundle_owner, - receiver: accounts.receiver, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_bundle_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&DeletePositionBundleInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position_bundle.clone()); - account_infos.push(self.position_bundle_mint.clone()); - account_infos.push(self.position_bundle_token_account.clone()); - account_infos.push(self.position_bundle_owner.clone()); - account_infos.push(self.receiver.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `DeletePositionBundle` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position_bundle -/// 1. `[writable]` position_bundle_mint -/// 2. `[writable]` position_bundle_token_account -/// 3. `[signer]` position_bundle_owner -/// 4. `[writable]` receiver -/// 5. `[]` token_program -#[derive(Clone, Debug)] -pub struct DeletePositionBundleCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DeletePositionBundleCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DeletePositionBundleCpiBuilderInstruction { - __program: program, - position_bundle: None, - position_bundle_mint: None, - position_bundle_token_account: None, - position_bundle_owner: None, - receiver: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position_bundle( - &mut self, - position_bundle: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle = Some(position_bundle); - self - } - - #[inline(always)] - pub fn position_bundle_mint( - &mut self, - position_bundle_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_mint = Some(position_bundle_mint); - self - } - - #[inline(always)] - pub fn position_bundle_token_account( - &mut self, - position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_token_account = Some(position_bundle_token_account); - self - } - - #[inline(always)] - pub fn position_bundle_owner( - &mut self, - position_bundle_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_owner = Some(position_bundle_owner); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.receiver = Some(receiver); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = DeletePositionBundleCpi { - __program: self.instruction.__program, - - position_bundle: self - .instruction - .position_bundle - .expect("position_bundle is not set"), - - position_bundle_mint: self - .instruction - .position_bundle_mint - .expect("position_bundle_mint is not set"), - - position_bundle_token_account: self - .instruction - .position_bundle_token_account - .expect("position_bundle_token_account is not set"), - - position_bundle_owner: self - .instruction - .position_bundle_owner - .expect("position_bundle_owner is not set"), - - receiver: self.instruction.receiver.expect("receiver is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DeletePositionBundleCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position_bundle: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/delete_token_badge.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/delete_token_badge.rs deleted file mode 100644 index 2d1cef8e..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/delete_token_badge.rs +++ /dev/null @@ -1,493 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct DeleteTokenBadge { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub whirlpools_config_extension: solana_pubkey::Pubkey, - - pub token_badge_authority: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub token_badge: solana_pubkey::Pubkey, - - pub receiver: solana_pubkey::Pubkey, -} - -impl DeleteTokenBadge { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config_extension, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_badge_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_badge, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.receiver, false)); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&DeleteTokenBadgeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DeleteTokenBadgeInstructionData { - discriminator: [u8; 8], -} - -impl DeleteTokenBadgeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [53, 146, 68, 8, 18, 117, 17, 185], - } - } -} - -impl Default for DeleteTokenBadgeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `DeleteTokenBadge`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[]` whirlpools_config_extension -/// 2. `[signer]` token_badge_authority -/// 3. `[]` token_mint -/// 4. `[writable]` token_badge -/// 5. `[writable]` receiver -#[derive(Clone, Debug, Default)] -pub struct DeleteTokenBadgeBuilder { - whirlpools_config: Option, - whirlpools_config_extension: Option, - token_badge_authority: Option, - token_mint: Option, - token_badge: Option, - receiver: Option, - __remaining_accounts: Vec, -} - -impl DeleteTokenBadgeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpools_config_extension( - &mut self, - whirlpools_config_extension: solana_pubkey::Pubkey, - ) -> &mut Self { - self.whirlpools_config_extension = Some(whirlpools_config_extension); - self - } - - #[inline(always)] - pub fn token_badge_authority( - &mut self, - token_badge_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_badge_authority = Some(token_badge_authority); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn token_badge(&mut self, token_badge: solana_pubkey::Pubkey) -> &mut Self { - self.token_badge = Some(token_badge); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: solana_pubkey::Pubkey) -> &mut Self { - self.receiver = Some(receiver); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = DeleteTokenBadge { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - whirlpools_config_extension: self - .whirlpools_config_extension - .expect("whirlpools_config_extension is not set"), - token_badge_authority: self - .token_badge_authority - .expect("token_badge_authority is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - token_badge: self.token_badge.expect("token_badge is not set"), - receiver: self.receiver.expect("receiver is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `delete_token_badge` CPI accounts. -pub struct DeleteTokenBadgeCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_authority: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, -} - -/// `delete_token_badge` CPI instruction. -pub struct DeleteTokenBadgeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_authority: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> DeleteTokenBadgeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DeleteTokenBadgeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - whirlpools_config_extension: accounts.whirlpools_config_extension, - token_badge_authority: accounts.token_badge_authority, - token_mint: accounts.token_mint, - token_badge: accounts.token_badge, - receiver: accounts.receiver, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config_extension.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_badge_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_badge.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.receiver.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&DeleteTokenBadgeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.whirlpools_config_extension.clone()); - account_infos.push(self.token_badge_authority.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.token_badge.clone()); - account_infos.push(self.receiver.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `DeleteTokenBadge` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[]` whirlpools_config_extension -/// 2. `[signer]` token_badge_authority -/// 3. `[]` token_mint -/// 4. `[writable]` token_badge -/// 5. `[writable]` receiver -#[derive(Clone, Debug)] -pub struct DeleteTokenBadgeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DeleteTokenBadgeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DeleteTokenBadgeCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - whirlpools_config_extension: None, - token_badge_authority: None, - token_mint: None, - token_badge: None, - receiver: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpools_config_extension( - &mut self, - whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config_extension = Some(whirlpools_config_extension); - self - } - - #[inline(always)] - pub fn token_badge_authority( - &mut self, - token_badge_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge_authority = Some(token_badge_authority); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn token_badge( - &mut self, - token_badge: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge = Some(token_badge); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.receiver = Some(receiver); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = DeleteTokenBadgeCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - whirlpools_config_extension: self - .instruction - .whirlpools_config_extension - .expect("whirlpools_config_extension is not set"), - - token_badge_authority: self - .instruction - .token_badge_authority - .expect("token_badge_authority is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - token_badge: self - .instruction - .token_badge - .expect("token_badge is not set"), - - receiver: self.instruction.receiver.expect("receiver is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DeleteTokenBadgeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpools_config_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge: Option<&'b solana_account_info::AccountInfo<'a>>, - receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/idl_include.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/idl_include.rs deleted file mode 100644 index 2bd0b94d..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/idl_include.rs +++ /dev/null @@ -1,325 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct IdlInclude { - pub tick_array: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl IdlInclude { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.tick_array, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&IdlIncludeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IdlIncludeInstructionData { - discriminator: [u8; 8], -} - -impl IdlIncludeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [223, 253, 121, 121, 60, 193, 129, 31], - } - } -} - -impl Default for IdlIncludeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `IdlInclude`. -/// -/// ### Accounts: -/// -/// 0. `[]` tick_array -/// 1. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct IdlIncludeBuilder { - tick_array: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl IdlIncludeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn tick_array(&mut self, tick_array: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array = Some(tick_array); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = IdlInclude { - tick_array: self.tick_array.expect("tick_array is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `idl_include` CPI accounts. -pub struct IdlIncludeCpiAccounts<'a, 'b> { - pub tick_array: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `idl_include` CPI instruction. -pub struct IdlIncludeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> IdlIncludeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: IdlIncludeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - tick_array: accounts.tick_array, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.tick_array.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&IdlIncludeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.tick_array.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `IdlInclude` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` tick_array -/// 1. `[]` system_program -#[derive(Clone, Debug)] -pub struct IdlIncludeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> IdlIncludeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(IdlIncludeCpiBuilderInstruction { - __program: program, - tick_array: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn tick_array( - &mut self, - tick_array: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array = Some(tick_array); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = IdlIncludeCpi { - __program: self.instruction.__program, - - tick_array: self.instruction.tick_array.expect("tick_array is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct IdlIncludeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - tick_array: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/increase_liquidity.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/increase_liquidity.rs deleted file mode 100644 index 9827649f..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/increase_liquidity.rs +++ /dev/null @@ -1,796 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct IncreaseLiquidity { - pub whirlpool: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub position_authority: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub token_owner_account_a: solana_pubkey::Pubkey, - - pub token_owner_account_b: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, -} - -impl IncreaseLiquidity { - pub fn instruction( - &self, - args: IncreaseLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: IncreaseLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&IncreaseLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IncreaseLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl IncreaseLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [46, 156, 243, 118, 13, 205, 251, 178], - } - } -} - -impl Default for IncreaseLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IncreaseLiquidityInstructionArgs { - pub liquidity_amount: u128, - pub token_max_a: u64, - pub token_max_b: u64, -} - -/// Instruction builder for `IncreaseLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 2. `[signer]` position_authority -/// 3. `[writable]` position -/// 4. `[]` position_token_account -/// 5. `[writable]` token_owner_account_a -/// 6. `[writable]` token_owner_account_b -/// 7. `[writable]` token_vault_a -/// 8. `[writable]` token_vault_b -/// 9. `[writable]` tick_array_lower -/// 10. `[writable]` tick_array_upper -#[derive(Clone, Debug, Default)] -pub struct IncreaseLiquidityBuilder { - whirlpool: Option, - token_program: Option, - position_authority: Option, - position: Option, - position_token_account: Option, - token_owner_account_a: Option, - token_owner_account_b: Option, - token_vault_a: Option, - token_vault_b: Option, - tick_array_lower: Option, - tick_array_upper: Option, - liquidity_amount: Option, - token_max_a: Option, - token_max_b: Option, - __remaining_accounts: Vec, -} - -impl IncreaseLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn liquidity_amount(&mut self, liquidity_amount: u128) -> &mut Self { - self.liquidity_amount = Some(liquidity_amount); - self - } - - #[inline(always)] - pub fn token_max_a(&mut self, token_max_a: u64) -> &mut Self { - self.token_max_a = Some(token_max_a); - self - } - - #[inline(always)] - pub fn token_max_b(&mut self, token_max_b: u64) -> &mut Self { - self.token_max_b = Some(token_max_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = IncreaseLiquidity { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - position_authority: self - .position_authority - .expect("position_authority is not set"), - position: self.position.expect("position is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - token_owner_account_a: self - .token_owner_account_a - .expect("token_owner_account_a is not set"), - token_owner_account_b: self - .token_owner_account_b - .expect("token_owner_account_b is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - }; - let args = IncreaseLiquidityInstructionArgs { - liquidity_amount: self - .liquidity_amount - .clone() - .expect("liquidity_amount is not set"), - token_max_a: self.token_max_a.clone().expect("token_max_a is not set"), - token_max_b: self.token_max_b.clone().expect("token_max_b is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `increase_liquidity` CPI accounts. -pub struct IncreaseLiquidityCpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, -} - -/// `increase_liquidity` CPI instruction. -pub struct IncreaseLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: IncreaseLiquidityInstructionArgs, -} - -impl<'a, 'b> IncreaseLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: IncreaseLiquidityCpiAccounts<'a, 'b>, - args: IncreaseLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - token_program: accounts.token_program, - position_authority: accounts.position_authority, - position: accounts.position, - position_token_account: accounts.position_token_account, - token_owner_account_a: accounts.token_owner_account_a, - token_owner_account_b: accounts.token_owner_account_b, - token_vault_a: accounts.token_vault_a, - token_vault_b: accounts.token_vault_b, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&IncreaseLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.token_owner_account_a.clone()); - account_infos.push(self.token_owner_account_b.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `IncreaseLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[]` token_program -/// 2. `[signer]` position_authority -/// 3. `[writable]` position -/// 4. `[]` position_token_account -/// 5. `[writable]` token_owner_account_a -/// 6. `[writable]` token_owner_account_b -/// 7. `[writable]` token_vault_a -/// 8. `[writable]` token_vault_b -/// 9. `[writable]` tick_array_lower -/// 10. `[writable]` tick_array_upper -#[derive(Clone, Debug)] -pub struct IncreaseLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> IncreaseLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(IncreaseLiquidityCpiBuilderInstruction { - __program: program, - whirlpool: None, - token_program: None, - position_authority: None, - position: None, - position_token_account: None, - token_owner_account_a: None, - token_owner_account_b: None, - token_vault_a: None, - token_vault_b: None, - tick_array_lower: None, - tick_array_upper: None, - liquidity_amount: None, - token_max_a: None, - token_max_b: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn liquidity_amount(&mut self, liquidity_amount: u128) -> &mut Self { - self.instruction.liquidity_amount = Some(liquidity_amount); - self - } - - #[inline(always)] - pub fn token_max_a(&mut self, token_max_a: u64) -> &mut Self { - self.instruction.token_max_a = Some(token_max_a); - self - } - - #[inline(always)] - pub fn token_max_b(&mut self, token_max_b: u64) -> &mut Self { - self.instruction.token_max_b = Some(token_max_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = IncreaseLiquidityInstructionArgs { - liquidity_amount: self - .instruction - .liquidity_amount - .clone() - .expect("liquidity_amount is not set"), - token_max_a: self - .instruction - .token_max_a - .clone() - .expect("token_max_a is not set"), - token_max_b: self - .instruction - .token_max_b - .clone() - .expect("token_max_b is not set"), - }; - let instruction = IncreaseLiquidityCpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - token_owner_account_a: self - .instruction - .token_owner_account_a - .expect("token_owner_account_a is not set"), - - token_owner_account_b: self - .instruction - .token_owner_account_b - .expect("token_owner_account_b is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct IncreaseLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity_amount: Option, - token_max_a: Option, - token_max_b: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/increase_liquidity_v2.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/increase_liquidity_v2.rs deleted file mode 100644 index 6c0cf795..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/increase_liquidity_v2.rs +++ /dev/null @@ -1,989 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct IncreaseLiquidityV2 { - pub whirlpool: solana_pubkey::Pubkey, - - pub token_program_a: solana_pubkey::Pubkey, - - pub token_program_b: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub position_authority: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub token_mint_a: solana_pubkey::Pubkey, - - pub token_mint_b: solana_pubkey::Pubkey, - - pub token_owner_account_a: solana_pubkey::Pubkey, - - pub token_owner_account_b: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, -} - -impl IncreaseLiquidityV2 { - pub fn instruction( - &self, - args: IncreaseLiquidityV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: IncreaseLiquidityV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&IncreaseLiquidityV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IncreaseLiquidityV2InstructionData { - discriminator: [u8; 8], -} - -impl IncreaseLiquidityV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [133, 29, 89, 223, 69, 238, 176, 10], - } - } -} - -impl Default for IncreaseLiquidityV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IncreaseLiquidityV2InstructionArgs { - pub liquidity_amount: u128, - pub token_max_a: u64, - pub token_max_b: u64, - pub remaining_accounts_info: Option, -} - -/// Instruction builder for `IncreaseLiquidityV2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[]` token_program_a -/// 2. `[]` token_program_b -/// 3. `[]` memo_program -/// 4. `[signer]` position_authority -/// 5. `[writable]` position -/// 6. `[]` position_token_account -/// 7. `[]` token_mint_a -/// 8. `[]` token_mint_b -/// 9. `[writable]` token_owner_account_a -/// 10. `[writable]` token_owner_account_b -/// 11. `[writable]` token_vault_a -/// 12. `[writable]` token_vault_b -/// 13. `[writable]` tick_array_lower -/// 14. `[writable]` tick_array_upper -#[derive(Clone, Debug, Default)] -pub struct IncreaseLiquidityV2Builder { - whirlpool: Option, - token_program_a: Option, - token_program_b: Option, - memo_program: Option, - position_authority: Option, - position: Option, - position_token_account: Option, - token_mint_a: Option, - token_mint_b: Option, - token_owner_account_a: Option, - token_owner_account_b: Option, - token_vault_a: Option, - token_vault_b: Option, - tick_array_lower: Option, - tick_array_upper: Option, - liquidity_amount: Option, - token_max_a: Option, - token_max_b: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl IncreaseLiquidityV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_program_a(&mut self, token_program_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b(&mut self, token_program_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_mint_a(&mut self, token_mint_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b(&mut self, token_mint_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn liquidity_amount(&mut self, liquidity_amount: u128) -> &mut Self { - self.liquidity_amount = Some(liquidity_amount); - self - } - - #[inline(always)] - pub fn token_max_a(&mut self, token_max_a: u64) -> &mut Self { - self.token_max_a = Some(token_max_a); - self - } - - #[inline(always)] - pub fn token_max_b(&mut self, token_max_b: u64) -> &mut Self { - self.token_max_b = Some(token_max_b); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = IncreaseLiquidityV2 { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token_program_a: self.token_program_a.expect("token_program_a is not set"), - token_program_b: self.token_program_b.expect("token_program_b is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - position_authority: self - .position_authority - .expect("position_authority is not set"), - position: self.position.expect("position is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - token_mint_a: self.token_mint_a.expect("token_mint_a is not set"), - token_mint_b: self.token_mint_b.expect("token_mint_b is not set"), - token_owner_account_a: self - .token_owner_account_a - .expect("token_owner_account_a is not set"), - token_owner_account_b: self - .token_owner_account_b - .expect("token_owner_account_b is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - }; - let args = IncreaseLiquidityV2InstructionArgs { - liquidity_amount: self - .liquidity_amount - .clone() - .expect("liquidity_amount is not set"), - token_max_a: self.token_max_a.clone().expect("token_max_a is not set"), - token_max_b: self.token_max_b.clone().expect("token_max_b is not set"), - remaining_accounts_info: self.remaining_accounts_info.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `increase_liquidity_v2` CPI accounts. -pub struct IncreaseLiquidityV2CpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, -} - -/// `increase_liquidity_v2` CPI instruction. -pub struct IncreaseLiquidityV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: IncreaseLiquidityV2InstructionArgs, -} - -impl<'a, 'b> IncreaseLiquidityV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: IncreaseLiquidityV2CpiAccounts<'a, 'b>, - args: IncreaseLiquidityV2InstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - token_program_a: accounts.token_program_a, - token_program_b: accounts.token_program_b, - memo_program: accounts.memo_program, - position_authority: accounts.position_authority, - position: accounts.position, - position_token_account: accounts.position_token_account, - token_mint_a: accounts.token_mint_a, - token_mint_b: accounts.token_mint_b, - token_owner_account_a: accounts.token_owner_account_a, - token_owner_account_b: accounts.token_owner_account_b, - token_vault_a: accounts.token_vault_a, - token_vault_b: accounts.token_vault_b, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&IncreaseLiquidityV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token_program_a.clone()); - account_infos.push(self.token_program_b.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.token_mint_a.clone()); - account_infos.push(self.token_mint_b.clone()); - account_infos.push(self.token_owner_account_a.clone()); - account_infos.push(self.token_owner_account_b.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `IncreaseLiquidityV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[]` token_program_a -/// 2. `[]` token_program_b -/// 3. `[]` memo_program -/// 4. `[signer]` position_authority -/// 5. `[writable]` position -/// 6. `[]` position_token_account -/// 7. `[]` token_mint_a -/// 8. `[]` token_mint_b -/// 9. `[writable]` token_owner_account_a -/// 10. `[writable]` token_owner_account_b -/// 11. `[writable]` token_vault_a -/// 12. `[writable]` token_vault_b -/// 13. `[writable]` tick_array_lower -/// 14. `[writable]` tick_array_upper -#[derive(Clone, Debug)] -pub struct IncreaseLiquidityV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> IncreaseLiquidityV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(IncreaseLiquidityV2CpiBuilderInstruction { - __program: program, - whirlpool: None, - token_program_a: None, - token_program_b: None, - memo_program: None, - position_authority: None, - position: None, - position_token_account: None, - token_mint_a: None, - token_mint_b: None, - token_owner_account_a: None, - token_owner_account_b: None, - token_vault_a: None, - token_vault_b: None, - tick_array_lower: None, - tick_array_upper: None, - liquidity_amount: None, - token_max_a: None, - token_max_b: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_program_a( - &mut self, - token_program_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b( - &mut self, - token_program_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn token_mint_a( - &mut self, - token_mint_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b( - &mut self, - token_mint_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn liquidity_amount(&mut self, liquidity_amount: u128) -> &mut Self { - self.instruction.liquidity_amount = Some(liquidity_amount); - self - } - - #[inline(always)] - pub fn token_max_a(&mut self, token_max_a: u64) -> &mut Self { - self.instruction.token_max_a = Some(token_max_a); - self - } - - #[inline(always)] - pub fn token_max_b(&mut self, token_max_b: u64) -> &mut Self { - self.instruction.token_max_b = Some(token_max_b); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = IncreaseLiquidityV2InstructionArgs { - liquidity_amount: self - .instruction - .liquidity_amount - .clone() - .expect("liquidity_amount is not set"), - token_max_a: self - .instruction - .token_max_a - .clone() - .expect("token_max_a is not set"), - token_max_b: self - .instruction - .token_max_b - .clone() - .expect("token_max_b is not set"), - remaining_accounts_info: self.instruction.remaining_accounts_info.clone(), - }; - let instruction = IncreaseLiquidityV2Cpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token_program_a: self - .instruction - .token_program_a - .expect("token_program_a is not set"), - - token_program_b: self - .instruction - .token_program_b - .expect("token_program_b is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - token_mint_a: self - .instruction - .token_mint_a - .expect("token_mint_a is not set"), - - token_mint_b: self - .instruction - .token_mint_b - .expect("token_mint_b is not set"), - - token_owner_account_a: self - .instruction - .token_owner_account_a - .expect("token_owner_account_a is not set"), - - token_owner_account_b: self - .instruction - .token_owner_account_b - .expect("token_owner_account_b is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct IncreaseLiquidityV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_b: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity_amount: Option, - token_max_a: Option, - token_max_b: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_adaptive_fee_tier.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_adaptive_fee_tier.rs deleted file mode 100644 index 3e010065..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_adaptive_fee_tier.rs +++ /dev/null @@ -1,763 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeAdaptiveFeeTier { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub adaptive_fee_tier: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeAdaptiveFeeTier { - pub fn instruction( - &self, - args: InitializeAdaptiveFeeTierInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeAdaptiveFeeTierInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.adaptive_fee_tier, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeAdaptiveFeeTierInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeAdaptiveFeeTierInstructionData { - discriminator: [u8; 8], -} - -impl InitializeAdaptiveFeeTierInstructionData { - pub fn new() -> Self { - Self { - discriminator: [77, 99, 208, 200, 141, 123, 117, 48], - } - } -} - -impl Default for InitializeAdaptiveFeeTierInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeAdaptiveFeeTierInstructionArgs { - pub fee_tier_index: u16, - pub tick_spacing: u16, - pub initialize_pool_authority: Pubkey, - pub delegated_fee_authority: Pubkey, - pub default_base_fee_rate: u16, - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub adaptive_fee_control_factor: u32, - pub max_volatility_accumulator: u32, - pub tick_group_size: u16, - pub major_swap_threshold_ticks: u16, -} - -/// Instruction builder for `InitializeAdaptiveFeeTier`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` adaptive_fee_tier -/// 2. `[writable, signer]` funder -/// 3. `[signer]` fee_authority -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeAdaptiveFeeTierBuilder { - whirlpools_config: Option, - adaptive_fee_tier: Option, - funder: Option, - fee_authority: Option, - system_program: Option, - fee_tier_index: Option, - tick_spacing: Option, - initialize_pool_authority: Option, - delegated_fee_authority: Option, - default_base_fee_rate: Option, - filter_period: Option, - decay_period: Option, - reduction_factor: Option, - adaptive_fee_control_factor: Option, - max_volatility_accumulator: Option, - tick_group_size: Option, - major_swap_threshold_ticks: Option, - __remaining_accounts: Vec, -} - -impl InitializeAdaptiveFeeTierBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier(&mut self, adaptive_fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn fee_tier_index(&mut self, fee_tier_index: u16) -> &mut Self { - self.fee_tier_index = Some(fee_tier_index); - self - } - - #[inline(always)] - pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self { - self.tick_spacing = Some(tick_spacing); - self - } - - #[inline(always)] - pub fn initialize_pool_authority(&mut self, initialize_pool_authority: Pubkey) -> &mut Self { - self.initialize_pool_authority = Some(initialize_pool_authority); - self - } - - #[inline(always)] - pub fn delegated_fee_authority(&mut self, delegated_fee_authority: Pubkey) -> &mut Self { - self.delegated_fee_authority = Some(delegated_fee_authority); - self - } - - #[inline(always)] - pub fn default_base_fee_rate(&mut self, default_base_fee_rate: u16) -> &mut Self { - self.default_base_fee_rate = Some(default_base_fee_rate); - self - } - - #[inline(always)] - pub fn filter_period(&mut self, filter_period: u16) -> &mut Self { - self.filter_period = Some(filter_period); - self - } - - #[inline(always)] - pub fn decay_period(&mut self, decay_period: u16) -> &mut Self { - self.decay_period = Some(decay_period); - self - } - - #[inline(always)] - pub fn reduction_factor(&mut self, reduction_factor: u16) -> &mut Self { - self.reduction_factor = Some(reduction_factor); - self - } - - #[inline(always)] - pub fn adaptive_fee_control_factor(&mut self, adaptive_fee_control_factor: u32) -> &mut Self { - self.adaptive_fee_control_factor = Some(adaptive_fee_control_factor); - self - } - - #[inline(always)] - pub fn max_volatility_accumulator(&mut self, max_volatility_accumulator: u32) -> &mut Self { - self.max_volatility_accumulator = Some(max_volatility_accumulator); - self - } - - #[inline(always)] - pub fn tick_group_size(&mut self, tick_group_size: u16) -> &mut Self { - self.tick_group_size = Some(tick_group_size); - self - } - - #[inline(always)] - pub fn major_swap_threshold_ticks(&mut self, major_swap_threshold_ticks: u16) -> &mut Self { - self.major_swap_threshold_ticks = Some(major_swap_threshold_ticks); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeAdaptiveFeeTier { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - adaptive_fee_tier: self - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - funder: self.funder.expect("funder is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializeAdaptiveFeeTierInstructionArgs { - fee_tier_index: self - .fee_tier_index - .clone() - .expect("fee_tier_index is not set"), - tick_spacing: self.tick_spacing.clone().expect("tick_spacing is not set"), - initialize_pool_authority: self - .initialize_pool_authority - .clone() - .expect("initialize_pool_authority is not set"), - delegated_fee_authority: self - .delegated_fee_authority - .clone() - .expect("delegated_fee_authority is not set"), - default_base_fee_rate: self - .default_base_fee_rate - .clone() - .expect("default_base_fee_rate is not set"), - filter_period: self - .filter_period - .clone() - .expect("filter_period is not set"), - decay_period: self.decay_period.clone().expect("decay_period is not set"), - reduction_factor: self - .reduction_factor - .clone() - .expect("reduction_factor is not set"), - adaptive_fee_control_factor: self - .adaptive_fee_control_factor - .clone() - .expect("adaptive_fee_control_factor is not set"), - max_volatility_accumulator: self - .max_volatility_accumulator - .clone() - .expect("max_volatility_accumulator is not set"), - tick_group_size: self - .tick_group_size - .clone() - .expect("tick_group_size is not set"), - major_swap_threshold_ticks: self - .major_swap_threshold_ticks - .clone() - .expect("major_swap_threshold_ticks is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_adaptive_fee_tier` CPI accounts. -pub struct InitializeAdaptiveFeeTierCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_adaptive_fee_tier` CPI instruction. -pub struct InitializeAdaptiveFeeTierCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeAdaptiveFeeTierInstructionArgs, -} - -impl<'a, 'b> InitializeAdaptiveFeeTierCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeAdaptiveFeeTierCpiAccounts<'a, 'b>, - args: InitializeAdaptiveFeeTierInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - adaptive_fee_tier: accounts.adaptive_fee_tier, - funder: accounts.funder, - fee_authority: accounts.fee_authority, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.adaptive_fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeAdaptiveFeeTierInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.adaptive_fee_tier.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.fee_authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeAdaptiveFeeTier` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` adaptive_fee_tier -/// 2. `[writable, signer]` funder -/// 3. `[signer]` fee_authority -/// 4. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeAdaptiveFeeTierCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeAdaptiveFeeTierCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeAdaptiveFeeTierCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - adaptive_fee_tier: None, - funder: None, - fee_authority: None, - system_program: None, - fee_tier_index: None, - tick_spacing: None, - initialize_pool_authority: None, - delegated_fee_authority: None, - default_base_fee_rate: None, - filter_period: None, - decay_period: None, - reduction_factor: None, - adaptive_fee_control_factor: None, - max_volatility_accumulator: None, - tick_group_size: None, - major_swap_threshold_ticks: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier( - &mut self, - adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn fee_tier_index(&mut self, fee_tier_index: u16) -> &mut Self { - self.instruction.fee_tier_index = Some(fee_tier_index); - self - } - - #[inline(always)] - pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self { - self.instruction.tick_spacing = Some(tick_spacing); - self - } - - #[inline(always)] - pub fn initialize_pool_authority(&mut self, initialize_pool_authority: Pubkey) -> &mut Self { - self.instruction.initialize_pool_authority = Some(initialize_pool_authority); - self - } - - #[inline(always)] - pub fn delegated_fee_authority(&mut self, delegated_fee_authority: Pubkey) -> &mut Self { - self.instruction.delegated_fee_authority = Some(delegated_fee_authority); - self - } - - #[inline(always)] - pub fn default_base_fee_rate(&mut self, default_base_fee_rate: u16) -> &mut Self { - self.instruction.default_base_fee_rate = Some(default_base_fee_rate); - self - } - - #[inline(always)] - pub fn filter_period(&mut self, filter_period: u16) -> &mut Self { - self.instruction.filter_period = Some(filter_period); - self - } - - #[inline(always)] - pub fn decay_period(&mut self, decay_period: u16) -> &mut Self { - self.instruction.decay_period = Some(decay_period); - self - } - - #[inline(always)] - pub fn reduction_factor(&mut self, reduction_factor: u16) -> &mut Self { - self.instruction.reduction_factor = Some(reduction_factor); - self - } - - #[inline(always)] - pub fn adaptive_fee_control_factor(&mut self, adaptive_fee_control_factor: u32) -> &mut Self { - self.instruction.adaptive_fee_control_factor = Some(adaptive_fee_control_factor); - self - } - - #[inline(always)] - pub fn max_volatility_accumulator(&mut self, max_volatility_accumulator: u32) -> &mut Self { - self.instruction.max_volatility_accumulator = Some(max_volatility_accumulator); - self - } - - #[inline(always)] - pub fn tick_group_size(&mut self, tick_group_size: u16) -> &mut Self { - self.instruction.tick_group_size = Some(tick_group_size); - self - } - - #[inline(always)] - pub fn major_swap_threshold_ticks(&mut self, major_swap_threshold_ticks: u16) -> &mut Self { - self.instruction.major_swap_threshold_ticks = Some(major_swap_threshold_ticks); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeAdaptiveFeeTierInstructionArgs { - fee_tier_index: self - .instruction - .fee_tier_index - .clone() - .expect("fee_tier_index is not set"), - tick_spacing: self - .instruction - .tick_spacing - .clone() - .expect("tick_spacing is not set"), - initialize_pool_authority: self - .instruction - .initialize_pool_authority - .clone() - .expect("initialize_pool_authority is not set"), - delegated_fee_authority: self - .instruction - .delegated_fee_authority - .clone() - .expect("delegated_fee_authority is not set"), - default_base_fee_rate: self - .instruction - .default_base_fee_rate - .clone() - .expect("default_base_fee_rate is not set"), - filter_period: self - .instruction - .filter_period - .clone() - .expect("filter_period is not set"), - decay_period: self - .instruction - .decay_period - .clone() - .expect("decay_period is not set"), - reduction_factor: self - .instruction - .reduction_factor - .clone() - .expect("reduction_factor is not set"), - adaptive_fee_control_factor: self - .instruction - .adaptive_fee_control_factor - .clone() - .expect("adaptive_fee_control_factor is not set"), - max_volatility_accumulator: self - .instruction - .max_volatility_accumulator - .clone() - .expect("max_volatility_accumulator is not set"), - tick_group_size: self - .instruction - .tick_group_size - .clone() - .expect("tick_group_size is not set"), - major_swap_threshold_ticks: self - .instruction - .major_swap_threshold_ticks - .clone() - .expect("major_swap_threshold_ticks is not set"), - }; - let instruction = InitializeAdaptiveFeeTierCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - adaptive_fee_tier: self - .instruction - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeAdaptiveFeeTierCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - adaptive_fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_tier_index: Option, - tick_spacing: Option, - initialize_pool_authority: Option, - delegated_fee_authority: Option, - default_base_fee_rate: Option, - filter_period: Option, - decay_period: Option, - reduction_factor: Option, - adaptive_fee_control_factor: Option, - max_volatility_accumulator: Option, - tick_group_size: Option, - major_swap_threshold_ticks: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_config.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_config.rs deleted file mode 100644 index cdd5d546..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_config.rs +++ /dev/null @@ -1,481 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeConfig { - pub config: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeConfig { - pub fn instruction( - &self, - args: InitializeConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.config, true)); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeConfigInstructionData { - discriminator: [u8; 8], -} - -impl InitializeConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [208, 127, 21, 1, 194, 190, 196, 70], - } - } -} - -impl Default for InitializeConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeConfigInstructionArgs { - pub fee_authority: Pubkey, - pub collect_protocol_fees_authority: Pubkey, - pub reward_emissions_super_authority: Pubkey, - pub default_protocol_fee_rate: u16, -} - -/// Instruction builder for `InitializeConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` config -/// 1. `[writable, signer]` funder -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeConfigBuilder { - config: Option, - funder: Option, - system_program: Option, - fee_authority: Option, - collect_protocol_fees_authority: Option, - reward_emissions_super_authority: Option, - default_protocol_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl InitializeConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn collect_protocol_fees_authority( - &mut self, - collect_protocol_fees_authority: Pubkey, - ) -> &mut Self { - self.collect_protocol_fees_authority = Some(collect_protocol_fees_authority); - self - } - - #[inline(always)] - pub fn reward_emissions_super_authority( - &mut self, - reward_emissions_super_authority: Pubkey, - ) -> &mut Self { - self.reward_emissions_super_authority = Some(reward_emissions_super_authority); - self - } - - #[inline(always)] - pub fn default_protocol_fee_rate(&mut self, default_protocol_fee_rate: u16) -> &mut Self { - self.default_protocol_fee_rate = Some(default_protocol_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeConfig { - config: self.config.expect("config is not set"), - funder: self.funder.expect("funder is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializeConfigInstructionArgs { - fee_authority: self - .fee_authority - .clone() - .expect("fee_authority is not set"), - collect_protocol_fees_authority: self - .collect_protocol_fees_authority - .clone() - .expect("collect_protocol_fees_authority is not set"), - reward_emissions_super_authority: self - .reward_emissions_super_authority - .clone() - .expect("reward_emissions_super_authority is not set"), - default_protocol_fee_rate: self - .default_protocol_fee_rate - .clone() - .expect("default_protocol_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_config` CPI accounts. -pub struct InitializeConfigCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_config` CPI instruction. -pub struct InitializeConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeConfigInstructionArgs, -} - -impl<'a, 'b> InitializeConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeConfigCpiAccounts<'a, 'b>, - args: InitializeConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - funder: accounts.funder, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.config.key, true)); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` config -/// 1. `[writable, signer]` funder -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeConfigCpiBuilderInstruction { - __program: program, - config: None, - funder: None, - system_program: None, - fee_authority: None, - collect_protocol_fees_authority: None, - reward_emissions_super_authority: None, - default_protocol_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: Pubkey) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn collect_protocol_fees_authority( - &mut self, - collect_protocol_fees_authority: Pubkey, - ) -> &mut Self { - self.instruction.collect_protocol_fees_authority = Some(collect_protocol_fees_authority); - self - } - - #[inline(always)] - pub fn reward_emissions_super_authority( - &mut self, - reward_emissions_super_authority: Pubkey, - ) -> &mut Self { - self.instruction.reward_emissions_super_authority = Some(reward_emissions_super_authority); - self - } - - #[inline(always)] - pub fn default_protocol_fee_rate(&mut self, default_protocol_fee_rate: u16) -> &mut Self { - self.instruction.default_protocol_fee_rate = Some(default_protocol_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeConfigInstructionArgs { - fee_authority: self - .instruction - .fee_authority - .clone() - .expect("fee_authority is not set"), - collect_protocol_fees_authority: self - .instruction - .collect_protocol_fees_authority - .clone() - .expect("collect_protocol_fees_authority is not set"), - reward_emissions_super_authority: self - .instruction - .reward_emissions_super_authority - .clone() - .expect("reward_emissions_super_authority is not set"), - default_protocol_fee_rate: self - .instruction - .default_protocol_fee_rate - .clone() - .expect("default_protocol_fee_rate is not set"), - }; - let instruction = InitializeConfigCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option, - collect_protocol_fees_authority: Option, - reward_emissions_super_authority: Option, - default_protocol_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_config_extension.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_config_extension.rs deleted file mode 100644 index c164c9d7..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_config_extension.rs +++ /dev/null @@ -1,436 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeConfigExtension { - pub config: solana_pubkey::Pubkey, - - pub config_extension: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeConfigExtension { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.config_extension, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeConfigExtensionInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeConfigExtensionInstructionData { - discriminator: [u8; 8], -} - -impl InitializeConfigExtensionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [55, 9, 53, 9, 114, 57, 209, 52], - } - } -} - -impl Default for InitializeConfigExtensionInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `InitializeConfigExtension`. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` config_extension -/// 2. `[writable, signer]` funder -/// 3. `[signer]` fee_authority -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeConfigExtensionBuilder { - config: Option, - config_extension: Option, - funder: Option, - fee_authority: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl InitializeConfigExtensionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn config_extension(&mut self, config_extension: solana_pubkey::Pubkey) -> &mut Self { - self.config_extension = Some(config_extension); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeConfigExtension { - config: self.config.expect("config is not set"), - config_extension: self.config_extension.expect("config_extension is not set"), - funder: self.funder.expect("funder is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize_config_extension` CPI accounts. -pub struct InitializeConfigExtensionCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub config_extension: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_config_extension` CPI instruction. -pub struct InitializeConfigExtensionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub config_extension: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializeConfigExtensionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeConfigExtensionCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - config: accounts.config, - config_extension: accounts.config_extension, - funder: accounts.funder, - fee_authority: accounts.fee_authority, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.config_extension.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializeConfigExtensionInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.config_extension.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.fee_authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeConfigExtension` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` config_extension -/// 2. `[writable, signer]` funder -/// 3. `[signer]` fee_authority -/// 4. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeConfigExtensionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeConfigExtensionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeConfigExtensionCpiBuilderInstruction { - __program: program, - config: None, - config_extension: None, - funder: None, - fee_authority: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn config_extension( - &mut self, - config_extension: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_extension = Some(config_extension); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializeConfigExtensionCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - config_extension: self - .instruction - .config_extension - .expect("config_extension is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeConfigExtensionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - config_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_dynamic_tick_array.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_dynamic_tick_array.rs deleted file mode 100644 index f6c2b291..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_dynamic_tick_array.rs +++ /dev/null @@ -1,457 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeDynamicTickArray { - pub whirlpool: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub tick_array: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeDynamicTickArray { - pub fn instruction( - &self, - args: InitializeDynamicTickArrayInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeDynamicTickArrayInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new(self.tick_array, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeDynamicTickArrayInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeDynamicTickArrayInstructionData { - discriminator: [u8; 8], -} - -impl InitializeDynamicTickArrayInstructionData { - pub fn new() -> Self { - Self { - discriminator: [41, 33, 165, 200, 120, 231, 142, 50], - } - } -} - -impl Default for InitializeDynamicTickArrayInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeDynamicTickArrayInstructionArgs { - pub start_tick_index: i32, - pub idempotent: bool, -} - -/// Instruction builder for `InitializeDynamicTickArray`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[writable, signer]` funder -/// 2. `[writable]` tick_array -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeDynamicTickArrayBuilder { - whirlpool: Option, - funder: Option, - tick_array: Option, - system_program: Option, - start_tick_index: Option, - idempotent: Option, - __remaining_accounts: Vec, -} - -impl InitializeDynamicTickArrayBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn tick_array(&mut self, tick_array: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array = Some(tick_array); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn start_tick_index(&mut self, start_tick_index: i32) -> &mut Self { - self.start_tick_index = Some(start_tick_index); - self - } - - #[inline(always)] - pub fn idempotent(&mut self, idempotent: bool) -> &mut Self { - self.idempotent = Some(idempotent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeDynamicTickArray { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - funder: self.funder.expect("funder is not set"), - tick_array: self.tick_array.expect("tick_array is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializeDynamicTickArrayInstructionArgs { - start_tick_index: self - .start_tick_index - .clone() - .expect("start_tick_index is not set"), - idempotent: self.idempotent.clone().expect("idempotent is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_dynamic_tick_array` CPI accounts. -pub struct InitializeDynamicTickArrayCpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_dynamic_tick_array` CPI instruction. -pub struct InitializeDynamicTickArrayCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeDynamicTickArrayInstructionArgs, -} - -impl<'a, 'b> InitializeDynamicTickArrayCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeDynamicTickArrayCpiAccounts<'a, 'b>, - args: InitializeDynamicTickArrayInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - funder: accounts.funder, - tick_array: accounts.tick_array, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeDynamicTickArrayInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.tick_array.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeDynamicTickArray` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[writable, signer]` funder -/// 2. `[writable]` tick_array -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeDynamicTickArrayCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeDynamicTickArrayCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeDynamicTickArrayCpiBuilderInstruction { - __program: program, - whirlpool: None, - funder: None, - tick_array: None, - system_program: None, - start_tick_index: None, - idempotent: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn tick_array( - &mut self, - tick_array: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array = Some(tick_array); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn start_tick_index(&mut self, start_tick_index: i32) -> &mut Self { - self.instruction.start_tick_index = Some(start_tick_index); - self - } - - #[inline(always)] - pub fn idempotent(&mut self, idempotent: bool) -> &mut Self { - self.instruction.idempotent = Some(idempotent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeDynamicTickArrayInstructionArgs { - start_tick_index: self - .instruction - .start_tick_index - .clone() - .expect("start_tick_index is not set"), - idempotent: self - .instruction - .idempotent - .clone() - .expect("idempotent is not set"), - }; - let instruction = InitializeDynamicTickArrayCpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - tick_array: self.instruction.tick_array.expect("tick_array is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeDynamicTickArrayCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - start_tick_index: Option, - idempotent: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_fee_tier.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_fee_tier.rs deleted file mode 100644 index 1cb47e5b..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_fee_tier.rs +++ /dev/null @@ -1,496 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeFeeTier { - pub config: solana_pubkey::Pubkey, - - pub fee_tier: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeFeeTier { - pub fn instruction( - &self, - args: InitializeFeeTierInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeFeeTierInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.fee_tier, false)); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeFeeTierInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeFeeTierInstructionData { - discriminator: [u8; 8], -} - -impl InitializeFeeTierInstructionData { - pub fn new() -> Self { - Self { - discriminator: [183, 74, 156, 160, 112, 2, 42, 30], - } - } -} - -impl Default for InitializeFeeTierInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeFeeTierInstructionArgs { - pub tick_spacing: u16, - pub default_fee_rate: u16, -} - -/// Instruction builder for `InitializeFeeTier`. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` fee_tier -/// 2. `[writable, signer]` funder -/// 3. `[signer]` fee_authority -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeFeeTierBuilder { - config: Option, - fee_tier: Option, - funder: Option, - fee_authority: Option, - system_program: Option, - tick_spacing: Option, - default_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl InitializeFeeTierBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn fee_tier(&mut self, fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.fee_tier = Some(fee_tier); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self { - self.tick_spacing = Some(tick_spacing); - self - } - - #[inline(always)] - pub fn default_fee_rate(&mut self, default_fee_rate: u16) -> &mut Self { - self.default_fee_rate = Some(default_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeFeeTier { - config: self.config.expect("config is not set"), - fee_tier: self.fee_tier.expect("fee_tier is not set"), - funder: self.funder.expect("funder is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializeFeeTierInstructionArgs { - tick_spacing: self.tick_spacing.clone().expect("tick_spacing is not set"), - default_fee_rate: self - .default_fee_rate - .clone() - .expect("default_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_fee_tier` CPI accounts. -pub struct InitializeFeeTierCpiAccounts<'a, 'b> { - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_fee_tier` CPI instruction. -pub struct InitializeFeeTierCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeFeeTierInstructionArgs, -} - -impl<'a, 'b> InitializeFeeTierCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeFeeTierCpiAccounts<'a, 'b>, - args: InitializeFeeTierInstructionArgs, - ) -> Self { - Self { - __program: program, - config: accounts.config, - fee_tier: accounts.fee_tier, - funder: accounts.funder, - fee_authority: accounts.fee_authority, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeFeeTierInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.fee_tier.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.fee_authority.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeFeeTier` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` config -/// 1. `[writable]` fee_tier -/// 2. `[writable, signer]` funder -/// 3. `[signer]` fee_authority -/// 4. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeFeeTierCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeFeeTierCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeFeeTierCpiBuilderInstruction { - __program: program, - config: None, - fee_tier: None, - funder: None, - fee_authority: None, - system_program: None, - tick_spacing: None, - default_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn fee_tier(&mut self, fee_tier: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_tier = Some(fee_tier); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self { - self.instruction.tick_spacing = Some(tick_spacing); - self - } - - #[inline(always)] - pub fn default_fee_rate(&mut self, default_fee_rate: u16) -> &mut Self { - self.instruction.default_fee_rate = Some(default_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeFeeTierInstructionArgs { - tick_spacing: self - .instruction - .tick_spacing - .clone() - .expect("tick_spacing is not set"), - default_fee_rate: self - .instruction - .default_fee_rate - .clone() - .expect("default_fee_rate is not set"), - }; - let instruction = InitializeFeeTierCpi { - __program: self.instruction.__program, - - config: self.instruction.config.expect("config is not set"), - - fee_tier: self.instruction.fee_tier.expect("fee_tier is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeFeeTierCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_spacing: Option, - default_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_pool.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_pool.rs deleted file mode 100644 index 54085f85..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_pool.rs +++ /dev/null @@ -1,774 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePool { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub token_mint_a: solana_pubkey::Pubkey, - - pub token_mint_b: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub fee_tier: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl InitializePool { - pub fn instruction( - &self, - args: InitializePoolInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePoolInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_tier, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolInstructionData { - discriminator: [u8; 8], -} - -impl InitializePoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [95, 180, 10, 172, 84, 174, 232, 40], - } - } -} - -impl Default for InitializePoolInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolInstructionArgs { - pub whirlpool_bump: u8, - pub tick_spacing: u16, - pub initial_sqrt_price: u128, -} - -/// Instruction builder for `InitializePool`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[]` token_mint_a -/// 2. `[]` token_mint_b -/// 3. `[writable, signer]` funder -/// 4. `[writable]` whirlpool -/// 5. `[writable, signer]` token_vault_a -/// 6. `[writable, signer]` token_vault_b -/// 7. `[]` fee_tier -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 10. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializePoolBuilder { - whirlpools_config: Option, - token_mint_a: Option, - token_mint_b: Option, - funder: Option, - whirlpool: Option, - token_vault_a: Option, - token_vault_b: Option, - fee_tier: Option, - token_program: Option, - system_program: Option, - rent: Option, - whirlpool_bump: Option, - tick_spacing: Option, - initial_sqrt_price: Option, - __remaining_accounts: Vec, -} - -impl InitializePoolBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn token_mint_a(&mut self, token_mint_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b(&mut self, token_mint_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn fee_tier(&mut self, fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.fee_tier = Some(fee_tier); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn whirlpool_bump(&mut self, whirlpool_bump: u8) -> &mut Self { - self.whirlpool_bump = Some(whirlpool_bump); - self - } - - #[inline(always)] - pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self { - self.tick_spacing = Some(tick_spacing); - self - } - - #[inline(always)] - pub fn initial_sqrt_price(&mut self, initial_sqrt_price: u128) -> &mut Self { - self.initial_sqrt_price = Some(initial_sqrt_price); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePool { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - token_mint_a: self.token_mint_a.expect("token_mint_a is not set"), - token_mint_b: self.token_mint_b.expect("token_mint_b is not set"), - funder: self.funder.expect("funder is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - fee_tier: self.fee_tier.expect("fee_tier is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = InitializePoolInstructionArgs { - whirlpool_bump: self - .whirlpool_bump - .clone() - .expect("whirlpool_bump is not set"), - tick_spacing: self.tick_spacing.clone().expect("tick_spacing is not set"), - initial_sqrt_price: self - .initial_sqrt_price - .clone() - .expect("initial_sqrt_price is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_pool` CPI accounts. -pub struct InitializePoolCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_pool` CPI instruction. -pub struct InitializePoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePoolInstructionArgs, -} - -impl<'a, 'b> InitializePoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePoolCpiAccounts<'a, 'b>, - args: InitializePoolInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - token_mint_a: accounts.token_mint_a, - token_mint_b: accounts.token_mint_b, - funder: accounts.funder, - whirlpool: accounts.whirlpool, - token_vault_a: accounts.token_vault_a, - token_vault_b: accounts.token_vault_b, - fee_tier: accounts.fee_tier, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.token_mint_a.clone()); - account_infos.push(self.token_mint_b.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.fee_tier.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[]` token_mint_a -/// 2. `[]` token_mint_b -/// 3. `[writable, signer]` funder -/// 4. `[writable]` whirlpool -/// 5. `[writable, signer]` token_vault_a -/// 6. `[writable, signer]` token_vault_b -/// 7. `[]` fee_tier -/// 8. `[]` token_program -/// 9. `[]` system_program -/// 10. `[]` rent -#[derive(Clone, Debug)] -pub struct InitializePoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePoolCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - token_mint_a: None, - token_mint_b: None, - funder: None, - whirlpool: None, - token_vault_a: None, - token_vault_b: None, - fee_tier: None, - token_program: None, - system_program: None, - rent: None, - whirlpool_bump: None, - tick_spacing: None, - initial_sqrt_price: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn token_mint_a( - &mut self, - token_mint_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b( - &mut self, - token_mint_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn fee_tier(&mut self, fee_tier: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_tier = Some(fee_tier); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn whirlpool_bump(&mut self, whirlpool_bump: u8) -> &mut Self { - self.instruction.whirlpool_bump = Some(whirlpool_bump); - self - } - - #[inline(always)] - pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self { - self.instruction.tick_spacing = Some(tick_spacing); - self - } - - #[inline(always)] - pub fn initial_sqrt_price(&mut self, initial_sqrt_price: u128) -> &mut Self { - self.instruction.initial_sqrt_price = Some(initial_sqrt_price); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePoolInstructionArgs { - whirlpool_bump: self - .instruction - .whirlpool_bump - .clone() - .expect("whirlpool_bump is not set"), - tick_spacing: self - .instruction - .tick_spacing - .clone() - .expect("tick_spacing is not set"), - initial_sqrt_price: self - .instruction - .initial_sqrt_price - .clone() - .expect("initial_sqrt_price is not set"), - }; - let instruction = InitializePoolCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - token_mint_a: self - .instruction - .token_mint_a - .expect("token_mint_a is not set"), - - token_mint_b: self - .instruction - .token_mint_b - .expect("token_mint_b is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - fee_tier: self.instruction.fee_tier.expect("fee_tier is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_b: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool_bump: Option, - tick_spacing: Option, - initial_sqrt_price: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_pool_v2.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_pool_v2.rs deleted file mode 100644 index 6cd5b2a0..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_pool_v2.rs +++ /dev/null @@ -1,872 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePoolV2 { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub token_mint_a: solana_pubkey::Pubkey, - - pub token_mint_b: solana_pubkey::Pubkey, - - pub token_badge_a: solana_pubkey::Pubkey, - - pub token_badge_b: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub fee_tier: solana_pubkey::Pubkey, - - pub token_program_a: solana_pubkey::Pubkey, - - pub token_program_b: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl InitializePoolV2 { - pub fn instruction( - &self, - args: InitializePoolV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePoolV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_badge_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_badge_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_tier, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePoolV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolV2InstructionData { - discriminator: [u8; 8], -} - -impl InitializePoolV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [207, 45, 87, 242, 27, 63, 204, 67], - } - } -} - -impl Default for InitializePoolV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolV2InstructionArgs { - pub tick_spacing: u16, - pub initial_sqrt_price: u128, -} - -/// Instruction builder for `InitializePoolV2`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[]` token_mint_a -/// 2. `[]` token_mint_b -/// 3. `[]` token_badge_a -/// 4. `[]` token_badge_b -/// 5. `[writable, signer]` funder -/// 6. `[writable]` whirlpool -/// 7. `[writable, signer]` token_vault_a -/// 8. `[writable, signer]` token_vault_b -/// 9. `[]` fee_tier -/// 10. `[]` token_program_a -/// 11. `[]` token_program_b -/// 12. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 13. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializePoolV2Builder { - whirlpools_config: Option, - token_mint_a: Option, - token_mint_b: Option, - token_badge_a: Option, - token_badge_b: Option, - funder: Option, - whirlpool: Option, - token_vault_a: Option, - token_vault_b: Option, - fee_tier: Option, - token_program_a: Option, - token_program_b: Option, - system_program: Option, - rent: Option, - tick_spacing: Option, - initial_sqrt_price: Option, - __remaining_accounts: Vec, -} - -impl InitializePoolV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn token_mint_a(&mut self, token_mint_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b(&mut self, token_mint_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_badge_a(&mut self, token_badge_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_badge_a = Some(token_badge_a); - self - } - - #[inline(always)] - pub fn token_badge_b(&mut self, token_badge_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_badge_b = Some(token_badge_b); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn fee_tier(&mut self, fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.fee_tier = Some(fee_tier); - self - } - - #[inline(always)] - pub fn token_program_a(&mut self, token_program_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b(&mut self, token_program_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_b = Some(token_program_b); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self { - self.tick_spacing = Some(tick_spacing); - self - } - - #[inline(always)] - pub fn initial_sqrt_price(&mut self, initial_sqrt_price: u128) -> &mut Self { - self.initial_sqrt_price = Some(initial_sqrt_price); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePoolV2 { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - token_mint_a: self.token_mint_a.expect("token_mint_a is not set"), - token_mint_b: self.token_mint_b.expect("token_mint_b is not set"), - token_badge_a: self.token_badge_a.expect("token_badge_a is not set"), - token_badge_b: self.token_badge_b.expect("token_badge_b is not set"), - funder: self.funder.expect("funder is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - fee_tier: self.fee_tier.expect("fee_tier is not set"), - token_program_a: self.token_program_a.expect("token_program_a is not set"), - token_program_b: self.token_program_b.expect("token_program_b is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = InitializePoolV2InstructionArgs { - tick_spacing: self.tick_spacing.clone().expect("tick_spacing is not set"), - initial_sqrt_price: self - .initial_sqrt_price - .clone() - .expect("initial_sqrt_price is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_pool_v2` CPI accounts. -pub struct InitializePoolV2CpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_b: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_pool_v2` CPI instruction. -pub struct InitializePoolV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_b: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePoolV2InstructionArgs, -} - -impl<'a, 'b> InitializePoolV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePoolV2CpiAccounts<'a, 'b>, - args: InitializePoolV2InstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - token_mint_a: accounts.token_mint_a, - token_mint_b: accounts.token_mint_b, - token_badge_a: accounts.token_badge_a, - token_badge_b: accounts.token_badge_b, - funder: accounts.funder, - whirlpool: accounts.whirlpool, - token_vault_a: accounts.token_vault_a, - token_vault_b: accounts.token_vault_b, - fee_tier: accounts.fee_tier, - token_program_a: accounts.token_program_a, - token_program_b: accounts.token_program_b, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_badge_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_badge_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePoolV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.token_mint_a.clone()); - account_infos.push(self.token_mint_b.clone()); - account_infos.push(self.token_badge_a.clone()); - account_infos.push(self.token_badge_b.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.fee_tier.clone()); - account_infos.push(self.token_program_a.clone()); - account_infos.push(self.token_program_b.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePoolV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[]` token_mint_a -/// 2. `[]` token_mint_b -/// 3. `[]` token_badge_a -/// 4. `[]` token_badge_b -/// 5. `[writable, signer]` funder -/// 6. `[writable]` whirlpool -/// 7. `[writable, signer]` token_vault_a -/// 8. `[writable, signer]` token_vault_b -/// 9. `[]` fee_tier -/// 10. `[]` token_program_a -/// 11. `[]` token_program_b -/// 12. `[]` system_program -/// 13. `[]` rent -#[derive(Clone, Debug)] -pub struct InitializePoolV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePoolV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePoolV2CpiBuilderInstruction { - __program: program, - whirlpools_config: None, - token_mint_a: None, - token_mint_b: None, - token_badge_a: None, - token_badge_b: None, - funder: None, - whirlpool: None, - token_vault_a: None, - token_vault_b: None, - fee_tier: None, - token_program_a: None, - token_program_b: None, - system_program: None, - rent: None, - tick_spacing: None, - initial_sqrt_price: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn token_mint_a( - &mut self, - token_mint_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b( - &mut self, - token_mint_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_badge_a( - &mut self, - token_badge_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge_a = Some(token_badge_a); - self - } - - #[inline(always)] - pub fn token_badge_b( - &mut self, - token_badge_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge_b = Some(token_badge_b); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn fee_tier(&mut self, fee_tier: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_tier = Some(fee_tier); - self - } - - #[inline(always)] - pub fn token_program_a( - &mut self, - token_program_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b( - &mut self, - token_program_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self { - self.instruction.tick_spacing = Some(tick_spacing); - self - } - - #[inline(always)] - pub fn initial_sqrt_price(&mut self, initial_sqrt_price: u128) -> &mut Self { - self.instruction.initial_sqrt_price = Some(initial_sqrt_price); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePoolV2InstructionArgs { - tick_spacing: self - .instruction - .tick_spacing - .clone() - .expect("tick_spacing is not set"), - initial_sqrt_price: self - .instruction - .initial_sqrt_price - .clone() - .expect("initial_sqrt_price is not set"), - }; - let instruction = InitializePoolV2Cpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - token_mint_a: self - .instruction - .token_mint_a - .expect("token_mint_a is not set"), - - token_mint_b: self - .instruction - .token_mint_b - .expect("token_mint_b is not set"), - - token_badge_a: self - .instruction - .token_badge_a - .expect("token_badge_a is not set"), - - token_badge_b: self - .instruction - .token_badge_b - .expect("token_badge_b is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - fee_tier: self.instruction.fee_tier.expect("fee_tier is not set"), - - token_program_a: self - .instruction - .token_program_a - .expect("token_program_a is not set"), - - token_program_b: self - .instruction - .token_program_b - .expect("token_program_b is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePoolV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_b: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_b: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_spacing: Option, - initial_sqrt_price: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_pool_with_adaptive_fee.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_pool_with_adaptive_fee.rs deleted file mode 100644 index 314cc33e..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_pool_with_adaptive_fee.rs +++ /dev/null @@ -1,958 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePoolWithAdaptiveFee { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub token_mint_a: solana_pubkey::Pubkey, - - pub token_mint_b: solana_pubkey::Pubkey, - - pub token_badge_a: solana_pubkey::Pubkey, - - pub token_badge_b: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub initialize_pool_authority: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub adaptive_fee_tier: solana_pubkey::Pubkey, - - pub token_program_a: solana_pubkey::Pubkey, - - pub token_program_b: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl InitializePoolWithAdaptiveFee { - pub fn instruction( - &self, - args: InitializePoolWithAdaptiveFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializePoolWithAdaptiveFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_badge_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_badge_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.initialize_pool_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.adaptive_fee_tier, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializePoolWithAdaptiveFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolWithAdaptiveFeeInstructionData { - discriminator: [u8; 8], -} - -impl InitializePoolWithAdaptiveFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [143, 94, 96, 76, 172, 124, 119, 199], - } - } -} - -impl Default for InitializePoolWithAdaptiveFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePoolWithAdaptiveFeeInstructionArgs { - pub initial_sqrt_price: u128, - pub trade_enable_timestamp: Option, -} - -/// Instruction builder for `InitializePoolWithAdaptiveFee`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[]` token_mint_a -/// 2. `[]` token_mint_b -/// 3. `[]` token_badge_a -/// 4. `[]` token_badge_b -/// 5. `[writable, signer]` funder -/// 6. `[signer]` initialize_pool_authority -/// 7. `[writable]` whirlpool -/// 8. `[writable]` oracle -/// 9. `[writable, signer]` token_vault_a -/// 10. `[writable, signer]` token_vault_b -/// 11. `[]` adaptive_fee_tier -/// 12. `[]` token_program_a -/// 13. `[]` token_program_b -/// 14. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 15. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializePoolWithAdaptiveFeeBuilder { - whirlpools_config: Option, - token_mint_a: Option, - token_mint_b: Option, - token_badge_a: Option, - token_badge_b: Option, - funder: Option, - initialize_pool_authority: Option, - whirlpool: Option, - oracle: Option, - token_vault_a: Option, - token_vault_b: Option, - adaptive_fee_tier: Option, - token_program_a: Option, - token_program_b: Option, - system_program: Option, - rent: Option, - initial_sqrt_price: Option, - trade_enable_timestamp: Option, - __remaining_accounts: Vec, -} - -impl InitializePoolWithAdaptiveFeeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn token_mint_a(&mut self, token_mint_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b(&mut self, token_mint_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_badge_a(&mut self, token_badge_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_badge_a = Some(token_badge_a); - self - } - - #[inline(always)] - pub fn token_badge_b(&mut self, token_badge_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_badge_b = Some(token_badge_b); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn initialize_pool_authority( - &mut self, - initialize_pool_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.initialize_pool_authority = Some(initialize_pool_authority); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier(&mut self, adaptive_fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn token_program_a(&mut self, token_program_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b(&mut self, token_program_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_b = Some(token_program_b); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn initial_sqrt_price(&mut self, initial_sqrt_price: u128) -> &mut Self { - self.initial_sqrt_price = Some(initial_sqrt_price); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn trade_enable_timestamp(&mut self, trade_enable_timestamp: u64) -> &mut Self { - self.trade_enable_timestamp = Some(trade_enable_timestamp); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePoolWithAdaptiveFee { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - token_mint_a: self.token_mint_a.expect("token_mint_a is not set"), - token_mint_b: self.token_mint_b.expect("token_mint_b is not set"), - token_badge_a: self.token_badge_a.expect("token_badge_a is not set"), - token_badge_b: self.token_badge_b.expect("token_badge_b is not set"), - funder: self.funder.expect("funder is not set"), - initialize_pool_authority: self - .initialize_pool_authority - .expect("initialize_pool_authority is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - oracle: self.oracle.expect("oracle is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - adaptive_fee_tier: self - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - token_program_a: self.token_program_a.expect("token_program_a is not set"), - token_program_b: self.token_program_b.expect("token_program_b is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = InitializePoolWithAdaptiveFeeInstructionArgs { - initial_sqrt_price: self - .initial_sqrt_price - .clone() - .expect("initial_sqrt_price is not set"), - trade_enable_timestamp: self.trade_enable_timestamp.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_pool_with_adaptive_fee` CPI accounts. -pub struct InitializePoolWithAdaptiveFeeCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_b: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub initialize_pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_pool_with_adaptive_fee` CPI instruction. -pub struct InitializePoolWithAdaptiveFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_b: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub initialize_pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializePoolWithAdaptiveFeeInstructionArgs, -} - -impl<'a, 'b> InitializePoolWithAdaptiveFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePoolWithAdaptiveFeeCpiAccounts<'a, 'b>, - args: InitializePoolWithAdaptiveFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - token_mint_a: accounts.token_mint_a, - token_mint_b: accounts.token_mint_b, - token_badge_a: accounts.token_badge_a, - token_badge_b: accounts.token_badge_b, - funder: accounts.funder, - initialize_pool_authority: accounts.initialize_pool_authority, - whirlpool: accounts.whirlpool, - oracle: accounts.oracle, - token_vault_a: accounts.token_vault_a, - token_vault_b: accounts.token_vault_b, - adaptive_fee_tier: accounts.adaptive_fee_tier, - token_program_a: accounts.token_program_a, - token_program_b: accounts.token_program_b, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_badge_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_badge_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.initialize_pool_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.adaptive_fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializePoolWithAdaptiveFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.token_mint_a.clone()); - account_infos.push(self.token_mint_b.clone()); - account_infos.push(self.token_badge_a.clone()); - account_infos.push(self.token_badge_b.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.initialize_pool_authority.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.oracle.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.adaptive_fee_tier.clone()); - account_infos.push(self.token_program_a.clone()); - account_infos.push(self.token_program_b.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePoolWithAdaptiveFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[]` token_mint_a -/// 2. `[]` token_mint_b -/// 3. `[]` token_badge_a -/// 4. `[]` token_badge_b -/// 5. `[writable, signer]` funder -/// 6. `[signer]` initialize_pool_authority -/// 7. `[writable]` whirlpool -/// 8. `[writable]` oracle -/// 9. `[writable, signer]` token_vault_a -/// 10. `[writable, signer]` token_vault_b -/// 11. `[]` adaptive_fee_tier -/// 12. `[]` token_program_a -/// 13. `[]` token_program_b -/// 14. `[]` system_program -/// 15. `[]` rent -#[derive(Clone, Debug)] -pub struct InitializePoolWithAdaptiveFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePoolWithAdaptiveFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePoolWithAdaptiveFeeCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - token_mint_a: None, - token_mint_b: None, - token_badge_a: None, - token_badge_b: None, - funder: None, - initialize_pool_authority: None, - whirlpool: None, - oracle: None, - token_vault_a: None, - token_vault_b: None, - adaptive_fee_tier: None, - token_program_a: None, - token_program_b: None, - system_program: None, - rent: None, - initial_sqrt_price: None, - trade_enable_timestamp: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn token_mint_a( - &mut self, - token_mint_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b( - &mut self, - token_mint_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_badge_a( - &mut self, - token_badge_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge_a = Some(token_badge_a); - self - } - - #[inline(always)] - pub fn token_badge_b( - &mut self, - token_badge_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge_b = Some(token_badge_b); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn initialize_pool_authority( - &mut self, - initialize_pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.initialize_pool_authority = Some(initialize_pool_authority); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier( - &mut self, - adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn token_program_a( - &mut self, - token_program_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b( - &mut self, - token_program_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn initial_sqrt_price(&mut self, initial_sqrt_price: u128) -> &mut Self { - self.instruction.initial_sqrt_price = Some(initial_sqrt_price); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn trade_enable_timestamp(&mut self, trade_enable_timestamp: u64) -> &mut Self { - self.instruction.trade_enable_timestamp = Some(trade_enable_timestamp); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializePoolWithAdaptiveFeeInstructionArgs { - initial_sqrt_price: self - .instruction - .initial_sqrt_price - .clone() - .expect("initial_sqrt_price is not set"), - trade_enable_timestamp: self.instruction.trade_enable_timestamp.clone(), - }; - let instruction = InitializePoolWithAdaptiveFeeCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - token_mint_a: self - .instruction - .token_mint_a - .expect("token_mint_a is not set"), - - token_mint_b: self - .instruction - .token_mint_b - .expect("token_mint_b is not set"), - - token_badge_a: self - .instruction - .token_badge_a - .expect("token_badge_a is not set"), - - token_badge_b: self - .instruction - .token_badge_b - .expect("token_badge_b is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - initialize_pool_authority: self - .instruction - .initialize_pool_authority - .expect("initialize_pool_authority is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - adaptive_fee_tier: self - .instruction - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - - token_program_a: self - .instruction - .token_program_a - .expect("token_program_a is not set"), - - token_program_b: self - .instruction - .token_program_b - .expect("token_program_b is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePoolWithAdaptiveFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_b: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - initialize_pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - adaptive_fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_b: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - initial_sqrt_price: Option, - trade_enable_timestamp: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_position_bundle.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_position_bundle.rs deleted file mode 100644 index f391cad0..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_position_bundle.rs +++ /dev/null @@ -1,629 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePositionBundle { - pub position_bundle: solana_pubkey::Pubkey, - - pub position_bundle_mint: solana_pubkey::Pubkey, - - pub position_bundle_token_account: solana_pubkey::Pubkey, - - pub position_bundle_owner: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl InitializePositionBundle { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_bundle_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializePositionBundleInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePositionBundleInstructionData { - discriminator: [u8; 8], -} - -impl InitializePositionBundleInstructionData { - pub fn new() -> Self { - Self { - discriminator: [117, 45, 241, 149, 24, 18, 194, 65], - } - } -} - -impl Default for InitializePositionBundleInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `InitializePositionBundle`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position_bundle -/// 1. `[writable, signer]` position_bundle_mint -/// 2. `[writable]` position_bundle_token_account -/// 3. `[]` position_bundle_owner -/// 4. `[writable, signer]` funder -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 7. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 8. `[]` associated_token_program -#[derive(Clone, Debug, Default)] -pub struct InitializePositionBundleBuilder { - position_bundle: Option, - position_bundle_mint: Option, - position_bundle_token_account: Option, - position_bundle_owner: Option, - funder: Option, - token_program: Option, - system_program: Option, - rent: Option, - associated_token_program: Option, - __remaining_accounts: Vec, -} - -impl InitializePositionBundleBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position_bundle(&mut self, position_bundle: solana_pubkey::Pubkey) -> &mut Self { - self.position_bundle = Some(position_bundle); - self - } - - #[inline(always)] - pub fn position_bundle_mint( - &mut self, - position_bundle_mint: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_mint = Some(position_bundle_mint); - self - } - - #[inline(always)] - pub fn position_bundle_token_account( - &mut self, - position_bundle_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_token_account = Some(position_bundle_token_account); - self - } - - #[inline(always)] - pub fn position_bundle_owner( - &mut self, - position_bundle_owner: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_owner = Some(position_bundle_owner); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePositionBundle { - position_bundle: self.position_bundle.expect("position_bundle is not set"), - position_bundle_mint: self - .position_bundle_mint - .expect("position_bundle_mint is not set"), - position_bundle_token_account: self - .position_bundle_token_account - .expect("position_bundle_token_account is not set"), - position_bundle_owner: self - .position_bundle_owner - .expect("position_bundle_owner is not set"), - funder: self.funder.expect("funder is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize_position_bundle` CPI accounts. -pub struct InitializePositionBundleCpiAccounts<'a, 'b> { - pub position_bundle: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_owner: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_position_bundle` CPI instruction. -pub struct InitializePositionBundleCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_owner: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializePositionBundleCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePositionBundleCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position_bundle: accounts.position_bundle, - position_bundle_mint: accounts.position_bundle_mint, - position_bundle_token_account: accounts.position_bundle_token_account, - position_bundle_owner: accounts.position_bundle_owner, - funder: accounts.funder, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - associated_token_program: accounts.associated_token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_bundle_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializePositionBundleInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position_bundle.clone()); - account_infos.push(self.position_bundle_mint.clone()); - account_infos.push(self.position_bundle_token_account.clone()); - account_infos.push(self.position_bundle_owner.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePositionBundle` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position_bundle -/// 1. `[writable, signer]` position_bundle_mint -/// 2. `[writable]` position_bundle_token_account -/// 3. `[]` position_bundle_owner -/// 4. `[writable, signer]` funder -/// 5. `[]` token_program -/// 6. `[]` system_program -/// 7. `[]` rent -/// 8. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct InitializePositionBundleCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePositionBundleCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePositionBundleCpiBuilderInstruction { - __program: program, - position_bundle: None, - position_bundle_mint: None, - position_bundle_token_account: None, - position_bundle_owner: None, - funder: None, - token_program: None, - system_program: None, - rent: None, - associated_token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position_bundle( - &mut self, - position_bundle: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle = Some(position_bundle); - self - } - - #[inline(always)] - pub fn position_bundle_mint( - &mut self, - position_bundle_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_mint = Some(position_bundle_mint); - self - } - - #[inline(always)] - pub fn position_bundle_token_account( - &mut self, - position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_token_account = Some(position_bundle_token_account); - self - } - - #[inline(always)] - pub fn position_bundle_owner( - &mut self, - position_bundle_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_owner = Some(position_bundle_owner); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializePositionBundleCpi { - __program: self.instruction.__program, - - position_bundle: self - .instruction - .position_bundle - .expect("position_bundle is not set"), - - position_bundle_mint: self - .instruction - .position_bundle_mint - .expect("position_bundle_mint is not set"), - - position_bundle_token_account: self - .instruction - .position_bundle_token_account - .expect("position_bundle_token_account is not set"), - - position_bundle_owner: self - .instruction - .position_bundle_owner - .expect("position_bundle_owner is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePositionBundleCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position_bundle: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_position_bundle_with_metadata.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_position_bundle_with_metadata.rs deleted file mode 100644 index 68508cee..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_position_bundle_with_metadata.rs +++ /dev/null @@ -1,769 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializePositionBundleWithMetadata { - pub position_bundle: solana_pubkey::Pubkey, - - pub position_bundle_mint: solana_pubkey::Pubkey, - /// https://github.com/metaplex-foundation/metaplex-program-library/blob/773a574c4b34e5b9f248a81306ec24db064e255f/token-metadata/program/src/utils/metadata.rs#L100 - pub position_bundle_metadata: solana_pubkey::Pubkey, - - pub position_bundle_token_account: solana_pubkey::Pubkey, - - pub position_bundle_owner: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub metadata_update_auth: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, -} - -impl InitializePositionBundleWithMetadata { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_bundle_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_update_auth, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = - borsh::to_vec(&InitializePositionBundleWithMetadataInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializePositionBundleWithMetadataInstructionData { - discriminator: [u8; 8], -} - -impl InitializePositionBundleWithMetadataInstructionData { - pub fn new() -> Self { - Self { - discriminator: [93, 124, 16, 179, 249, 131, 115, 245], - } - } -} - -impl Default for InitializePositionBundleWithMetadataInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `InitializePositionBundleWithMetadata`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position_bundle -/// 1. `[writable, signer]` position_bundle_mint -/// 2. `[writable]` position_bundle_metadata -/// 3. `[writable]` position_bundle_token_account -/// 4. `[]` position_bundle_owner -/// 5. `[writable, signer]` funder -/// 6. `[]` metadata_update_auth -/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 10. `[]` associated_token_program -/// 11. `[]` metadata_program -#[derive(Clone, Debug, Default)] -pub struct InitializePositionBundleWithMetadataBuilder { - position_bundle: Option, - position_bundle_mint: Option, - position_bundle_metadata: Option, - position_bundle_token_account: Option, - position_bundle_owner: Option, - funder: Option, - metadata_update_auth: Option, - token_program: Option, - system_program: Option, - rent: Option, - associated_token_program: Option, - metadata_program: Option, - __remaining_accounts: Vec, -} - -impl InitializePositionBundleWithMetadataBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position_bundle(&mut self, position_bundle: solana_pubkey::Pubkey) -> &mut Self { - self.position_bundle = Some(position_bundle); - self - } - - #[inline(always)] - pub fn position_bundle_mint( - &mut self, - position_bundle_mint: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_mint = Some(position_bundle_mint); - self - } - - /// https://github.com/metaplex-foundation/metaplex-program-library/blob/773a574c4b34e5b9f248a81306ec24db064e255f/token-metadata/program/src/utils/metadata.rs#L100 - #[inline(always)] - pub fn position_bundle_metadata( - &mut self, - position_bundle_metadata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_metadata = Some(position_bundle_metadata); - self - } - - #[inline(always)] - pub fn position_bundle_token_account( - &mut self, - position_bundle_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_token_account = Some(position_bundle_token_account); - self - } - - #[inline(always)] - pub fn position_bundle_owner( - &mut self, - position_bundle_owner: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_owner = Some(position_bundle_owner); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn metadata_update_auth( - &mut self, - metadata_update_auth: solana_pubkey::Pubkey, - ) -> &mut Self { - self.metadata_update_auth = Some(metadata_update_auth); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializePositionBundleWithMetadata { - position_bundle: self.position_bundle.expect("position_bundle is not set"), - position_bundle_mint: self - .position_bundle_mint - .expect("position_bundle_mint is not set"), - position_bundle_metadata: self - .position_bundle_metadata - .expect("position_bundle_metadata is not set"), - position_bundle_token_account: self - .position_bundle_token_account - .expect("position_bundle_token_account is not set"), - position_bundle_owner: self - .position_bundle_owner - .expect("position_bundle_owner is not set"), - funder: self.funder.expect("funder is not set"), - metadata_update_auth: self - .metadata_update_auth - .expect("metadata_update_auth is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize_position_bundle_with_metadata` CPI accounts. -pub struct InitializePositionBundleWithMetadataCpiAccounts<'a, 'b> { - pub position_bundle: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_mint: &'b solana_account_info::AccountInfo<'a>, - /// https://github.com/metaplex-foundation/metaplex-program-library/blob/773a574c4b34e5b9f248a81306ec24db064e255f/token-metadata/program/src/utils/metadata.rs#L100 - pub position_bundle_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_owner: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_update_auth: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_position_bundle_with_metadata` CPI instruction. -pub struct InitializePositionBundleWithMetadataCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_mint: &'b solana_account_info::AccountInfo<'a>, - /// https://github.com/metaplex-foundation/metaplex-program-library/blob/773a574c4b34e5b9f248a81306ec24db064e255f/token-metadata/program/src/utils/metadata.rs#L100 - pub position_bundle_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_owner: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_update_auth: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializePositionBundleWithMetadataCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializePositionBundleWithMetadataCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position_bundle: accounts.position_bundle, - position_bundle_mint: accounts.position_bundle_mint, - position_bundle_metadata: accounts.position_bundle_metadata, - position_bundle_token_account: accounts.position_bundle_token_account, - position_bundle_owner: accounts.position_bundle_owner, - funder: accounts.funder, - metadata_update_auth: accounts.metadata_update_auth, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - associated_token_program: accounts.associated_token_program, - metadata_program: accounts.metadata_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_bundle_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_update_auth.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = - borsh::to_vec(&InitializePositionBundleWithMetadataInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position_bundle.clone()); - account_infos.push(self.position_bundle_mint.clone()); - account_infos.push(self.position_bundle_metadata.clone()); - account_infos.push(self.position_bundle_token_account.clone()); - account_infos.push(self.position_bundle_owner.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.metadata_update_auth.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.metadata_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializePositionBundleWithMetadata` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` position_bundle -/// 1. `[writable, signer]` position_bundle_mint -/// 2. `[writable]` position_bundle_metadata -/// 3. `[writable]` position_bundle_token_account -/// 4. `[]` position_bundle_owner -/// 5. `[writable, signer]` funder -/// 6. `[]` metadata_update_auth -/// 7. `[]` token_program -/// 8. `[]` system_program -/// 9. `[]` rent -/// 10. `[]` associated_token_program -/// 11. `[]` metadata_program -#[derive(Clone, Debug)] -pub struct InitializePositionBundleWithMetadataCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializePositionBundleWithMetadataCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializePositionBundleWithMetadataCpiBuilderInstruction { - __program: program, - position_bundle: None, - position_bundle_mint: None, - position_bundle_metadata: None, - position_bundle_token_account: None, - position_bundle_owner: None, - funder: None, - metadata_update_auth: None, - token_program: None, - system_program: None, - rent: None, - associated_token_program: None, - metadata_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position_bundle( - &mut self, - position_bundle: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle = Some(position_bundle); - self - } - - #[inline(always)] - pub fn position_bundle_mint( - &mut self, - position_bundle_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_mint = Some(position_bundle_mint); - self - } - - /// https://github.com/metaplex-foundation/metaplex-program-library/blob/773a574c4b34e5b9f248a81306ec24db064e255f/token-metadata/program/src/utils/metadata.rs#L100 - #[inline(always)] - pub fn position_bundle_metadata( - &mut self, - position_bundle_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_metadata = Some(position_bundle_metadata); - self - } - - #[inline(always)] - pub fn position_bundle_token_account( - &mut self, - position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_token_account = Some(position_bundle_token_account); - self - } - - #[inline(always)] - pub fn position_bundle_owner( - &mut self, - position_bundle_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_owner = Some(position_bundle_owner); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn metadata_update_auth( - &mut self, - metadata_update_auth: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_update_auth = Some(metadata_update_auth); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializePositionBundleWithMetadataCpi { - __program: self.instruction.__program, - - position_bundle: self - .instruction - .position_bundle - .expect("position_bundle is not set"), - - position_bundle_mint: self - .instruction - .position_bundle_mint - .expect("position_bundle_mint is not set"), - - position_bundle_metadata: self - .instruction - .position_bundle_metadata - .expect("position_bundle_metadata is not set"), - - position_bundle_token_account: self - .instruction - .position_bundle_token_account - .expect("position_bundle_token_account is not set"), - - position_bundle_owner: self - .instruction - .position_bundle_owner - .expect("position_bundle_owner is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - metadata_update_auth: self - .instruction - .metadata_update_auth - .expect("metadata_update_auth is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializePositionBundleWithMetadataCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position_bundle: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_update_auth: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_reward.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_reward.rs deleted file mode 100644 index 6bd40b57..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_reward.rs +++ /dev/null @@ -1,602 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeReward { - pub reward_authority: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl InitializeReward { - pub fn instruction( - &self, - args: InitializeRewardInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeRewardInstructionData { - discriminator: [u8; 8], -} - -impl InitializeRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [95, 135, 192, 196, 242, 129, 230, 68], - } - } -} - -impl Default for InitializeRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeRewardInstructionArgs { - pub reward_index: u8, -} - -/// Instruction builder for `InitializeReward`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` reward_authority -/// 1. `[writable, signer]` funder -/// 2. `[writable]` whirlpool -/// 3. `[]` reward_mint -/// 4. `[writable, signer]` reward_vault -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 7. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeRewardBuilder { - reward_authority: Option, - funder: Option, - whirlpool: Option, - reward_mint: Option, - reward_vault: Option, - token_program: Option, - system_program: Option, - rent: Option, - reward_index: Option, - __remaining_accounts: Vec, -} - -impl InitializeRewardBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn reward_authority(&mut self, reward_authority: solana_pubkey::Pubkey) -> &mut Self { - self.reward_authority = Some(reward_authority); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeReward { - reward_authority: self.reward_authority.expect("reward_authority is not set"), - funder: self.funder.expect("funder is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = InitializeRewardInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_reward` CPI accounts. -pub struct InitializeRewardCpiAccounts<'a, 'b> { - pub reward_authority: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_reward` CPI instruction. -pub struct InitializeRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub reward_authority: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeRewardInstructionArgs, -} - -impl<'a, 'b> InitializeRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeRewardCpiAccounts<'a, 'b>, - args: InitializeRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - reward_authority: accounts.reward_authority, - funder: accounts.funder, - whirlpool: accounts.whirlpool, - reward_mint: accounts.reward_mint, - reward_vault: accounts.reward_vault, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.reward_authority.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` reward_authority -/// 1. `[writable, signer]` funder -/// 2. `[writable]` whirlpool -/// 3. `[]` reward_mint -/// 4. `[writable, signer]` reward_vault -/// 5. `[]` token_program -/// 6. `[]` system_program -/// 7. `[]` rent -#[derive(Clone, Debug)] -pub struct InitializeRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeRewardCpiBuilderInstruction { - __program: program, - reward_authority: None, - funder: None, - whirlpool: None, - reward_mint: None, - reward_vault: None, - token_program: None, - system_program: None, - rent: None, - reward_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn reward_authority( - &mut self, - reward_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_authority = Some(reward_authority); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeRewardInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - }; - let instruction = InitializeRewardCpi { - __program: self.instruction.__program, - - reward_authority: self - .instruction - .reward_authority - .expect("reward_authority is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - reward_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_reward_v2.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_reward_v2.rs deleted file mode 100644 index c66795e5..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_reward_v2.rs +++ /dev/null @@ -1,648 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeRewardV2 { - pub reward_authority: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub reward_mint: solana_pubkey::Pubkey, - - pub reward_token_badge: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, - - pub reward_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl InitializeRewardV2 { - pub fn instruction( - &self, - args: InitializeRewardV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeRewardV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_token_badge, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_vault, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeRewardV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeRewardV2InstructionData { - discriminator: [u8; 8], -} - -impl InitializeRewardV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [91, 1, 77, 50, 235, 229, 133, 49], - } - } -} - -impl Default for InitializeRewardV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeRewardV2InstructionArgs { - pub reward_index: u8, -} - -/// Instruction builder for `InitializeRewardV2`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` reward_authority -/// 1. `[writable, signer]` funder -/// 2. `[writable]` whirlpool -/// 3. `[]` reward_mint -/// 4. `[]` reward_token_badge -/// 5. `[writable, signer]` reward_vault -/// 6. `[]` reward_token_program -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 8. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeRewardV2Builder { - reward_authority: Option, - funder: Option, - whirlpool: Option, - reward_mint: Option, - reward_token_badge: Option, - reward_vault: Option, - reward_token_program: Option, - system_program: Option, - rent: Option, - reward_index: Option, - __remaining_accounts: Vec, -} - -impl InitializeRewardV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn reward_authority(&mut self, reward_authority: solana_pubkey::Pubkey) -> &mut Self { - self.reward_authority = Some(reward_authority); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_mint(&mut self, reward_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn reward_token_badge(&mut self, reward_token_badge: solana_pubkey::Pubkey) -> &mut Self { - self.reward_token_badge = Some(reward_token_badge); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_token_program( - &mut self, - reward_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.reward_token_program = Some(reward_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeRewardV2 { - reward_authority: self.reward_authority.expect("reward_authority is not set"), - funder: self.funder.expect("funder is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - reward_mint: self.reward_mint.expect("reward_mint is not set"), - reward_token_badge: self - .reward_token_badge - .expect("reward_token_badge is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - reward_token_program: self - .reward_token_program - .expect("reward_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = InitializeRewardV2InstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_reward_v2` CPI accounts. -pub struct InitializeRewardV2CpiAccounts<'a, 'b> { - pub reward_authority: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_reward_v2` CPI instruction. -pub struct InitializeRewardV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub reward_authority: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_mint: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeRewardV2InstructionArgs, -} - -impl<'a, 'b> InitializeRewardV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeRewardV2CpiAccounts<'a, 'b>, - args: InitializeRewardV2InstructionArgs, - ) -> Self { - Self { - __program: program, - reward_authority: accounts.reward_authority, - funder: accounts.funder, - whirlpool: accounts.whirlpool, - reward_mint: accounts.reward_mint, - reward_token_badge: accounts.reward_token_badge, - reward_vault: accounts.reward_vault, - reward_token_program: accounts.reward_token_program, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_token_badge.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_vault.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeRewardV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.reward_authority.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.reward_mint.clone()); - account_infos.push(self.reward_token_badge.clone()); - account_infos.push(self.reward_vault.clone()); - account_infos.push(self.reward_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeRewardV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` reward_authority -/// 1. `[writable, signer]` funder -/// 2. `[writable]` whirlpool -/// 3. `[]` reward_mint -/// 4. `[]` reward_token_badge -/// 5. `[writable, signer]` reward_vault -/// 6. `[]` reward_token_program -/// 7. `[]` system_program -/// 8. `[]` rent -#[derive(Clone, Debug)] -pub struct InitializeRewardV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeRewardV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeRewardV2CpiBuilderInstruction { - __program: program, - reward_authority: None, - funder: None, - whirlpool: None, - reward_mint: None, - reward_token_badge: None, - reward_vault: None, - reward_token_program: None, - system_program: None, - rent: None, - reward_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn reward_authority( - &mut self, - reward_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_authority = Some(reward_authority); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_mint( - &mut self, - reward_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_mint = Some(reward_mint); - self - } - - #[inline(always)] - pub fn reward_token_badge( - &mut self, - reward_token_badge: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_token_badge = Some(reward_token_badge); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_token_program( - &mut self, - reward_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_token_program = Some(reward_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeRewardV2InstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - }; - let instruction = InitializeRewardV2Cpi { - __program: self.instruction.__program, - - reward_authority: self - .instruction - .reward_authority - .expect("reward_authority is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - reward_mint: self - .instruction - .reward_mint - .expect("reward_mint is not set"), - - reward_token_badge: self - .instruction - .reward_token_badge - .expect("reward_token_badge is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - - reward_token_program: self - .instruction - .reward_token_program - .expect("reward_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeRewardV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - reward_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_token_badge: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_tick_array.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_tick_array.rs deleted file mode 100644 index 44e15f35..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_tick_array.rs +++ /dev/null @@ -1,435 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeTickArray { - pub whirlpool: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub tick_array: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeTickArray { - pub fn instruction( - &self, - args: InitializeTickArrayInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeTickArrayInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new(self.tick_array, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeTickArrayInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeTickArrayInstructionData { - discriminator: [u8; 8], -} - -impl InitializeTickArrayInstructionData { - pub fn new() -> Self { - Self { - discriminator: [11, 188, 193, 214, 141, 91, 149, 184], - } - } -} - -impl Default for InitializeTickArrayInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeTickArrayInstructionArgs { - pub start_tick_index: i32, -} - -/// Instruction builder for `InitializeTickArray`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[writable, signer]` funder -/// 2. `[writable]` tick_array -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeTickArrayBuilder { - whirlpool: Option, - funder: Option, - tick_array: Option, - system_program: Option, - start_tick_index: Option, - __remaining_accounts: Vec, -} - -impl InitializeTickArrayBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn tick_array(&mut self, tick_array: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array = Some(tick_array); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn start_tick_index(&mut self, start_tick_index: i32) -> &mut Self { - self.start_tick_index = Some(start_tick_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeTickArray { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - funder: self.funder.expect("funder is not set"), - tick_array: self.tick_array.expect("tick_array is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializeTickArrayInstructionArgs { - start_tick_index: self - .start_tick_index - .clone() - .expect("start_tick_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_tick_array` CPI accounts. -pub struct InitializeTickArrayCpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_tick_array` CPI instruction. -pub struct InitializeTickArrayCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeTickArrayInstructionArgs, -} - -impl<'a, 'b> InitializeTickArrayCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeTickArrayCpiAccounts<'a, 'b>, - args: InitializeTickArrayInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - funder: accounts.funder, - tick_array: accounts.tick_array, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeTickArrayInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.tick_array.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeTickArray` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpool -/// 1. `[writable, signer]` funder -/// 2. `[writable]` tick_array -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeTickArrayCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeTickArrayCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeTickArrayCpiBuilderInstruction { - __program: program, - whirlpool: None, - funder: None, - tick_array: None, - system_program: None, - start_tick_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn tick_array( - &mut self, - tick_array: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array = Some(tick_array); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn start_tick_index(&mut self, start_tick_index: i32) -> &mut Self { - self.instruction.start_tick_index = Some(start_tick_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeTickArrayInstructionArgs { - start_tick_index: self - .instruction - .start_tick_index - .clone() - .expect("start_tick_index is not set"), - }; - let instruction = InitializeTickArrayCpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - tick_array: self.instruction.tick_array.expect("tick_array is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeTickArrayCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - start_tick_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_token_badge.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_token_badge.rs deleted file mode 100644 index a772a669..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/initialize_token_badge.rs +++ /dev/null @@ -1,535 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeTokenBadge { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub whirlpools_config_extension: solana_pubkey::Pubkey, - - pub token_badge_authority: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub token_badge: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeTokenBadge { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config_extension, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_badge_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_badge, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeTokenBadgeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeTokenBadgeInstructionData { - discriminator: [u8; 8], -} - -impl InitializeTokenBadgeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [253, 77, 205, 95, 27, 224, 89, 223], - } - } -} - -impl Default for InitializeTokenBadgeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `InitializeTokenBadge`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[]` whirlpools_config_extension -/// 2. `[signer]` token_badge_authority -/// 3. `[]` token_mint -/// 4. `[writable]` token_badge -/// 5. `[writable, signer]` funder -/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeTokenBadgeBuilder { - whirlpools_config: Option, - whirlpools_config_extension: Option, - token_badge_authority: Option, - token_mint: Option, - token_badge: Option, - funder: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl InitializeTokenBadgeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpools_config_extension( - &mut self, - whirlpools_config_extension: solana_pubkey::Pubkey, - ) -> &mut Self { - self.whirlpools_config_extension = Some(whirlpools_config_extension); - self - } - - #[inline(always)] - pub fn token_badge_authority( - &mut self, - token_badge_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_badge_authority = Some(token_badge_authority); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn token_badge(&mut self, token_badge: solana_pubkey::Pubkey) -> &mut Self { - self.token_badge = Some(token_badge); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeTokenBadge { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - whirlpools_config_extension: self - .whirlpools_config_extension - .expect("whirlpools_config_extension is not set"), - token_badge_authority: self - .token_badge_authority - .expect("token_badge_authority is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - token_badge: self.token_badge.expect("token_badge is not set"), - funder: self.funder.expect("funder is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize_token_badge` CPI accounts. -pub struct InitializeTokenBadgeCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_authority: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_token_badge` CPI instruction. -pub struct InitializeTokenBadgeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge_authority: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_badge: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializeTokenBadgeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeTokenBadgeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - whirlpools_config_extension: accounts.whirlpools_config_extension, - token_badge_authority: accounts.token_badge_authority, - token_mint: accounts.token_mint, - token_badge: accounts.token_badge, - funder: accounts.funder, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config_extension.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_badge_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_badge.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializeTokenBadgeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.whirlpools_config_extension.clone()); - account_infos.push(self.token_badge_authority.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.token_badge.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeTokenBadge` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[]` whirlpools_config_extension -/// 2. `[signer]` token_badge_authority -/// 3. `[]` token_mint -/// 4. `[writable]` token_badge -/// 5. `[writable, signer]` funder -/// 6. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeTokenBadgeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeTokenBadgeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeTokenBadgeCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - whirlpools_config_extension: None, - token_badge_authority: None, - token_mint: None, - token_badge: None, - funder: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpools_config_extension( - &mut self, - whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config_extension = Some(whirlpools_config_extension); - self - } - - #[inline(always)] - pub fn token_badge_authority( - &mut self, - token_badge_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge_authority = Some(token_badge_authority); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn token_badge( - &mut self, - token_badge: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_badge = Some(token_badge); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializeTokenBadgeCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - whirlpools_config_extension: self - .instruction - .whirlpools_config_extension - .expect("whirlpools_config_extension is not set"), - - token_badge_authority: self - .instruction - .token_badge_authority - .expect("token_badge_authority is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - token_badge: self - .instruction - .token_badge - .expect("token_badge is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeTokenBadgeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpools_config_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_badge: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/lock_position.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/lock_position.rs deleted file mode 100644 index 742428b0..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/lock_position.rs +++ /dev/null @@ -1,653 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::LockType; - -/// Accounts. -#[derive(Debug)] -pub struct LockPosition { - pub funder: solana_pubkey::Pubkey, - - pub position_authority: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_mint: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub lock_config: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub token2022_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl LockPosition { - pub fn instruction( - &self, - args: LockPositionInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: LockPositionInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lock_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&LockPositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockPositionInstructionData { - discriminator: [u8; 8], -} - -impl LockPositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [227, 62, 2, 252, 247, 10, 171, 185], - } - } -} - -impl Default for LockPositionInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LockPositionInstructionArgs { - pub lock_type: LockType, -} - -/// Instruction builder for `LockPosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` funder -/// 1. `[signer]` position_authority -/// 2. `[]` position -/// 3. `[]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[writable]` lock_config -/// 6. `[]` whirlpool -/// 7. `[]` token2022_program -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct LockPositionBuilder { - funder: Option, - position_authority: Option, - position: Option, - position_mint: Option, - position_token_account: Option, - lock_config: Option, - whirlpool: Option, - token2022_program: Option, - system_program: Option, - lock_type: Option, - __remaining_accounts: Vec, -} - -impl LockPositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint(&mut self, position_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn lock_config(&mut self, lock_config: solana_pubkey::Pubkey) -> &mut Self { - self.lock_config = Some(lock_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn lock_type(&mut self, lock_type: LockType) -> &mut Self { - self.lock_type = Some(lock_type); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = LockPosition { - funder: self.funder.expect("funder is not set"), - position_authority: self - .position_authority - .expect("position_authority is not set"), - position: self.position.expect("position is not set"), - position_mint: self.position_mint.expect("position_mint is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - lock_config: self.lock_config.expect("lock_config is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token2022_program: self - .token2022_program - .expect("token2022_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = LockPositionInstructionArgs { - lock_type: self.lock_type.clone().expect("lock_type is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `lock_position` CPI accounts. -pub struct LockPositionCpiAccounts<'a, 'b> { - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub lock_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `lock_position` CPI instruction. -pub struct LockPositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub lock_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: LockPositionInstructionArgs, -} - -impl<'a, 'b> LockPositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: LockPositionCpiAccounts<'a, 'b>, - args: LockPositionInstructionArgs, - ) -> Self { - Self { - __program: program, - funder: accounts.funder, - position_authority: accounts.position_authority, - position: accounts.position, - position_mint: accounts.position_mint, - position_token_account: accounts.position_token_account, - lock_config: accounts.lock_config, - whirlpool: accounts.whirlpool, - token2022_program: accounts.token2022_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lock_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&LockPositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_mint.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.lock_config.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token2022_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `LockPosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` funder -/// 1. `[signer]` position_authority -/// 2. `[]` position -/// 3. `[]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[writable]` lock_config -/// 6. `[]` whirlpool -/// 7. `[]` token2022_program -/// 8. `[]` system_program -#[derive(Clone, Debug)] -pub struct LockPositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> LockPositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(LockPositionCpiBuilderInstruction { - __program: program, - funder: None, - position_authority: None, - position: None, - position_mint: None, - position_token_account: None, - lock_config: None, - whirlpool: None, - token2022_program: None, - system_program: None, - lock_type: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint( - &mut self, - position_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn lock_config( - &mut self, - lock_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_config = Some(lock_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn lock_type(&mut self, lock_type: LockType) -> &mut Self { - self.instruction.lock_type = Some(lock_type); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = LockPositionInstructionArgs { - lock_type: self - .instruction - .lock_type - .clone() - .expect("lock_type is not set"), - }; - let instruction = LockPositionCpi { - __program: self.instruction.__program, - - funder: self.instruction.funder.expect("funder is not set"), - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_mint: self - .instruction - .position_mint - .expect("position_mint is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - lock_config: self - .instruction - .lock_config - .expect("lock_config is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct LockPositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_config: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_type: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/mod.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index 0161c9d0..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,92 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#close_bundled_position; -pub(crate) mod r#close_position; -pub(crate) mod r#close_position_with_token_extensions; -pub(crate) mod r#collect_fees; -pub(crate) mod r#collect_fees_v2; -pub(crate) mod r#collect_protocol_fees; -pub(crate) mod r#collect_protocol_fees_v2; -pub(crate) mod r#collect_reward; -pub(crate) mod r#collect_reward_v2; -pub(crate) mod r#decrease_liquidity; -pub(crate) mod r#decrease_liquidity_v2; -pub(crate) mod r#delete_position_bundle; -pub(crate) mod r#delete_token_badge; -pub(crate) mod r#idl_include; -pub(crate) mod r#increase_liquidity; -pub(crate) mod r#increase_liquidity_v2; -pub(crate) mod r#initialize_adaptive_fee_tier; -pub(crate) mod r#initialize_config; -pub(crate) mod r#initialize_config_extension; -pub(crate) mod r#initialize_dynamic_tick_array; -pub(crate) mod r#initialize_fee_tier; -pub(crate) mod r#initialize_pool; -pub(crate) mod r#initialize_pool_v2; -pub(crate) mod r#initialize_pool_with_adaptive_fee; -pub(crate) mod r#initialize_position_bundle; -pub(crate) mod r#initialize_position_bundle_with_metadata; -pub(crate) mod r#initialize_reward; -pub(crate) mod r#initialize_reward_v2; -pub(crate) mod r#initialize_tick_array; -pub(crate) mod r#initialize_token_badge; -pub(crate) mod r#lock_position; -pub(crate) mod r#open_bundled_position; -pub(crate) mod r#open_position; -pub(crate) mod r#open_position_with_metadata; -pub(crate) mod r#open_position_with_token_extensions; -pub(crate) mod r#reset_position_range; -pub(crate) mod r#set_collect_protocol_fees_authority; -pub(crate) mod r#set_config_extension_authority; -pub(crate) mod r#set_default_base_fee_rate; -pub(crate) mod r#set_default_fee_rate; -pub(crate) mod r#set_default_protocol_fee_rate; -pub(crate) mod r#set_delegated_fee_authority; -pub(crate) mod r#set_fee_authority; -pub(crate) mod r#set_fee_rate; -pub(crate) mod r#set_fee_rate_by_delegated_fee_authority; -pub(crate) mod r#set_initialize_pool_authority; -pub(crate) mod r#set_preset_adaptive_fee_constants; -pub(crate) mod r#set_protocol_fee_rate; -pub(crate) mod r#set_reward_authority; -pub(crate) mod r#set_reward_authority_by_super_authority; -pub(crate) mod r#set_reward_emissions; -pub(crate) mod r#set_reward_emissions_super_authority; -pub(crate) mod r#set_reward_emissions_v2; -pub(crate) mod r#set_token_badge_authority; -pub(crate) mod r#swap; -pub(crate) mod r#swap_v2; -pub(crate) mod r#transfer_locked_position; -pub(crate) mod r#two_hop_swap; -pub(crate) mod r#two_hop_swap_v2; -pub(crate) mod r#update_fees_and_rewards; - -pub use self::{ - r#close_bundled_position::*, r#close_position::*, r#close_position_with_token_extensions::*, - r#collect_fees::*, r#collect_fees_v2::*, r#collect_protocol_fees::*, - r#collect_protocol_fees_v2::*, r#collect_reward::*, r#collect_reward_v2::*, - r#decrease_liquidity::*, r#decrease_liquidity_v2::*, r#delete_position_bundle::*, - r#delete_token_badge::*, r#idl_include::*, r#increase_liquidity::*, r#increase_liquidity_v2::*, - r#initialize_adaptive_fee_tier::*, r#initialize_config::*, r#initialize_config_extension::*, - r#initialize_dynamic_tick_array::*, r#initialize_fee_tier::*, r#initialize_pool::*, - r#initialize_pool_v2::*, r#initialize_pool_with_adaptive_fee::*, - r#initialize_position_bundle::*, r#initialize_position_bundle_with_metadata::*, - r#initialize_reward::*, r#initialize_reward_v2::*, r#initialize_tick_array::*, - r#initialize_token_badge::*, r#lock_position::*, r#open_bundled_position::*, - r#open_position::*, r#open_position_with_metadata::*, r#open_position_with_token_extensions::*, - r#reset_position_range::*, r#set_collect_protocol_fees_authority::*, - r#set_config_extension_authority::*, r#set_default_base_fee_rate::*, r#set_default_fee_rate::*, - r#set_default_protocol_fee_rate::*, r#set_delegated_fee_authority::*, r#set_fee_authority::*, - r#set_fee_rate::*, r#set_fee_rate_by_delegated_fee_authority::*, - r#set_initialize_pool_authority::*, r#set_preset_adaptive_fee_constants::*, - r#set_protocol_fee_rate::*, r#set_reward_authority::*, - r#set_reward_authority_by_super_authority::*, r#set_reward_emissions::*, - r#set_reward_emissions_super_authority::*, r#set_reward_emissions_v2::*, - r#set_token_badge_authority::*, r#swap::*, r#swap_v2::*, r#transfer_locked_position::*, - r#two_hop_swap::*, r#two_hop_swap_v2::*, r#update_fees_and_rewards::*, -}; diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_bundled_position.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_bundled_position.rs deleted file mode 100644 index 048eadf1..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_bundled_position.rs +++ /dev/null @@ -1,662 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct OpenBundledPosition { - pub bundled_position: solana_pubkey::Pubkey, - - pub position_bundle: solana_pubkey::Pubkey, - - pub position_bundle_token_account: solana_pubkey::Pubkey, - - pub position_bundle_authority: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub funder: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl OpenBundledPosition { - pub fn instruction( - &self, - args: OpenBundledPositionInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: OpenBundledPositionInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.bundled_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_bundle, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_bundle_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_bundle_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&OpenBundledPositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenBundledPositionInstructionData { - discriminator: [u8; 8], -} - -impl OpenBundledPositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [169, 113, 126, 171, 213, 172, 212, 49], - } - } -} - -impl Default for OpenBundledPositionInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenBundledPositionInstructionArgs { - pub bundle_index: u16, - pub tick_lower_index: i32, - pub tick_upper_index: i32, -} - -/// Instruction builder for `OpenBundledPosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` bundled_position -/// 1. `[writable]` position_bundle -/// 2. `[]` position_bundle_token_account -/// 3. `[signer]` position_bundle_authority -/// 4. `[]` whirlpool -/// 5. `[writable, signer]` funder -/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 7. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct OpenBundledPositionBuilder { - bundled_position: Option, - position_bundle: Option, - position_bundle_token_account: Option, - position_bundle_authority: Option, - whirlpool: Option, - funder: Option, - system_program: Option, - rent: Option, - bundle_index: Option, - tick_lower_index: Option, - tick_upper_index: Option, - __remaining_accounts: Vec, -} - -impl OpenBundledPositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn bundled_position(&mut self, bundled_position: solana_pubkey::Pubkey) -> &mut Self { - self.bundled_position = Some(bundled_position); - self - } - - #[inline(always)] - pub fn position_bundle(&mut self, position_bundle: solana_pubkey::Pubkey) -> &mut Self { - self.position_bundle = Some(position_bundle); - self - } - - #[inline(always)] - pub fn position_bundle_token_account( - &mut self, - position_bundle_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_token_account = Some(position_bundle_token_account); - self - } - - #[inline(always)] - pub fn position_bundle_authority( - &mut self, - position_bundle_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_bundle_authority = Some(position_bundle_authority); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn bundle_index(&mut self, bundle_index: u16) -> &mut Self { - self.bundle_index = Some(bundle_index); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.tick_upper_index = Some(tick_upper_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = OpenBundledPosition { - bundled_position: self.bundled_position.expect("bundled_position is not set"), - position_bundle: self.position_bundle.expect("position_bundle is not set"), - position_bundle_token_account: self - .position_bundle_token_account - .expect("position_bundle_token_account is not set"), - position_bundle_authority: self - .position_bundle_authority - .expect("position_bundle_authority is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - funder: self.funder.expect("funder is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = OpenBundledPositionInstructionArgs { - bundle_index: self.bundle_index.clone().expect("bundle_index is not set"), - tick_lower_index: self - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `open_bundled_position` CPI accounts. -pub struct OpenBundledPositionCpiAccounts<'a, 'b> { - pub bundled_position: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `open_bundled_position` CPI instruction. -pub struct OpenBundledPositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub bundled_position: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_bundle_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: OpenBundledPositionInstructionArgs, -} - -impl<'a, 'b> OpenBundledPositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: OpenBundledPositionCpiAccounts<'a, 'b>, - args: OpenBundledPositionInstructionArgs, - ) -> Self { - Self { - __program: program, - bundled_position: accounts.bundled_position, - position_bundle: accounts.position_bundle, - position_bundle_token_account: accounts.position_bundle_token_account, - position_bundle_authority: accounts.position_bundle_authority, - whirlpool: accounts.whirlpool, - funder: accounts.funder, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.bundled_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_bundle.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_bundle_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_bundle_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&OpenBundledPositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.bundled_position.clone()); - account_infos.push(self.position_bundle.clone()); - account_infos.push(self.position_bundle_token_account.clone()); - account_infos.push(self.position_bundle_authority.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `OpenBundledPosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` bundled_position -/// 1. `[writable]` position_bundle -/// 2. `[]` position_bundle_token_account -/// 3. `[signer]` position_bundle_authority -/// 4. `[]` whirlpool -/// 5. `[writable, signer]` funder -/// 6. `[]` system_program -/// 7. `[]` rent -#[derive(Clone, Debug)] -pub struct OpenBundledPositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> OpenBundledPositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(OpenBundledPositionCpiBuilderInstruction { - __program: program, - bundled_position: None, - position_bundle: None, - position_bundle_token_account: None, - position_bundle_authority: None, - whirlpool: None, - funder: None, - system_program: None, - rent: None, - bundle_index: None, - tick_lower_index: None, - tick_upper_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn bundled_position( - &mut self, - bundled_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bundled_position = Some(bundled_position); - self - } - - #[inline(always)] - pub fn position_bundle( - &mut self, - position_bundle: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle = Some(position_bundle); - self - } - - #[inline(always)] - pub fn position_bundle_token_account( - &mut self, - position_bundle_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_token_account = Some(position_bundle_token_account); - self - } - - #[inline(always)] - pub fn position_bundle_authority( - &mut self, - position_bundle_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_bundle_authority = Some(position_bundle_authority); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn bundle_index(&mut self, bundle_index: u16) -> &mut Self { - self.instruction.bundle_index = Some(bundle_index); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.instruction.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.instruction.tick_upper_index = Some(tick_upper_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = OpenBundledPositionInstructionArgs { - bundle_index: self - .instruction - .bundle_index - .clone() - .expect("bundle_index is not set"), - tick_lower_index: self - .instruction - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .instruction - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - }; - let instruction = OpenBundledPositionCpi { - __program: self.instruction.__program, - - bundled_position: self - .instruction - .bundled_position - .expect("bundled_position is not set"), - - position_bundle: self - .instruction - .position_bundle - .expect("position_bundle is not set"), - - position_bundle_token_account: self - .instruction - .position_bundle_token_account - .expect("position_bundle_token_account is not set"), - - position_bundle_authority: self - .instruction - .position_bundle_authority - .expect("position_bundle_authority is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - funder: self.instruction.funder.expect("funder is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct OpenBundledPositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - bundled_position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bundle_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - bundle_index: Option, - tick_lower_index: Option, - tick_upper_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_position.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_position.rs deleted file mode 100644 index a7139a41..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_position.rs +++ /dev/null @@ -1,736 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct OpenPosition { - pub funder: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_mint: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl OpenPosition { - pub fn instruction( - &self, - args: OpenPositionInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: OpenPositionInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.position_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&OpenPositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionInstructionData { - discriminator: [u8; 8], -} - -impl OpenPositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [135, 128, 47, 77, 15, 152, 240, 49], - } - } -} - -impl Default for OpenPositionInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionInstructionArgs { - pub position_bump: u8, - pub tick_lower_index: i32, - pub tick_upper_index: i32, -} - -/// Instruction builder for `OpenPosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` funder -/// 1. `[]` owner -/// 2. `[writable]` position -/// 3. `[writable, signer]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[]` whirlpool -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 8. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 9. `[]` associated_token_program -#[derive(Clone, Debug, Default)] -pub struct OpenPositionBuilder { - funder: Option, - owner: Option, - position: Option, - position_mint: Option, - position_token_account: Option, - whirlpool: Option, - token_program: Option, - system_program: Option, - rent: Option, - associated_token_program: Option, - position_bump: Option, - tick_lower_index: Option, - tick_upper_index: Option, - __remaining_accounts: Vec, -} - -impl OpenPositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint(&mut self, position_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn position_bump(&mut self, position_bump: u8) -> &mut Self { - self.position_bump = Some(position_bump); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.tick_upper_index = Some(tick_upper_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = OpenPosition { - funder: self.funder.expect("funder is not set"), - owner: self.owner.expect("owner is not set"), - position: self.position.expect("position is not set"), - position_mint: self.position_mint.expect("position_mint is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - }; - let args = OpenPositionInstructionArgs { - position_bump: self - .position_bump - .clone() - .expect("position_bump is not set"), - tick_lower_index: self - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `open_position` CPI accounts. -pub struct OpenPositionCpiAccounts<'a, 'b> { - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `open_position` CPI instruction. -pub struct OpenPositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: OpenPositionInstructionArgs, -} - -impl<'a, 'b> OpenPositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: OpenPositionCpiAccounts<'a, 'b>, - args: OpenPositionInstructionArgs, - ) -> Self { - Self { - __program: program, - funder: accounts.funder, - owner: accounts.owner, - position: accounts.position, - position_mint: accounts.position_mint, - position_token_account: accounts.position_token_account, - whirlpool: accounts.whirlpool, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - associated_token_program: accounts.associated_token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&OpenPositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_mint.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `OpenPosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` funder -/// 1. `[]` owner -/// 2. `[writable]` position -/// 3. `[writable, signer]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[]` whirlpool -/// 6. `[]` token_program -/// 7. `[]` system_program -/// 8. `[]` rent -/// 9. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct OpenPositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> OpenPositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(OpenPositionCpiBuilderInstruction { - __program: program, - funder: None, - owner: None, - position: None, - position_mint: None, - position_token_account: None, - whirlpool: None, - token_program: None, - system_program: None, - rent: None, - associated_token_program: None, - position_bump: None, - tick_lower_index: None, - tick_upper_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint( - &mut self, - position_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn position_bump(&mut self, position_bump: u8) -> &mut Self { - self.instruction.position_bump = Some(position_bump); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.instruction.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.instruction.tick_upper_index = Some(tick_upper_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = OpenPositionInstructionArgs { - position_bump: self - .instruction - .position_bump - .clone() - .expect("position_bump is not set"), - tick_lower_index: self - .instruction - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .instruction - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - }; - let instruction = OpenPositionCpi { - __program: self.instruction.__program, - - funder: self.instruction.funder.expect("funder is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_mint: self - .instruction - .position_mint - .expect("position_mint is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct OpenPositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bump: Option, - tick_lower_index: Option, - tick_upper_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_position_with_metadata.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_position_with_metadata.rs deleted file mode 100644 index a869ff79..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_position_with_metadata.rs +++ /dev/null @@ -1,899 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct OpenPositionWithMetadata { - pub funder: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_mint: solana_pubkey::Pubkey, - /// https://github.com/metaplex-foundation/mpl-token-metadata/blob/master/programs/token-metadata/program/src/utils/metadata.rs#L78 - pub position_metadata_account: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - - pub metadata_update_auth: solana_pubkey::Pubkey, -} - -impl OpenPositionWithMetadata { - pub fn instruction( - &self, - args: OpenPositionWithMetadataInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: OpenPositionWithMetadataInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.position_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_metadata_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_update_auth, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&OpenPositionWithMetadataInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionWithMetadataInstructionData { - discriminator: [u8; 8], -} - -impl OpenPositionWithMetadataInstructionData { - pub fn new() -> Self { - Self { - discriminator: [242, 29, 134, 48, 58, 110, 14, 60], - } - } -} - -impl Default for OpenPositionWithMetadataInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionWithMetadataInstructionArgs { - pub position_bump: u8, - pub metadata_bump: u8, - pub tick_lower_index: i32, - pub tick_upper_index: i32, -} - -/// Instruction builder for `OpenPositionWithMetadata`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` funder -/// 1. `[]` owner -/// 2. `[writable]` position -/// 3. `[writable, signer]` position_mint -/// 4. `[writable]` position_metadata_account -/// 5. `[writable]` position_token_account -/// 6. `[]` whirlpool -/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 10. `[]` associated_token_program -/// 11. `[]` metadata_program -/// 12. `[]` metadata_update_auth -#[derive(Clone, Debug, Default)] -pub struct OpenPositionWithMetadataBuilder { - funder: Option, - owner: Option, - position: Option, - position_mint: Option, - position_metadata_account: Option, - position_token_account: Option, - whirlpool: Option, - token_program: Option, - system_program: Option, - rent: Option, - associated_token_program: Option, - metadata_program: Option, - metadata_update_auth: Option, - position_bump: Option, - metadata_bump: Option, - tick_lower_index: Option, - tick_upper_index: Option, - __remaining_accounts: Vec, -} - -impl OpenPositionWithMetadataBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint(&mut self, position_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_mint = Some(position_mint); - self - } - - /// https://github.com/metaplex-foundation/mpl-token-metadata/blob/master/programs/token-metadata/program/src/utils/metadata.rs#L78 - #[inline(always)] - pub fn position_metadata_account( - &mut self, - position_metadata_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_metadata_account = Some(position_metadata_account); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - #[inline(always)] - pub fn metadata_update_auth( - &mut self, - metadata_update_auth: solana_pubkey::Pubkey, - ) -> &mut Self { - self.metadata_update_auth = Some(metadata_update_auth); - self - } - - #[inline(always)] - pub fn position_bump(&mut self, position_bump: u8) -> &mut Self { - self.position_bump = Some(position_bump); - self - } - - #[inline(always)] - pub fn metadata_bump(&mut self, metadata_bump: u8) -> &mut Self { - self.metadata_bump = Some(metadata_bump); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.tick_upper_index = Some(tick_upper_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = OpenPositionWithMetadata { - funder: self.funder.expect("funder is not set"), - owner: self.owner.expect("owner is not set"), - position: self.position.expect("position is not set"), - position_mint: self.position_mint.expect("position_mint is not set"), - position_metadata_account: self - .position_metadata_account - .expect("position_metadata_account is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - metadata_update_auth: self - .metadata_update_auth - .expect("metadata_update_auth is not set"), - }; - let args = OpenPositionWithMetadataInstructionArgs { - position_bump: self - .position_bump - .clone() - .expect("position_bump is not set"), - metadata_bump: self - .metadata_bump - .clone() - .expect("metadata_bump is not set"), - tick_lower_index: self - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `open_position_with_metadata` CPI accounts. -pub struct OpenPositionWithMetadataCpiAccounts<'a, 'b> { - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - /// https://github.com/metaplex-foundation/mpl-token-metadata/blob/master/programs/token-metadata/program/src/utils/metadata.rs#L78 - pub position_metadata_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_update_auth: &'b solana_account_info::AccountInfo<'a>, -} - -/// `open_position_with_metadata` CPI instruction. -pub struct OpenPositionWithMetadataCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - /// https://github.com/metaplex-foundation/mpl-token-metadata/blob/master/programs/token-metadata/program/src/utils/metadata.rs#L78 - pub position_metadata_account: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_update_auth: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: OpenPositionWithMetadataInstructionArgs, -} - -impl<'a, 'b> OpenPositionWithMetadataCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: OpenPositionWithMetadataCpiAccounts<'a, 'b>, - args: OpenPositionWithMetadataInstructionArgs, - ) -> Self { - Self { - __program: program, - funder: accounts.funder, - owner: accounts.owner, - position: accounts.position, - position_mint: accounts.position_mint, - position_metadata_account: accounts.position_metadata_account, - position_token_account: accounts.position_token_account, - whirlpool: accounts.whirlpool, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - associated_token_program: accounts.associated_token_program, - metadata_program: accounts.metadata_program, - metadata_update_auth: accounts.metadata_update_auth, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_metadata_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_update_auth.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&OpenPositionWithMetadataInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_mint.clone()); - account_infos.push(self.position_metadata_account.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.metadata_update_auth.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `OpenPositionWithMetadata` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` funder -/// 1. `[]` owner -/// 2. `[writable]` position -/// 3. `[writable, signer]` position_mint -/// 4. `[writable]` position_metadata_account -/// 5. `[writable]` position_token_account -/// 6. `[]` whirlpool -/// 7. `[]` token_program -/// 8. `[]` system_program -/// 9. `[]` rent -/// 10. `[]` associated_token_program -/// 11. `[]` metadata_program -/// 12. `[]` metadata_update_auth -#[derive(Clone, Debug)] -pub struct OpenPositionWithMetadataCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> OpenPositionWithMetadataCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(OpenPositionWithMetadataCpiBuilderInstruction { - __program: program, - funder: None, - owner: None, - position: None, - position_mint: None, - position_metadata_account: None, - position_token_account: None, - whirlpool: None, - token_program: None, - system_program: None, - rent: None, - associated_token_program: None, - metadata_program: None, - metadata_update_auth: None, - position_bump: None, - metadata_bump: None, - tick_lower_index: None, - tick_upper_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint( - &mut self, - position_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_mint = Some(position_mint); - self - } - - /// https://github.com/metaplex-foundation/mpl-token-metadata/blob/master/programs/token-metadata/program/src/utils/metadata.rs#L78 - #[inline(always)] - pub fn position_metadata_account( - &mut self, - position_metadata_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_metadata_account = Some(position_metadata_account); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - #[inline(always)] - pub fn metadata_update_auth( - &mut self, - metadata_update_auth: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_update_auth = Some(metadata_update_auth); - self - } - - #[inline(always)] - pub fn position_bump(&mut self, position_bump: u8) -> &mut Self { - self.instruction.position_bump = Some(position_bump); - self - } - - #[inline(always)] - pub fn metadata_bump(&mut self, metadata_bump: u8) -> &mut Self { - self.instruction.metadata_bump = Some(metadata_bump); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.instruction.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.instruction.tick_upper_index = Some(tick_upper_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = OpenPositionWithMetadataInstructionArgs { - position_bump: self - .instruction - .position_bump - .clone() - .expect("position_bump is not set"), - metadata_bump: self - .instruction - .metadata_bump - .clone() - .expect("metadata_bump is not set"), - tick_lower_index: self - .instruction - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .instruction - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - }; - let instruction = OpenPositionWithMetadataCpi { - __program: self.instruction.__program, - - funder: self.instruction.funder.expect("funder is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_mint: self - .instruction - .position_mint - .expect("position_mint is not set"), - - position_metadata_account: self - .instruction - .position_metadata_account - .expect("position_metadata_account is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - metadata_update_auth: self - .instruction - .metadata_update_auth - .expect("metadata_update_auth is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct OpenPositionWithMetadataCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_metadata_account: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_update_auth: Option<&'b solana_account_info::AccountInfo<'a>>, - position_bump: Option, - metadata_bump: Option, - tick_lower_index: Option, - tick_upper_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_position_with_token_extensions.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_position_with_token_extensions.rs deleted file mode 100644 index 2bd39f40..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/open_position_with_token_extensions.rs +++ /dev/null @@ -1,752 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct OpenPositionWithTokenExtensions { - pub funder: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_mint: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub token2022_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub metadata_update_auth: solana_pubkey::Pubkey, -} - -impl OpenPositionWithTokenExtensions { - pub fn instruction( - &self, - args: OpenPositionWithTokenExtensionsInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: OpenPositionWithTokenExtensionsInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.position_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_update_auth, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = - borsh::to_vec(&OpenPositionWithTokenExtensionsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionWithTokenExtensionsInstructionData { - discriminator: [u8; 8], -} - -impl OpenPositionWithTokenExtensionsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [212, 47, 95, 92, 114, 102, 131, 250], - } - } -} - -impl Default for OpenPositionWithTokenExtensionsInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionWithTokenExtensionsInstructionArgs { - pub tick_lower_index: i32, - pub tick_upper_index: i32, - pub with_token_metadata_extension: bool, -} - -/// Instruction builder for `OpenPositionWithTokenExtensions`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` funder -/// 1. `[]` owner -/// 2. `[writable]` position -/// 3. `[writable, signer]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[]` whirlpool -/// 6. `[]` token2022_program -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 8. `[]` associated_token_program -/// 9. `[]` metadata_update_auth -#[derive(Clone, Debug, Default)] -pub struct OpenPositionWithTokenExtensionsBuilder { - funder: Option, - owner: Option, - position: Option, - position_mint: Option, - position_token_account: Option, - whirlpool: Option, - token2022_program: Option, - system_program: Option, - associated_token_program: Option, - metadata_update_auth: Option, - tick_lower_index: Option, - tick_upper_index: Option, - with_token_metadata_extension: Option, - __remaining_accounts: Vec, -} - -impl OpenPositionWithTokenExtensionsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint(&mut self, position_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn metadata_update_auth( - &mut self, - metadata_update_auth: solana_pubkey::Pubkey, - ) -> &mut Self { - self.metadata_update_auth = Some(metadata_update_auth); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.tick_upper_index = Some(tick_upper_index); - self - } - - #[inline(always)] - pub fn with_token_metadata_extension( - &mut self, - with_token_metadata_extension: bool, - ) -> &mut Self { - self.with_token_metadata_extension = Some(with_token_metadata_extension); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = OpenPositionWithTokenExtensions { - funder: self.funder.expect("funder is not set"), - owner: self.owner.expect("owner is not set"), - position: self.position.expect("position is not set"), - position_mint: self.position_mint.expect("position_mint is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token2022_program: self - .token2022_program - .expect("token2022_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - metadata_update_auth: self - .metadata_update_auth - .expect("metadata_update_auth is not set"), - }; - let args = OpenPositionWithTokenExtensionsInstructionArgs { - tick_lower_index: self - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - with_token_metadata_extension: self - .with_token_metadata_extension - .clone() - .expect("with_token_metadata_extension is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `open_position_with_token_extensions` CPI accounts. -pub struct OpenPositionWithTokenExtensionsCpiAccounts<'a, 'b> { - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_update_auth: &'b solana_account_info::AccountInfo<'a>, -} - -/// `open_position_with_token_extensions` CPI instruction. -pub struct OpenPositionWithTokenExtensionsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_update_auth: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: OpenPositionWithTokenExtensionsInstructionArgs, -} - -impl<'a, 'b> OpenPositionWithTokenExtensionsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: OpenPositionWithTokenExtensionsCpiAccounts<'a, 'b>, - args: OpenPositionWithTokenExtensionsInstructionArgs, - ) -> Self { - Self { - __program: program, - funder: accounts.funder, - owner: accounts.owner, - position: accounts.position, - position_mint: accounts.position_mint, - position_token_account: accounts.position_token_account, - whirlpool: accounts.whirlpool, - token2022_program: accounts.token2022_program, - system_program: accounts.system_program, - associated_token_program: accounts.associated_token_program, - metadata_update_auth: accounts.metadata_update_auth, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_update_auth.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = - borsh::to_vec(&OpenPositionWithTokenExtensionsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_mint.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token2022_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.metadata_update_auth.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `OpenPositionWithTokenExtensions` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` funder -/// 1. `[]` owner -/// 2. `[writable]` position -/// 3. `[writable, signer]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[]` whirlpool -/// 6. `[]` token2022_program -/// 7. `[]` system_program -/// 8. `[]` associated_token_program -/// 9. `[]` metadata_update_auth -#[derive(Clone, Debug)] -pub struct OpenPositionWithTokenExtensionsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> OpenPositionWithTokenExtensionsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(OpenPositionWithTokenExtensionsCpiBuilderInstruction { - __program: program, - funder: None, - owner: None, - position: None, - position_mint: None, - position_token_account: None, - whirlpool: None, - token2022_program: None, - system_program: None, - associated_token_program: None, - metadata_update_auth: None, - tick_lower_index: None, - tick_upper_index: None, - with_token_metadata_extension: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint( - &mut self, - position_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn metadata_update_auth( - &mut self, - metadata_update_auth: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_update_auth = Some(metadata_update_auth); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.instruction.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.instruction.tick_upper_index = Some(tick_upper_index); - self - } - - #[inline(always)] - pub fn with_token_metadata_extension( - &mut self, - with_token_metadata_extension: bool, - ) -> &mut Self { - self.instruction.with_token_metadata_extension = Some(with_token_metadata_extension); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = OpenPositionWithTokenExtensionsInstructionArgs { - tick_lower_index: self - .instruction - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .instruction - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - with_token_metadata_extension: self - .instruction - .with_token_metadata_extension - .clone() - .expect("with_token_metadata_extension is not set"), - }; - let instruction = OpenPositionWithTokenExtensionsCpi { - __program: self.instruction.__program, - - funder: self.instruction.funder.expect("funder is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_mint: self - .instruction - .position_mint - .expect("position_mint is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - metadata_update_auth: self - .instruction - .metadata_update_auth - .expect("metadata_update_auth is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct OpenPositionWithTokenExtensionsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_update_auth: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_lower_index: Option, - tick_upper_index: Option, - with_token_metadata_extension: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/reset_position_range.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/reset_position_range.rs deleted file mode 100644 index faa673e9..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/reset_position_range.rs +++ /dev/null @@ -1,548 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ResetPositionRange { - pub funder: solana_pubkey::Pubkey, - - pub position_authority: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl ResetPositionRange { - pub fn instruction( - &self, - args: ResetPositionRangeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: ResetPositionRangeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.funder, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&ResetPositionRangeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ResetPositionRangeInstructionData { - discriminator: [u8; 8], -} - -impl ResetPositionRangeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [164, 123, 180, 141, 194, 100, 160, 175], - } - } -} - -impl Default for ResetPositionRangeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ResetPositionRangeInstructionArgs { - pub new_tick_lower_index: i32, - pub new_tick_upper_index: i32, -} - -/// Instruction builder for `ResetPositionRange`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` funder -/// 1. `[signer]` position_authority -/// 2. `[]` whirlpool -/// 3. `[writable]` position -/// 4. `[]` position_token_account -/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct ResetPositionRangeBuilder { - funder: Option, - position_authority: Option, - whirlpool: Option, - position: Option, - position_token_account: Option, - system_program: Option, - new_tick_lower_index: Option, - new_tick_upper_index: Option, - __remaining_accounts: Vec, -} - -impl ResetPositionRangeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn funder(&mut self, funder: solana_pubkey::Pubkey) -> &mut Self { - self.funder = Some(funder); - self - } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn new_tick_lower_index(&mut self, new_tick_lower_index: i32) -> &mut Self { - self.new_tick_lower_index = Some(new_tick_lower_index); - self - } - - #[inline(always)] - pub fn new_tick_upper_index(&mut self, new_tick_upper_index: i32) -> &mut Self { - self.new_tick_upper_index = Some(new_tick_upper_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ResetPositionRange { - funder: self.funder.expect("funder is not set"), - position_authority: self - .position_authority - .expect("position_authority is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - position: self.position.expect("position is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = ResetPositionRangeInstructionArgs { - new_tick_lower_index: self - .new_tick_lower_index - .clone() - .expect("new_tick_lower_index is not set"), - new_tick_upper_index: self - .new_tick_upper_index - .clone() - .expect("new_tick_upper_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `reset_position_range` CPI accounts. -pub struct ResetPositionRangeCpiAccounts<'a, 'b> { - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `reset_position_range` CPI instruction. -pub struct ResetPositionRangeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub funder: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: ResetPositionRangeInstructionArgs, -} - -impl<'a, 'b> ResetPositionRangeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ResetPositionRangeCpiAccounts<'a, 'b>, - args: ResetPositionRangeInstructionArgs, - ) -> Self { - Self { - __program: program, - funder: accounts.funder, - position_authority: accounts.position_authority, - whirlpool: accounts.whirlpool, - position: accounts.position, - position_token_account: accounts.position_token_account, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.funder.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&ResetPositionRangeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.funder.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ResetPositionRange` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` funder -/// 1. `[signer]` position_authority -/// 2. `[]` whirlpool -/// 3. `[writable]` position -/// 4. `[]` position_token_account -/// 5. `[]` system_program -#[derive(Clone, Debug)] -pub struct ResetPositionRangeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ResetPositionRangeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ResetPositionRangeCpiBuilderInstruction { - __program: program, - funder: None, - position_authority: None, - whirlpool: None, - position: None, - position_token_account: None, - system_program: None, - new_tick_lower_index: None, - new_tick_upper_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn funder(&mut self, funder: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.funder = Some(funder); - self - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn new_tick_lower_index(&mut self, new_tick_lower_index: i32) -> &mut Self { - self.instruction.new_tick_lower_index = Some(new_tick_lower_index); - self - } - - #[inline(always)] - pub fn new_tick_upper_index(&mut self, new_tick_upper_index: i32) -> &mut Self { - self.instruction.new_tick_upper_index = Some(new_tick_upper_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = ResetPositionRangeInstructionArgs { - new_tick_lower_index: self - .instruction - .new_tick_lower_index - .clone() - .expect("new_tick_lower_index is not set"), - new_tick_upper_index: self - .instruction - .new_tick_upper_index - .clone() - .expect("new_tick_upper_index is not set"), - }; - let instruction = ResetPositionRangeCpi { - __program: self.instruction.__program, - - funder: self.instruction.funder.expect("funder is not set"), - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ResetPositionRangeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - funder: Option<&'b solana_account_info::AccountInfo<'a>>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - new_tick_lower_index: Option, - new_tick_upper_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_collect_protocol_fees_authority.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_collect_protocol_fees_authority.rs deleted file mode 100644 index ab8abca6..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_collect_protocol_fees_authority.rs +++ /dev/null @@ -1,380 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetCollectProtocolFeesAuthority { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub collect_protocol_fees_authority: solana_pubkey::Pubkey, - - pub new_collect_protocol_fees_authority: solana_pubkey::Pubkey, -} - -impl SetCollectProtocolFeesAuthority { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.collect_protocol_fees_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_collect_protocol_fees_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetCollectProtocolFeesAuthorityInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetCollectProtocolFeesAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl SetCollectProtocolFeesAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [34, 150, 93, 244, 139, 225, 233, 67], - } - } -} - -impl Default for SetCollectProtocolFeesAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetCollectProtocolFeesAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpools_config -/// 1. `[signer]` collect_protocol_fees_authority -/// 2. `[]` new_collect_protocol_fees_authority -#[derive(Clone, Debug, Default)] -pub struct SetCollectProtocolFeesAuthorityBuilder { - whirlpools_config: Option, - collect_protocol_fees_authority: Option, - new_collect_protocol_fees_authority: Option, - __remaining_accounts: Vec, -} - -impl SetCollectProtocolFeesAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn collect_protocol_fees_authority( - &mut self, - collect_protocol_fees_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.collect_protocol_fees_authority = Some(collect_protocol_fees_authority); - self - } - - #[inline(always)] - pub fn new_collect_protocol_fees_authority( - &mut self, - new_collect_protocol_fees_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.new_collect_protocol_fees_authority = Some(new_collect_protocol_fees_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetCollectProtocolFeesAuthority { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - collect_protocol_fees_authority: self - .collect_protocol_fees_authority - .expect("collect_protocol_fees_authority is not set"), - new_collect_protocol_fees_authority: self - .new_collect_protocol_fees_authority - .expect("new_collect_protocol_fees_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_collect_protocol_fees_authority` CPI accounts. -pub struct SetCollectProtocolFeesAuthorityCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_collect_protocol_fees_authority` CPI instruction. -pub struct SetCollectProtocolFeesAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetCollectProtocolFeesAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetCollectProtocolFeesAuthorityCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - collect_protocol_fees_authority: accounts.collect_protocol_fees_authority, - new_collect_protocol_fees_authority: accounts.new_collect_protocol_fees_authority, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.collect_protocol_fees_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_collect_protocol_fees_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetCollectProtocolFeesAuthorityInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.collect_protocol_fees_authority.clone()); - account_infos.push(self.new_collect_protocol_fees_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetCollectProtocolFeesAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpools_config -/// 1. `[signer]` collect_protocol_fees_authority -/// 2. `[]` new_collect_protocol_fees_authority -#[derive(Clone, Debug)] -pub struct SetCollectProtocolFeesAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetCollectProtocolFeesAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetCollectProtocolFeesAuthorityCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - collect_protocol_fees_authority: None, - new_collect_protocol_fees_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn collect_protocol_fees_authority( - &mut self, - collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.collect_protocol_fees_authority = Some(collect_protocol_fees_authority); - self - } - - #[inline(always)] - pub fn new_collect_protocol_fees_authority( - &mut self, - new_collect_protocol_fees_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_collect_protocol_fees_authority = - Some(new_collect_protocol_fees_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetCollectProtocolFeesAuthorityCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - collect_protocol_fees_authority: self - .instruction - .collect_protocol_fees_authority - .expect("collect_protocol_fees_authority is not set"), - - new_collect_protocol_fees_authority: self - .instruction - .new_collect_protocol_fees_authority - .expect("new_collect_protocol_fees_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetCollectProtocolFeesAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - collect_protocol_fees_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - new_collect_protocol_fees_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_config_extension_authority.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_config_extension_authority.rs deleted file mode 100644 index 1009d505..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_config_extension_authority.rs +++ /dev/null @@ -1,426 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetConfigExtensionAuthority { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub whirlpools_config_extension: solana_pubkey::Pubkey, - - pub config_extension_authority: solana_pubkey::Pubkey, - - pub new_config_extension_authority: solana_pubkey::Pubkey, -} - -impl SetConfigExtensionAuthority { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.whirlpools_config_extension, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config_extension_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_config_extension_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetConfigExtensionAuthorityInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetConfigExtensionAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl SetConfigExtensionAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [44, 94, 241, 116, 24, 188, 60, 143], - } - } -} - -impl Default for SetConfigExtensionAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetConfigExtensionAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpools_config_extension -/// 2. `[signer]` config_extension_authority -/// 3. `[]` new_config_extension_authority -#[derive(Clone, Debug, Default)] -pub struct SetConfigExtensionAuthorityBuilder { - whirlpools_config: Option, - whirlpools_config_extension: Option, - config_extension_authority: Option, - new_config_extension_authority: Option, - __remaining_accounts: Vec, -} - -impl SetConfigExtensionAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpools_config_extension( - &mut self, - whirlpools_config_extension: solana_pubkey::Pubkey, - ) -> &mut Self { - self.whirlpools_config_extension = Some(whirlpools_config_extension); - self - } - - #[inline(always)] - pub fn config_extension_authority( - &mut self, - config_extension_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.config_extension_authority = Some(config_extension_authority); - self - } - - #[inline(always)] - pub fn new_config_extension_authority( - &mut self, - new_config_extension_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.new_config_extension_authority = Some(new_config_extension_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetConfigExtensionAuthority { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - whirlpools_config_extension: self - .whirlpools_config_extension - .expect("whirlpools_config_extension is not set"), - config_extension_authority: self - .config_extension_authority - .expect("config_extension_authority is not set"), - new_config_extension_authority: self - .new_config_extension_authority - .expect("new_config_extension_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_config_extension_authority` CPI accounts. -pub struct SetConfigExtensionAuthorityCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - - pub config_extension_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_config_extension_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_config_extension_authority` CPI instruction. -pub struct SetConfigExtensionAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - - pub config_extension_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_config_extension_authority: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetConfigExtensionAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetConfigExtensionAuthorityCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - whirlpools_config_extension: accounts.whirlpools_config_extension, - config_extension_authority: accounts.config_extension_authority, - new_config_extension_authority: accounts.new_config_extension_authority, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpools_config_extension.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config_extension_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_config_extension_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetConfigExtensionAuthorityInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.whirlpools_config_extension.clone()); - account_infos.push(self.config_extension_authority.clone()); - account_infos.push(self.new_config_extension_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetConfigExtensionAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpools_config_extension -/// 2. `[signer]` config_extension_authority -/// 3. `[]` new_config_extension_authority -#[derive(Clone, Debug)] -pub struct SetConfigExtensionAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetConfigExtensionAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetConfigExtensionAuthorityCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - whirlpools_config_extension: None, - config_extension_authority: None, - new_config_extension_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpools_config_extension( - &mut self, - whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config_extension = Some(whirlpools_config_extension); - self - } - - #[inline(always)] - pub fn config_extension_authority( - &mut self, - config_extension_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_extension_authority = Some(config_extension_authority); - self - } - - #[inline(always)] - pub fn new_config_extension_authority( - &mut self, - new_config_extension_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_config_extension_authority = Some(new_config_extension_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetConfigExtensionAuthorityCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - whirlpools_config_extension: self - .instruction - .whirlpools_config_extension - .expect("whirlpools_config_extension is not set"), - - config_extension_authority: self - .instruction - .config_extension_authority - .expect("config_extension_authority is not set"), - - new_config_extension_authority: self - .instruction - .new_config_extension_authority - .expect("new_config_extension_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetConfigExtensionAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpools_config_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - config_extension_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - new_config_extension_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_default_base_fee_rate.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_default_base_fee_rate.rs deleted file mode 100644 index 3bb819b6..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_default_base_fee_rate.rs +++ /dev/null @@ -1,418 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetDefaultBaseFeeRate { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub adaptive_fee_tier: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, -} - -impl SetDefaultBaseFeeRate { - pub fn instruction( - &self, - args: SetDefaultBaseFeeRateInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetDefaultBaseFeeRateInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.adaptive_fee_tier, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetDefaultBaseFeeRateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetDefaultBaseFeeRateInstructionData { - discriminator: [u8; 8], -} - -impl SetDefaultBaseFeeRateInstructionData { - pub fn new() -> Self { - Self { - discriminator: [229, 66, 84, 251, 164, 134, 183, 7], - } - } -} - -impl Default for SetDefaultBaseFeeRateInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetDefaultBaseFeeRateInstructionArgs { - pub default_base_fee_rate: u16, -} - -/// Instruction builder for `SetDefaultBaseFeeRate`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` adaptive_fee_tier -/// 2. `[signer]` fee_authority -#[derive(Clone, Debug, Default)] -pub struct SetDefaultBaseFeeRateBuilder { - whirlpools_config: Option, - adaptive_fee_tier: Option, - fee_authority: Option, - default_base_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl SetDefaultBaseFeeRateBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier(&mut self, adaptive_fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn default_base_fee_rate(&mut self, default_base_fee_rate: u16) -> &mut Self { - self.default_base_fee_rate = Some(default_base_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetDefaultBaseFeeRate { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - adaptive_fee_tier: self - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - }; - let args = SetDefaultBaseFeeRateInstructionArgs { - default_base_fee_rate: self - .default_base_fee_rate - .clone() - .expect("default_base_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_default_base_fee_rate` CPI accounts. -pub struct SetDefaultBaseFeeRateCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_default_base_fee_rate` CPI instruction. -pub struct SetDefaultBaseFeeRateCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetDefaultBaseFeeRateInstructionArgs, -} - -impl<'a, 'b> SetDefaultBaseFeeRateCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetDefaultBaseFeeRateCpiAccounts<'a, 'b>, - args: SetDefaultBaseFeeRateInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - adaptive_fee_tier: accounts.adaptive_fee_tier, - fee_authority: accounts.fee_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.adaptive_fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetDefaultBaseFeeRateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.adaptive_fee_tier.clone()); - account_infos.push(self.fee_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetDefaultBaseFeeRate` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` adaptive_fee_tier -/// 2. `[signer]` fee_authority -#[derive(Clone, Debug)] -pub struct SetDefaultBaseFeeRateCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetDefaultBaseFeeRateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetDefaultBaseFeeRateCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - adaptive_fee_tier: None, - fee_authority: None, - default_base_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier( - &mut self, - adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn default_base_fee_rate(&mut self, default_base_fee_rate: u16) -> &mut Self { - self.instruction.default_base_fee_rate = Some(default_base_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetDefaultBaseFeeRateInstructionArgs { - default_base_fee_rate: self - .instruction - .default_base_fee_rate - .clone() - .expect("default_base_fee_rate is not set"), - }; - let instruction = SetDefaultBaseFeeRateCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - adaptive_fee_tier: self - .instruction - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetDefaultBaseFeeRateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - adaptive_fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - default_base_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_default_fee_rate.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_default_fee_rate.rs deleted file mode 100644 index cc878c69..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_default_fee_rate.rs +++ /dev/null @@ -1,407 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetDefaultFeeRate { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub fee_tier: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, -} - -impl SetDefaultFeeRate { - pub fn instruction( - &self, - args: SetDefaultFeeRateInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetDefaultFeeRateInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.fee_tier, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetDefaultFeeRateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetDefaultFeeRateInstructionData { - discriminator: [u8; 8], -} - -impl SetDefaultFeeRateInstructionData { - pub fn new() -> Self { - Self { - discriminator: [118, 215, 214, 157, 182, 229, 208, 228], - } - } -} - -impl Default for SetDefaultFeeRateInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetDefaultFeeRateInstructionArgs { - pub default_fee_rate: u16, -} - -/// Instruction builder for `SetDefaultFeeRate`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` fee_tier -/// 2. `[signer]` fee_authority -#[derive(Clone, Debug, Default)] -pub struct SetDefaultFeeRateBuilder { - whirlpools_config: Option, - fee_tier: Option, - fee_authority: Option, - default_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl SetDefaultFeeRateBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn fee_tier(&mut self, fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.fee_tier = Some(fee_tier); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn default_fee_rate(&mut self, default_fee_rate: u16) -> &mut Self { - self.default_fee_rate = Some(default_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetDefaultFeeRate { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - fee_tier: self.fee_tier.expect("fee_tier is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - }; - let args = SetDefaultFeeRateInstructionArgs { - default_fee_rate: self - .default_fee_rate - .clone() - .expect("default_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_default_fee_rate` CPI accounts. -pub struct SetDefaultFeeRateCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_default_fee_rate` CPI instruction. -pub struct SetDefaultFeeRateCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetDefaultFeeRateInstructionArgs, -} - -impl<'a, 'b> SetDefaultFeeRateCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetDefaultFeeRateCpiAccounts<'a, 'b>, - args: SetDefaultFeeRateInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - fee_tier: accounts.fee_tier, - fee_authority: accounts.fee_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetDefaultFeeRateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.fee_tier.clone()); - account_infos.push(self.fee_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetDefaultFeeRate` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` fee_tier -/// 2. `[signer]` fee_authority -#[derive(Clone, Debug)] -pub struct SetDefaultFeeRateCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetDefaultFeeRateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetDefaultFeeRateCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - fee_tier: None, - fee_authority: None, - default_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn fee_tier(&mut self, fee_tier: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.fee_tier = Some(fee_tier); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn default_fee_rate(&mut self, default_fee_rate: u16) -> &mut Self { - self.instruction.default_fee_rate = Some(default_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetDefaultFeeRateInstructionArgs { - default_fee_rate: self - .instruction - .default_fee_rate - .clone() - .expect("default_fee_rate is not set"), - }; - let instruction = SetDefaultFeeRateCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - fee_tier: self.instruction.fee_tier.expect("fee_tier is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetDefaultFeeRateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - default_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_default_protocol_fee_rate.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_default_protocol_fee_rate.rs deleted file mode 100644 index 866c069b..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_default_protocol_fee_rate.rs +++ /dev/null @@ -1,374 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetDefaultProtocolFeeRate { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, -} - -impl SetDefaultProtocolFeeRate { - pub fn instruction( - &self, - args: SetDefaultProtocolFeeRateInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetDefaultProtocolFeeRateInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetDefaultProtocolFeeRateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetDefaultProtocolFeeRateInstructionData { - discriminator: [u8; 8], -} - -impl SetDefaultProtocolFeeRateInstructionData { - pub fn new() -> Self { - Self { - discriminator: [107, 205, 249, 226, 151, 35, 86, 0], - } - } -} - -impl Default for SetDefaultProtocolFeeRateInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetDefaultProtocolFeeRateInstructionArgs { - pub default_protocol_fee_rate: u16, -} - -/// Instruction builder for `SetDefaultProtocolFeeRate`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpools_config -/// 1. `[signer]` fee_authority -#[derive(Clone, Debug, Default)] -pub struct SetDefaultProtocolFeeRateBuilder { - whirlpools_config: Option, - fee_authority: Option, - default_protocol_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl SetDefaultProtocolFeeRateBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn default_protocol_fee_rate(&mut self, default_protocol_fee_rate: u16) -> &mut Self { - self.default_protocol_fee_rate = Some(default_protocol_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetDefaultProtocolFeeRate { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - }; - let args = SetDefaultProtocolFeeRateInstructionArgs { - default_protocol_fee_rate: self - .default_protocol_fee_rate - .clone() - .expect("default_protocol_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_default_protocol_fee_rate` CPI accounts. -pub struct SetDefaultProtocolFeeRateCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_default_protocol_fee_rate` CPI instruction. -pub struct SetDefaultProtocolFeeRateCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetDefaultProtocolFeeRateInstructionArgs, -} - -impl<'a, 'b> SetDefaultProtocolFeeRateCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetDefaultProtocolFeeRateCpiAccounts<'a, 'b>, - args: SetDefaultProtocolFeeRateInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - fee_authority: accounts.fee_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetDefaultProtocolFeeRateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.fee_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetDefaultProtocolFeeRate` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpools_config -/// 1. `[signer]` fee_authority -#[derive(Clone, Debug)] -pub struct SetDefaultProtocolFeeRateCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetDefaultProtocolFeeRateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetDefaultProtocolFeeRateCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - fee_authority: None, - default_protocol_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn default_protocol_fee_rate(&mut self, default_protocol_fee_rate: u16) -> &mut Self { - self.instruction.default_protocol_fee_rate = Some(default_protocol_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetDefaultProtocolFeeRateInstructionArgs { - default_protocol_fee_rate: self - .instruction - .default_protocol_fee_rate - .clone() - .expect("default_protocol_fee_rate is not set"), - }; - let instruction = SetDefaultProtocolFeeRateCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetDefaultProtocolFeeRateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - default_protocol_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_delegated_fee_authority.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_delegated_fee_authority.rs deleted file mode 100644 index d353a646..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_delegated_fee_authority.rs +++ /dev/null @@ -1,418 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetDelegatedFeeAuthority { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub adaptive_fee_tier: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, - - pub new_delegated_fee_authority: solana_pubkey::Pubkey, -} - -impl SetDelegatedFeeAuthority { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.adaptive_fee_tier, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_delegated_fee_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetDelegatedFeeAuthorityInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetDelegatedFeeAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl SetDelegatedFeeAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [193, 234, 231, 147, 138, 57, 3, 122], - } - } -} - -impl Default for SetDelegatedFeeAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetDelegatedFeeAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` adaptive_fee_tier -/// 2. `[signer]` fee_authority -/// 3. `[]` new_delegated_fee_authority -#[derive(Clone, Debug, Default)] -pub struct SetDelegatedFeeAuthorityBuilder { - whirlpools_config: Option, - adaptive_fee_tier: Option, - fee_authority: Option, - new_delegated_fee_authority: Option, - __remaining_accounts: Vec, -} - -impl SetDelegatedFeeAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier(&mut self, adaptive_fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn new_delegated_fee_authority( - &mut self, - new_delegated_fee_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.new_delegated_fee_authority = Some(new_delegated_fee_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetDelegatedFeeAuthority { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - adaptive_fee_tier: self - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - new_delegated_fee_authority: self - .new_delegated_fee_authority - .expect("new_delegated_fee_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_delegated_fee_authority` CPI accounts. -pub struct SetDelegatedFeeAuthorityCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_delegated_fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_delegated_fee_authority` CPI instruction. -pub struct SetDelegatedFeeAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_delegated_fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetDelegatedFeeAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetDelegatedFeeAuthorityCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - adaptive_fee_tier: accounts.adaptive_fee_tier, - fee_authority: accounts.fee_authority, - new_delegated_fee_authority: accounts.new_delegated_fee_authority, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.adaptive_fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_delegated_fee_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetDelegatedFeeAuthorityInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.adaptive_fee_tier.clone()); - account_infos.push(self.fee_authority.clone()); - account_infos.push(self.new_delegated_fee_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetDelegatedFeeAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` adaptive_fee_tier -/// 2. `[signer]` fee_authority -/// 3. `[]` new_delegated_fee_authority -#[derive(Clone, Debug)] -pub struct SetDelegatedFeeAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetDelegatedFeeAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetDelegatedFeeAuthorityCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - adaptive_fee_tier: None, - fee_authority: None, - new_delegated_fee_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier( - &mut self, - adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn new_delegated_fee_authority( - &mut self, - new_delegated_fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_delegated_fee_authority = Some(new_delegated_fee_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetDelegatedFeeAuthorityCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - adaptive_fee_tier: self - .instruction - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - - new_delegated_fee_authority: self - .instruction - .new_delegated_fee_authority - .expect("new_delegated_fee_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetDelegatedFeeAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - adaptive_fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - new_delegated_fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_fee_authority.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_fee_authority.rs deleted file mode 100644 index a8b8b185..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_fee_authority.rs +++ /dev/null @@ -1,371 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetFeeAuthority { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, - - pub new_fee_authority: solana_pubkey::Pubkey, -} - -impl SetFeeAuthority { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_fee_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetFeeAuthorityInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetFeeAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl SetFeeAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [31, 1, 50, 87, 237, 101, 97, 132], - } - } -} - -impl Default for SetFeeAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetFeeAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpools_config -/// 1. `[signer]` fee_authority -/// 2. `[]` new_fee_authority -#[derive(Clone, Debug, Default)] -pub struct SetFeeAuthorityBuilder { - whirlpools_config: Option, - fee_authority: Option, - new_fee_authority: Option, - __remaining_accounts: Vec, -} - -impl SetFeeAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn new_fee_authority(&mut self, new_fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.new_fee_authority = Some(new_fee_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetFeeAuthority { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - new_fee_authority: self - .new_fee_authority - .expect("new_fee_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_fee_authority` CPI accounts. -pub struct SetFeeAuthorityCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_fee_authority` CPI instruction. -pub struct SetFeeAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetFeeAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetFeeAuthorityCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - fee_authority: accounts.fee_authority, - new_fee_authority: accounts.new_fee_authority, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_fee_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetFeeAuthorityInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.fee_authority.clone()); - account_infos.push(self.new_fee_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetFeeAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpools_config -/// 1. `[signer]` fee_authority -/// 2. `[]` new_fee_authority -#[derive(Clone, Debug)] -pub struct SetFeeAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetFeeAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetFeeAuthorityCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - fee_authority: None, - new_fee_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn new_fee_authority( - &mut self, - new_fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_fee_authority = Some(new_fee_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetFeeAuthorityCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - - new_fee_authority: self - .instruction - .new_fee_authority - .expect("new_fee_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetFeeAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - new_fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_fee_rate.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_fee_rate.rs deleted file mode 100644 index 29a63a96..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_fee_rate.rs +++ /dev/null @@ -1,401 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetFeeRate { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, -} - -impl SetFeeRate { - pub fn instruction(&self, args: SetFeeRateInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetFeeRateInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetFeeRateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetFeeRateInstructionData { - discriminator: [u8; 8], -} - -impl SetFeeRateInstructionData { - pub fn new() -> Self { - Self { - discriminator: [53, 243, 137, 65, 8, 140, 158, 6], - } - } -} - -impl Default for SetFeeRateInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetFeeRateInstructionArgs { - pub fee_rate: u16, -} - -/// Instruction builder for `SetFeeRate`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpool -/// 2. `[signer]` fee_authority -#[derive(Clone, Debug, Default)] -pub struct SetFeeRateBuilder { - whirlpools_config: Option, - whirlpool: Option, - fee_authority: Option, - fee_rate: Option, - __remaining_accounts: Vec, -} - -impl SetFeeRateBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn fee_rate(&mut self, fee_rate: u16) -> &mut Self { - self.fee_rate = Some(fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetFeeRate { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - }; - let args = SetFeeRateInstructionArgs { - fee_rate: self.fee_rate.clone().expect("fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_fee_rate` CPI accounts. -pub struct SetFeeRateCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_fee_rate` CPI instruction. -pub struct SetFeeRateCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetFeeRateInstructionArgs, -} - -impl<'a, 'b> SetFeeRateCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetFeeRateCpiAccounts<'a, 'b>, - args: SetFeeRateInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - whirlpool: accounts.whirlpool, - fee_authority: accounts.fee_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetFeeRateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.fee_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetFeeRate` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpool -/// 2. `[signer]` fee_authority -#[derive(Clone, Debug)] -pub struct SetFeeRateCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetFeeRateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetFeeRateCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - whirlpool: None, - fee_authority: None, - fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn fee_rate(&mut self, fee_rate: u16) -> &mut Self { - self.instruction.fee_rate = Some(fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetFeeRateInstructionArgs { - fee_rate: self - .instruction - .fee_rate - .clone() - .expect("fee_rate is not set"), - }; - let instruction = SetFeeRateCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetFeeRateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_fee_rate_by_delegated_fee_authority.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_fee_rate_by_delegated_fee_authority.rs deleted file mode 100644 index 2abbe625..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_fee_rate_by_delegated_fee_authority.rs +++ /dev/null @@ -1,411 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetFeeRateByDelegatedFeeAuthority { - pub whirlpool: solana_pubkey::Pubkey, - - pub adaptive_fee_tier: solana_pubkey::Pubkey, - - pub delegated_fee_authority: solana_pubkey::Pubkey, -} - -impl SetFeeRateByDelegatedFeeAuthority { - pub fn instruction( - &self, - args: SetFeeRateByDelegatedFeeAuthorityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetFeeRateByDelegatedFeeAuthorityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.adaptive_fee_tier, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.delegated_fee_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = - borsh::to_vec(&SetFeeRateByDelegatedFeeAuthorityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetFeeRateByDelegatedFeeAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl SetFeeRateByDelegatedFeeAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [121, 121, 54, 114, 131, 230, 162, 104], - } - } -} - -impl Default for SetFeeRateByDelegatedFeeAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetFeeRateByDelegatedFeeAuthorityInstructionArgs { - pub fee_rate: u16, -} - -/// Instruction builder for `SetFeeRateByDelegatedFeeAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[]` adaptive_fee_tier -/// 2. `[signer]` delegated_fee_authority -#[derive(Clone, Debug, Default)] -pub struct SetFeeRateByDelegatedFeeAuthorityBuilder { - whirlpool: Option, - adaptive_fee_tier: Option, - delegated_fee_authority: Option, - fee_rate: Option, - __remaining_accounts: Vec, -} - -impl SetFeeRateByDelegatedFeeAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier(&mut self, adaptive_fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn delegated_fee_authority( - &mut self, - delegated_fee_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.delegated_fee_authority = Some(delegated_fee_authority); - self - } - - #[inline(always)] - pub fn fee_rate(&mut self, fee_rate: u16) -> &mut Self { - self.fee_rate = Some(fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetFeeRateByDelegatedFeeAuthority { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - adaptive_fee_tier: self - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - delegated_fee_authority: self - .delegated_fee_authority - .expect("delegated_fee_authority is not set"), - }; - let args = SetFeeRateByDelegatedFeeAuthorityInstructionArgs { - fee_rate: self.fee_rate.clone().expect("fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_fee_rate_by_delegated_fee_authority` CPI accounts. -pub struct SetFeeRateByDelegatedFeeAuthorityCpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub delegated_fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_fee_rate_by_delegated_fee_authority` CPI instruction. -pub struct SetFeeRateByDelegatedFeeAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub delegated_fee_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetFeeRateByDelegatedFeeAuthorityInstructionArgs, -} - -impl<'a, 'b> SetFeeRateByDelegatedFeeAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetFeeRateByDelegatedFeeAuthorityCpiAccounts<'a, 'b>, - args: SetFeeRateByDelegatedFeeAuthorityInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - adaptive_fee_tier: accounts.adaptive_fee_tier, - delegated_fee_authority: accounts.delegated_fee_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.adaptive_fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.delegated_fee_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = - borsh::to_vec(&SetFeeRateByDelegatedFeeAuthorityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.adaptive_fee_tier.clone()); - account_infos.push(self.delegated_fee_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetFeeRateByDelegatedFeeAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[]` adaptive_fee_tier -/// 2. `[signer]` delegated_fee_authority -#[derive(Clone, Debug)] -pub struct SetFeeRateByDelegatedFeeAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetFeeRateByDelegatedFeeAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetFeeRateByDelegatedFeeAuthorityCpiBuilderInstruction { - __program: program, - whirlpool: None, - adaptive_fee_tier: None, - delegated_fee_authority: None, - fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier( - &mut self, - adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn delegated_fee_authority( - &mut self, - delegated_fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.delegated_fee_authority = Some(delegated_fee_authority); - self - } - - #[inline(always)] - pub fn fee_rate(&mut self, fee_rate: u16) -> &mut Self { - self.instruction.fee_rate = Some(fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetFeeRateByDelegatedFeeAuthorityInstructionArgs { - fee_rate: self - .instruction - .fee_rate - .clone() - .expect("fee_rate is not set"), - }; - let instruction = SetFeeRateByDelegatedFeeAuthorityCpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - adaptive_fee_tier: self - .instruction - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - - delegated_fee_authority: self - .instruction - .delegated_fee_authority - .expect("delegated_fee_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetFeeRateByDelegatedFeeAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - adaptive_fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - delegated_fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_initialize_pool_authority.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_initialize_pool_authority.rs deleted file mode 100644 index f9e394d3..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_initialize_pool_authority.rs +++ /dev/null @@ -1,418 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetInitializePoolAuthority { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub adaptive_fee_tier: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, - - pub new_initialize_pool_authority: solana_pubkey::Pubkey, -} - -impl SetInitializePoolAuthority { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.adaptive_fee_tier, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_initialize_pool_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetInitializePoolAuthorityInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetInitializePoolAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl SetInitializePoolAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [125, 43, 127, 235, 149, 26, 106, 236], - } - } -} - -impl Default for SetInitializePoolAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetInitializePoolAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` adaptive_fee_tier -/// 2. `[signer]` fee_authority -/// 3. `[]` new_initialize_pool_authority -#[derive(Clone, Debug, Default)] -pub struct SetInitializePoolAuthorityBuilder { - whirlpools_config: Option, - adaptive_fee_tier: Option, - fee_authority: Option, - new_initialize_pool_authority: Option, - __remaining_accounts: Vec, -} - -impl SetInitializePoolAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier(&mut self, adaptive_fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn new_initialize_pool_authority( - &mut self, - new_initialize_pool_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.new_initialize_pool_authority = Some(new_initialize_pool_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetInitializePoolAuthority { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - adaptive_fee_tier: self - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - new_initialize_pool_authority: self - .new_initialize_pool_authority - .expect("new_initialize_pool_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_initialize_pool_authority` CPI accounts. -pub struct SetInitializePoolAuthorityCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_initialize_pool_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_initialize_pool_authority` CPI instruction. -pub struct SetInitializePoolAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_initialize_pool_authority: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetInitializePoolAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetInitializePoolAuthorityCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - adaptive_fee_tier: accounts.adaptive_fee_tier, - fee_authority: accounts.fee_authority, - new_initialize_pool_authority: accounts.new_initialize_pool_authority, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.adaptive_fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_initialize_pool_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetInitializePoolAuthorityInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.adaptive_fee_tier.clone()); - account_infos.push(self.fee_authority.clone()); - account_infos.push(self.new_initialize_pool_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetInitializePoolAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` adaptive_fee_tier -/// 2. `[signer]` fee_authority -/// 3. `[]` new_initialize_pool_authority -#[derive(Clone, Debug)] -pub struct SetInitializePoolAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetInitializePoolAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetInitializePoolAuthorityCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - adaptive_fee_tier: None, - fee_authority: None, - new_initialize_pool_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier( - &mut self, - adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn new_initialize_pool_authority( - &mut self, - new_initialize_pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_initialize_pool_authority = Some(new_initialize_pool_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetInitializePoolAuthorityCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - adaptive_fee_tier: self - .instruction - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - - new_initialize_pool_authority: self - .instruction - .new_initialize_pool_authority - .expect("new_initialize_pool_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetInitializePoolAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - adaptive_fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - new_initialize_pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_preset_adaptive_fee_constants.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_preset_adaptive_fee_constants.rs deleted file mode 100644 index e7c2c65a..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_preset_adaptive_fee_constants.rs +++ /dev/null @@ -1,565 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetPresetAdaptiveFeeConstants { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub adaptive_fee_tier: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, -} - -impl SetPresetAdaptiveFeeConstants { - pub fn instruction( - &self, - args: SetPresetAdaptiveFeeConstantsInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetPresetAdaptiveFeeConstantsInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.adaptive_fee_tier, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetPresetAdaptiveFeeConstantsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPresetAdaptiveFeeConstantsInstructionData { - discriminator: [u8; 8], -} - -impl SetPresetAdaptiveFeeConstantsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [132, 185, 66, 148, 83, 88, 134, 198], - } - } -} - -impl Default for SetPresetAdaptiveFeeConstantsInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetPresetAdaptiveFeeConstantsInstructionArgs { - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub adaptive_fee_control_factor: u32, - pub max_volatility_accumulator: u32, - pub tick_group_size: u16, - pub major_swap_threshold_ticks: u16, -} - -/// Instruction builder for `SetPresetAdaptiveFeeConstants`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` adaptive_fee_tier -/// 2. `[signer]` fee_authority -#[derive(Clone, Debug, Default)] -pub struct SetPresetAdaptiveFeeConstantsBuilder { - whirlpools_config: Option, - adaptive_fee_tier: Option, - fee_authority: Option, - filter_period: Option, - decay_period: Option, - reduction_factor: Option, - adaptive_fee_control_factor: Option, - max_volatility_accumulator: Option, - tick_group_size: Option, - major_swap_threshold_ticks: Option, - __remaining_accounts: Vec, -} - -impl SetPresetAdaptiveFeeConstantsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier(&mut self, adaptive_fee_tier: solana_pubkey::Pubkey) -> &mut Self { - self.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn filter_period(&mut self, filter_period: u16) -> &mut Self { - self.filter_period = Some(filter_period); - self - } - - #[inline(always)] - pub fn decay_period(&mut self, decay_period: u16) -> &mut Self { - self.decay_period = Some(decay_period); - self - } - - #[inline(always)] - pub fn reduction_factor(&mut self, reduction_factor: u16) -> &mut Self { - self.reduction_factor = Some(reduction_factor); - self - } - - #[inline(always)] - pub fn adaptive_fee_control_factor(&mut self, adaptive_fee_control_factor: u32) -> &mut Self { - self.adaptive_fee_control_factor = Some(adaptive_fee_control_factor); - self - } - - #[inline(always)] - pub fn max_volatility_accumulator(&mut self, max_volatility_accumulator: u32) -> &mut Self { - self.max_volatility_accumulator = Some(max_volatility_accumulator); - self - } - - #[inline(always)] - pub fn tick_group_size(&mut self, tick_group_size: u16) -> &mut Self { - self.tick_group_size = Some(tick_group_size); - self - } - - #[inline(always)] - pub fn major_swap_threshold_ticks(&mut self, major_swap_threshold_ticks: u16) -> &mut Self { - self.major_swap_threshold_ticks = Some(major_swap_threshold_ticks); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetPresetAdaptiveFeeConstants { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - adaptive_fee_tier: self - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - }; - let args = SetPresetAdaptiveFeeConstantsInstructionArgs { - filter_period: self - .filter_period - .clone() - .expect("filter_period is not set"), - decay_period: self.decay_period.clone().expect("decay_period is not set"), - reduction_factor: self - .reduction_factor - .clone() - .expect("reduction_factor is not set"), - adaptive_fee_control_factor: self - .adaptive_fee_control_factor - .clone() - .expect("adaptive_fee_control_factor is not set"), - max_volatility_accumulator: self - .max_volatility_accumulator - .clone() - .expect("max_volatility_accumulator is not set"), - tick_group_size: self - .tick_group_size - .clone() - .expect("tick_group_size is not set"), - major_swap_threshold_ticks: self - .major_swap_threshold_ticks - .clone() - .expect("major_swap_threshold_ticks is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_preset_adaptive_fee_constants` CPI accounts. -pub struct SetPresetAdaptiveFeeConstantsCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_preset_adaptive_fee_constants` CPI instruction. -pub struct SetPresetAdaptiveFeeConstantsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetPresetAdaptiveFeeConstantsInstructionArgs, -} - -impl<'a, 'b> SetPresetAdaptiveFeeConstantsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetPresetAdaptiveFeeConstantsCpiAccounts<'a, 'b>, - args: SetPresetAdaptiveFeeConstantsInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - adaptive_fee_tier: accounts.adaptive_fee_tier, - fee_authority: accounts.fee_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.adaptive_fee_tier.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetPresetAdaptiveFeeConstantsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.adaptive_fee_tier.clone()); - account_infos.push(self.fee_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetPresetAdaptiveFeeConstants` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` adaptive_fee_tier -/// 2. `[signer]` fee_authority -#[derive(Clone, Debug)] -pub struct SetPresetAdaptiveFeeConstantsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetPresetAdaptiveFeeConstantsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetPresetAdaptiveFeeConstantsCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - adaptive_fee_tier: None, - fee_authority: None, - filter_period: None, - decay_period: None, - reduction_factor: None, - adaptive_fee_control_factor: None, - max_volatility_accumulator: None, - tick_group_size: None, - major_swap_threshold_ticks: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn adaptive_fee_tier( - &mut self, - adaptive_fee_tier: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.adaptive_fee_tier = Some(adaptive_fee_tier); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn filter_period(&mut self, filter_period: u16) -> &mut Self { - self.instruction.filter_period = Some(filter_period); - self - } - - #[inline(always)] - pub fn decay_period(&mut self, decay_period: u16) -> &mut Self { - self.instruction.decay_period = Some(decay_period); - self - } - - #[inline(always)] - pub fn reduction_factor(&mut self, reduction_factor: u16) -> &mut Self { - self.instruction.reduction_factor = Some(reduction_factor); - self - } - - #[inline(always)] - pub fn adaptive_fee_control_factor(&mut self, adaptive_fee_control_factor: u32) -> &mut Self { - self.instruction.adaptive_fee_control_factor = Some(adaptive_fee_control_factor); - self - } - - #[inline(always)] - pub fn max_volatility_accumulator(&mut self, max_volatility_accumulator: u32) -> &mut Self { - self.instruction.max_volatility_accumulator = Some(max_volatility_accumulator); - self - } - - #[inline(always)] - pub fn tick_group_size(&mut self, tick_group_size: u16) -> &mut Self { - self.instruction.tick_group_size = Some(tick_group_size); - self - } - - #[inline(always)] - pub fn major_swap_threshold_ticks(&mut self, major_swap_threshold_ticks: u16) -> &mut Self { - self.instruction.major_swap_threshold_ticks = Some(major_swap_threshold_ticks); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetPresetAdaptiveFeeConstantsInstructionArgs { - filter_period: self - .instruction - .filter_period - .clone() - .expect("filter_period is not set"), - decay_period: self - .instruction - .decay_period - .clone() - .expect("decay_period is not set"), - reduction_factor: self - .instruction - .reduction_factor - .clone() - .expect("reduction_factor is not set"), - adaptive_fee_control_factor: self - .instruction - .adaptive_fee_control_factor - .clone() - .expect("adaptive_fee_control_factor is not set"), - max_volatility_accumulator: self - .instruction - .max_volatility_accumulator - .clone() - .expect("max_volatility_accumulator is not set"), - tick_group_size: self - .instruction - .tick_group_size - .clone() - .expect("tick_group_size is not set"), - major_swap_threshold_ticks: self - .instruction - .major_swap_threshold_ticks - .clone() - .expect("major_swap_threshold_ticks is not set"), - }; - let instruction = SetPresetAdaptiveFeeConstantsCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - adaptive_fee_tier: self - .instruction - .adaptive_fee_tier - .expect("adaptive_fee_tier is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetPresetAdaptiveFeeConstantsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - adaptive_fee_tier: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - filter_period: Option, - decay_period: Option, - reduction_factor: Option, - adaptive_fee_control_factor: Option, - max_volatility_accumulator: Option, - tick_group_size: Option, - major_swap_threshold_ticks: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_protocol_fee_rate.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_protocol_fee_rate.rs deleted file mode 100644 index fe361233..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_protocol_fee_rate.rs +++ /dev/null @@ -1,407 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetProtocolFeeRate { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub fee_authority: solana_pubkey::Pubkey, -} - -impl SetProtocolFeeRate { - pub fn instruction( - &self, - args: SetProtocolFeeRateInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetProtocolFeeRateInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_authority, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetProtocolFeeRateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetProtocolFeeRateInstructionData { - discriminator: [u8; 8], -} - -impl SetProtocolFeeRateInstructionData { - pub fn new() -> Self { - Self { - discriminator: [95, 7, 4, 50, 154, 79, 156, 131], - } - } -} - -impl Default for SetProtocolFeeRateInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetProtocolFeeRateInstructionArgs { - pub protocol_fee_rate: u16, -} - -/// Instruction builder for `SetProtocolFeeRate`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpool -/// 2. `[signer]` fee_authority -#[derive(Clone, Debug, Default)] -pub struct SetProtocolFeeRateBuilder { - whirlpools_config: Option, - whirlpool: Option, - fee_authority: Option, - protocol_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl SetProtocolFeeRateBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn protocol_fee_rate(&mut self, protocol_fee_rate: u16) -> &mut Self { - self.protocol_fee_rate = Some(protocol_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetProtocolFeeRate { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - fee_authority: self.fee_authority.expect("fee_authority is not set"), - }; - let args = SetProtocolFeeRateInstructionArgs { - protocol_fee_rate: self - .protocol_fee_rate - .clone() - .expect("protocol_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_protocol_fee_rate` CPI accounts. -pub struct SetProtocolFeeRateCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_protocol_fee_rate` CPI instruction. -pub struct SetProtocolFeeRateCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub fee_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetProtocolFeeRateInstructionArgs, -} - -impl<'a, 'b> SetProtocolFeeRateCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetProtocolFeeRateCpiAccounts<'a, 'b>, - args: SetProtocolFeeRateInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - whirlpool: accounts.whirlpool, - fee_authority: accounts.fee_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_authority.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetProtocolFeeRateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.fee_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetProtocolFeeRate` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpool -/// 2. `[signer]` fee_authority -#[derive(Clone, Debug)] -pub struct SetProtocolFeeRateCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetProtocolFeeRateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetProtocolFeeRateCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - whirlpool: None, - fee_authority: None, - protocol_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn fee_authority( - &mut self, - fee_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_authority = Some(fee_authority); - self - } - - #[inline(always)] - pub fn protocol_fee_rate(&mut self, protocol_fee_rate: u16) -> &mut Self { - self.instruction.protocol_fee_rate = Some(protocol_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetProtocolFeeRateInstructionArgs { - protocol_fee_rate: self - .instruction - .protocol_fee_rate - .clone() - .expect("protocol_fee_rate is not set"), - }; - let instruction = SetProtocolFeeRateCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - fee_authority: self - .instruction - .fee_authority - .expect("fee_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetProtocolFeeRateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_authority.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_authority.rs deleted file mode 100644 index fe09f7ed..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_authority.rs +++ /dev/null @@ -1,407 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetRewardAuthority { - pub whirlpool: solana_pubkey::Pubkey, - - pub reward_authority: solana_pubkey::Pubkey, - - pub new_reward_authority: solana_pubkey::Pubkey, -} - -impl SetRewardAuthority { - pub fn instruction( - &self, - args: SetRewardAuthorityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetRewardAuthorityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_reward_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetRewardAuthorityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl SetRewardAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [34, 39, 183, 252, 83, 28, 85, 127], - } - } -} - -impl Default for SetRewardAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardAuthorityInstructionArgs { - pub reward_index: u8, -} - -/// Instruction builder for `SetRewardAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[signer]` reward_authority -/// 2. `[]` new_reward_authority -#[derive(Clone, Debug, Default)] -pub struct SetRewardAuthorityBuilder { - whirlpool: Option, - reward_authority: Option, - new_reward_authority: Option, - reward_index: Option, - __remaining_accounts: Vec, -} - -impl SetRewardAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_authority(&mut self, reward_authority: solana_pubkey::Pubkey) -> &mut Self { - self.reward_authority = Some(reward_authority); - self - } - - #[inline(always)] - pub fn new_reward_authority( - &mut self, - new_reward_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.new_reward_authority = Some(new_reward_authority); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetRewardAuthority { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - reward_authority: self.reward_authority.expect("reward_authority is not set"), - new_reward_authority: self - .new_reward_authority - .expect("new_reward_authority is not set"), - }; - let args = SetRewardAuthorityInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_reward_authority` CPI accounts. -pub struct SetRewardAuthorityCpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_reward_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_reward_authority` CPI instruction. -pub struct SetRewardAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_reward_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetRewardAuthorityInstructionArgs, -} - -impl<'a, 'b> SetRewardAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetRewardAuthorityCpiAccounts<'a, 'b>, - args: SetRewardAuthorityInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - reward_authority: accounts.reward_authority, - new_reward_authority: accounts.new_reward_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_reward_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetRewardAuthorityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.reward_authority.clone()); - account_infos.push(self.new_reward_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetRewardAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[signer]` reward_authority -/// 2. `[]` new_reward_authority -#[derive(Clone, Debug)] -pub struct SetRewardAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetRewardAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetRewardAuthorityCpiBuilderInstruction { - __program: program, - whirlpool: None, - reward_authority: None, - new_reward_authority: None, - reward_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_authority( - &mut self, - reward_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_authority = Some(reward_authority); - self - } - - #[inline(always)] - pub fn new_reward_authority( - &mut self, - new_reward_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_reward_authority = Some(new_reward_authority); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetRewardAuthorityInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - }; - let instruction = SetRewardAuthorityCpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - reward_authority: self - .instruction - .reward_authority - .expect("reward_authority is not set"), - - new_reward_authority: self - .instruction - .new_reward_authority - .expect("new_reward_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetRewardAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - new_reward_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_authority_by_super_authority.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_authority_by_super_authority.rs deleted file mode 100644 index f6428aad..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_authority_by_super_authority.rs +++ /dev/null @@ -1,458 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetRewardAuthorityBySuperAuthority { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub reward_emissions_super_authority: solana_pubkey::Pubkey, - - pub new_reward_authority: solana_pubkey::Pubkey, -} - -impl SetRewardAuthorityBySuperAuthority { - pub fn instruction( - &self, - args: SetRewardAuthorityBySuperAuthorityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetRewardAuthorityBySuperAuthorityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_emissions_super_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_reward_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = - borsh::to_vec(&SetRewardAuthorityBySuperAuthorityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardAuthorityBySuperAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl SetRewardAuthorityBySuperAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [240, 154, 201, 198, 148, 93, 56, 25], - } - } -} - -impl Default for SetRewardAuthorityBySuperAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardAuthorityBySuperAuthorityInstructionArgs { - pub reward_index: u8, -} - -/// Instruction builder for `SetRewardAuthorityBySuperAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpool -/// 2. `[signer]` reward_emissions_super_authority -/// 3. `[]` new_reward_authority -#[derive(Clone, Debug, Default)] -pub struct SetRewardAuthorityBySuperAuthorityBuilder { - whirlpools_config: Option, - whirlpool: Option, - reward_emissions_super_authority: Option, - new_reward_authority: Option, - reward_index: Option, - __remaining_accounts: Vec, -} - -impl SetRewardAuthorityBySuperAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_emissions_super_authority( - &mut self, - reward_emissions_super_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.reward_emissions_super_authority = Some(reward_emissions_super_authority); - self - } - - #[inline(always)] - pub fn new_reward_authority( - &mut self, - new_reward_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.new_reward_authority = Some(new_reward_authority); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetRewardAuthorityBySuperAuthority { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - reward_emissions_super_authority: self - .reward_emissions_super_authority - .expect("reward_emissions_super_authority is not set"), - new_reward_authority: self - .new_reward_authority - .expect("new_reward_authority is not set"), - }; - let args = SetRewardAuthorityBySuperAuthorityInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_reward_authority_by_super_authority` CPI accounts. -pub struct SetRewardAuthorityBySuperAuthorityCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_emissions_super_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_reward_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_reward_authority_by_super_authority` CPI instruction. -pub struct SetRewardAuthorityBySuperAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_emissions_super_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_reward_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetRewardAuthorityBySuperAuthorityInstructionArgs, -} - -impl<'a, 'b> SetRewardAuthorityBySuperAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetRewardAuthorityBySuperAuthorityCpiAccounts<'a, 'b>, - args: SetRewardAuthorityBySuperAuthorityInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - whirlpool: accounts.whirlpool, - reward_emissions_super_authority: accounts.reward_emissions_super_authority, - new_reward_authority: accounts.new_reward_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_emissions_super_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_reward_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = - borsh::to_vec(&SetRewardAuthorityBySuperAuthorityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.reward_emissions_super_authority.clone()); - account_infos.push(self.new_reward_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetRewardAuthorityBySuperAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpool -/// 2. `[signer]` reward_emissions_super_authority -/// 3. `[]` new_reward_authority -#[derive(Clone, Debug)] -pub struct SetRewardAuthorityBySuperAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetRewardAuthorityBySuperAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetRewardAuthorityBySuperAuthorityCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - whirlpool: None, - reward_emissions_super_authority: None, - new_reward_authority: None, - reward_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_emissions_super_authority( - &mut self, - reward_emissions_super_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_emissions_super_authority = Some(reward_emissions_super_authority); - self - } - - #[inline(always)] - pub fn new_reward_authority( - &mut self, - new_reward_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_reward_authority = Some(new_reward_authority); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetRewardAuthorityBySuperAuthorityInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - }; - let instruction = SetRewardAuthorityBySuperAuthorityCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - reward_emissions_super_authority: self - .instruction - .reward_emissions_super_authority - .expect("reward_emissions_super_authority is not set"), - - new_reward_authority: self - .instruction - .new_reward_authority - .expect("new_reward_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetRewardAuthorityBySuperAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_emissions_super_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - new_reward_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_emissions.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_emissions.rs deleted file mode 100644 index 6e6df0c9..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_emissions.rs +++ /dev/null @@ -1,427 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetRewardEmissions { - pub whirlpool: solana_pubkey::Pubkey, - - pub reward_authority: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, -} - -impl SetRewardEmissions { - pub fn instruction( - &self, - args: SetRewardEmissionsInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetRewardEmissionsInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_vault, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetRewardEmissionsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardEmissionsInstructionData { - discriminator: [u8; 8], -} - -impl SetRewardEmissionsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [13, 197, 86, 168, 109, 176, 27, 244], - } - } -} - -impl Default for SetRewardEmissionsInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardEmissionsInstructionArgs { - pub reward_index: u8, - pub emissions_per_second_x64: u128, -} - -/// Instruction builder for `SetRewardEmissions`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[signer]` reward_authority -/// 2. `[]` reward_vault -#[derive(Clone, Debug, Default)] -pub struct SetRewardEmissionsBuilder { - whirlpool: Option, - reward_authority: Option, - reward_vault: Option, - reward_index: Option, - emissions_per_second_x64: Option, - __remaining_accounts: Vec, -} - -impl SetRewardEmissionsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_authority(&mut self, reward_authority: solana_pubkey::Pubkey) -> &mut Self { - self.reward_authority = Some(reward_authority); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn emissions_per_second_x64(&mut self, emissions_per_second_x64: u128) -> &mut Self { - self.emissions_per_second_x64 = Some(emissions_per_second_x64); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetRewardEmissions { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - reward_authority: self.reward_authority.expect("reward_authority is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - }; - let args = SetRewardEmissionsInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - emissions_per_second_x64: self - .emissions_per_second_x64 - .clone() - .expect("emissions_per_second_x64 is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_reward_emissions` CPI accounts. -pub struct SetRewardEmissionsCpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_authority: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_reward_emissions` CPI instruction. -pub struct SetRewardEmissionsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_authority: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetRewardEmissionsInstructionArgs, -} - -impl<'a, 'b> SetRewardEmissionsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetRewardEmissionsCpiAccounts<'a, 'b>, - args: SetRewardEmissionsInstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - reward_authority: accounts.reward_authority, - reward_vault: accounts.reward_vault, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_vault.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetRewardEmissionsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.reward_authority.clone()); - account_infos.push(self.reward_vault.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetRewardEmissions` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[signer]` reward_authority -/// 2. `[]` reward_vault -#[derive(Clone, Debug)] -pub struct SetRewardEmissionsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetRewardEmissionsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetRewardEmissionsCpiBuilderInstruction { - __program: program, - whirlpool: None, - reward_authority: None, - reward_vault: None, - reward_index: None, - emissions_per_second_x64: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_authority( - &mut self, - reward_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_authority = Some(reward_authority); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn emissions_per_second_x64(&mut self, emissions_per_second_x64: u128) -> &mut Self { - self.instruction.emissions_per_second_x64 = Some(emissions_per_second_x64); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetRewardEmissionsInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - emissions_per_second_x64: self - .instruction - .emissions_per_second_x64 - .clone() - .expect("emissions_per_second_x64 is not set"), - }; - let instruction = SetRewardEmissionsCpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - reward_authority: self - .instruction - .reward_authority - .expect("reward_authority is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetRewardEmissionsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - emissions_per_second_x64: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_emissions_super_authority.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_emissions_super_authority.rs deleted file mode 100644 index 8b396024..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_emissions_super_authority.rs +++ /dev/null @@ -1,380 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetRewardEmissionsSuperAuthority { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub reward_emissions_super_authority: solana_pubkey::Pubkey, - - pub new_reward_emissions_super_authority: solana_pubkey::Pubkey, -} - -impl SetRewardEmissionsSuperAuthority { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_emissions_super_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_reward_emissions_super_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetRewardEmissionsSuperAuthorityInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardEmissionsSuperAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl SetRewardEmissionsSuperAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [207, 5, 200, 209, 122, 56, 82, 183], - } - } -} - -impl Default for SetRewardEmissionsSuperAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetRewardEmissionsSuperAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpools_config -/// 1. `[signer]` reward_emissions_super_authority -/// 2. `[]` new_reward_emissions_super_authority -#[derive(Clone, Debug, Default)] -pub struct SetRewardEmissionsSuperAuthorityBuilder { - whirlpools_config: Option, - reward_emissions_super_authority: Option, - new_reward_emissions_super_authority: Option, - __remaining_accounts: Vec, -} - -impl SetRewardEmissionsSuperAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn reward_emissions_super_authority( - &mut self, - reward_emissions_super_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.reward_emissions_super_authority = Some(reward_emissions_super_authority); - self - } - - #[inline(always)] - pub fn new_reward_emissions_super_authority( - &mut self, - new_reward_emissions_super_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.new_reward_emissions_super_authority = Some(new_reward_emissions_super_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetRewardEmissionsSuperAuthority { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - reward_emissions_super_authority: self - .reward_emissions_super_authority - .expect("reward_emissions_super_authority is not set"), - new_reward_emissions_super_authority: self - .new_reward_emissions_super_authority - .expect("new_reward_emissions_super_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_reward_emissions_super_authority` CPI accounts. -pub struct SetRewardEmissionsSuperAuthorityCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub reward_emissions_super_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_reward_emissions_super_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_reward_emissions_super_authority` CPI instruction. -pub struct SetRewardEmissionsSuperAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub reward_emissions_super_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_reward_emissions_super_authority: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetRewardEmissionsSuperAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetRewardEmissionsSuperAuthorityCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - reward_emissions_super_authority: accounts.reward_emissions_super_authority, - new_reward_emissions_super_authority: accounts.new_reward_emissions_super_authority, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_emissions_super_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_reward_emissions_super_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetRewardEmissionsSuperAuthorityInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.reward_emissions_super_authority.clone()); - account_infos.push(self.new_reward_emissions_super_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetRewardEmissionsSuperAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpools_config -/// 1. `[signer]` reward_emissions_super_authority -/// 2. `[]` new_reward_emissions_super_authority -#[derive(Clone, Debug)] -pub struct SetRewardEmissionsSuperAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetRewardEmissionsSuperAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetRewardEmissionsSuperAuthorityCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - reward_emissions_super_authority: None, - new_reward_emissions_super_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn reward_emissions_super_authority( - &mut self, - reward_emissions_super_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_emissions_super_authority = Some(reward_emissions_super_authority); - self - } - - #[inline(always)] - pub fn new_reward_emissions_super_authority( - &mut self, - new_reward_emissions_super_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_reward_emissions_super_authority = - Some(new_reward_emissions_super_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetRewardEmissionsSuperAuthorityCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - reward_emissions_super_authority: self - .instruction - .reward_emissions_super_authority - .expect("reward_emissions_super_authority is not set"), - - new_reward_emissions_super_authority: self - .instruction - .new_reward_emissions_super_authority - .expect("new_reward_emissions_super_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetRewardEmissionsSuperAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_emissions_super_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - new_reward_emissions_super_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_emissions_v2.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_emissions_v2.rs deleted file mode 100644 index 5f8b3194..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_reward_emissions_v2.rs +++ /dev/null @@ -1,427 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetRewardEmissionsV2 { - pub whirlpool: solana_pubkey::Pubkey, - - pub reward_authority: solana_pubkey::Pubkey, - - pub reward_vault: solana_pubkey::Pubkey, -} - -impl SetRewardEmissionsV2 { - pub fn instruction( - &self, - args: SetRewardEmissionsV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetRewardEmissionsV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_vault, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetRewardEmissionsV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardEmissionsV2InstructionData { - discriminator: [u8; 8], -} - -impl SetRewardEmissionsV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [114, 228, 72, 32, 193, 48, 160, 102], - } - } -} - -impl Default for SetRewardEmissionsV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardEmissionsV2InstructionArgs { - pub reward_index: u8, - pub emissions_per_second_x64: u128, -} - -/// Instruction builder for `SetRewardEmissionsV2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[signer]` reward_authority -/// 2. `[]` reward_vault -#[derive(Clone, Debug, Default)] -pub struct SetRewardEmissionsV2Builder { - whirlpool: Option, - reward_authority: Option, - reward_vault: Option, - reward_index: Option, - emissions_per_second_x64: Option, - __remaining_accounts: Vec, -} - -impl SetRewardEmissionsV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_authority(&mut self, reward_authority: solana_pubkey::Pubkey) -> &mut Self { - self.reward_authority = Some(reward_authority); - self - } - - #[inline(always)] - pub fn reward_vault(&mut self, reward_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn emissions_per_second_x64(&mut self, emissions_per_second_x64: u128) -> &mut Self { - self.emissions_per_second_x64 = Some(emissions_per_second_x64); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetRewardEmissionsV2 { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - reward_authority: self.reward_authority.expect("reward_authority is not set"), - reward_vault: self.reward_vault.expect("reward_vault is not set"), - }; - let args = SetRewardEmissionsV2InstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - emissions_per_second_x64: self - .emissions_per_second_x64 - .clone() - .expect("emissions_per_second_x64 is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_reward_emissions_v2` CPI accounts. -pub struct SetRewardEmissionsV2CpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_authority: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_reward_emissions_v2` CPI instruction. -pub struct SetRewardEmissionsV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub reward_authority: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetRewardEmissionsV2InstructionArgs, -} - -impl<'a, 'b> SetRewardEmissionsV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetRewardEmissionsV2CpiAccounts<'a, 'b>, - args: SetRewardEmissionsV2InstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - reward_authority: accounts.reward_authority, - reward_vault: accounts.reward_vault, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_vault.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetRewardEmissionsV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.reward_authority.clone()); - account_infos.push(self.reward_vault.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetRewardEmissionsV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[signer]` reward_authority -/// 2. `[]` reward_vault -#[derive(Clone, Debug)] -pub struct SetRewardEmissionsV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetRewardEmissionsV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetRewardEmissionsV2CpiBuilderInstruction { - __program: program, - whirlpool: None, - reward_authority: None, - reward_vault: None, - reward_index: None, - emissions_per_second_x64: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn reward_authority( - &mut self, - reward_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_authority = Some(reward_authority); - self - } - - #[inline(always)] - pub fn reward_vault( - &mut self, - reward_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault = Some(reward_vault); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn emissions_per_second_x64(&mut self, emissions_per_second_x64: u128) -> &mut Self { - self.instruction.emissions_per_second_x64 = Some(emissions_per_second_x64); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetRewardEmissionsV2InstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - emissions_per_second_x64: self - .instruction - .emissions_per_second_x64 - .clone() - .expect("emissions_per_second_x64 is not set"), - }; - let instruction = SetRewardEmissionsV2Cpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - reward_authority: self - .instruction - .reward_authority - .expect("reward_authority is not set"), - - reward_vault: self - .instruction - .reward_vault - .expect("reward_vault is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetRewardEmissionsV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - emissions_per_second_x64: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_token_badge_authority.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_token_badge_authority.rs deleted file mode 100644 index 67851e56..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/set_token_badge_authority.rs +++ /dev/null @@ -1,426 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetTokenBadgeAuthority { - pub whirlpools_config: solana_pubkey::Pubkey, - - pub whirlpools_config_extension: solana_pubkey::Pubkey, - - pub config_extension_authority: solana_pubkey::Pubkey, - - pub new_token_badge_authority: solana_pubkey::Pubkey, -} - -impl SetTokenBadgeAuthority { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.whirlpools_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.whirlpools_config_extension, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config_extension_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_token_badge_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetTokenBadgeAuthorityInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetTokenBadgeAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl SetTokenBadgeAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [207, 202, 4, 32, 205, 79, 13, 178], - } - } -} - -impl Default for SetTokenBadgeAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetTokenBadgeAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpools_config_extension -/// 2. `[signer]` config_extension_authority -/// 3. `[]` new_token_badge_authority -#[derive(Clone, Debug, Default)] -pub struct SetTokenBadgeAuthorityBuilder { - whirlpools_config: Option, - whirlpools_config_extension: Option, - config_extension_authority: Option, - new_token_badge_authority: Option, - __remaining_accounts: Vec, -} - -impl SetTokenBadgeAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpools_config(&mut self, whirlpools_config: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpools_config_extension( - &mut self, - whirlpools_config_extension: solana_pubkey::Pubkey, - ) -> &mut Self { - self.whirlpools_config_extension = Some(whirlpools_config_extension); - self - } - - #[inline(always)] - pub fn config_extension_authority( - &mut self, - config_extension_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.config_extension_authority = Some(config_extension_authority); - self - } - - #[inline(always)] - pub fn new_token_badge_authority( - &mut self, - new_token_badge_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.new_token_badge_authority = Some(new_token_badge_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetTokenBadgeAuthority { - whirlpools_config: self - .whirlpools_config - .expect("whirlpools_config is not set"), - whirlpools_config_extension: self - .whirlpools_config_extension - .expect("whirlpools_config_extension is not set"), - config_extension_authority: self - .config_extension_authority - .expect("config_extension_authority is not set"), - new_token_badge_authority: self - .new_token_badge_authority - .expect("new_token_badge_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_token_badge_authority` CPI accounts. -pub struct SetTokenBadgeAuthorityCpiAccounts<'a, 'b> { - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - - pub config_extension_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_token_badge_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_token_badge_authority` CPI instruction. -pub struct SetTokenBadgeAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - - pub config_extension_authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_token_badge_authority: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetTokenBadgeAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetTokenBadgeAuthorityCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpools_config: accounts.whirlpools_config, - whirlpools_config_extension: accounts.whirlpools_config_extension, - config_extension_authority: accounts.config_extension_authority, - new_token_badge_authority: accounts.new_token_badge_authority, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.whirlpools_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpools_config_extension.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config_extension_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_token_badge_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetTokenBadgeAuthorityInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpools_config.clone()); - account_infos.push(self.whirlpools_config_extension.clone()); - account_infos.push(self.config_extension_authority.clone()); - account_infos.push(self.new_token_badge_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetTokenBadgeAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` whirlpools_config -/// 1. `[writable]` whirlpools_config_extension -/// 2. `[signer]` config_extension_authority -/// 3. `[]` new_token_badge_authority -#[derive(Clone, Debug)] -pub struct SetTokenBadgeAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetTokenBadgeAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetTokenBadgeAuthorityCpiBuilderInstruction { - __program: program, - whirlpools_config: None, - whirlpools_config_extension: None, - config_extension_authority: None, - new_token_badge_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpools_config( - &mut self, - whirlpools_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config = Some(whirlpools_config); - self - } - - #[inline(always)] - pub fn whirlpools_config_extension( - &mut self, - whirlpools_config_extension: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpools_config_extension = Some(whirlpools_config_extension); - self - } - - #[inline(always)] - pub fn config_extension_authority( - &mut self, - config_extension_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.config_extension_authority = Some(config_extension_authority); - self - } - - #[inline(always)] - pub fn new_token_badge_authority( - &mut self, - new_token_badge_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_token_badge_authority = Some(new_token_badge_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetTokenBadgeAuthorityCpi { - __program: self.instruction.__program, - - whirlpools_config: self - .instruction - .whirlpools_config - .expect("whirlpools_config is not set"), - - whirlpools_config_extension: self - .instruction - .whirlpools_config_extension - .expect("whirlpools_config_extension is not set"), - - config_extension_authority: self - .instruction - .config_extension_authority - .expect("config_extension_authority is not set"), - - new_token_badge_authority: self - .instruction - .new_token_badge_authority - .expect("new_token_badge_authority is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetTokenBadgeAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpools_config: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpools_config_extension: Option<&'b solana_account_info::AccountInfo<'a>>, - config_extension_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - new_token_badge_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/swap.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/swap.rs deleted file mode 100644 index e83d4fea..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/swap.rs +++ /dev/null @@ -1,831 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Swap { - pub token_program: solana_pubkey::Pubkey, - - pub token_authority: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub token_owner_account_a: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_owner_account_b: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub tick_array0: solana_pubkey::Pubkey, - - pub tick_array1: solana_pubkey::Pubkey, - - pub tick_array2: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, -} - -impl Swap { - pub fn instruction(&self, args: SwapInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array2, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.oracle, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionData { - discriminator: [u8; 8], -} - -impl SwapInstructionData { - pub fn new() -> Self { - Self { - discriminator: [248, 198, 158, 145, 225, 117, 135, 200], - } - } -} - -impl Default for SwapInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionArgs { - pub amount: u64, - pub other_amount_threshold: u64, - pub sqrt_price_limit: u128, - pub amount_specified_is_input: bool, - pub a_to_b: bool, -} - -/// Instruction builder for `Swap`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[signer]` token_authority -/// 2. `[writable]` whirlpool -/// 3. `[writable]` token_owner_account_a -/// 4. `[writable]` token_vault_a -/// 5. `[writable]` token_owner_account_b -/// 6. `[writable]` token_vault_b -/// 7. `[writable]` tick_array0 -/// 8. `[writable]` tick_array1 -/// 9. `[writable]` tick_array2 -/// 10. `[]` oracle -#[derive(Clone, Debug, Default)] -pub struct SwapBuilder { - token_program: Option, - token_authority: Option, - whirlpool: Option, - token_owner_account_a: Option, - token_vault_a: Option, - token_owner_account_b: Option, - token_vault_b: Option, - tick_array0: Option, - tick_array1: Option, - tick_array2: Option, - oracle: Option, - amount: Option, - other_amount_threshold: Option, - sqrt_price_limit: Option, - amount_specified_is_input: Option, - a_to_b: Option, - __remaining_accounts: Vec, -} - -impl SwapBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_authority(&mut self, token_authority: solana_pubkey::Pubkey) -> &mut Self { - self.token_authority = Some(token_authority); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array0(&mut self, tick_array0: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array0 = Some(tick_array0); - self - } - - #[inline(always)] - pub fn tick_array1(&mut self, tick_array1: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array1 = Some(tick_array1); - self - } - - #[inline(always)] - pub fn tick_array2(&mut self, tick_array2: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array2 = Some(tick_array2); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn sqrt_price_limit(&mut self, sqrt_price_limit: u128) -> &mut Self { - self.sqrt_price_limit = Some(sqrt_price_limit); - self - } - - #[inline(always)] - pub fn amount_specified_is_input(&mut self, amount_specified_is_input: bool) -> &mut Self { - self.amount_specified_is_input = Some(amount_specified_is_input); - self - } - - #[inline(always)] - pub fn a_to_b(&mut self, a_to_b: bool) -> &mut Self { - self.a_to_b = Some(a_to_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Swap { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_authority: self.token_authority.expect("token_authority is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token_owner_account_a: self - .token_owner_account_a - .expect("token_owner_account_a is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_owner_account_b: self - .token_owner_account_b - .expect("token_owner_account_b is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - tick_array0: self.tick_array0.expect("tick_array0 is not set"), - tick_array1: self.tick_array1.expect("tick_array1 is not set"), - tick_array2: self.tick_array2.expect("tick_array2 is not set"), - oracle: self.oracle.expect("oracle is not set"), - }; - let args = SwapInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - sqrt_price_limit: self - .sqrt_price_limit - .clone() - .expect("sqrt_price_limit is not set"), - amount_specified_is_input: self - .amount_specified_is_input - .clone() - .expect("amount_specified_is_input is not set"), - a_to_b: self.a_to_b.clone().expect("a_to_b is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap` CPI accounts. -pub struct SwapCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array2: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap` CPI instruction. -pub struct SwapCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array2: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapInstructionArgs, -} - -impl<'a, 'b> SwapCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapCpiAccounts<'a, 'b>, - args: SwapInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - token_authority: accounts.token_authority, - whirlpool: accounts.whirlpool, - token_owner_account_a: accounts.token_owner_account_a, - token_vault_a: accounts.token_vault_a, - token_owner_account_b: accounts.token_owner_account_b, - token_vault_b: accounts.token_vault_b, - tick_array0: accounts.tick_array0, - tick_array1: accounts.tick_array1, - tick_array2: accounts.tick_array2, - oracle: accounts.oracle, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array2.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.oracle.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_authority.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token_owner_account_a.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_owner_account_b.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.tick_array0.clone()); - account_infos.push(self.tick_array1.clone()); - account_infos.push(self.tick_array2.clone()); - account_infos.push(self.oracle.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Swap` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[signer]` token_authority -/// 2. `[writable]` whirlpool -/// 3. `[writable]` token_owner_account_a -/// 4. `[writable]` token_vault_a -/// 5. `[writable]` token_owner_account_b -/// 6. `[writable]` token_vault_b -/// 7. `[writable]` tick_array0 -/// 8. `[writable]` tick_array1 -/// 9. `[writable]` tick_array2 -/// 10. `[]` oracle -#[derive(Clone, Debug)] -pub struct SwapCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapCpiBuilderInstruction { - __program: program, - token_program: None, - token_authority: None, - whirlpool: None, - token_owner_account_a: None, - token_vault_a: None, - token_owner_account_b: None, - token_vault_b: None, - tick_array0: None, - tick_array1: None, - tick_array2: None, - oracle: None, - amount: None, - other_amount_threshold: None, - sqrt_price_limit: None, - amount_specified_is_input: None, - a_to_b: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_authority( - &mut self, - token_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_authority = Some(token_authority); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array0( - &mut self, - tick_array0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array0 = Some(tick_array0); - self - } - - #[inline(always)] - pub fn tick_array1( - &mut self, - tick_array1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array1 = Some(tick_array1); - self - } - - #[inline(always)] - pub fn tick_array2( - &mut self, - tick_array2: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array2 = Some(tick_array2); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.instruction.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn sqrt_price_limit(&mut self, sqrt_price_limit: u128) -> &mut Self { - self.instruction.sqrt_price_limit = Some(sqrt_price_limit); - self - } - - #[inline(always)] - pub fn amount_specified_is_input(&mut self, amount_specified_is_input: bool) -> &mut Self { - self.instruction.amount_specified_is_input = Some(amount_specified_is_input); - self - } - - #[inline(always)] - pub fn a_to_b(&mut self, a_to_b: bool) -> &mut Self { - self.instruction.a_to_b = Some(a_to_b); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .instruction - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - sqrt_price_limit: self - .instruction - .sqrt_price_limit - .clone() - .expect("sqrt_price_limit is not set"), - amount_specified_is_input: self - .instruction - .amount_specified_is_input - .clone() - .expect("amount_specified_is_input is not set"), - a_to_b: self.instruction.a_to_b.clone().expect("a_to_b is not set"), - }; - let instruction = SwapCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_authority: self - .instruction - .token_authority - .expect("token_authority is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token_owner_account_a: self - .instruction - .token_owner_account_a - .expect("token_owner_account_a is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_owner_account_b: self - .instruction - .token_owner_account_b - .expect("token_owner_account_b is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - tick_array0: self - .instruction - .tick_array0 - .expect("tick_array0 is not set"), - - tick_array1: self - .instruction - .tick_array1 - .expect("tick_array1 is not set"), - - tick_array2: self - .instruction - .tick_array2 - .expect("tick_array2 is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array0: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array1: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array2: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - other_amount_threshold: Option, - sqrt_price_limit: Option, - amount_specified_is_input: Option, - a_to_b: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/swap_v2.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/swap_v2.rs deleted file mode 100644 index 6815eff6..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/swap_v2.rs +++ /dev/null @@ -1,1021 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct SwapV2 { - pub token_program_a: solana_pubkey::Pubkey, - - pub token_program_b: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub token_authority: solana_pubkey::Pubkey, - - pub whirlpool: solana_pubkey::Pubkey, - - pub token_mint_a: solana_pubkey::Pubkey, - - pub token_mint_b: solana_pubkey::Pubkey, - - pub token_owner_account_a: solana_pubkey::Pubkey, - - pub token_vault_a: solana_pubkey::Pubkey, - - pub token_owner_account_b: solana_pubkey::Pubkey, - - pub token_vault_b: solana_pubkey::Pubkey, - - pub tick_array0: solana_pubkey::Pubkey, - - pub tick_array1: solana_pubkey::Pubkey, - - pub tick_array2: solana_pubkey::Pubkey, - - pub oracle: solana_pubkey::Pubkey, -} - -impl SwapV2 { - pub fn instruction(&self, args: SwapV2InstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array2, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.oracle, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapV2InstructionData { - discriminator: [u8; 8], -} - -impl SwapV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [43, 4, 237, 11, 26, 201, 30, 98], - } - } -} - -impl Default for SwapV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapV2InstructionArgs { - pub amount: u64, - pub other_amount_threshold: u64, - pub sqrt_price_limit: u128, - pub amount_specified_is_input: bool, - pub a_to_b: bool, - pub remaining_accounts_info: Option, -} - -/// Instruction builder for `SwapV2`. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program_a -/// 1. `[]` token_program_b -/// 2. `[]` memo_program -/// 3. `[signer]` token_authority -/// 4. `[writable]` whirlpool -/// 5. `[]` token_mint_a -/// 6. `[]` token_mint_b -/// 7. `[writable]` token_owner_account_a -/// 8. `[writable]` token_vault_a -/// 9. `[writable]` token_owner_account_b -/// 10. `[writable]` token_vault_b -/// 11. `[writable]` tick_array0 -/// 12. `[writable]` tick_array1 -/// 13. `[writable]` tick_array2 -/// 14. `[writable]` oracle -#[derive(Clone, Debug, Default)] -pub struct SwapV2Builder { - token_program_a: Option, - token_program_b: Option, - memo_program: Option, - token_authority: Option, - whirlpool: Option, - token_mint_a: Option, - token_mint_b: Option, - token_owner_account_a: Option, - token_vault_a: Option, - token_owner_account_b: Option, - token_vault_b: Option, - tick_array0: Option, - tick_array1: Option, - tick_array2: Option, - oracle: Option, - amount: Option, - other_amount_threshold: Option, - sqrt_price_limit: Option, - amount_specified_is_input: Option, - a_to_b: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl SwapV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn token_program_a(&mut self, token_program_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b(&mut self, token_program_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn token_authority(&mut self, token_authority: solana_pubkey::Pubkey) -> &mut Self { - self.token_authority = Some(token_authority); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_mint_a(&mut self, token_mint_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b(&mut self, token_mint_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array0(&mut self, tick_array0: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array0 = Some(tick_array0); - self - } - - #[inline(always)] - pub fn tick_array1(&mut self, tick_array1: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array1 = Some(tick_array1); - self - } - - #[inline(always)] - pub fn tick_array2(&mut self, tick_array2: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array2 = Some(tick_array2); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: solana_pubkey::Pubkey) -> &mut Self { - self.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn sqrt_price_limit(&mut self, sqrt_price_limit: u128) -> &mut Self { - self.sqrt_price_limit = Some(sqrt_price_limit); - self - } - - #[inline(always)] - pub fn amount_specified_is_input(&mut self, amount_specified_is_input: bool) -> &mut Self { - self.amount_specified_is_input = Some(amount_specified_is_input); - self - } - - #[inline(always)] - pub fn a_to_b(&mut self, a_to_b: bool) -> &mut Self { - self.a_to_b = Some(a_to_b); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapV2 { - token_program_a: self.token_program_a.expect("token_program_a is not set"), - token_program_b: self.token_program_b.expect("token_program_b is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - token_authority: self.token_authority.expect("token_authority is not set"), - whirlpool: self.whirlpool.expect("whirlpool is not set"), - token_mint_a: self.token_mint_a.expect("token_mint_a is not set"), - token_mint_b: self.token_mint_b.expect("token_mint_b is not set"), - token_owner_account_a: self - .token_owner_account_a - .expect("token_owner_account_a is not set"), - token_vault_a: self.token_vault_a.expect("token_vault_a is not set"), - token_owner_account_b: self - .token_owner_account_b - .expect("token_owner_account_b is not set"), - token_vault_b: self.token_vault_b.expect("token_vault_b is not set"), - tick_array0: self.tick_array0.expect("tick_array0 is not set"), - tick_array1: self.tick_array1.expect("tick_array1 is not set"), - tick_array2: self.tick_array2.expect("tick_array2 is not set"), - oracle: self.oracle.expect("oracle is not set"), - }; - let args = SwapV2InstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - sqrt_price_limit: self - .sqrt_price_limit - .clone() - .expect("sqrt_price_limit is not set"), - amount_specified_is_input: self - .amount_specified_is_input - .clone() - .expect("amount_specified_is_input is not set"), - a_to_b: self.a_to_b.clone().expect("a_to_b is not set"), - remaining_accounts_info: self.remaining_accounts_info.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_v2` CPI accounts. -pub struct SwapV2CpiAccounts<'a, 'b> { - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array2: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_v2` CPI instruction. -pub struct SwapV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_b: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array2: &'b solana_account_info::AccountInfo<'a>, - - pub oracle: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapV2InstructionArgs, -} - -impl<'a, 'b> SwapV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapV2CpiAccounts<'a, 'b>, - args: SwapV2InstructionArgs, - ) -> Self { - Self { - __program: program, - token_program_a: accounts.token_program_a, - token_program_b: accounts.token_program_b, - memo_program: accounts.memo_program, - token_authority: accounts.token_authority, - whirlpool: accounts.whirlpool, - token_mint_a: accounts.token_mint_a, - token_mint_b: accounts.token_mint_b, - token_owner_account_a: accounts.token_owner_account_a, - token_vault_a: accounts.token_vault_a, - token_owner_account_b: accounts.token_owner_account_b, - token_vault_b: accounts.token_vault_b, - tick_array0: accounts.tick_array0, - tick_array1: accounts.tick_array1, - tick_array2: accounts.tick_array2, - oracle: accounts.oracle, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array2.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program_a.clone()); - account_infos.push(self.token_program_b.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.token_authority.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.token_mint_a.clone()); - account_infos.push(self.token_mint_b.clone()); - account_infos.push(self.token_owner_account_a.clone()); - account_infos.push(self.token_vault_a.clone()); - account_infos.push(self.token_owner_account_b.clone()); - account_infos.push(self.token_vault_b.clone()); - account_infos.push(self.tick_array0.clone()); - account_infos.push(self.tick_array1.clone()); - account_infos.push(self.tick_array2.clone()); - account_infos.push(self.oracle.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program_a -/// 1. `[]` token_program_b -/// 2. `[]` memo_program -/// 3. `[signer]` token_authority -/// 4. `[writable]` whirlpool -/// 5. `[]` token_mint_a -/// 6. `[]` token_mint_b -/// 7. `[writable]` token_owner_account_a -/// 8. `[writable]` token_vault_a -/// 9. `[writable]` token_owner_account_b -/// 10. `[writable]` token_vault_b -/// 11. `[writable]` tick_array0 -/// 12. `[writable]` tick_array1 -/// 13. `[writable]` tick_array2 -/// 14. `[writable]` oracle -#[derive(Clone, Debug)] -pub struct SwapV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapV2CpiBuilderInstruction { - __program: program, - token_program_a: None, - token_program_b: None, - memo_program: None, - token_authority: None, - whirlpool: None, - token_mint_a: None, - token_mint_b: None, - token_owner_account_a: None, - token_vault_a: None, - token_owner_account_b: None, - token_vault_b: None, - tick_array0: None, - tick_array1: None, - tick_array2: None, - oracle: None, - amount: None, - other_amount_threshold: None, - sqrt_price_limit: None, - amount_specified_is_input: None, - a_to_b: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program_a( - &mut self, - token_program_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_a = Some(token_program_a); - self - } - - #[inline(always)] - pub fn token_program_b( - &mut self, - token_program_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_b = Some(token_program_b); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn token_authority( - &mut self, - token_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_authority = Some(token_authority); - self - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn token_mint_a( - &mut self, - token_mint_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_a = Some(token_mint_a); - self - } - - #[inline(always)] - pub fn token_mint_b( - &mut self, - token_mint_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_b = Some(token_mint_b); - self - } - - #[inline(always)] - pub fn token_owner_account_a( - &mut self, - token_owner_account_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_a = Some(token_owner_account_a); - self - } - - #[inline(always)] - pub fn token_vault_a( - &mut self, - token_vault_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_a = Some(token_vault_a); - self - } - - #[inline(always)] - pub fn token_owner_account_b( - &mut self, - token_owner_account_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_b = Some(token_owner_account_b); - self - } - - #[inline(always)] - pub fn token_vault_b( - &mut self, - token_vault_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_b = Some(token_vault_b); - self - } - - #[inline(always)] - pub fn tick_array0( - &mut self, - tick_array0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array0 = Some(tick_array0); - self - } - - #[inline(always)] - pub fn tick_array1( - &mut self, - tick_array1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array1 = Some(tick_array1); - self - } - - #[inline(always)] - pub fn tick_array2( - &mut self, - tick_array2: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array2 = Some(tick_array2); - self - } - - #[inline(always)] - pub fn oracle(&mut self, oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.oracle = Some(oracle); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.instruction.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn sqrt_price_limit(&mut self, sqrt_price_limit: u128) -> &mut Self { - self.instruction.sqrt_price_limit = Some(sqrt_price_limit); - self - } - - #[inline(always)] - pub fn amount_specified_is_input(&mut self, amount_specified_is_input: bool) -> &mut Self { - self.instruction.amount_specified_is_input = Some(amount_specified_is_input); - self - } - - #[inline(always)] - pub fn a_to_b(&mut self, a_to_b: bool) -> &mut Self { - self.instruction.a_to_b = Some(a_to_b); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapV2InstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .instruction - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - sqrt_price_limit: self - .instruction - .sqrt_price_limit - .clone() - .expect("sqrt_price_limit is not set"), - amount_specified_is_input: self - .instruction - .amount_specified_is_input - .clone() - .expect("amount_specified_is_input is not set"), - a_to_b: self.instruction.a_to_b.clone().expect("a_to_b is not set"), - remaining_accounts_info: self.instruction.remaining_accounts_info.clone(), - }; - let instruction = SwapV2Cpi { - __program: self.instruction.__program, - - token_program_a: self - .instruction - .token_program_a - .expect("token_program_a is not set"), - - token_program_b: self - .instruction - .token_program_b - .expect("token_program_b is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - token_authority: self - .instruction - .token_authority - .expect("token_authority is not set"), - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - token_mint_a: self - .instruction - .token_mint_a - .expect("token_mint_a is not set"), - - token_mint_b: self - .instruction - .token_mint_b - .expect("token_mint_b is not set"), - - token_owner_account_a: self - .instruction - .token_owner_account_a - .expect("token_owner_account_a is not set"), - - token_vault_a: self - .instruction - .token_vault_a - .expect("token_vault_a is not set"), - - token_owner_account_b: self - .instruction - .token_owner_account_b - .expect("token_owner_account_b is not set"), - - token_vault_b: self - .instruction - .token_vault_b - .expect("token_vault_b is not set"), - - tick_array0: self - .instruction - .tick_array0 - .expect("tick_array0 is not set"), - - tick_array1: self - .instruction - .tick_array1 - .expect("tick_array1 is not set"), - - tick_array2: self - .instruction - .tick_array2 - .expect("tick_array2 is not set"), - - oracle: self.instruction.oracle.expect("oracle is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_b: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array0: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array1: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array2: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - other_amount_threshold: Option, - sqrt_price_limit: Option, - amount_specified_is_input: Option, - a_to_b: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/transfer_locked_position.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/transfer_locked_position.rs deleted file mode 100644 index 8ff16f03..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/transfer_locked_position.rs +++ /dev/null @@ -1,576 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct TransferLockedPosition { - pub position_authority: solana_pubkey::Pubkey, - - pub receiver: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub position_mint: solana_pubkey::Pubkey, - - pub position_token_account: solana_pubkey::Pubkey, - - pub destination_token_account: solana_pubkey::Pubkey, - - pub lock_config: solana_pubkey::Pubkey, - - pub token2022_program: solana_pubkey::Pubkey, -} - -impl TransferLockedPosition { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.receiver, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.destination_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lock_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&TransferLockedPositionInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TransferLockedPositionInstructionData { - discriminator: [u8; 8], -} - -impl TransferLockedPositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [179, 121, 229, 46, 67, 138, 194, 138], - } - } -} - -impl Default for TransferLockedPositionInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `TransferLockedPosition`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` position_authority -/// 1. `[writable]` receiver -/// 2. `[]` position -/// 3. `[]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[writable]` destination_token_account -/// 6. `[writable]` lock_config -/// 7. `[]` token2022_program -#[derive(Clone, Debug, Default)] -pub struct TransferLockedPositionBuilder { - position_authority: Option, - receiver: Option, - position: Option, - position_mint: Option, - position_token_account: Option, - destination_token_account: Option, - lock_config: Option, - token2022_program: Option, - __remaining_accounts: Vec, -} - -impl TransferLockedPositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self { - self.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: solana_pubkey::Pubkey) -> &mut Self { - self.receiver = Some(receiver); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint(&mut self, position_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.destination_token_account = Some(destination_token_account); - self - } - - #[inline(always)] - pub fn lock_config(&mut self, lock_config: solana_pubkey::Pubkey) -> &mut Self { - self.lock_config = Some(lock_config); - self - } - - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = TransferLockedPosition { - position_authority: self - .position_authority - .expect("position_authority is not set"), - receiver: self.receiver.expect("receiver is not set"), - position: self.position.expect("position is not set"), - position_mint: self.position_mint.expect("position_mint is not set"), - position_token_account: self - .position_token_account - .expect("position_token_account is not set"), - destination_token_account: self - .destination_token_account - .expect("destination_token_account is not set"), - lock_config: self.lock_config.expect("lock_config is not set"), - token2022_program: self - .token2022_program - .expect("token2022_program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `transfer_locked_position` CPI accounts. -pub struct TransferLockedPositionCpiAccounts<'a, 'b> { - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub lock_config: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `transfer_locked_position` CPI instruction. -pub struct TransferLockedPositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub position_authority: &'b solana_account_info::AccountInfo<'a>, - - pub receiver: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub position_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub lock_config: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> TransferLockedPositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: TransferLockedPositionCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - position_authority: accounts.position_authority, - receiver: accounts.receiver, - position: accounts.position, - position_mint: accounts.position_mint, - position_token_account: accounts.position_token_account, - destination_token_account: accounts.destination_token_account, - lock_config: accounts.lock_config, - token2022_program: accounts.token2022_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.receiver.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.destination_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lock_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&TransferLockedPositionInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.position_authority.clone()); - account_infos.push(self.receiver.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.position_mint.clone()); - account_infos.push(self.position_token_account.clone()); - account_infos.push(self.destination_token_account.clone()); - account_infos.push(self.lock_config.clone()); - account_infos.push(self.token2022_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `TransferLockedPosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` position_authority -/// 1. `[writable]` receiver -/// 2. `[]` position -/// 3. `[]` position_mint -/// 4. `[writable]` position_token_account -/// 5. `[writable]` destination_token_account -/// 6. `[writable]` lock_config -/// 7. `[]` token2022_program -#[derive(Clone, Debug)] -pub struct TransferLockedPositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> TransferLockedPositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(TransferLockedPositionCpiBuilderInstruction { - __program: program, - position_authority: None, - receiver: None, - position: None, - position_mint: None, - position_token_account: None, - destination_token_account: None, - lock_config: None, - token2022_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn position_authority( - &mut self, - position_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_authority = Some(position_authority); - self - } - - #[inline(always)] - pub fn receiver(&mut self, receiver: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.receiver = Some(receiver); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn position_mint( - &mut self, - position_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_mint = Some(position_mint); - self - } - - #[inline(always)] - pub fn position_token_account( - &mut self, - position_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_token_account = Some(position_token_account); - self - } - - #[inline(always)] - pub fn destination_token_account( - &mut self, - destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.destination_token_account = Some(destination_token_account); - self - } - - #[inline(always)] - pub fn lock_config( - &mut self, - lock_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_config = Some(lock_config); - self - } - - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = TransferLockedPositionCpi { - __program: self.instruction.__program, - - position_authority: self - .instruction - .position_authority - .expect("position_authority is not set"), - - receiver: self.instruction.receiver.expect("receiver is not set"), - - position: self.instruction.position.expect("position is not set"), - - position_mint: self - .instruction - .position_mint - .expect("position_mint is not set"), - - position_token_account: self - .instruction - .position_token_account - .expect("position_token_account is not set"), - - destination_token_account: self - .instruction - .destination_token_account - .expect("destination_token_account is not set"), - - lock_config: self - .instruction - .lock_config - .expect("lock_config is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct TransferLockedPositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - position_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - receiver: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - position_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_config: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/two_hop_swap.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/two_hop_swap.rs deleted file mode 100644 index 83b42df2..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/two_hop_swap.rs +++ /dev/null @@ -1,1287 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct TwoHopSwap { - pub token_program: solana_pubkey::Pubkey, - - pub token_authority: solana_pubkey::Pubkey, - - pub whirlpool_one: solana_pubkey::Pubkey, - - pub whirlpool_two: solana_pubkey::Pubkey, - - pub token_owner_account_one_a: solana_pubkey::Pubkey, - - pub token_vault_one_a: solana_pubkey::Pubkey, - - pub token_owner_account_one_b: solana_pubkey::Pubkey, - - pub token_vault_one_b: solana_pubkey::Pubkey, - - pub token_owner_account_two_a: solana_pubkey::Pubkey, - - pub token_vault_two_a: solana_pubkey::Pubkey, - - pub token_owner_account_two_b: solana_pubkey::Pubkey, - - pub token_vault_two_b: solana_pubkey::Pubkey, - - pub tick_array_one0: solana_pubkey::Pubkey, - - pub tick_array_one1: solana_pubkey::Pubkey, - - pub tick_array_one2: solana_pubkey::Pubkey, - - pub tick_array_two0: solana_pubkey::Pubkey, - - pub tick_array_two1: solana_pubkey::Pubkey, - - pub tick_array_two2: solana_pubkey::Pubkey, - - pub oracle_one: solana_pubkey::Pubkey, - - pub oracle_two: solana_pubkey::Pubkey, -} - -impl TwoHopSwap { - pub fn instruction(&self, args: TwoHopSwapInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: TwoHopSwapInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(20 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.whirlpool_one, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.whirlpool_two, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_one_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_one_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_one_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_one_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_two_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_two_a, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_two_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_two_b, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_one0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_one1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_one2, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_two0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_two1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_two2, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.oracle_one, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.oracle_two, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&TwoHopSwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TwoHopSwapInstructionData { - discriminator: [u8; 8], -} - -impl TwoHopSwapInstructionData { - pub fn new() -> Self { - Self { - discriminator: [195, 96, 237, 108, 68, 162, 219, 230], - } - } -} - -impl Default for TwoHopSwapInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TwoHopSwapInstructionArgs { - pub amount: u64, - pub other_amount_threshold: u64, - pub amount_specified_is_input: bool, - pub a_to_b_one: bool, - pub a_to_b_two: bool, - pub sqrt_price_limit_one: u128, - pub sqrt_price_limit_two: u128, -} - -/// Instruction builder for `TwoHopSwap`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[signer]` token_authority -/// 2. `[writable]` whirlpool_one -/// 3. `[writable]` whirlpool_two -/// 4. `[writable]` token_owner_account_one_a -/// 5. `[writable]` token_vault_one_a -/// 6. `[writable]` token_owner_account_one_b -/// 7. `[writable]` token_vault_one_b -/// 8. `[writable]` token_owner_account_two_a -/// 9. `[writable]` token_vault_two_a -/// 10. `[writable]` token_owner_account_two_b -/// 11. `[writable]` token_vault_two_b -/// 12. `[writable]` tick_array_one0 -/// 13. `[writable]` tick_array_one1 -/// 14. `[writable]` tick_array_one2 -/// 15. `[writable]` tick_array_two0 -/// 16. `[writable]` tick_array_two1 -/// 17. `[writable]` tick_array_two2 -/// 18. `[]` oracle_one -/// 19. `[]` oracle_two -#[derive(Clone, Debug, Default)] -pub struct TwoHopSwapBuilder { - token_program: Option, - token_authority: Option, - whirlpool_one: Option, - whirlpool_two: Option, - token_owner_account_one_a: Option, - token_vault_one_a: Option, - token_owner_account_one_b: Option, - token_vault_one_b: Option, - token_owner_account_two_a: Option, - token_vault_two_a: Option, - token_owner_account_two_b: Option, - token_vault_two_b: Option, - tick_array_one0: Option, - tick_array_one1: Option, - tick_array_one2: Option, - tick_array_two0: Option, - tick_array_two1: Option, - tick_array_two2: Option, - oracle_one: Option, - oracle_two: Option, - amount: Option, - other_amount_threshold: Option, - amount_specified_is_input: Option, - a_to_b_one: Option, - a_to_b_two: Option, - sqrt_price_limit_one: Option, - sqrt_price_limit_two: Option, - __remaining_accounts: Vec, -} - -impl TwoHopSwapBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_authority(&mut self, token_authority: solana_pubkey::Pubkey) -> &mut Self { - self.token_authority = Some(token_authority); - self - } - - #[inline(always)] - pub fn whirlpool_one(&mut self, whirlpool_one: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool_one = Some(whirlpool_one); - self - } - - #[inline(always)] - pub fn whirlpool_two(&mut self, whirlpool_two: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool_two = Some(whirlpool_two); - self - } - - #[inline(always)] - pub fn token_owner_account_one_a( - &mut self, - token_owner_account_one_a: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_one_a = Some(token_owner_account_one_a); - self - } - - #[inline(always)] - pub fn token_vault_one_a(&mut self, token_vault_one_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_one_a = Some(token_vault_one_a); - self - } - - #[inline(always)] - pub fn token_owner_account_one_b( - &mut self, - token_owner_account_one_b: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_one_b = Some(token_owner_account_one_b); - self - } - - #[inline(always)] - pub fn token_vault_one_b(&mut self, token_vault_one_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_one_b = Some(token_vault_one_b); - self - } - - #[inline(always)] - pub fn token_owner_account_two_a( - &mut self, - token_owner_account_two_a: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_two_a = Some(token_owner_account_two_a); - self - } - - #[inline(always)] - pub fn token_vault_two_a(&mut self, token_vault_two_a: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_two_a = Some(token_vault_two_a); - self - } - - #[inline(always)] - pub fn token_owner_account_two_b( - &mut self, - token_owner_account_two_b: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_two_b = Some(token_owner_account_two_b); - self - } - - #[inline(always)] - pub fn token_vault_two_b(&mut self, token_vault_two_b: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_two_b = Some(token_vault_two_b); - self - } - - #[inline(always)] - pub fn tick_array_one0(&mut self, tick_array_one0: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_one0 = Some(tick_array_one0); - self - } - - #[inline(always)] - pub fn tick_array_one1(&mut self, tick_array_one1: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_one1 = Some(tick_array_one1); - self - } - - #[inline(always)] - pub fn tick_array_one2(&mut self, tick_array_one2: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_one2 = Some(tick_array_one2); - self - } - - #[inline(always)] - pub fn tick_array_two0(&mut self, tick_array_two0: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_two0 = Some(tick_array_two0); - self - } - - #[inline(always)] - pub fn tick_array_two1(&mut self, tick_array_two1: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_two1 = Some(tick_array_two1); - self - } - - #[inline(always)] - pub fn tick_array_two2(&mut self, tick_array_two2: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_two2 = Some(tick_array_two2); - self - } - - #[inline(always)] - pub fn oracle_one(&mut self, oracle_one: solana_pubkey::Pubkey) -> &mut Self { - self.oracle_one = Some(oracle_one); - self - } - - #[inline(always)] - pub fn oracle_two(&mut self, oracle_two: solana_pubkey::Pubkey) -> &mut Self { - self.oracle_two = Some(oracle_two); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn amount_specified_is_input(&mut self, amount_specified_is_input: bool) -> &mut Self { - self.amount_specified_is_input = Some(amount_specified_is_input); - self - } - - #[inline(always)] - pub fn a_to_b_one(&mut self, a_to_b_one: bool) -> &mut Self { - self.a_to_b_one = Some(a_to_b_one); - self - } - - #[inline(always)] - pub fn a_to_b_two(&mut self, a_to_b_two: bool) -> &mut Self { - self.a_to_b_two = Some(a_to_b_two); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_one(&mut self, sqrt_price_limit_one: u128) -> &mut Self { - self.sqrt_price_limit_one = Some(sqrt_price_limit_one); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_two(&mut self, sqrt_price_limit_two: u128) -> &mut Self { - self.sqrt_price_limit_two = Some(sqrt_price_limit_two); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = TwoHopSwap { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_authority: self.token_authority.expect("token_authority is not set"), - whirlpool_one: self.whirlpool_one.expect("whirlpool_one is not set"), - whirlpool_two: self.whirlpool_two.expect("whirlpool_two is not set"), - token_owner_account_one_a: self - .token_owner_account_one_a - .expect("token_owner_account_one_a is not set"), - token_vault_one_a: self - .token_vault_one_a - .expect("token_vault_one_a is not set"), - token_owner_account_one_b: self - .token_owner_account_one_b - .expect("token_owner_account_one_b is not set"), - token_vault_one_b: self - .token_vault_one_b - .expect("token_vault_one_b is not set"), - token_owner_account_two_a: self - .token_owner_account_two_a - .expect("token_owner_account_two_a is not set"), - token_vault_two_a: self - .token_vault_two_a - .expect("token_vault_two_a is not set"), - token_owner_account_two_b: self - .token_owner_account_two_b - .expect("token_owner_account_two_b is not set"), - token_vault_two_b: self - .token_vault_two_b - .expect("token_vault_two_b is not set"), - tick_array_one0: self.tick_array_one0.expect("tick_array_one0 is not set"), - tick_array_one1: self.tick_array_one1.expect("tick_array_one1 is not set"), - tick_array_one2: self.tick_array_one2.expect("tick_array_one2 is not set"), - tick_array_two0: self.tick_array_two0.expect("tick_array_two0 is not set"), - tick_array_two1: self.tick_array_two1.expect("tick_array_two1 is not set"), - tick_array_two2: self.tick_array_two2.expect("tick_array_two2 is not set"), - oracle_one: self.oracle_one.expect("oracle_one is not set"), - oracle_two: self.oracle_two.expect("oracle_two is not set"), - }; - let args = TwoHopSwapInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - amount_specified_is_input: self - .amount_specified_is_input - .clone() - .expect("amount_specified_is_input is not set"), - a_to_b_one: self.a_to_b_one.clone().expect("a_to_b_one is not set"), - a_to_b_two: self.a_to_b_two.clone().expect("a_to_b_two is not set"), - sqrt_price_limit_one: self - .sqrt_price_limit_one - .clone() - .expect("sqrt_price_limit_one is not set"), - sqrt_price_limit_two: self - .sqrt_price_limit_two - .clone() - .expect("sqrt_price_limit_two is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `two_hop_swap` CPI accounts. -pub struct TwoHopSwapCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool_one: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool_two: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_one_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_one_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_one_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_one_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_two_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_two_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_two_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_two_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one2: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two2: &'b solana_account_info::AccountInfo<'a>, - - pub oracle_one: &'b solana_account_info::AccountInfo<'a>, - - pub oracle_two: &'b solana_account_info::AccountInfo<'a>, -} - -/// `two_hop_swap` CPI instruction. -pub struct TwoHopSwapCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_authority: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool_one: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool_two: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_one_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_one_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_one_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_one_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_two_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_two_a: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_two_b: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_two_b: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one2: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two2: &'b solana_account_info::AccountInfo<'a>, - - pub oracle_one: &'b solana_account_info::AccountInfo<'a>, - - pub oracle_two: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: TwoHopSwapInstructionArgs, -} - -impl<'a, 'b> TwoHopSwapCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: TwoHopSwapCpiAccounts<'a, 'b>, - args: TwoHopSwapInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - token_authority: accounts.token_authority, - whirlpool_one: accounts.whirlpool_one, - whirlpool_two: accounts.whirlpool_two, - token_owner_account_one_a: accounts.token_owner_account_one_a, - token_vault_one_a: accounts.token_vault_one_a, - token_owner_account_one_b: accounts.token_owner_account_one_b, - token_vault_one_b: accounts.token_vault_one_b, - token_owner_account_two_a: accounts.token_owner_account_two_a, - token_vault_two_a: accounts.token_vault_two_a, - token_owner_account_two_b: accounts.token_owner_account_two_b, - token_vault_two_b: accounts.token_vault_two_b, - tick_array_one0: accounts.tick_array_one0, - tick_array_one1: accounts.tick_array_one1, - tick_array_one2: accounts.tick_array_one2, - tick_array_two0: accounts.tick_array_two0, - tick_array_two1: accounts.tick_array_two1, - tick_array_two2: accounts.tick_array_two2, - oracle_one: accounts.oracle_one, - oracle_two: accounts.oracle_two, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(20 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool_one.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool_two.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_one_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_one_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_one_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_one_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_two_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_two_a.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_two_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_two_b.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_one0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_one1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_one2.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_two0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_two1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_two2.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.oracle_one.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.oracle_two.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&TwoHopSwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(21 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_authority.clone()); - account_infos.push(self.whirlpool_one.clone()); - account_infos.push(self.whirlpool_two.clone()); - account_infos.push(self.token_owner_account_one_a.clone()); - account_infos.push(self.token_vault_one_a.clone()); - account_infos.push(self.token_owner_account_one_b.clone()); - account_infos.push(self.token_vault_one_b.clone()); - account_infos.push(self.token_owner_account_two_a.clone()); - account_infos.push(self.token_vault_two_a.clone()); - account_infos.push(self.token_owner_account_two_b.clone()); - account_infos.push(self.token_vault_two_b.clone()); - account_infos.push(self.tick_array_one0.clone()); - account_infos.push(self.tick_array_one1.clone()); - account_infos.push(self.tick_array_one2.clone()); - account_infos.push(self.tick_array_two0.clone()); - account_infos.push(self.tick_array_two1.clone()); - account_infos.push(self.tick_array_two2.clone()); - account_infos.push(self.oracle_one.clone()); - account_infos.push(self.oracle_two.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `TwoHopSwap` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[signer]` token_authority -/// 2. `[writable]` whirlpool_one -/// 3. `[writable]` whirlpool_two -/// 4. `[writable]` token_owner_account_one_a -/// 5. `[writable]` token_vault_one_a -/// 6. `[writable]` token_owner_account_one_b -/// 7. `[writable]` token_vault_one_b -/// 8. `[writable]` token_owner_account_two_a -/// 9. `[writable]` token_vault_two_a -/// 10. `[writable]` token_owner_account_two_b -/// 11. `[writable]` token_vault_two_b -/// 12. `[writable]` tick_array_one0 -/// 13. `[writable]` tick_array_one1 -/// 14. `[writable]` tick_array_one2 -/// 15. `[writable]` tick_array_two0 -/// 16. `[writable]` tick_array_two1 -/// 17. `[writable]` tick_array_two2 -/// 18. `[]` oracle_one -/// 19. `[]` oracle_two -#[derive(Clone, Debug)] -pub struct TwoHopSwapCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> TwoHopSwapCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(TwoHopSwapCpiBuilderInstruction { - __program: program, - token_program: None, - token_authority: None, - whirlpool_one: None, - whirlpool_two: None, - token_owner_account_one_a: None, - token_vault_one_a: None, - token_owner_account_one_b: None, - token_vault_one_b: None, - token_owner_account_two_a: None, - token_vault_two_a: None, - token_owner_account_two_b: None, - token_vault_two_b: None, - tick_array_one0: None, - tick_array_one1: None, - tick_array_one2: None, - tick_array_two0: None, - tick_array_two1: None, - tick_array_two2: None, - oracle_one: None, - oracle_two: None, - amount: None, - other_amount_threshold: None, - amount_specified_is_input: None, - a_to_b_one: None, - a_to_b_two: None, - sqrt_price_limit_one: None, - sqrt_price_limit_two: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_authority( - &mut self, - token_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_authority = Some(token_authority); - self - } - - #[inline(always)] - pub fn whirlpool_one( - &mut self, - whirlpool_one: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpool_one = Some(whirlpool_one); - self - } - - #[inline(always)] - pub fn whirlpool_two( - &mut self, - whirlpool_two: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpool_two = Some(whirlpool_two); - self - } - - #[inline(always)] - pub fn token_owner_account_one_a( - &mut self, - token_owner_account_one_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_one_a = Some(token_owner_account_one_a); - self - } - - #[inline(always)] - pub fn token_vault_one_a( - &mut self, - token_vault_one_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_one_a = Some(token_vault_one_a); - self - } - - #[inline(always)] - pub fn token_owner_account_one_b( - &mut self, - token_owner_account_one_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_one_b = Some(token_owner_account_one_b); - self - } - - #[inline(always)] - pub fn token_vault_one_b( - &mut self, - token_vault_one_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_one_b = Some(token_vault_one_b); - self - } - - #[inline(always)] - pub fn token_owner_account_two_a( - &mut self, - token_owner_account_two_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_two_a = Some(token_owner_account_two_a); - self - } - - #[inline(always)] - pub fn token_vault_two_a( - &mut self, - token_vault_two_a: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_two_a = Some(token_vault_two_a); - self - } - - #[inline(always)] - pub fn token_owner_account_two_b( - &mut self, - token_owner_account_two_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_two_b = Some(token_owner_account_two_b); - self - } - - #[inline(always)] - pub fn token_vault_two_b( - &mut self, - token_vault_two_b: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_two_b = Some(token_vault_two_b); - self - } - - #[inline(always)] - pub fn tick_array_one0( - &mut self, - tick_array_one0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_one0 = Some(tick_array_one0); - self - } - - #[inline(always)] - pub fn tick_array_one1( - &mut self, - tick_array_one1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_one1 = Some(tick_array_one1); - self - } - - #[inline(always)] - pub fn tick_array_one2( - &mut self, - tick_array_one2: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_one2 = Some(tick_array_one2); - self - } - - #[inline(always)] - pub fn tick_array_two0( - &mut self, - tick_array_two0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_two0 = Some(tick_array_two0); - self - } - - #[inline(always)] - pub fn tick_array_two1( - &mut self, - tick_array_two1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_two1 = Some(tick_array_two1); - self - } - - #[inline(always)] - pub fn tick_array_two2( - &mut self, - tick_array_two2: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_two2 = Some(tick_array_two2); - self - } - - #[inline(always)] - pub fn oracle_one( - &mut self, - oracle_one: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.oracle_one = Some(oracle_one); - self - } - - #[inline(always)] - pub fn oracle_two( - &mut self, - oracle_two: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.oracle_two = Some(oracle_two); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.instruction.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn amount_specified_is_input(&mut self, amount_specified_is_input: bool) -> &mut Self { - self.instruction.amount_specified_is_input = Some(amount_specified_is_input); - self - } - - #[inline(always)] - pub fn a_to_b_one(&mut self, a_to_b_one: bool) -> &mut Self { - self.instruction.a_to_b_one = Some(a_to_b_one); - self - } - - #[inline(always)] - pub fn a_to_b_two(&mut self, a_to_b_two: bool) -> &mut Self { - self.instruction.a_to_b_two = Some(a_to_b_two); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_one(&mut self, sqrt_price_limit_one: u128) -> &mut Self { - self.instruction.sqrt_price_limit_one = Some(sqrt_price_limit_one); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_two(&mut self, sqrt_price_limit_two: u128) -> &mut Self { - self.instruction.sqrt_price_limit_two = Some(sqrt_price_limit_two); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = TwoHopSwapInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .instruction - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - amount_specified_is_input: self - .instruction - .amount_specified_is_input - .clone() - .expect("amount_specified_is_input is not set"), - a_to_b_one: self - .instruction - .a_to_b_one - .clone() - .expect("a_to_b_one is not set"), - a_to_b_two: self - .instruction - .a_to_b_two - .clone() - .expect("a_to_b_two is not set"), - sqrt_price_limit_one: self - .instruction - .sqrt_price_limit_one - .clone() - .expect("sqrt_price_limit_one is not set"), - sqrt_price_limit_two: self - .instruction - .sqrt_price_limit_two - .clone() - .expect("sqrt_price_limit_two is not set"), - }; - let instruction = TwoHopSwapCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_authority: self - .instruction - .token_authority - .expect("token_authority is not set"), - - whirlpool_one: self - .instruction - .whirlpool_one - .expect("whirlpool_one is not set"), - - whirlpool_two: self - .instruction - .whirlpool_two - .expect("whirlpool_two is not set"), - - token_owner_account_one_a: self - .instruction - .token_owner_account_one_a - .expect("token_owner_account_one_a is not set"), - - token_vault_one_a: self - .instruction - .token_vault_one_a - .expect("token_vault_one_a is not set"), - - token_owner_account_one_b: self - .instruction - .token_owner_account_one_b - .expect("token_owner_account_one_b is not set"), - - token_vault_one_b: self - .instruction - .token_vault_one_b - .expect("token_vault_one_b is not set"), - - token_owner_account_two_a: self - .instruction - .token_owner_account_two_a - .expect("token_owner_account_two_a is not set"), - - token_vault_two_a: self - .instruction - .token_vault_two_a - .expect("token_vault_two_a is not set"), - - token_owner_account_two_b: self - .instruction - .token_owner_account_two_b - .expect("token_owner_account_two_b is not set"), - - token_vault_two_b: self - .instruction - .token_vault_two_b - .expect("token_vault_two_b is not set"), - - tick_array_one0: self - .instruction - .tick_array_one0 - .expect("tick_array_one0 is not set"), - - tick_array_one1: self - .instruction - .tick_array_one1 - .expect("tick_array_one1 is not set"), - - tick_array_one2: self - .instruction - .tick_array_one2 - .expect("tick_array_one2 is not set"), - - tick_array_two0: self - .instruction - .tick_array_two0 - .expect("tick_array_two0 is not set"), - - tick_array_two1: self - .instruction - .tick_array_two1 - .expect("tick_array_two1 is not set"), - - tick_array_two2: self - .instruction - .tick_array_two2 - .expect("tick_array_two2 is not set"), - - oracle_one: self.instruction.oracle_one.expect("oracle_one is not set"), - - oracle_two: self.instruction.oracle_two.expect("oracle_two is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct TwoHopSwapCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool_one: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool_two: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_one_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_one_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_one_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_one_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_two_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_two_a: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_two_b: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_two_b: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_one0: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_one1: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_one2: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_two0: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_two1: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_two2: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle_one: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle_two: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - other_amount_threshold: Option, - amount_specified_is_input: Option, - a_to_b_one: Option, - a_to_b_two: Option, - sqrt_price_limit_one: Option, - sqrt_price_limit_two: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/two_hop_swap_v2.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/two_hop_swap_v2.rs deleted file mode 100644 index 1d971da2..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/two_hop_swap_v2.rs +++ /dev/null @@ -1,1498 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsInfo; - -/// Accounts. -#[derive(Debug)] -pub struct TwoHopSwapV2 { - pub whirlpool_one: solana_pubkey::Pubkey, - - pub whirlpool_two: solana_pubkey::Pubkey, - - pub token_mint_input: solana_pubkey::Pubkey, - - pub token_mint_intermediate: solana_pubkey::Pubkey, - - pub token_mint_output: solana_pubkey::Pubkey, - - pub token_program_input: solana_pubkey::Pubkey, - - pub token_program_intermediate: solana_pubkey::Pubkey, - - pub token_program_output: solana_pubkey::Pubkey, - - pub token_owner_account_input: solana_pubkey::Pubkey, - - pub token_vault_one_input: solana_pubkey::Pubkey, - - pub token_vault_one_intermediate: solana_pubkey::Pubkey, - - pub token_vault_two_intermediate: solana_pubkey::Pubkey, - - pub token_vault_two_output: solana_pubkey::Pubkey, - - pub token_owner_account_output: solana_pubkey::Pubkey, - - pub token_authority: solana_pubkey::Pubkey, - - pub tick_array_one0: solana_pubkey::Pubkey, - - pub tick_array_one1: solana_pubkey::Pubkey, - - pub tick_array_one2: solana_pubkey::Pubkey, - - pub tick_array_two0: solana_pubkey::Pubkey, - - pub tick_array_two1: solana_pubkey::Pubkey, - - pub tick_array_two2: solana_pubkey::Pubkey, - - pub oracle_one: solana_pubkey::Pubkey, - - pub oracle_two: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, -} - -impl TwoHopSwapV2 { - pub fn instruction( - &self, - args: TwoHopSwapV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: TwoHopSwapV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(24 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.whirlpool_one, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.whirlpool_two, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_input, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_intermediate, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint_output, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_input, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_intermediate, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program_output, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_input, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_one_input, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_one_intermediate, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_two_intermediate, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_two_output, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_owner_account_output, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_one0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_one1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_one2, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_two0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_two1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_two2, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.oracle_one, false)); - accounts.push(solana_instruction::AccountMeta::new(self.oracle_two, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&TwoHopSwapV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TwoHopSwapV2InstructionData { - discriminator: [u8; 8], -} - -impl TwoHopSwapV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [186, 143, 209, 29, 254, 2, 194, 117], - } - } -} - -impl Default for TwoHopSwapV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TwoHopSwapV2InstructionArgs { - pub amount: u64, - pub other_amount_threshold: u64, - pub amount_specified_is_input: bool, - pub a_to_b_one: bool, - pub a_to_b_two: bool, - pub sqrt_price_limit_one: u128, - pub sqrt_price_limit_two: u128, - pub remaining_accounts_info: Option, -} - -/// Instruction builder for `TwoHopSwapV2`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool_one -/// 1. `[writable]` whirlpool_two -/// 2. `[]` token_mint_input -/// 3. `[]` token_mint_intermediate -/// 4. `[]` token_mint_output -/// 5. `[]` token_program_input -/// 6. `[]` token_program_intermediate -/// 7. `[]` token_program_output -/// 8. `[writable]` token_owner_account_input -/// 9. `[writable]` token_vault_one_input -/// 10. `[writable]` token_vault_one_intermediate -/// 11. `[writable]` token_vault_two_intermediate -/// 12. `[writable]` token_vault_two_output -/// 13. `[writable]` token_owner_account_output -/// 14. `[signer]` token_authority -/// 15. `[writable]` tick_array_one0 -/// 16. `[writable]` tick_array_one1 -/// 17. `[writable]` tick_array_one2 -/// 18. `[writable]` tick_array_two0 -/// 19. `[writable]` tick_array_two1 -/// 20. `[writable]` tick_array_two2 -/// 21. `[writable]` oracle_one -/// 22. `[writable]` oracle_two -/// 23. `[]` memo_program -#[derive(Clone, Debug, Default)] -pub struct TwoHopSwapV2Builder { - whirlpool_one: Option, - whirlpool_two: Option, - token_mint_input: Option, - token_mint_intermediate: Option, - token_mint_output: Option, - token_program_input: Option, - token_program_intermediate: Option, - token_program_output: Option, - token_owner_account_input: Option, - token_vault_one_input: Option, - token_vault_one_intermediate: Option, - token_vault_two_intermediate: Option, - token_vault_two_output: Option, - token_owner_account_output: Option, - token_authority: Option, - tick_array_one0: Option, - tick_array_one1: Option, - tick_array_one2: Option, - tick_array_two0: Option, - tick_array_two1: Option, - tick_array_two2: Option, - oracle_one: Option, - oracle_two: Option, - memo_program: Option, - amount: Option, - other_amount_threshold: Option, - amount_specified_is_input: Option, - a_to_b_one: Option, - a_to_b_two: Option, - sqrt_price_limit_one: Option, - sqrt_price_limit_two: Option, - remaining_accounts_info: Option, - __remaining_accounts: Vec, -} - -impl TwoHopSwapV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool_one(&mut self, whirlpool_one: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool_one = Some(whirlpool_one); - self - } - - #[inline(always)] - pub fn whirlpool_two(&mut self, whirlpool_two: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool_two = Some(whirlpool_two); - self - } - - #[inline(always)] - pub fn token_mint_input(&mut self, token_mint_input: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_input = Some(token_mint_input); - self - } - - #[inline(always)] - pub fn token_mint_intermediate( - &mut self, - token_mint_intermediate: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_mint_intermediate = Some(token_mint_intermediate); - self - } - - #[inline(always)] - pub fn token_mint_output(&mut self, token_mint_output: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint_output = Some(token_mint_output); - self - } - - #[inline(always)] - pub fn token_program_input(&mut self, token_program_input: solana_pubkey::Pubkey) -> &mut Self { - self.token_program_input = Some(token_program_input); - self - } - - #[inline(always)] - pub fn token_program_intermediate( - &mut self, - token_program_intermediate: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_program_intermediate = Some(token_program_intermediate); - self - } - - #[inline(always)] - pub fn token_program_output( - &mut self, - token_program_output: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_program_output = Some(token_program_output); - self - } - - #[inline(always)] - pub fn token_owner_account_input( - &mut self, - token_owner_account_input: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_input = Some(token_owner_account_input); - self - } - - #[inline(always)] - pub fn token_vault_one_input( - &mut self, - token_vault_one_input: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_vault_one_input = Some(token_vault_one_input); - self - } - - #[inline(always)] - pub fn token_vault_one_intermediate( - &mut self, - token_vault_one_intermediate: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_vault_one_intermediate = Some(token_vault_one_intermediate); - self - } - - #[inline(always)] - pub fn token_vault_two_intermediate( - &mut self, - token_vault_two_intermediate: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_vault_two_intermediate = Some(token_vault_two_intermediate); - self - } - - #[inline(always)] - pub fn token_vault_two_output( - &mut self, - token_vault_two_output: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_vault_two_output = Some(token_vault_two_output); - self - } - - #[inline(always)] - pub fn token_owner_account_output( - &mut self, - token_owner_account_output: solana_pubkey::Pubkey, - ) -> &mut Self { - self.token_owner_account_output = Some(token_owner_account_output); - self - } - - #[inline(always)] - pub fn token_authority(&mut self, token_authority: solana_pubkey::Pubkey) -> &mut Self { - self.token_authority = Some(token_authority); - self - } - - #[inline(always)] - pub fn tick_array_one0(&mut self, tick_array_one0: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_one0 = Some(tick_array_one0); - self - } - - #[inline(always)] - pub fn tick_array_one1(&mut self, tick_array_one1: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_one1 = Some(tick_array_one1); - self - } - - #[inline(always)] - pub fn tick_array_one2(&mut self, tick_array_one2: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_one2 = Some(tick_array_one2); - self - } - - #[inline(always)] - pub fn tick_array_two0(&mut self, tick_array_two0: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_two0 = Some(tick_array_two0); - self - } - - #[inline(always)] - pub fn tick_array_two1(&mut self, tick_array_two1: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_two1 = Some(tick_array_two1); - self - } - - #[inline(always)] - pub fn tick_array_two2(&mut self, tick_array_two2: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_two2 = Some(tick_array_two2); - self - } - - #[inline(always)] - pub fn oracle_one(&mut self, oracle_one: solana_pubkey::Pubkey) -> &mut Self { - self.oracle_one = Some(oracle_one); - self - } - - #[inline(always)] - pub fn oracle_two(&mut self, oracle_two: solana_pubkey::Pubkey) -> &mut Self { - self.oracle_two = Some(oracle_two); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn amount_specified_is_input(&mut self, amount_specified_is_input: bool) -> &mut Self { - self.amount_specified_is_input = Some(amount_specified_is_input); - self - } - - #[inline(always)] - pub fn a_to_b_one(&mut self, a_to_b_one: bool) -> &mut Self { - self.a_to_b_one = Some(a_to_b_one); - self - } - - #[inline(always)] - pub fn a_to_b_two(&mut self, a_to_b_two: bool) -> &mut Self { - self.a_to_b_two = Some(a_to_b_two); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_one(&mut self, sqrt_price_limit_one: u128) -> &mut Self { - self.sqrt_price_limit_one = Some(sqrt_price_limit_one); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_two(&mut self, sqrt_price_limit_two: u128) -> &mut Self { - self.sqrt_price_limit_two = Some(sqrt_price_limit_two); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = TwoHopSwapV2 { - whirlpool_one: self.whirlpool_one.expect("whirlpool_one is not set"), - whirlpool_two: self.whirlpool_two.expect("whirlpool_two is not set"), - token_mint_input: self.token_mint_input.expect("token_mint_input is not set"), - token_mint_intermediate: self - .token_mint_intermediate - .expect("token_mint_intermediate is not set"), - token_mint_output: self - .token_mint_output - .expect("token_mint_output is not set"), - token_program_input: self - .token_program_input - .expect("token_program_input is not set"), - token_program_intermediate: self - .token_program_intermediate - .expect("token_program_intermediate is not set"), - token_program_output: self - .token_program_output - .expect("token_program_output is not set"), - token_owner_account_input: self - .token_owner_account_input - .expect("token_owner_account_input is not set"), - token_vault_one_input: self - .token_vault_one_input - .expect("token_vault_one_input is not set"), - token_vault_one_intermediate: self - .token_vault_one_intermediate - .expect("token_vault_one_intermediate is not set"), - token_vault_two_intermediate: self - .token_vault_two_intermediate - .expect("token_vault_two_intermediate is not set"), - token_vault_two_output: self - .token_vault_two_output - .expect("token_vault_two_output is not set"), - token_owner_account_output: self - .token_owner_account_output - .expect("token_owner_account_output is not set"), - token_authority: self.token_authority.expect("token_authority is not set"), - tick_array_one0: self.tick_array_one0.expect("tick_array_one0 is not set"), - tick_array_one1: self.tick_array_one1.expect("tick_array_one1 is not set"), - tick_array_one2: self.tick_array_one2.expect("tick_array_one2 is not set"), - tick_array_two0: self.tick_array_two0.expect("tick_array_two0 is not set"), - tick_array_two1: self.tick_array_two1.expect("tick_array_two1 is not set"), - tick_array_two2: self.tick_array_two2.expect("tick_array_two2 is not set"), - oracle_one: self.oracle_one.expect("oracle_one is not set"), - oracle_two: self.oracle_two.expect("oracle_two is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - }; - let args = TwoHopSwapV2InstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - amount_specified_is_input: self - .amount_specified_is_input - .clone() - .expect("amount_specified_is_input is not set"), - a_to_b_one: self.a_to_b_one.clone().expect("a_to_b_one is not set"), - a_to_b_two: self.a_to_b_two.clone().expect("a_to_b_two is not set"), - sqrt_price_limit_one: self - .sqrt_price_limit_one - .clone() - .expect("sqrt_price_limit_one is not set"), - sqrt_price_limit_two: self - .sqrt_price_limit_two - .clone() - .expect("sqrt_price_limit_two is not set"), - remaining_accounts_info: self.remaining_accounts_info.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `two_hop_swap_v2` CPI accounts. -pub struct TwoHopSwapV2CpiAccounts<'a, 'b> { - pub whirlpool_one: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool_two: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_input: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_intermediate: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_output: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_input: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_intermediate: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_output: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_input: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_one_input: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_one_intermediate: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_two_intermediate: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_two_output: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_output: &'b solana_account_info::AccountInfo<'a>, - - pub token_authority: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one2: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two2: &'b solana_account_info::AccountInfo<'a>, - - pub oracle_one: &'b solana_account_info::AccountInfo<'a>, - - pub oracle_two: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `two_hop_swap_v2` CPI instruction. -pub struct TwoHopSwapV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool_one: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool_two: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_input: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_intermediate: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint_output: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_input: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_intermediate: &'b solana_account_info::AccountInfo<'a>, - - pub token_program_output: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_input: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_one_input: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_one_intermediate: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_two_intermediate: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_two_output: &'b solana_account_info::AccountInfo<'a>, - - pub token_owner_account_output: &'b solana_account_info::AccountInfo<'a>, - - pub token_authority: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_one2: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two0: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_two2: &'b solana_account_info::AccountInfo<'a>, - - pub oracle_one: &'b solana_account_info::AccountInfo<'a>, - - pub oracle_two: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: TwoHopSwapV2InstructionArgs, -} - -impl<'a, 'b> TwoHopSwapV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: TwoHopSwapV2CpiAccounts<'a, 'b>, - args: TwoHopSwapV2InstructionArgs, - ) -> Self { - Self { - __program: program, - whirlpool_one: accounts.whirlpool_one, - whirlpool_two: accounts.whirlpool_two, - token_mint_input: accounts.token_mint_input, - token_mint_intermediate: accounts.token_mint_intermediate, - token_mint_output: accounts.token_mint_output, - token_program_input: accounts.token_program_input, - token_program_intermediate: accounts.token_program_intermediate, - token_program_output: accounts.token_program_output, - token_owner_account_input: accounts.token_owner_account_input, - token_vault_one_input: accounts.token_vault_one_input, - token_vault_one_intermediate: accounts.token_vault_one_intermediate, - token_vault_two_intermediate: accounts.token_vault_two_intermediate, - token_vault_two_output: accounts.token_vault_two_output, - token_owner_account_output: accounts.token_owner_account_output, - token_authority: accounts.token_authority, - tick_array_one0: accounts.tick_array_one0, - tick_array_one1: accounts.tick_array_one1, - tick_array_one2: accounts.tick_array_one2, - tick_array_two0: accounts.tick_array_two0, - tick_array_two1: accounts.tick_array_two1, - tick_array_two2: accounts.tick_array_two2, - oracle_one: accounts.oracle_one, - oracle_two: accounts.oracle_two, - memo_program: accounts.memo_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(24 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool_one.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool_two.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_input.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_intermediate.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint_output.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_input.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_intermediate.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program_output.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_input.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_one_input.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_one_intermediate.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_two_intermediate.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_two_output.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_owner_account_output.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_one0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_one1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_one2.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_two0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_two1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_two2.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle_one.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.oracle_two.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&TwoHopSwapV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(25 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool_one.clone()); - account_infos.push(self.whirlpool_two.clone()); - account_infos.push(self.token_mint_input.clone()); - account_infos.push(self.token_mint_intermediate.clone()); - account_infos.push(self.token_mint_output.clone()); - account_infos.push(self.token_program_input.clone()); - account_infos.push(self.token_program_intermediate.clone()); - account_infos.push(self.token_program_output.clone()); - account_infos.push(self.token_owner_account_input.clone()); - account_infos.push(self.token_vault_one_input.clone()); - account_infos.push(self.token_vault_one_intermediate.clone()); - account_infos.push(self.token_vault_two_intermediate.clone()); - account_infos.push(self.token_vault_two_output.clone()); - account_infos.push(self.token_owner_account_output.clone()); - account_infos.push(self.token_authority.clone()); - account_infos.push(self.tick_array_one0.clone()); - account_infos.push(self.tick_array_one1.clone()); - account_infos.push(self.tick_array_one2.clone()); - account_infos.push(self.tick_array_two0.clone()); - account_infos.push(self.tick_array_two1.clone()); - account_infos.push(self.tick_array_two2.clone()); - account_infos.push(self.oracle_one.clone()); - account_infos.push(self.oracle_two.clone()); - account_infos.push(self.memo_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `TwoHopSwapV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool_one -/// 1. `[writable]` whirlpool_two -/// 2. `[]` token_mint_input -/// 3. `[]` token_mint_intermediate -/// 4. `[]` token_mint_output -/// 5. `[]` token_program_input -/// 6. `[]` token_program_intermediate -/// 7. `[]` token_program_output -/// 8. `[writable]` token_owner_account_input -/// 9. `[writable]` token_vault_one_input -/// 10. `[writable]` token_vault_one_intermediate -/// 11. `[writable]` token_vault_two_intermediate -/// 12. `[writable]` token_vault_two_output -/// 13. `[writable]` token_owner_account_output -/// 14. `[signer]` token_authority -/// 15. `[writable]` tick_array_one0 -/// 16. `[writable]` tick_array_one1 -/// 17. `[writable]` tick_array_one2 -/// 18. `[writable]` tick_array_two0 -/// 19. `[writable]` tick_array_two1 -/// 20. `[writable]` tick_array_two2 -/// 21. `[writable]` oracle_one -/// 22. `[writable]` oracle_two -/// 23. `[]` memo_program -#[derive(Clone, Debug)] -pub struct TwoHopSwapV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> TwoHopSwapV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(TwoHopSwapV2CpiBuilderInstruction { - __program: program, - whirlpool_one: None, - whirlpool_two: None, - token_mint_input: None, - token_mint_intermediate: None, - token_mint_output: None, - token_program_input: None, - token_program_intermediate: None, - token_program_output: None, - token_owner_account_input: None, - token_vault_one_input: None, - token_vault_one_intermediate: None, - token_vault_two_intermediate: None, - token_vault_two_output: None, - token_owner_account_output: None, - token_authority: None, - tick_array_one0: None, - tick_array_one1: None, - tick_array_one2: None, - tick_array_two0: None, - tick_array_two1: None, - tick_array_two2: None, - oracle_one: None, - oracle_two: None, - memo_program: None, - amount: None, - other_amount_threshold: None, - amount_specified_is_input: None, - a_to_b_one: None, - a_to_b_two: None, - sqrt_price_limit_one: None, - sqrt_price_limit_two: None, - remaining_accounts_info: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool_one( - &mut self, - whirlpool_one: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpool_one = Some(whirlpool_one); - self - } - - #[inline(always)] - pub fn whirlpool_two( - &mut self, - whirlpool_two: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.whirlpool_two = Some(whirlpool_two); - self - } - - #[inline(always)] - pub fn token_mint_input( - &mut self, - token_mint_input: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_input = Some(token_mint_input); - self - } - - #[inline(always)] - pub fn token_mint_intermediate( - &mut self, - token_mint_intermediate: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_intermediate = Some(token_mint_intermediate); - self - } - - #[inline(always)] - pub fn token_mint_output( - &mut self, - token_mint_output: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint_output = Some(token_mint_output); - self - } - - #[inline(always)] - pub fn token_program_input( - &mut self, - token_program_input: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_input = Some(token_program_input); - self - } - - #[inline(always)] - pub fn token_program_intermediate( - &mut self, - token_program_intermediate: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_intermediate = Some(token_program_intermediate); - self - } - - #[inline(always)] - pub fn token_program_output( - &mut self, - token_program_output: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program_output = Some(token_program_output); - self - } - - #[inline(always)] - pub fn token_owner_account_input( - &mut self, - token_owner_account_input: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_input = Some(token_owner_account_input); - self - } - - #[inline(always)] - pub fn token_vault_one_input( - &mut self, - token_vault_one_input: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_one_input = Some(token_vault_one_input); - self - } - - #[inline(always)] - pub fn token_vault_one_intermediate( - &mut self, - token_vault_one_intermediate: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_one_intermediate = Some(token_vault_one_intermediate); - self - } - - #[inline(always)] - pub fn token_vault_two_intermediate( - &mut self, - token_vault_two_intermediate: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_two_intermediate = Some(token_vault_two_intermediate); - self - } - - #[inline(always)] - pub fn token_vault_two_output( - &mut self, - token_vault_two_output: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_two_output = Some(token_vault_two_output); - self - } - - #[inline(always)] - pub fn token_owner_account_output( - &mut self, - token_owner_account_output: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_owner_account_output = Some(token_owner_account_output); - self - } - - #[inline(always)] - pub fn token_authority( - &mut self, - token_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_authority = Some(token_authority); - self - } - - #[inline(always)] - pub fn tick_array_one0( - &mut self, - tick_array_one0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_one0 = Some(tick_array_one0); - self - } - - #[inline(always)] - pub fn tick_array_one1( - &mut self, - tick_array_one1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_one1 = Some(tick_array_one1); - self - } - - #[inline(always)] - pub fn tick_array_one2( - &mut self, - tick_array_one2: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_one2 = Some(tick_array_one2); - self - } - - #[inline(always)] - pub fn tick_array_two0( - &mut self, - tick_array_two0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_two0 = Some(tick_array_two0); - self - } - - #[inline(always)] - pub fn tick_array_two1( - &mut self, - tick_array_two1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_two1 = Some(tick_array_two1); - self - } - - #[inline(always)] - pub fn tick_array_two2( - &mut self, - tick_array_two2: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_two2 = Some(tick_array_two2); - self - } - - #[inline(always)] - pub fn oracle_one( - &mut self, - oracle_one: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.oracle_one = Some(oracle_one); - self - } - - #[inline(always)] - pub fn oracle_two( - &mut self, - oracle_two: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.oracle_two = Some(oracle_two); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.instruction.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn amount_specified_is_input(&mut self, amount_specified_is_input: bool) -> &mut Self { - self.instruction.amount_specified_is_input = Some(amount_specified_is_input); - self - } - - #[inline(always)] - pub fn a_to_b_one(&mut self, a_to_b_one: bool) -> &mut Self { - self.instruction.a_to_b_one = Some(a_to_b_one); - self - } - - #[inline(always)] - pub fn a_to_b_two(&mut self, a_to_b_two: bool) -> &mut Self { - self.instruction.a_to_b_two = Some(a_to_b_two); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_one(&mut self, sqrt_price_limit_one: u128) -> &mut Self { - self.instruction.sqrt_price_limit_one = Some(sqrt_price_limit_one); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_two(&mut self, sqrt_price_limit_two: u128) -> &mut Self { - self.instruction.sqrt_price_limit_two = Some(sqrt_price_limit_two); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn remaining_accounts_info( - &mut self, - remaining_accounts_info: RemainingAccountsInfo, - ) -> &mut Self { - self.instruction.remaining_accounts_info = Some(remaining_accounts_info); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = TwoHopSwapV2InstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .instruction - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - amount_specified_is_input: self - .instruction - .amount_specified_is_input - .clone() - .expect("amount_specified_is_input is not set"), - a_to_b_one: self - .instruction - .a_to_b_one - .clone() - .expect("a_to_b_one is not set"), - a_to_b_two: self - .instruction - .a_to_b_two - .clone() - .expect("a_to_b_two is not set"), - sqrt_price_limit_one: self - .instruction - .sqrt_price_limit_one - .clone() - .expect("sqrt_price_limit_one is not set"), - sqrt_price_limit_two: self - .instruction - .sqrt_price_limit_two - .clone() - .expect("sqrt_price_limit_two is not set"), - remaining_accounts_info: self.instruction.remaining_accounts_info.clone(), - }; - let instruction = TwoHopSwapV2Cpi { - __program: self.instruction.__program, - - whirlpool_one: self - .instruction - .whirlpool_one - .expect("whirlpool_one is not set"), - - whirlpool_two: self - .instruction - .whirlpool_two - .expect("whirlpool_two is not set"), - - token_mint_input: self - .instruction - .token_mint_input - .expect("token_mint_input is not set"), - - token_mint_intermediate: self - .instruction - .token_mint_intermediate - .expect("token_mint_intermediate is not set"), - - token_mint_output: self - .instruction - .token_mint_output - .expect("token_mint_output is not set"), - - token_program_input: self - .instruction - .token_program_input - .expect("token_program_input is not set"), - - token_program_intermediate: self - .instruction - .token_program_intermediate - .expect("token_program_intermediate is not set"), - - token_program_output: self - .instruction - .token_program_output - .expect("token_program_output is not set"), - - token_owner_account_input: self - .instruction - .token_owner_account_input - .expect("token_owner_account_input is not set"), - - token_vault_one_input: self - .instruction - .token_vault_one_input - .expect("token_vault_one_input is not set"), - - token_vault_one_intermediate: self - .instruction - .token_vault_one_intermediate - .expect("token_vault_one_intermediate is not set"), - - token_vault_two_intermediate: self - .instruction - .token_vault_two_intermediate - .expect("token_vault_two_intermediate is not set"), - - token_vault_two_output: self - .instruction - .token_vault_two_output - .expect("token_vault_two_output is not set"), - - token_owner_account_output: self - .instruction - .token_owner_account_output - .expect("token_owner_account_output is not set"), - - token_authority: self - .instruction - .token_authority - .expect("token_authority is not set"), - - tick_array_one0: self - .instruction - .tick_array_one0 - .expect("tick_array_one0 is not set"), - - tick_array_one1: self - .instruction - .tick_array_one1 - .expect("tick_array_one1 is not set"), - - tick_array_one2: self - .instruction - .tick_array_one2 - .expect("tick_array_one2 is not set"), - - tick_array_two0: self - .instruction - .tick_array_two0 - .expect("tick_array_two0 is not set"), - - tick_array_two1: self - .instruction - .tick_array_two1 - .expect("tick_array_two1 is not set"), - - tick_array_two2: self - .instruction - .tick_array_two2 - .expect("tick_array_two2 is not set"), - - oracle_one: self.instruction.oracle_one.expect("oracle_one is not set"), - - oracle_two: self.instruction.oracle_two.expect("oracle_two is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct TwoHopSwapV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool_one: Option<&'b solana_account_info::AccountInfo<'a>>, - whirlpool_two: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_input: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_intermediate: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint_output: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_input: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_intermediate: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program_output: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_input: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_one_input: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_one_intermediate: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_two_intermediate: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_two_output: Option<&'b solana_account_info::AccountInfo<'a>>, - token_owner_account_output: Option<&'b solana_account_info::AccountInfo<'a>>, - token_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_one0: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_one1: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_one2: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_two0: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_two1: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_two2: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle_one: Option<&'b solana_account_info::AccountInfo<'a>>, - oracle_two: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - other_amount_threshold: Option, - amount_specified_is_input: Option, - a_to_b_one: Option, - a_to_b_two: Option, - sqrt_price_limit_one: Option, - sqrt_price_limit_two: Option, - remaining_accounts_info: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/update_fees_and_rewards.rs b/crates/orca-whirlpool-parser/src/generated_sdk/instructions/update_fees_and_rewards.rs deleted file mode 100644 index 18d0e8a8..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/instructions/update_fees_and_rewards.rs +++ /dev/null @@ -1,391 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateFeesAndRewards { - pub whirlpool: solana_pubkey::Pubkey, - - pub position: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, -} - -impl UpdateFeesAndRewards { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.position, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.tick_array_upper, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&UpdateFeesAndRewardsInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateFeesAndRewardsInstructionData { - discriminator: [u8; 8], -} - -impl UpdateFeesAndRewardsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [154, 230, 250, 13, 236, 209, 75, 223], - } - } -} - -impl Default for UpdateFeesAndRewardsInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `UpdateFeesAndRewards`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[writable]` position -/// 2. `[]` tick_array_lower -/// 3. `[]` tick_array_upper -#[derive(Clone, Debug, Default)] -pub struct UpdateFeesAndRewardsBuilder { - whirlpool: Option, - position: Option, - tick_array_lower: Option, - tick_array_upper: Option, - __remaining_accounts: Vec, -} - -impl UpdateFeesAndRewardsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self { - self.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self { - self.position = Some(position); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateFeesAndRewards { - whirlpool: self.whirlpool.expect("whirlpool is not set"), - position: self.position.expect("position is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `update_fees_and_rewards` CPI accounts. -pub struct UpdateFeesAndRewardsCpiAccounts<'a, 'b> { - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_fees_and_rewards` CPI instruction. -pub struct UpdateFeesAndRewardsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub whirlpool: &'b solana_account_info::AccountInfo<'a>, - - pub position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> UpdateFeesAndRewardsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateFeesAndRewardsCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - whirlpool: accounts.whirlpool, - position: accounts.position, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.whirlpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.tick_array_upper.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&UpdateFeesAndRewardsInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::WHIRLPOOL_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.whirlpool.clone()); - account_infos.push(self.position.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateFeesAndRewards` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` whirlpool -/// 1. `[writable]` position -/// 2. `[]` tick_array_lower -/// 3. `[]` tick_array_upper -#[derive(Clone, Debug)] -pub struct UpdateFeesAndRewardsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateFeesAndRewardsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateFeesAndRewardsCpiBuilderInstruction { - __program: program, - whirlpool: None, - position: None, - tick_array_lower: None, - tick_array_upper: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.whirlpool = Some(whirlpool); - self - } - - #[inline(always)] - pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.position = Some(position); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = UpdateFeesAndRewardsCpi { - __program: self.instruction.__program, - - whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"), - - position: self.instruction.position.expect("position is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateFeesAndRewardsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>, - position: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/mod.rs b/crates/orca-whirlpool-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/programs.rs b/crates/orca-whirlpool-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 3a938815..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `whirlpool` program ID. -pub const WHIRLPOOL_ID: Pubkey = pubkey!("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"); diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/shared.rs b/crates/orca-whirlpool-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/accounts_type.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/accounts_type.rs deleted file mode 100644 index 7e59bef9..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/accounts_type.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum AccountsType { - TransferHookA, - TransferHookB, - TransferHookReward, - TransferHookInput, - TransferHookIntermediate, - TransferHookOutput, - SupplementalTickArrays, - SupplementalTickArraysOne, - SupplementalTickArraysTwo, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/adaptive_fee_constants.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/adaptive_fee_constants.rs deleted file mode 100644 index dbd6074f..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/adaptive_fee_constants.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AdaptiveFeeConstants { - pub filter_period: u16, - pub decay_period: u16, - pub reduction_factor: u16, - pub adaptive_fee_control_factor: u32, - pub max_volatility_accumulator: u32, - pub tick_group_size: u16, - pub major_swap_threshold_ticks: u16, - pub reserved: [u8; 16], -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/adaptive_fee_variables.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/adaptive_fee_variables.rs deleted file mode 100644 index 17aca49a..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/adaptive_fee_variables.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AdaptiveFeeVariables { - pub last_reference_update_timestamp: u64, - pub last_major_swap_timestamp: u64, - pub volatility_reference: u32, - pub tick_group_index_reference: i32, - pub volatility_accumulator: u32, - pub reserved: [u8; 16], -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/dynamic_tick.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/dynamic_tick.rs deleted file mode 100644 index 55aa77e0..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/dynamic_tick.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::DynamicTickData; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum DynamicTick { - Uninitialized, - Initialized(DynamicTickData), -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/dynamic_tick_data.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/dynamic_tick_data.rs deleted file mode 100644 index 56b89405..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/dynamic_tick_data.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DynamicTickData { - pub liquidity_net: i128, - pub liquidity_gross: u128, - pub fee_growth_outside_a: u128, - pub fee_growth_outside_b: u128, - pub reward_growths_outside: [u128; 3], -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/lock_type.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/lock_type.rs deleted file mode 100644 index 550acccd..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/lock_type.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum LockType { - Permanent, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/lock_type_label.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/lock_type_label.rs deleted file mode 100644 index ea617369..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/lock_type_label.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum LockTypeLabel { - Permanent, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/mod.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index e6b50365..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#accounts_type; -pub(crate) mod r#adaptive_fee_constants; -pub(crate) mod r#adaptive_fee_variables; -pub(crate) mod r#dynamic_tick; -pub(crate) mod r#dynamic_tick_data; -pub(crate) mod r#lock_type; -pub(crate) mod r#lock_type_label; -pub(crate) mod r#position_reward_info; -pub(crate) mod r#remaining_accounts_info; -pub(crate) mod r#remaining_accounts_slice; -pub(crate) mod r#tick; -pub(crate) mod r#whirlpool_reward_info; - -pub use self::{ - r#accounts_type::*, r#adaptive_fee_constants::*, r#adaptive_fee_variables::*, - r#dynamic_tick::*, r#dynamic_tick_data::*, r#lock_type::*, r#lock_type_label::*, - r#position_reward_info::*, r#remaining_accounts_info::*, r#remaining_accounts_slice::*, - r#tick::*, r#whirlpool_reward_info::*, -}; diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/position_reward_info.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/position_reward_info.rs deleted file mode 100644 index 431cc87b..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/position_reward_info.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PositionRewardInfo { - pub growth_inside_checkpoint: u128, - pub amount_owed: u64, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/remaining_accounts_info.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/remaining_accounts_info.rs deleted file mode 100644 index d8a464a1..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/remaining_accounts_info.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::RemainingAccountsSlice; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemainingAccountsInfo { - pub slices: Vec, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/remaining_accounts_slice.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/remaining_accounts_slice.rs deleted file mode 100644 index b96d81aa..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/remaining_accounts_slice.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::AccountsType; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemainingAccountsSlice { - pub accounts_type: AccountsType, - pub length: u8, -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/tick.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/tick.rs deleted file mode 100644 index 4a657936..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/tick.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Tick { - pub initialized: bool, - pub liquidity_net: i128, - pub liquidity_gross: u128, - pub fee_growth_outside_a: u128, - pub fee_growth_outside_b: u128, - pub reward_growths_outside: [u128; 3], -} diff --git a/crates/orca-whirlpool-parser/src/generated_sdk/types/whirlpool_reward_info.rs b/crates/orca-whirlpool-parser/src/generated_sdk/types/whirlpool_reward_info.rs deleted file mode 100644 index 485dd761..00000000 --- a/crates/orca-whirlpool-parser/src/generated_sdk/types/whirlpool_reward_info.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Stores the state relevant for tracking liquidity mining rewards at the `Whirlpool` level. -/// These values are used in conjunction with `PositionRewardInfo`, `Tick.reward_growths_outside`, -/// and `Whirlpool.reward_last_updated_timestamp` to determine how many rewards are earned by open -/// positions. -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WhirlpoolRewardInfo { - /// Reward token mint. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - /// Reward vault token account. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vault: Pubkey, - /// Authority account that has permission to initialize the reward and set emissions. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub authority: Pubkey, - /// Q64.64 number that indicates how many tokens per second are earned per unit of liquidity. - pub emissions_per_second_x64: u128, - /// Q64.64 number that tracks the total tokens earned per unit of liquidity since the reward - /// emissions were turned on. - pub growth_global_x64: u128, -} diff --git a/crates/orca-whirlpool-parser/src/lib.rs b/crates/orca-whirlpool-parser/src/lib.rs deleted file mode 100644 index 88f42bd5..00000000 --- a/crates/orca-whirlpool-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = WHIRLPOOL_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.orca_whirlpool"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml index aeed705b..fe0258f1 100644 --- a/crates/parser/Cargo.toml +++ b/crates/parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yellowstone-vixen-parser" -description = "Vixen program parsers for the solana program library." +description = "Vixen program parser utilties." version.workspace = true edition.workspace = true license.workspace = true @@ -10,25 +10,14 @@ authors.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -spl-pod = { workspace = true } -spl-token = { workspace = true, optional = true } -spl-token-2022 = { workspace = true, optional = true } -spl-type-length-value = { workspace = true, optional = true } -spl-token-group-interface = { workspace = true, optional = true } -spl-token-metadata-interface = { workspace = true, optional = true } -solana-program-error = { workspace = true } -yellowstone-grpc-proto = { workspace = true } yellowstone-vixen-core = { workspace = true } +solana-program-option = { workspace = true, optional = true } +solana-pubkey = { workspace = true } yellowstone-vixen-proto = { workspace = true, features = [ "parser", ], optional = true } thiserror.workspace = true bs58.workspace = true -tracing = { workspace = true, optional = true } -solana-pubkey = { workspace = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } -bytemuck = { workspace = true, optional = true } [dev-dependencies] yellowstone-vixen-mock = { workspace = true } @@ -36,20 +25,9 @@ tokio.workspace = true [features] default = [] -block-meta = [] -slot = [] proto = [ "dep:yellowstone-vixen-proto", "yellowstone-vixen-core/proto", "yellowstone-vixen-proto/parser", + "solana-program-option", ] -token-extensions = [ - "dep:spl-token-2022", - "dep:spl-type-length-value", - "dep:spl-token-group-interface", - "dep:spl-token-metadata-interface", - "dep:bytemuck", - "token-program", -] -token-program = ["dep:spl-token"] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] diff --git a/crates/parser/src/error.rs b/crates/parser/src/error.rs new file mode 100644 index 00000000..8d853f3e --- /dev/null +++ b/crates/parser/src/error.rs @@ -0,0 +1,43 @@ +use std::{borrow::Cow, error::Error as StdError}; + +pub type Result = std::result::Result; + +#[derive(Debug, thiserror::Error)] +#[error("{message}")] +pub struct Error { + message: Cow<'static, str>, + #[source] + inner: Option>, +} + +impl Error { + pub fn new>>(message: M) -> Self { + Self { + message: message.into(), + inner: None, + } + } + + pub fn from_inner< + M: Into>, + T: Into>, + >( + message: M, + inner: T, + ) -> Self { + Self { + message: message.into(), + inner: Some(inner.into()), + } + } +} + +pub trait ResultExt: Sized { + fn parse_err(self, message: &'static str) -> Result; +} + +impl ResultExt for Result { + fn parse_err(self, message: &'static str) -> Result { + self.map_err(|e| Error::from_inner(message, e)) + } +} diff --git a/crates/parser/src/helpers.rs b/crates/parser/src/helpers.rs deleted file mode 100644 index 17ea42eb..00000000 --- a/crates/parser/src/helpers.rs +++ /dev/null @@ -1,62 +0,0 @@ -use crate::{Error, Result}; - -pub fn check_min_accounts_req(actual: usize, expected: usize) -> Result<()> { - if actual < expected { - Err(Error::new(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -yellowstone_vixen_core::pubkey_convert_helpers!(spl_pod::solana_program::pubkey::Pubkey); -#[cfg(feature = "proto")] -yellowstone_vixen_core::proto_helper_traits!(); - -#[cfg(feature = "proto")] -pub mod proto { - pub const MAX_SIGNERS: usize = 11; - - use spl_pod::solana_program::{program_option::COption, pubkey::Pubkey}; - use yellowstone_vixen_core::KeyBytes; - - pub trait FromCOptionPubkeyToOptString { - fn to_opt_string(self) -> Option; - } - - pub trait FromVecPubkeyToVecString { - fn to_string_vec(self) -> Vec; - } - - pub trait FromOptPubkeyToOptString { - fn to_opt_string(self) -> Option; - } - - impl FromOptPubkeyToOptString for KeyBytes<32> { - fn to_opt_string(self) -> Option { Some(self.to_string()) } - } - - impl FromVecPubkeyToVecString for Vec { - fn to_string_vec(self) -> Vec { self.into_iter().map(|p| p.to_string()).collect() } - } - - impl FromVecPubkeyToVecString for [Pubkey; MAX_SIGNERS] { - fn to_string_vec(self) -> Vec { - self.iter().map(std::string::ToString::to_string).collect() - } - } - - impl FromOptPubkeyToOptString for Option { - fn to_opt_string(self) -> Option { self.map(|p| p.to_string()) } - } - - impl FromCOptionPubkeyToOptString for COption { - fn to_opt_string(self) -> Option { - match self { - COption::Some(val) => Some(val.to_string()), - COption::None => None, - } - } - } -} diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index 0fa23e40..0bc57da5 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -8,70 +8,23 @@ )] #![warn(clippy::pedantic, missing_docs)] #![allow(clippy::module_name_repetitions)] -// TODO: document everything #![allow(missing_docs, clippy::missing_errors_doc, clippy::missing_panics_doc)] -pub use error::*; +mod error; -mod helpers; +pub use error::*; pub mod prelude; -#[cfg(feature = "block-meta")] -pub mod block_meta; - -#[cfg(feature = "slot")] -pub mod slot; - -#[cfg(feature = "token-extensions")] -pub mod token_extension_program; -#[cfg(feature = "token-program")] -pub mod token_program; - -mod error { - use std::{borrow::Cow, error::Error as StdError}; - - pub type Result = std::result::Result; - - #[derive(Debug, thiserror::Error)] - #[error("{message}")] - pub struct Error { - message: Cow<'static, str>, - #[source] - inner: Option>, - } - - impl Error { - pub(crate) fn new>>(message: M) -> Self { - Self { - message: message.into(), - inner: None, - } - } - - pub(crate) fn from_inner< - M: Into>, - T: Into>, - >( - message: M, - inner: T, - ) -> Self { - Self { - message: message.into(), - inner: Some(inner.into()), - } - } - } - - pub(crate) trait ResultExt: - Sized - { - fn parse_err(self, message: &'static str) -> Result; - } +pub use yellowstone_vixen_core::Pubkey; +yellowstone_vixen_core::pubkey_convert_helpers!(solana_pubkey::Pubkey); - impl ResultExt for Result { - fn parse_err(self, message: &'static str) -> Result { - self.map_err(|e| Error::from_inner(message, e)) - } +pub fn check_min_accounts_req(actual: usize, expected: usize) -> Result<()> { + if actual < expected { + Err(Error::new(format!( + "Too few accounts provided: expected {expected}, got {actual}" + ))) + } else { + Ok(()) } } diff --git a/crates/parser/src/prelude.rs b/crates/parser/src/prelude.rs index 98ba923e..7b3b1dea 100644 --- a/crates/parser/src/prelude.rs +++ b/crates/parser/src/prelude.rs @@ -1,8 +1,5 @@ pub use std::collections::{HashMap, HashSet}; -pub use solana_program_error::ProgramError; -pub use solana_pubkey; pub use yellowstone_vixen_core::{ - instruction, pubkey_convert_helpers, AccountUpdate, KeyBytes, ParseError, ParseResult, Parser, - Prefilter, Pubkey, + instruction, AccountUpdate, KeyBytes, ParseError, ParseResult, Parser, Prefilter, }; diff --git a/crates/parser/src/token_extension_program/account_helpers.rs b/crates/parser/src/token_extension_program/account_helpers.rs deleted file mode 100644 index 2aa9ea6e..00000000 --- a/crates/parser/src/token_extension_program/account_helpers.rs +++ /dev/null @@ -1,613 +0,0 @@ -use bytemuck::Pod; -use spl_pod::{ - bytemuck::pod_from_bytes, - solana_program::{program_error::ProgramError, program_pack::Pack}, -}; -use spl_token_2022::{ - extension::{ - self, BaseState, BaseStateWithExtensions, Extension, ExtensionType, StateWithExtensions, - }, - state::{Account, Mint}, -}; -use spl_token_group_interface::state::{TokenGroup, TokenGroupMember}; -use spl_token_metadata_interface::state::TokenMetadata; -use spl_type_length_value::variable_len_pack::VariableLenPack; - -fn get_extension_data_bytes<'data, T: BaseState + Pack>( - state_with_ex: &'data StateWithExtensions, - extension_type: ExtensionType, -) -> Result<&'data [u8], ProgramError> { - let extension_data = match extension_type { - ExtensionType::ImmutableOwner => state_with_ex.get_extension_bytes::()?, - ExtensionType::TransferFeeAmount => state_with_ex.get_extension_bytes::()?, - ExtensionType::ConfidentialTransferAccount => state_with_ex.get_extension_bytes::()?, - ExtensionType::MemoTransfer => state_with_ex.get_extension_bytes::()?, - ExtensionType::NonTransferableAccount => state_with_ex.get_extension_bytes::()?, - ExtensionType::TransferHookAccount => state_with_ex.get_extension_bytes::()?, - ExtensionType::CpiGuard => state_with_ex.get_extension_bytes::()?, - ExtensionType::ConfidentialTransferFeeAmount => state_with_ex.get_extension_bytes::()?, - ExtensionType::TransferFeeConfig => state_with_ex.get_extension_bytes::()?, - ExtensionType::MintCloseAuthority => state_with_ex.get_extension_bytes::()?, - ExtensionType::ConfidentialTransferMint => state_with_ex.get_extension_bytes::()?, - ExtensionType::DefaultAccountState => state_with_ex.get_extension_bytes::()?, - ExtensionType::NonTransferable => state_with_ex.get_extension_bytes::()?, - ExtensionType::InterestBearingConfig => state_with_ex.get_extension_bytes::()?, - ExtensionType::PermanentDelegate => state_with_ex.get_extension_bytes::()?, - ExtensionType::TransferHook => state_with_ex.get_extension_bytes::()?, - ExtensionType::ConfidentialTransferFeeConfig => state_with_ex.get_extension_bytes::()?, - ExtensionType::MetadataPointer => state_with_ex.get_extension_bytes::()?, - ExtensionType::TokenMetadata => state_with_ex.get_extension_bytes::()?, - ExtensionType::GroupPointer => state_with_ex.get_extension_bytes::()?, - ExtensionType::TokenGroup => state_with_ex.get_extension_bytes::()?, - ExtensionType::GroupMemberPointer => state_with_ex.get_extension_bytes::()?, - ExtensionType::TokenGroupMember => state_with_ex.get_extension_bytes::()?, - ExtensionType::ConfidentialMintBurn => state_with_ex.get_extension_bytes::()?, - ExtensionType::ScaledUiAmount => state_with_ex.get_extension_bytes::()?, - ExtensionType::Pausable => state_with_ex.get_extension_bytes::()?, - ExtensionType::PausableAccount => state_with_ex.get_extension_bytes::()?, - ExtensionType::Uninitialized => &[], - }; - - Ok(extension_data) -} - -pub fn token_account_extensions_data_bytes<'data>( - state_with_ex: &'data StateWithExtensions, - extension_type: ExtensionType, -) -> Result<&'data [u8], ProgramError> { - get_extension_data_bytes(state_with_ex, extension_type) -} - -pub fn mint_account_extensions_data_bytes<'data>( - state_with_ex: &'data StateWithExtensions, - extension_type: ExtensionType, -) -> Result<&'data [u8], ProgramError> { - get_extension_data_bytes(state_with_ex, extension_type) -} - -pub fn parse_extension_data(data_bytes: &[u8]) -> Result { - let extension = pod_from_bytes::(data_bytes)?; - Ok(extension.to_owned()) -} - -pub fn parse_token_metadata_extension(data_bytes: &[u8]) -> Result { - let token_metadata = TokenMetadata::unpack_from_slice(data_bytes)?; - Ok(token_metadata.clone()) -} - -#[derive(Debug, PartialEq)] -pub enum ExtensionData { - ImmutableOwner(extension::immutable_owner::ImmutableOwner), - TransferFeeAmount(extension::transfer_fee::TransferFeeAmount), - ConfidentialTransferAccount(extension::confidential_transfer::ConfidentialTransferAccount), - MemoTransfer(extension::memo_transfer::MemoTransfer), - NonTransferableAccount(extension::non_transferable::NonTransferableAccount), - TransferHookAccount(extension::transfer_hook::TransferHookAccount), - CpiGuard(extension::cpi_guard::CpiGuard), - ConfidentialTransferFeeAmount( - extension::confidential_transfer_fee::ConfidentialTransferFeeAmount, - ), - TransferFeeConfig(extension::transfer_fee::TransferFeeConfig), - MintCloseAuthority(extension::mint_close_authority::MintCloseAuthority), - ConfidentialTransferMint(extension::confidential_transfer::ConfidentialTransferMint), - DefaultAccountState(extension::default_account_state::DefaultAccountState), - NonTransferable(extension::non_transferable::NonTransferable), - InterestBearingConfig(extension::interest_bearing_mint::InterestBearingConfig), - PermanentDelegate(extension::permanent_delegate::PermanentDelegate), - TransferHook(extension::transfer_hook::TransferHook), - ConfidentialTransferFeeConfig( - extension::confidential_transfer_fee::ConfidentialTransferFeeConfig, - ), - MetadataPointer(extension::metadata_pointer::MetadataPointer), - TokenMetadata(TokenMetadata), - GroupPointer(extension::group_pointer::GroupPointer), - TokenGroup(TokenGroup), - GroupMemberPointer(extension::group_member_pointer::GroupMemberPointer), - TokenGroupMember(TokenGroupMember), - ConfidentialMintBurn(extension::confidential_mint_burn::ConfidentialMintBurn), - ScaledUiAmountConfig(extension::scaled_ui_amount::ScaledUiAmountConfig), - PausableConfig(extension::pausable::PausableConfig), - PausableAccount(extension::pausable::PausableAccount), -} - -impl TryFrom<(ExtensionType, &[u8])> for ExtensionData { - type Error = ProgramError; - - fn try_from(value: (ExtensionType, &[u8])) -> Result { - let (extension_type, data_bytes) = value; - match extension_type { - ExtensionType::ImmutableOwner => Ok(ExtensionData::ImmutableOwner( - parse_extension_data(data_bytes)?, - )), - ExtensionType::TransferFeeAmount => Ok(ExtensionData::TransferFeeAmount( - parse_extension_data(data_bytes)?, - )), - ExtensionType::ConfidentialTransferAccount => Ok( - ExtensionData::ConfidentialTransferAccount(parse_extension_data(data_bytes)?), - ), - ExtensionType::MemoTransfer => Ok(ExtensionData::MemoTransfer(parse_extension_data( - data_bytes, - )?)), - ExtensionType::NonTransferableAccount => Ok(ExtensionData::NonTransferableAccount( - parse_extension_data(data_bytes)?, - )), - ExtensionType::TransferHookAccount => Ok(ExtensionData::TransferHookAccount( - parse_extension_data(data_bytes)?, - )), - ExtensionType::CpiGuard => { - Ok(ExtensionData::CpiGuard(parse_extension_data(data_bytes)?)) - }, - ExtensionType::ConfidentialTransferFeeAmount => Ok( - ExtensionData::ConfidentialTransferFeeAmount(parse_extension_data(data_bytes)?), - ), - ExtensionType::TransferFeeConfig => Ok(ExtensionData::TransferFeeConfig( - parse_extension_data(data_bytes)?, - )), - ExtensionType::MintCloseAuthority => Ok(ExtensionData::MintCloseAuthority( - parse_extension_data(data_bytes)?, - )), - ExtensionType::ConfidentialTransferMint => Ok(ExtensionData::ConfidentialTransferMint( - parse_extension_data(data_bytes)?, - )), - ExtensionType::DefaultAccountState => Ok(ExtensionData::DefaultAccountState( - parse_extension_data(data_bytes)?, - )), - ExtensionType::NonTransferable => Ok(ExtensionData::NonTransferable( - parse_extension_data(data_bytes)?, - )), - ExtensionType::InterestBearingConfig => Ok(ExtensionData::InterestBearingConfig( - parse_extension_data(data_bytes)?, - )), - ExtensionType::PermanentDelegate => Ok(ExtensionData::PermanentDelegate( - parse_extension_data(data_bytes)?, - )), - ExtensionType::TransferHook => Ok(ExtensionData::TransferHook(parse_extension_data( - data_bytes, - )?)), - ExtensionType::ConfidentialTransferFeeConfig => Ok( - ExtensionData::ConfidentialTransferFeeConfig(parse_extension_data(data_bytes)?), - ), - ExtensionType::MetadataPointer => Ok(ExtensionData::MetadataPointer( - parse_extension_data(data_bytes)?, - )), - ExtensionType::TokenMetadata => Ok(ExtensionData::TokenMetadata( - parse_token_metadata_extension(data_bytes)?, - )), - ExtensionType::GroupPointer => Ok(ExtensionData::GroupPointer(parse_extension_data( - data_bytes, - )?)), - ExtensionType::TokenGroup => { - Ok(ExtensionData::TokenGroup(parse_extension_data(data_bytes)?)) - }, - ExtensionType::GroupMemberPointer => Ok(ExtensionData::GroupMemberPointer( - parse_extension_data(data_bytes)?, - )), - ExtensionType::TokenGroupMember => Ok(ExtensionData::TokenGroupMember( - parse_extension_data(data_bytes)?, - )), - ExtensionType::ConfidentialMintBurn => Ok(ExtensionData::ConfidentialMintBurn( - parse_extension_data(data_bytes)?, - )), - ExtensionType::ScaledUiAmount => Ok(ExtensionData::ScaledUiAmountConfig( - parse_extension_data(data_bytes)?, - )), - ExtensionType::Pausable => Ok(ExtensionData::PausableConfig(parse_extension_data( - data_bytes, - )?)), - ExtensionType::PausableAccount => Ok(ExtensionData::PausableAccount( - parse_extension_data(data_bytes)?, - )), - - ExtensionType::Uninitialized => Err(ProgramError::InvalidArgument), - } - } -} - -#[cfg(feature = "proto")] -pub mod token_extensions_proto_parser { - use extension::{ - group_member_pointer::GroupMemberPointer, group_pointer::GroupPointer, - immutable_owner::ImmutableOwner, metadata_pointer::MetadataPointer, - }; - use spl_pod::solana_program::pubkey::Pubkey; - use spl_token_2022::{ - solana_zk_sdk::encryption::pod::elgamal::PodElGamalPubkey, - state::{Account, Mint, Multisig}, - }; - use spl_token_group_interface::state::{TokenGroup, TokenGroupMember}; - use spl_token_metadata_interface::state::TokenMetadata; - use yellowstone_vixen_proto::parser::token::{MintProto, MultisigProto, TokenAccountProto}; - #[allow(clippy::wildcard_imports)] - use yellowstone_vixen_proto::parser::token_extensions::{ - extension_data_proto::Data, ConfidentialMintBurnProto, ConfidentialTransferAccountProto, - ConfidentialTransferFeeAmountProto, ConfidentialTransferFeeConfigProto, - ConfidentialTransferMintProto, CpiGuardProto, DefaultAccountStateProto, ExtensionDataProto, - GroupMemberPointerProto, GroupPointerProto, ImmutableOwnerProto, - InterestBearingConfigProto, KeyValue, MemoTransferProto, MetadataPointerProto, - MintCloseAuthorityProto, NonTransferableAccountProto, NonTransferableProto, - PausableAccountProto, PausableConfigProto, PermanentDelegateProto, - ScaledUiAmountConfigProto, TokenGroupMemberProto, TokenGroupProto, TokenMetadataProto, - TransferFeeAmountProto, TransferFeeConfigProto, TransferFeeProto, TransferHookAccountProto, - TransferHookProto, - }; - - use super::{extension, ExtensionData}; - use crate::helpers::{proto::FromCOptionPubkeyToOptString, IntoProto}; - - macro_rules! impl_into_proto { - ($($variant:ident),*) => { - impl IntoProto for ExtensionData { - fn into_proto(self) -> ExtensionDataProto { - match self { - $( - ExtensionData::$variant(data) => ExtensionDataProto { - data: Some(Data::$variant(data.into_proto())), - }, - )* - } - } - } - }; - } - - impl_into_proto!( - ImmutableOwner, - TransferFeeAmount, - ConfidentialTransferAccount, - MemoTransfer, - NonTransferableAccount, - TransferHookAccount, - CpiGuard, - ConfidentialTransferFeeAmount, - TransferFeeConfig, - MintCloseAuthority, - ConfidentialTransferMint, - DefaultAccountState, - NonTransferable, - InterestBearingConfig, - PermanentDelegate, - TransferHook, - MetadataPointer, - TokenMetadata, - GroupPointer, - TokenGroup, - GroupMemberPointer, - TokenGroupMember, - ConfidentialTransferFeeConfig, - ConfidentialMintBurn, - ScaledUiAmountConfig, - PausableConfig, - PausableAccount - ); - - impl IntoProto for Account { - fn into_proto(self) -> TokenAccountProto { - TokenAccountProto { - mint: self.mint.to_string(), - owner: self.owner.to_string(), - amount: self.amount, - delegate: self.delegate.to_opt_string(), - state: self.state as i32, - is_native: self.is_native.into(), - delegated_amount: self.delegated_amount, - close_authority: self.close_authority.to_opt_string(), - } - } - } - - impl IntoProto for Mint { - fn into_proto(self) -> MintProto { - MintProto { - mint_authority: self.mint_authority.to_opt_string(), - - supply: self.supply, - decimals: self.decimals.into(), - is_initialized: self.is_initialized, - freeze_authority: self.freeze_authority.to_opt_string(), - } - } - } - - impl IntoProto for Multisig { - fn into_proto(self) -> MultisigProto { - MultisigProto { - m: self.m.into(), - n: self.n.into(), - is_initialized: self.is_initialized, - signers: self.signers.into_iter().map(|s| s.to_string()).collect(), - } - } - } - - impl IntoProto for ImmutableOwner { - fn into_proto(self) -> ImmutableOwnerProto { ImmutableOwnerProto {} } - } - - impl IntoProto for extension::transfer_fee::TransferFeeAmount { - fn into_proto(self) -> TransferFeeAmountProto { - TransferFeeAmountProto { - withheld_amount: self.withheld_amount.into(), - } - } - } - - impl IntoProto - for extension::confidential_transfer::ConfidentialTransferAccount - { - fn into_proto(self) -> ConfidentialTransferAccountProto { - ConfidentialTransferAccountProto { - approved: self.approved.into(), - elgamal_pubkey: self.elgamal_pubkey.to_string(), - pending_balance: self.pending_balance_lo.to_string(), - pending_balance_lo: self.pending_balance_lo.to_string(), - pending_balance_hi: self.pending_balance_hi.to_string(), - available_balance: self.available_balance.to_string(), - decryptable_available_balance: self.decryptable_available_balance.to_string(), - allow_confidential_credits: self.allow_confidential_credits.into(), - pending_balance_credit_counter: self.pending_balance_credit_counter.into(), - maximum_pending_balance_credit_counter: self - .maximum_pending_balance_credit_counter - .into(), - expected_pending_balance_credit_counter: self - .expected_pending_balance_credit_counter - .into(), - actual_pending_balance_credit_counter: self - .actual_pending_balance_credit_counter - .into(), - } - } - } - - impl IntoProto for extension::memo_transfer::MemoTransfer { - fn into_proto(self) -> MemoTransferProto { - MemoTransferProto { - require_incoming_transfer_memos: self.require_incoming_transfer_memos.into(), - } - } - } - - impl IntoProto - for extension::non_transferable::NonTransferableAccount - { - fn into_proto(self) -> NonTransferableAccountProto { NonTransferableAccountProto {} } - } - - impl IntoProto for extension::transfer_hook::TransferHookAccount { - fn into_proto(self) -> TransferHookAccountProto { - TransferHookAccountProto { - transferring: self.transferring.into(), - } - } - } - - impl IntoProto for extension::cpi_guard::CpiGuard { - fn into_proto(self) -> CpiGuardProto { - CpiGuardProto { - lock_cpi: self.lock_cpi.into(), - } - } - } - - impl IntoProto - for extension::confidential_transfer_fee::ConfidentialTransferFeeAmount - { - fn into_proto(self) -> ConfidentialTransferFeeAmountProto { - ConfidentialTransferFeeAmountProto { - withheld_amount: self.withheld_amount.to_string(), - } - } - } - - impl IntoProto for extension::transfer_fee::TransferFeeConfig { - fn into_proto(self) -> TransferFeeConfigProto { - TransferFeeConfigProto { - transfer_fee_config_authority: self.transfer_fee_config_authority.0.to_string(), - - withdraw_withheld_authority: self.withdraw_withheld_authority.0.to_string(), - withheld_amount: self.withheld_amount.into(), - older_transfer_fee: Some(TransferFeeProto { - epoch: self.older_transfer_fee.epoch.into(), - maximum_fee: self.older_transfer_fee.maximum_fee.into(), - transfer_fee_basis_points: Into::::into( - self.older_transfer_fee.transfer_fee_basis_points, - ) - .into(), - }), - newer_transfer_fee: Some(TransferFeeProto { - epoch: self.newer_transfer_fee.epoch.into(), - maximum_fee: self.newer_transfer_fee.maximum_fee.into(), - transfer_fee_basis_points: Into::::into( - self.newer_transfer_fee.transfer_fee_basis_points, - ) - .into(), - }), - } - } - } - - impl IntoProto for extension::mint_close_authority::MintCloseAuthority { - fn into_proto(self) -> MintCloseAuthorityProto { - MintCloseAuthorityProto { - close_authority: self.close_authority.0.to_string(), - } - } - } - - impl IntoProto - for extension::confidential_transfer::ConfidentialTransferMint - { - fn into_proto(self) -> ConfidentialTransferMintProto { - ConfidentialTransferMintProto { - authority: self.authority.0.to_string(), - auditor_elgamal_pubkey: Option::::from( - self.auditor_elgamal_pubkey, - ) - .map(|x| x.to_string()), - auto_approve_new_accounts: self.auto_approve_new_accounts.into(), - } - } - } - - impl IntoProto for extension::default_account_state::DefaultAccountState { - fn into_proto(self) -> DefaultAccountStateProto { - DefaultAccountStateProto { - state: self.state.into(), - } - } - } - - impl IntoProto for extension::non_transferable::NonTransferable { - fn into_proto(self) -> NonTransferableProto { NonTransferableProto {} } - } - - impl IntoProto - for extension::interest_bearing_mint::InterestBearingConfig - { - fn into_proto(self) -> InterestBearingConfigProto { - InterestBearingConfigProto { - rate_authority: self.rate_authority.0.to_string(), - initialization_timestamp: self.initialization_timestamp.into(), - pre_update_average_rate: Into::::into(self.pre_update_average_rate).into(), - last_update_timestamp: self.last_update_timestamp.into(), - current_rate: Into::::into(self.current_rate).into(), - } - } - } - - impl IntoProto for extension::permanent_delegate::PermanentDelegate { - fn into_proto(self) -> PermanentDelegateProto { - PermanentDelegateProto { - delegate: self.delegate.0.to_string(), - } - } - } - - impl IntoProto for extension::transfer_hook::TransferHook { - fn into_proto(self) -> TransferHookProto { - TransferHookProto { - authority: self.authority.0.to_string(), - program_id: self.program_id.0.to_string(), - } - } - } - - impl IntoProto - for extension::confidential_transfer_fee::ConfidentialTransferFeeConfig - { - fn into_proto(self) -> ConfidentialTransferFeeConfigProto { - ConfidentialTransferFeeConfigProto { - authority: self.authority.0.to_string(), - withheld_amount: self.withheld_amount.to_string(), - withdraw_withheld_authority_elgamal_pubkey: self - .withdraw_withheld_authority_elgamal_pubkey - .to_string(), - harvest_to_mint_enabled: self.harvest_to_mint_enabled.into(), - } - } - } - - impl IntoProto for MetadataPointer { - fn into_proto(self) -> MetadataPointerProto { - MetadataPointerProto { - authority: self.authority.0.to_string(), - metadata_address: self.metadata_address.0.to_string(), - } - } - } - - impl IntoProto for TokenMetadata { - fn into_proto(self) -> TokenMetadataProto { - TokenMetadataProto { - update_authority: self.update_authority.0.to_string(), - mint: self.mint.to_string(), - name: self.name, - symbol: self.symbol, - uri: self.uri, - additional_metadata: self - .additional_metadata - .into_iter() - .map(|x| KeyValue { - key: x.0, - value: x.1, - }) - .collect(), - } - } - } - - impl IntoProto for GroupPointer { - fn into_proto(self) -> GroupPointerProto { - GroupPointerProto { - authority: self.authority.0.to_string(), - group_address: self.group_address.0.to_string(), - } - } - } - - impl IntoProto for TokenGroup { - fn into_proto(self) -> TokenGroupProto { - TokenGroupProto { - update_authority: self.update_authority.0.to_string(), - mint: self.mint.to_string(), - size: self.size.into(), - max_size: self.max_size.into(), - } - } - } - - impl IntoProto for GroupMemberPointer { - fn into_proto(self) -> GroupMemberPointerProto { - GroupMemberPointerProto { - authority: self.authority.0.to_string(), - member_address: self.member_address.0.to_string(), - } - } - } - - impl IntoProto for TokenGroupMember { - fn into_proto(self) -> TokenGroupMemberProto { - TokenGroupMemberProto { - member_number: self.member_number.into(), - mint: self.mint.to_string(), - group: self.group.to_string(), - } - } - } - - impl IntoProto - for extension::confidential_mint_burn::ConfidentialMintBurn - { - fn into_proto(self) -> ConfidentialMintBurnProto { - ConfidentialMintBurnProto { - confidential_supply: self.confidential_supply.to_string(), - decryptable_supply: self.decryptable_supply.to_string(), - supply_elgamal_pubkey: self.supply_elgamal_pubkey.to_string(), - pending_burn: self.pending_burn.to_string(), - } - } - } - - impl IntoProto for extension::scaled_ui_amount::ScaledUiAmountConfig { - fn into_proto(self) -> ScaledUiAmountConfigProto { - ScaledUiAmountConfigProto { - authority: Into::>::into(self.authority).map(|x| x.to_string()), - multiplier: self.multiplier.into(), - new_multiplier_effective_timestamp: self.new_multiplier_effective_timestamp.into(), - new_multiplier: self.new_multiplier.into(), - } - } - } - - impl IntoProto for extension::pausable::PausableConfig { - fn into_proto(self) -> PausableConfigProto { - PausableConfigProto { - authority: Into::>::into(self.authority).map(|x| x.to_string()), - paused: self.paused.into(), - } - } - } - - impl IntoProto for extension::pausable::PausableAccount { - fn into_proto(self) -> PausableAccountProto { PausableAccountProto {} } - } -} diff --git a/crates/parser/src/token_extension_program/extensions/common_ix.rs b/crates/parser/src/token_extension_program/extensions/common_ix.rs deleted file mode 100644 index 744d79a5..00000000 --- a/crates/parser/src/token_extension_program/extensions/common_ix.rs +++ /dev/null @@ -1,221 +0,0 @@ -use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; - -use super::helpers::decode_extension_ix_type; -use crate::{helpers::check_min_accounts_req, Error, Result}; - -#[derive(Debug, Clone, Copy)] -pub enum ExtensionWithCommonIxs { - CpiGuard, - DefaultAccountState, - InterestBearingMint, - MemoTransfer, - GroupMemberPointer, - GroupPointer, - MetadataPointer, - TransferHook, -} - -#[derive(Debug, Clone, Copy)] -pub enum IxsSupported { - InitAndUpdate, - EnableAndDisable, -} - -impl ExtensionWithCommonIxs { - #[must_use] - pub fn get_ixs_supported(extension: &ExtensionWithCommonIxs) -> IxsSupported { - match extension { - ExtensionWithCommonIxs::CpiGuard | ExtensionWithCommonIxs::MemoTransfer => { - IxsSupported::EnableAndDisable - }, - ExtensionWithCommonIxs::DefaultAccountState - | ExtensionWithCommonIxs::InterestBearingMint - | ExtensionWithCommonIxs::GroupMemberPointer - | ExtensionWithCommonIxs::MetadataPointer - | ExtensionWithCommonIxs::TransferHook - | ExtensionWithCommonIxs::GroupPointer => IxsSupported::InitAndUpdate, - } - } -} - -#[derive(Debug, Clone, Copy)] -pub struct ExtInitializeAccounts { - pub mint: Pubkey, -} - -#[derive(Debug)] -pub struct UpdateAccounts { - pub mint: Pubkey, - pub extension_authority: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] -pub struct EnableAccounts { - pub account: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] -pub struct DisableAccounts { - pub account: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] -pub struct CommonExtensionIxs { - pub extension: ExtensionWithCommonIxs, - pub ix: CommonIx, -} - -#[derive(Debug)] -pub enum CommonIx { - Initialize(ExtInitializeAccounts), - Update(UpdateAccounts), - Enable(EnableAccounts), - Disable(DisableAccounts), -} - -impl CommonExtensionIxs { - pub fn try_parse_extension_ix( - extension: ExtensionWithCommonIxs, - ix: &InstructionUpdate, - ) -> Result { - let ix_type = decode_extension_ix_type(&ix.data[1..])?; - let accounts_len = ix.accounts.len(); - match ExtensionWithCommonIxs::get_ixs_supported(&extension) { - IxsSupported::InitAndUpdate => match ix_type { - 0 => { - check_min_accounts_req(accounts_len, 1)?; - Ok(CommonExtensionIxs { - extension, - ix: CommonIx::Initialize(ExtInitializeAccounts { - mint: ix.accounts[0], - }), - }) - }, - 1 => { - check_min_accounts_req(accounts_len, 2)?; - Ok(CommonExtensionIxs { - extension, - ix: CommonIx::Update(UpdateAccounts { - mint: ix.accounts[0], - extension_authority: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }), - }) - }, - _ => Err(Error::new("Invalid instruction")), - }, - IxsSupported::EnableAndDisable => match ix_type { - 0 => { - check_min_accounts_req(accounts_len, 2)?; - Ok(CommonExtensionIxs { - extension, - ix: CommonIx::Enable(EnableAccounts { - account: ix.accounts[0], - owner: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }), - }) - }, - 1 => { - check_min_accounts_req(accounts_len, 2)?; - Ok(CommonExtensionIxs { - extension, - ix: CommonIx::Disable(DisableAccounts { - account: ix.accounts[0], - owner: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }), - }) - }, - _ => Err(Error::new("Invalid instruction")), - }, - } - } -} - -#[cfg(feature = "proto")] -mod proto_parser { - - use common_extension_ix_proto::IxOneof; - use yellowstone_vixen_proto::parser::token_extensions::{ - common_extension_ix_proto, CommonExtensionIxProto, DisableAccountsProto, DisableIxProto, - EnableAccountsProto, EnableIxProto, ExtInitializeAccountsProto, ExtInitializeIxProto, - UpdateAccountsProto, UpdateIxProto, - }; - - use super::{CommonIx, DisableAccounts, EnableAccounts, ExtInitializeAccounts, UpdateAccounts}; - use crate::helpers::{proto::FromVecPubkeyToVecString, IntoProto}; - - impl IntoProto for ExtInitializeAccounts { - fn into_proto(self) -> ExtInitializeAccountsProto { - ExtInitializeAccountsProto { - mint: self.mint.to_string(), - } - } - } - - impl IntoProto for UpdateAccounts { - fn into_proto(self) -> UpdateAccountsProto { - UpdateAccountsProto { - mint: self.mint.to_string(), - extension_authority: self.extension_authority.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for EnableAccounts { - fn into_proto(self) -> EnableAccountsProto { - EnableAccountsProto { - account: self.account.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for DisableAccounts { - fn into_proto(self) -> DisableAccountsProto { - DisableAccountsProto { - account: self.account.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for CommonIx { - fn into_proto(self) -> CommonExtensionIxProto { - match self { - CommonIx::Initialize(acc) => CommonExtensionIxProto { - ix_oneof: Some(IxOneof::ExtInitializeIx(ExtInitializeIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - CommonIx::Update(acc) => CommonExtensionIxProto { - ix_oneof: Some(IxOneof::UpdateIx(UpdateIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - CommonIx::Enable(acc) => CommonExtensionIxProto { - ix_oneof: Some(IxOneof::EnableIx(EnableIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - CommonIx::Disable(acc) => CommonExtensionIxProto { - ix_oneof: Some(IxOneof::DisableIx(DisableIxProto { - accounts: Some(acc.into_proto()), - })), - }, - } - } - } -} diff --git a/crates/parser/src/token_extension_program/extensions/confidential_transfer.rs b/crates/parser/src/token_extension_program/extensions/confidential_transfer.rs deleted file mode 100644 index 5e2326e0..00000000 --- a/crates/parser/src/token_extension_program/extensions/confidential_transfer.rs +++ /dev/null @@ -1,555 +0,0 @@ -use spl_token_2022::extension::confidential_transfer::instruction::ConfidentialTransferInstruction; -use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; - -use super::helpers::{decode_extension_ix_type, ExtensionIxParser}; -use crate::{helpers::check_min_accounts_req, token_program::InitializeMintAccounts, Result}; - -#[derive(Debug, Clone, Copy)] -pub struct UpdateMintAccounts { - pub mint: Pubkey, - pub authority: Pubkey, -} - -#[derive(Debug, Clone)] -pub struct ConfigureAccountAccounts { - pub account: Pubkey, - pub mint: Pubkey, - pub sysvar: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct ApproveAccountAccounts { - pub account: Pubkey, - pub mint: Pubkey, - pub authority: Pubkey, -} - -#[derive(Debug)] -pub struct EmptyAccountAccounts { - pub account: Pubkey, - pub sysvar: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] - -pub struct DepositAccounts { - pub account: Pubkey, - pub mint: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] -pub struct WithdrawAccounts { - pub source_account: Pubkey, - pub mint: Pubkey, - pub destination: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] - -pub struct ConfidentialTransferAccounts { - pub source_account: Pubkey, - pub mint: Pubkey, - pub destination: Pubkey, - pub owner: Pubkey, - pub context_account: Pubkey, // Sysvar account or context state account - pub multisig_signers: Vec, -} - -#[derive(Debug)] -pub struct ApplyPendingBalanceAccounts { - pub account: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] - -pub struct CreditsAccounts { - pub account: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] - -pub struct TransferWithFeeAccounts { - pub source_account: Pubkey, - pub mint: Pubkey, - pub destination: Pubkey, -} - -#[derive(Debug, Clone, Copy)] - -pub struct ConfigureAccountWithRegistryAccounts { - pub account: Pubkey, - pub mint: Pubkey, - pub registry: Pubkey, -} - -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -pub enum ConfidentaltransferIx { - InitializeMint(InitializeMintAccounts), - UpdateMint(UpdateMintAccounts), - ConfigureAccount(ConfigureAccountAccounts), - ApproveAccount(ApproveAccountAccounts), - EmptyAccount(EmptyAccountAccounts), - Deposit(DepositAccounts), - Withdraw(WithdrawAccounts), - Transfer(ConfidentialTransferAccounts), - ApplyPendingBalance(ApplyPendingBalanceAccounts), - EnableConfidentialCredits(CreditsAccounts), - DisableConfidentialCredits(CreditsAccounts), - EnableNonConfidentialCredits(CreditsAccounts), - DisableNonConfidentialCredits(CreditsAccounts), - TransferWithFee(TransferWithFeeAccounts), - ConfigureAccountWithRegistry(ConfigureAccountWithRegistryAccounts), -} - -impl ExtensionIxParser for ConfidentaltransferIx { - #[allow(clippy::too_many_lines)] - fn try_parse_extension_ix(ix: &InstructionUpdate) -> Result { - let accounts_len = ix.accounts.len(); - let ix_type = decode_extension_ix_type(&ix.data[1..])?; - match ix_type { - ConfidentialTransferInstruction::InitializeMint => { - check_min_accounts_req(accounts_len, 1)?; - Ok(ConfidentaltransferIx::InitializeMint( - InitializeMintAccounts { - mint: ix.accounts[0], - }, - )) - }, - ConfidentialTransferInstruction::UpdateMint => { - check_min_accounts_req(accounts_len, 2)?; - Ok(ConfidentaltransferIx::UpdateMint(UpdateMintAccounts { - mint: ix.accounts[0], - authority: ix.accounts[1], - })) - }, - ConfidentialTransferInstruction::ConfigureAccount => { - check_min_accounts_req(accounts_len, 4)?; - Ok(ConfidentaltransferIx::ConfigureAccount( - ConfigureAccountAccounts { - account: ix.accounts[0], - mint: ix.accounts[1], - sysvar: ix.accounts[2], - owner: ix.accounts[3], - multisig_signers: ix.accounts[4..].to_vec(), - }, - )) - }, - - ConfidentialTransferInstruction::ApproveAccount => { - check_min_accounts_req(accounts_len, 3)?; - Ok(ConfidentaltransferIx::ApproveAccount( - ApproveAccountAccounts { - account: ix.accounts[0], - mint: ix.accounts[1], - authority: ix.accounts[2], - }, - )) - }, - - ConfidentialTransferInstruction::EmptyAccount => { - check_min_accounts_req(accounts_len, 3)?; - Ok(ConfidentaltransferIx::EmptyAccount(EmptyAccountAccounts { - account: ix.accounts[0], - sysvar: ix.accounts[1], - owner: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - })) - }, - - ConfidentialTransferInstruction::Deposit => { - check_min_accounts_req(accounts_len, 3)?; - Ok(ConfidentaltransferIx::Deposit(DepositAccounts { - account: ix.accounts[0], - mint: ix.accounts[1], - owner: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - })) - }, - - ConfidentialTransferInstruction::Withdraw => { - check_min_accounts_req(accounts_len, 4)?; - Ok(ConfidentaltransferIx::Withdraw(WithdrawAccounts { - source_account: ix.accounts[0], - mint: ix.accounts[1], - destination: ix.accounts[2], - owner: ix.accounts[3], - multisig_signers: ix.accounts[4..].to_vec(), - })) - }, - - ConfidentialTransferInstruction::Transfer => { - check_min_accounts_req(accounts_len, 5)?; - Ok(ConfidentaltransferIx::Transfer( - ConfidentialTransferAccounts { - source_account: ix.accounts[0], - mint: ix.accounts[1], - destination: ix.accounts[2], - context_account: ix.accounts[3], - owner: ix.accounts[4], - multisig_signers: ix.accounts[5..].to_vec(), - }, - )) - }, - - ConfidentialTransferInstruction::ApplyPendingBalance => { - check_min_accounts_req(accounts_len, 2)?; - Ok(ConfidentaltransferIx::ApplyPendingBalance( - ApplyPendingBalanceAccounts { - account: ix.accounts[0], - owner: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }, - )) - }, - - ConfidentialTransferInstruction::EnableConfidentialCredits => { - check_min_accounts_req(accounts_len, 2)?; - Ok(ConfidentaltransferIx::EnableConfidentialCredits( - CreditsAccounts { - account: ix.accounts[0], - owner: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }, - )) - }, - - ConfidentialTransferInstruction::DisableConfidentialCredits => { - check_min_accounts_req(accounts_len, 2)?; - Ok(ConfidentaltransferIx::DisableConfidentialCredits( - CreditsAccounts { - account: ix.accounts[0], - owner: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }, - )) - }, - - ConfidentialTransferInstruction::EnableNonConfidentialCredits => { - check_min_accounts_req(accounts_len, 2)?; - Ok(ConfidentaltransferIx::EnableNonConfidentialCredits( - CreditsAccounts { - account: ix.accounts[0], - owner: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }, - )) - }, - - ConfidentialTransferInstruction::DisableNonConfidentialCredits => { - check_min_accounts_req(accounts_len, 2)?; - Ok(ConfidentaltransferIx::DisableNonConfidentialCredits( - CreditsAccounts { - account: ix.accounts[0], - owner: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }, - )) - }, - ConfidentialTransferInstruction::TransferWithFee => { - check_min_accounts_req(accounts_len, 5)?; - Ok(ConfidentaltransferIx::TransferWithFee( - TransferWithFeeAccounts { - source_account: ix.accounts[0], - mint: ix.accounts[1], - destination: ix.accounts[2], - }, - )) - }, - ConfidentialTransferInstruction::ConfigureAccountWithRegistry => { - check_min_accounts_req(accounts_len, 4)?; - Ok(ConfidentaltransferIx::ConfigureAccountWithRegistry( - ConfigureAccountWithRegistryAccounts { - account: ix.accounts[0], - mint: ix.accounts[1], - registry: ix.accounts[2], - }, - )) - }, - } - } -} - -#[cfg(feature = "proto")] -mod proto_parser { - - use confidential_transfer_ext_ix_proto::IxOneof; - use yellowstone_vixen_proto::parser::token_extensions::{ - confidential_transfer_ext_ix_proto, ApplyPendingBalanceAccountsProto, - ApplyPendingBalanceIxProto, ApproveAccountAccountsProto, ApproveAccountIxProto, - ConfidentialTransferAccountsProto, ConfidentialTransferExtIxProto, - ConfidentialTransferIxProto, ConfigureAccountAccountsProto, ConfigureAccountIxProto, - ConfigureAccountWithRegistryAccountsProto, ConfigureAccountWithRegistryIxProto, - CreditsAccountsProto, DepositAccountsProto, DepositIxProto, - DisableConfidentialCreditsIxProto, DisableNonConfidentialCreditsIxProto, - EmptyAccountAccountsProto, EmptyAccountIxProto, EnableConfidentialCreditsIxProto, - EnableNonConfidentialCreditsIxProto, InitializeConfidentialMintAccountsProto, - InitializeConfidentialMintIxProto, TransferWithFeeAccountsProto, TransferWithFeeIxProto, - UpdateMintAccountsProto, UpdateMintIxProto, WithdrawAccountsProto, WithdrawIxProto, - }; - - use super::{ - ApplyPendingBalanceAccounts, ApproveAccountAccounts, ConfidentaltransferIx, - ConfidentialTransferAccounts, ConfigureAccountAccounts, CreditsAccounts, DepositAccounts, - EmptyAccountAccounts, InitializeMintAccounts, UpdateMintAccounts, WithdrawAccounts, - }; - use crate::{ - helpers::{proto::FromVecPubkeyToVecString, IntoProto}, - token_extension_program::{ConfigureAccountWithRegistryAccounts, TransferWithFeeAccounts}, - }; - - impl IntoProto for InitializeMintAccounts { - fn into_proto(self) -> InitializeConfidentialMintAccountsProto { - InitializeConfidentialMintAccountsProto { - mint: self.mint.to_string(), - } - } - } - - impl IntoProto for UpdateMintAccounts { - fn into_proto(self) -> UpdateMintAccountsProto { - UpdateMintAccountsProto { - mint: self.mint.to_string(), - authority: self.authority.to_string(), - } - } - } - - impl IntoProto for ConfigureAccountAccounts { - fn into_proto(self) -> ConfigureAccountAccountsProto { - ConfigureAccountAccountsProto { - account: self.account.to_string(), - mint: self.mint.to_string(), - sysvar: self.sysvar.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for ApproveAccountAccounts { - fn into_proto(self) -> ApproveAccountAccountsProto { - ApproveAccountAccountsProto { - account: self.account.to_string(), - mint: self.mint.to_string(), - authority: self.authority.to_string(), - } - } - } - - impl IntoProto for EmptyAccountAccounts { - fn into_proto(self) -> EmptyAccountAccountsProto { - EmptyAccountAccountsProto { - account: self.account.to_string(), - sysvar: self.sysvar.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for DepositAccounts { - fn into_proto(self) -> DepositAccountsProto { - DepositAccountsProto { - account: self.account.to_string(), - mint: self.mint.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for WithdrawAccounts { - fn into_proto(self) -> WithdrawAccountsProto { - WithdrawAccountsProto { - source_account: self.source_account.to_string(), - mint: self.mint.to_string(), - destination: self.destination.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for ConfidentialTransferAccounts { - fn into_proto(self) -> ConfidentialTransferAccountsProto { - ConfidentialTransferAccountsProto { - source_account: self.source_account.to_string(), - mint: self.mint.to_string(), - destination: self.destination.to_string(), - owner: self.owner.to_string(), - context_account: self.context_account.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for ApplyPendingBalanceAccounts { - fn into_proto(self) -> ApplyPendingBalanceAccountsProto { - ApplyPendingBalanceAccountsProto { - account: self.account.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for CreditsAccounts { - fn into_proto(self) -> CreditsAccountsProto { - CreditsAccountsProto { - account: self.account.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for TransferWithFeeAccounts { - fn into_proto(self) -> TransferWithFeeAccountsProto { - TransferWithFeeAccountsProto { - source_account: self.source_account.to_string(), - mint: self.mint.to_string(), - destination: self.destination.to_string(), - } - } - } - - impl IntoProto for ConfigureAccountWithRegistryAccounts { - fn into_proto(self) -> ConfigureAccountWithRegistryAccountsProto { - ConfigureAccountWithRegistryAccountsProto { - account: self.account.to_string(), - mint: self.mint.to_string(), - registry: self.registry.to_string(), - } - } - } - impl IntoProto for ConfidentaltransferIx { - fn into_proto(self) -> ConfidentialTransferExtIxProto { - match self { - ConfidentaltransferIx::InitializeMint(acc) => ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::InitializeMintIx( - InitializeConfidentialMintIxProto { - accounts: Some(acc.into_proto()), - }, - )), - }, - - ConfidentaltransferIx::UpdateMint(acc) => ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::UpdateMintIx(UpdateMintIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - ConfidentaltransferIx::ConfigureAccount(acc) => ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::ConfigureAccountIx(ConfigureAccountIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - ConfidentaltransferIx::ApproveAccount(acc) => ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::ApproveAccountIx(ApproveAccountIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - ConfidentaltransferIx::EmptyAccount(acc) => ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::EmptyAccountIx(EmptyAccountIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - ConfidentaltransferIx::Deposit(acc) => ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::DepositIx(DepositIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - ConfidentaltransferIx::Withdraw(acc) => ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::WithdrawIx(WithdrawIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - ConfidentaltransferIx::Transfer(acc) => ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::TransferIx(ConfidentialTransferIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - ConfidentaltransferIx::ApplyPendingBalance(acc) => ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::ApplyPendingBalanceIx(ApplyPendingBalanceIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - ConfidentaltransferIx::EnableConfidentialCredits(acc) => { - ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::EnableConfidentialCreditsIx( - EnableConfidentialCreditsIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - - ConfidentaltransferIx::DisableConfidentialCredits(acc) => { - ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::DisableConfidentialCreditsIx( - DisableConfidentialCreditsIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - - ConfidentaltransferIx::EnableNonConfidentialCredits(acc) => { - ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::EnableNonConfidentialCreditsIx( - EnableNonConfidentialCreditsIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - - ConfidentaltransferIx::DisableNonConfidentialCredits(acc) => { - ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::DisableNonConfidentialCreditsIx( - DisableNonConfidentialCreditsIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - - ConfidentaltransferIx::TransferWithFee(acc) => ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::TransferWithFeeIx(TransferWithFeeIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - ConfidentaltransferIx::ConfigureAccountWithRegistry(acc) => { - ConfidentialTransferExtIxProto { - ix_oneof: Some(IxOneof::ConfigureAccountWithRegistryIx( - ConfigureAccountWithRegistryIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - } - } - } -} diff --git a/crates/parser/src/token_extension_program/extensions/confidential_transfer_fee.rs b/crates/parser/src/token_extension_program/extensions/confidential_transfer_fee.rs deleted file mode 100644 index 3052a59d..00000000 --- a/crates/parser/src/token_extension_program/extensions/confidential_transfer_fee.rs +++ /dev/null @@ -1,302 +0,0 @@ -use spl_token_2022::extension::confidential_transfer_fee::instruction::ConfidentialTransferFeeInstruction; -use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; - -use super::helpers::{decode_extension_ix_type, ExtensionIxParser}; -use crate::{helpers::check_min_accounts_req, Result}; -#[derive(Debug, Clone, Copy)] -pub struct InitializeConfidentialTransferFeeConfigAccounts { - pub mint: Pubkey, -} - -#[derive(Debug)] -pub struct ConfidentialWithdrawWithheldTokensFromMintAccounts { - pub mint: Pubkey, - pub fee_recipient: Pubkey, - pub sysvar: Pubkey, - pub withdraw_withheld_authority: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] -pub struct ConfidentialWithdrawWithheldTokensFromAccounts { - pub mint: Pubkey, - pub fee_recipient: Pubkey, - pub sysvar: Pubkey, - pub withdraw_withheld_authority: Pubkey, - pub multisig_signers: Vec, - pub source_accounts: Vec, -} - -#[derive(Debug)] -pub struct ConfidentialHarvestWithheldTokensToMintAccounts { - pub mint: Pubkey, - pub source_accounts: Vec, -} - -#[derive(Debug)] -pub struct EnableHarvestToMintAccounts { - pub mint: Pubkey, - pub confidential_transfer_fee_authority: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] -pub struct DisableHarvestToMintAccounts { - pub account: Pubkey, - pub confidential_transfer_fee_authority: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] -pub enum ConfidentaltransferFeeIx { - InitializeConfidentialTransferFeeConfig(InitializeConfidentialTransferFeeConfigAccounts), - WithdrawWithheldTokensFromMint(ConfidentialWithdrawWithheldTokensFromMintAccounts), - WithdrawWithheldTokensFromAccounts(ConfidentialWithdrawWithheldTokensFromAccounts), - HarvestWithheldTokensToMint(ConfidentialHarvestWithheldTokensToMintAccounts), - EnableHarvestToMint(EnableHarvestToMintAccounts), - DisableHarvestToMint(DisableHarvestToMintAccounts), -} - -impl ExtensionIxParser for ConfidentaltransferFeeIx { - fn try_parse_extension_ix(ix: &InstructionUpdate) -> Result { - let accounts_len = ix.accounts.len(); - let ix_type = decode_extension_ix_type(&ix.data[1..])?; - - match ix_type { - ConfidentialTransferFeeInstruction::InitializeConfidentialTransferFeeConfig => { - check_min_accounts_req(accounts_len, 1)?; - Ok( - ConfidentaltransferFeeIx::InitializeConfidentialTransferFeeConfig( - InitializeConfidentialTransferFeeConfigAccounts { - mint: ix.accounts[0], - }, - ), - ) - }, - - ConfidentialTransferFeeInstruction::WithdrawWithheldTokensFromMint => { - check_min_accounts_req(accounts_len, 4)?; - Ok(ConfidentaltransferFeeIx::WithdrawWithheldTokensFromMint( - ConfidentialWithdrawWithheldTokensFromMintAccounts { - mint: ix.accounts[0], - fee_recipient: ix.accounts[1], - sysvar: ix.accounts[2], - withdraw_withheld_authority: ix.accounts[3], - multisig_signers: ix.accounts[4..].to_vec(), - }, - )) - }, - - ConfidentialTransferFeeInstruction::WithdrawWithheldTokensFromAccounts => { - check_min_accounts_req(accounts_len, 5)?; - Ok( - ConfidentaltransferFeeIx::WithdrawWithheldTokensFromAccounts( - ConfidentialWithdrawWithheldTokensFromAccounts { - mint: ix.accounts[0], - fee_recipient: ix.accounts[1], - sysvar: ix.accounts[2], - withdraw_withheld_authority: ix.accounts[3], - source_accounts: ix.accounts[4..].to_vec(), - multisig_signers: Vec::new(), - }, - ), - ) - }, - - ConfidentialTransferFeeInstruction::HarvestWithheldTokensToMint => { - check_min_accounts_req(accounts_len, 2)?; - Ok(ConfidentaltransferFeeIx::HarvestWithheldTokensToMint( - ConfidentialHarvestWithheldTokensToMintAccounts { - mint: ix.accounts[0], - source_accounts: ix.accounts[1..].to_vec(), - }, - )) - }, - - ConfidentialTransferFeeInstruction::EnableHarvestToMint => { - check_min_accounts_req(accounts_len, 2)?; - Ok(ConfidentaltransferFeeIx::EnableHarvestToMint( - EnableHarvestToMintAccounts { - mint: ix.accounts[0], - confidential_transfer_fee_authority: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }, - )) - }, - - ConfidentialTransferFeeInstruction::DisableHarvestToMint => { - check_min_accounts_req(accounts_len, 2)?; - Ok(ConfidentaltransferFeeIx::DisableHarvestToMint( - DisableHarvestToMintAccounts { - account: ix.accounts[0], - confidential_transfer_fee_authority: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }, - )) - }, - } - } -} - -#[cfg(feature = "proto")] -mod proto_parser { - use confidential_transfer_fee_ix_proto::IxOneof; - use yellowstone_vixen_proto::parser::token_extensions::{ - confidential_transfer_fee_ix_proto, ConfidentialHarvestWithheldTokensToMintAccountsProto, - ConfidentialHarvestWithheldTokensToMintIxProto, ConfidentialTransferFeeIxProto, - ConfidentialWithdrawWithheldTokensFromAccountsAccountsProto, - ConfidentialWithdrawWithheldTokensFromAccountsIxProto, - ConfidentialWithdrawWithheldTokensFromMintAccountsProto, - ConfidentialWithdrawWithheldTokensFromMintIxProto, DisableHarvestToMintAccountsProto, - DisableHarvestToMintIxProto, EnableHarvestToMintAccountsProto, EnableHarvestToMintIxProto, - InitializeConfidentialTransferFeeConfigAccountsProto, - InitializeConfidentialTransferFeeConfigIxProto, - }; - - use super::{ - ConfidentaltransferFeeIx, ConfidentialHarvestWithheldTokensToMintAccounts, - ConfidentialWithdrawWithheldTokensFromAccounts, - ConfidentialWithdrawWithheldTokensFromMintAccounts, DisableHarvestToMintAccounts, - EnableHarvestToMintAccounts, InitializeConfidentialTransferFeeConfigAccounts, - }; - use crate::helpers::{proto::FromVecPubkeyToVecString, IntoProto}; - - impl IntoProto - for InitializeConfidentialTransferFeeConfigAccounts - { - fn into_proto(self) -> InitializeConfidentialTransferFeeConfigAccountsProto { - InitializeConfidentialTransferFeeConfigAccountsProto { - mint: self.mint.to_string(), - } - } - } - - impl IntoProto - for ConfidentialWithdrawWithheldTokensFromMintAccounts - { - fn into_proto(self) -> ConfidentialWithdrawWithheldTokensFromMintAccountsProto { - ConfidentialWithdrawWithheldTokensFromMintAccountsProto { - mint: self.mint.to_string(), - fee_recipient: self.fee_recipient.to_string(), - sysvar: self.sysvar.to_string(), - withdraw_withheld_authority: self.withdraw_withheld_authority.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto - for ConfidentialWithdrawWithheldTokensFromAccounts - { - fn into_proto(self) -> ConfidentialWithdrawWithheldTokensFromAccountsAccountsProto { - ConfidentialWithdrawWithheldTokensFromAccountsAccountsProto { - mint: self.mint.to_string(), - fee_recipient: self.fee_recipient.to_string(), - withdraw_withheld_authority: self.withdraw_withheld_authority.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - source_accounts: self.source_accounts.to_string_vec(), - } - } - } - - impl IntoProto - for ConfidentialHarvestWithheldTokensToMintAccounts - { - fn into_proto(self) -> ConfidentialHarvestWithheldTokensToMintAccountsProto { - ConfidentialHarvestWithheldTokensToMintAccountsProto { - mint: self.mint.to_string(), - source_accounts: self.source_accounts.to_string_vec(), - } - } - } - - impl IntoProto for EnableHarvestToMintAccounts { - fn into_proto(self) -> EnableHarvestToMintAccountsProto { - EnableHarvestToMintAccountsProto { - mint: self.mint.to_string(), - confidential_transfer_fee_authority: self - .confidential_transfer_fee_authority - .to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for DisableHarvestToMintAccounts { - fn into_proto(self) -> DisableHarvestToMintAccountsProto { - DisableHarvestToMintAccountsProto { - account: self.account.to_string(), - confidential_transfer_fee_authority: self - .confidential_transfer_fee_authority - .to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for ConfidentaltransferFeeIx { - fn into_proto(self) -> ConfidentialTransferFeeIxProto { - match self { - ConfidentaltransferFeeIx::InitializeConfidentialTransferFeeConfig(acc) => { - ConfidentialTransferFeeIxProto { - ix_oneof: Some(IxOneof::InitializeConfidentialTransferFeeConfigIx( - InitializeConfidentialTransferFeeConfigIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - - ConfidentaltransferFeeIx::WithdrawWithheldTokensFromMint(acc) => { - ConfidentialTransferFeeIxProto { - ix_oneof: Some(IxOneof::WithdrawWithheldTokensFromMintIx( - ConfidentialWithdrawWithheldTokensFromMintIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - - ConfidentaltransferFeeIx::WithdrawWithheldTokensFromAccounts(acc) => { - ConfidentialTransferFeeIxProto { - ix_oneof: Some(IxOneof::WithdrawWithheldTokensFromAccountsIx( - ConfidentialWithdrawWithheldTokensFromAccountsIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - - ConfidentaltransferFeeIx::HarvestWithheldTokensToMint(acc) => { - ConfidentialTransferFeeIxProto { - ix_oneof: Some(IxOneof::HarvestWithheldTokensToMintIx( - ConfidentialHarvestWithheldTokensToMintIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - - ConfidentaltransferFeeIx::EnableHarvestToMint(acc) => { - ConfidentialTransferFeeIxProto { - ix_oneof: Some(IxOneof::EnableHarvestToMintIx( - EnableHarvestToMintIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - - ConfidentaltransferFeeIx::DisableHarvestToMint(acc) => { - ConfidentialTransferFeeIxProto { - ix_oneof: Some(IxOneof::DisableHarvestToMintIx( - DisableHarvestToMintIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - } - } - } -} diff --git a/crates/parser/src/token_extension_program/extensions/token_group.rs b/crates/parser/src/token_extension_program/extensions/token_group.rs deleted file mode 100644 index 34860398..00000000 --- a/crates/parser/src/token_extension_program/extensions/token_group.rs +++ /dev/null @@ -1,230 +0,0 @@ -use spl_token_group_interface::instruction::{ - InitializeGroup, InitializeMember, TokenGroupInstruction, UpdateGroupAuthority, - UpdateGroupMaxSize, -}; -use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; - -use super::helpers::ExtensionIxParser; -use crate::{helpers::check_min_accounts_req, Result, ResultExt}; - -#[derive(Debug, Clone, Copy)] -pub struct InitializeGroupAccounts { - pub group: Pubkey, - pub mint: Pubkey, - pub mint_authority: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct UpdateGroupMaxSizeAccounts { - pub group: Pubkey, - pub update_authority: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct UpdateGroupAuthorityAccounts { - pub group: Pubkey, - pub current_authority: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeMemberAccounts { - pub member: Pubkey, - pub member_mint: Pubkey, - pub member_mint_authority: Pubkey, - pub group: Pubkey, - pub group_update_authority: Pubkey, -} -#[derive(Debug, Clone, Copy)] -pub enum TokenGroupIx { - InitializeGroup(InitializeGroupAccounts, InitializeGroup), - UpdateGroupMaxSize(UpdateGroupMaxSizeAccounts, UpdateGroupMaxSize), - UpdateGroupAuthority(UpdateGroupAuthorityAccounts, UpdateGroupAuthority), - InitializeMember(InitializeMemberAccounts, InitializeMember), -} - -impl ExtensionIxParser for TokenGroupIx { - fn try_parse_extension_ix(ix: &InstructionUpdate) -> Result { - let accounts_len = ix.accounts.len(); - - let ix_type = TokenGroupInstruction::unpack(&ix.data) - .parse_err("Error unpacking token group instruction data")?; - - match ix_type { - TokenGroupInstruction::InitializeGroup(data) => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenGroupIx::InitializeGroup( - InitializeGroupAccounts { - group: ix.accounts[0], - mint: ix.accounts[1], - mint_authority: ix.accounts[2], - }, - data, - )) - }, - TokenGroupInstruction::UpdateGroupMaxSize(data) => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TokenGroupIx::UpdateGroupMaxSize( - UpdateGroupMaxSizeAccounts { - group: ix.accounts[0], - update_authority: ix.accounts[1], - }, - data, - )) - }, - - TokenGroupInstruction::UpdateGroupAuthority(data) => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TokenGroupIx::UpdateGroupAuthority( - UpdateGroupAuthorityAccounts { - group: ix.accounts[0], - current_authority: ix.accounts[1], - }, - data, - )) - }, - - TokenGroupInstruction::InitializeMember(data) => { - check_min_accounts_req(accounts_len, 5)?; - Ok(TokenGroupIx::InitializeMember( - InitializeMemberAccounts { - member: ix.accounts[0], - member_mint: ix.accounts[1], - member_mint_authority: ix.accounts[2], - group: ix.accounts[3], - group_update_authority: ix.accounts[4], - }, - data, - )) - }, - } - } -} - -#[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_proto::parser::token_extensions::{ - token_group_ix_proto, InitializeGroupAccountsProto, InitializeGroupDataProto, - InitializeGroupIxProto, InitializeMemberAccountsProto, InitializeMemberIxProto, - TokenGroupIxProto, UpdateGroupAuthorityAccountsProto, UpdateGroupAuthorityDataProto, - UpdateGroupAuthorityIxProto, UpdateGroupMaxSizeAccountsProto, UpdateGroupMaxSizeDataProto, - UpdateGroupMaxSizeIxProto, - }; - - use super::{ - InitializeGroupAccounts, InitializeMemberAccounts, TokenGroupIx, - UpdateGroupAuthorityAccounts, UpdateGroupMaxSizeAccounts, - }; - use crate::helpers::IntoProto; - - impl IntoProto for InitializeGroupAccounts { - fn into_proto(self) -> InitializeGroupAccountsProto { - InitializeGroupAccountsProto { - group: self.group.to_string(), - mint: self.mint.to_string(), - mint_authority: self.mint_authority.to_string(), - } - } - } - - impl IntoProto for UpdateGroupMaxSizeAccounts { - fn into_proto(self) -> UpdateGroupMaxSizeAccountsProto { - UpdateGroupMaxSizeAccountsProto { - group: self.group.to_string(), - update_authority: self.update_authority.to_string(), - } - } - } - - impl IntoProto for UpdateGroupAuthorityAccounts { - fn into_proto(self) -> UpdateGroupAuthorityAccountsProto { - UpdateGroupAuthorityAccountsProto { - group: self.group.to_string(), - current_authority: self.current_authority.to_string(), - } - } - } - - impl IntoProto for InitializeMemberAccounts { - fn into_proto(self) -> InitializeMemberAccountsProto { - InitializeMemberAccountsProto { - member: self.member.to_string(), - member_mint: self.member_mint.to_string(), - member_mint_authority: self.member_mint_authority.to_string(), - group: self.group.to_string(), - group_update_authority: self.group_update_authority.to_string(), - } - } - } - - impl IntoProto - for spl_token_group_interface::instruction::InitializeGroup - { - fn into_proto(self) -> InitializeGroupDataProto { - InitializeGroupDataProto { - update_authority: Some(self.update_authority.0.to_string()), - max_size: Into::::into(self.max_size), - } - } - } - - impl IntoProto - for spl_token_group_interface::instruction::UpdateGroupMaxSize - { - fn into_proto(self) -> UpdateGroupMaxSizeDataProto { - UpdateGroupMaxSizeDataProto { - max_size: Into::::into(self.max_size), - } - } - } - - impl IntoProto - for spl_token_group_interface::instruction::UpdateGroupAuthority - { - fn into_proto(self) -> UpdateGroupAuthorityDataProto { - UpdateGroupAuthorityDataProto { - new_authority: self.new_authority.0.to_string(), - } - } - } - - impl IntoProto for TokenGroupIx { - fn into_proto(self) -> TokenGroupIxProto { - match self { - TokenGroupIx::InitializeGroup(acc, data) => TokenGroupIxProto { - ix_oneof: Some(token_group_ix_proto::IxOneof::InitializeGroupIx( - InitializeGroupIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - - TokenGroupIx::UpdateGroupMaxSize(acc, data) => TokenGroupIxProto { - ix_oneof: Some(token_group_ix_proto::IxOneof::UpdateGroupMaxSizeIx( - UpdateGroupMaxSizeIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - - TokenGroupIx::UpdateGroupAuthority(acc, data) => TokenGroupIxProto { - ix_oneof: Some(token_group_ix_proto::IxOneof::UpdateGroupAuthorityIx( - UpdateGroupAuthorityIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - - TokenGroupIx::InitializeMember(acc, _) => TokenGroupIxProto { - ix_oneof: Some(token_group_ix_proto::IxOneof::InitializeMemberIx( - InitializeMemberIxProto { - accounts: Some(acc.into_proto()), - }, - )), - }, - } - } - } -} diff --git a/crates/parser/src/token_extension_program/extensions/token_metadata.rs b/crates/parser/src/token_extension_program/extensions/token_metadata.rs deleted file mode 100644 index fe685170..00000000 --- a/crates/parser/src/token_extension_program/extensions/token_metadata.rs +++ /dev/null @@ -1,278 +0,0 @@ -use spl_token_metadata_interface::instruction::{ - Emit, Initialize, RemoveKey, TokenMetadataInstruction, UpdateAuthority, UpdateField, -}; -use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; - -use super::helpers::ExtensionIxParser; -use crate::{helpers::check_min_accounts_req, Result, ResultExt}; - -#[derive(Debug, Clone, Copy)] -pub struct InitializeAccounts { - pub metadata: Pubkey, - pub update_authority: Pubkey, - pub mint: Pubkey, - pub mint_authority: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct UpdateFieldAccounts { - pub metadata: Pubkey, - pub update_authority: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct RmoveKeyAccounts { - pub metadata: Pubkey, - pub update_authority: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct UpdateAuthorityAccounts { - pub metadata: Pubkey, - pub current_update_authority: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct EmitAccounts { - pub metadata: Pubkey, -} - -#[derive(Debug)] -pub enum TokenMetadataIx { - Initialize(InitializeAccounts, Initialize), - UpdateField(UpdateFieldAccounts, UpdateField), - RemoveKey(RmoveKeyAccounts, RemoveKey), - UpdateAuthority(UpdateAuthorityAccounts, UpdateAuthority), - Emit(EmitAccounts, Emit), -} - -impl ExtensionIxParser for TokenMetadataIx { - fn try_parse_extension_ix(ix: &InstructionUpdate) -> Result { - let accounts_len = ix.accounts.len(); - - let ix_type = TokenMetadataInstruction::unpack(&ix.data) - .parse_err("Error unpacking token metadata instruction data")?; - - match ix_type { - TokenMetadataInstruction::Initialize(data) => { - check_min_accounts_req(accounts_len, 4)?; - - Ok(TokenMetadataIx::Initialize( - InitializeAccounts { - metadata: ix.accounts[0], - update_authority: ix.accounts[1], - mint: ix.accounts[2], - mint_authority: ix.accounts[3], - }, - data, - )) - }, - TokenMetadataInstruction::UpdateField(data) => { - check_min_accounts_req(accounts_len, 2)?; - - Ok(TokenMetadataIx::UpdateField( - UpdateFieldAccounts { - metadata: ix.accounts[0], - update_authority: ix.accounts[1], - }, - data, - )) - }, - - TokenMetadataInstruction::RemoveKey(data) => { - check_min_accounts_req(accounts_len, 2)?; - - Ok(TokenMetadataIx::RemoveKey( - RmoveKeyAccounts { - metadata: ix.accounts[0], - update_authority: ix.accounts[1], - }, - data, - )) - }, - - TokenMetadataInstruction::UpdateAuthority(data) => { - check_min_accounts_req(accounts_len, 2)?; - - Ok(TokenMetadataIx::UpdateAuthority( - UpdateAuthorityAccounts { - metadata: ix.accounts[0], - current_update_authority: ix.accounts[1], - }, - data, - )) - }, - - TokenMetadataInstruction::Emit(data) => { - check_min_accounts_req(accounts_len, 1)?; - - Ok(TokenMetadataIx::Emit( - EmitAccounts { - metadata: ix.accounts[0], - }, - data, - )) - }, - } - } -} - -#[cfg(feature = "proto")] -mod proto_parser { - use token_metadata_ix_proto::IxOneof; - use yellowstone_vixen_proto::parser::token_extensions::{ - token_metadata_ix_proto, EmitAccountsProto, EmitDataProto, EmitIxProto, - InitializeAccountsProto, InitializeDataProto, InitializeIxProto, RemoveKeyDataProto, - RemoveKeyIxProto, RmoveKeyAccountsProto, TokenMetadataIxProto, - UpdateAuthorityAccountsProto, UpdateAuthorityDataProto, UpdateAuthorityIxProto, - UpdateFieldAccountsProto, UpdateFieldDataProto, UpdateFieldIxProto, - }; - - use super::{ - EmitAccounts, InitializeAccounts, RmoveKeyAccounts, TokenMetadataIx, - UpdateAuthorityAccounts, UpdateFieldAccounts, - }; - use crate::helpers::IntoProto; - - impl IntoProto for InitializeAccounts { - fn into_proto(self) -> InitializeAccountsProto { - InitializeAccountsProto { - metadata: self.metadata.to_string(), - update_authority: self.update_authority.to_string(), - mint: self.mint.to_string(), - mint_authority: self.mint_authority.to_string(), - } - } - } - - impl IntoProto for UpdateFieldAccounts { - fn into_proto(self) -> UpdateFieldAccountsProto { - UpdateFieldAccountsProto { - metadata: self.metadata.to_string(), - update_authority: self.update_authority.to_string(), - } - } - } - - impl IntoProto for RmoveKeyAccounts { - fn into_proto(self) -> RmoveKeyAccountsProto { - RmoveKeyAccountsProto { - metadata: self.metadata.to_string(), - update_authority: self.update_authority.to_string(), - } - } - } - - impl IntoProto for UpdateAuthorityAccounts { - fn into_proto(self) -> UpdateAuthorityAccountsProto { - UpdateAuthorityAccountsProto { - metadata: self.metadata.to_string(), - current_update_authority: self.current_update_authority.to_string(), - } - } - } - - impl IntoProto for EmitAccounts { - fn into_proto(self) -> EmitAccountsProto { - EmitAccountsProto { - metadata: self.metadata.to_string(), - } - } - } - - impl IntoProto for spl_token_metadata_interface::instruction::Initialize { - fn into_proto(self) -> InitializeDataProto { - InitializeDataProto { - name: self.name, - symbol: self.symbol, - uri: self.uri, - } - } - } - - fn from_field_to_string(field: spl_token_metadata_interface::state::Field) -> String { - match field { - spl_token_metadata_interface::state::Field::Name => "Name".to_string(), - spl_token_metadata_interface::state::Field::Symbol => "Symbol".to_string(), - spl_token_metadata_interface::state::Field::Uri => "Uri".to_string(), - spl_token_metadata_interface::state::Field::Key(key) => key, - } - } - - impl IntoProto for spl_token_metadata_interface::instruction::UpdateField { - fn into_proto(self) -> UpdateFieldDataProto { - UpdateFieldDataProto { - key: from_field_to_string(self.field), - value: self.value, - } - } - } - - impl IntoProto for spl_token_metadata_interface::instruction::RemoveKey { - fn into_proto(self) -> RemoveKeyDataProto { - RemoveKeyDataProto { - idempotent: self.idempotent, - key: self.key, - } - } - } - - impl IntoProto - for spl_token_metadata_interface::instruction::UpdateAuthority - { - fn into_proto(self) -> UpdateAuthorityDataProto { - UpdateAuthorityDataProto { - new_authority: self.new_authority.0.to_string(), - } - } - } - - impl IntoProto for spl_token_metadata_interface::instruction::Emit { - fn into_proto(self) -> EmitDataProto { - EmitDataProto { - start: self.start, - end: self.end, - } - } - } - - impl IntoProto for TokenMetadataIx { - fn into_proto(self) -> TokenMetadataIxProto { - match self { - TokenMetadataIx::Initialize(acc, data) => TokenMetadataIxProto { - ix_oneof: Some(IxOneof::InitializeIx(InitializeIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - TokenMetadataIx::UpdateField(acc, data) => TokenMetadataIxProto { - ix_oneof: Some(IxOneof::UpdateFieldsIx(UpdateFieldIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenMetadataIx::RemoveKey(acc, data) => TokenMetadataIxProto { - ix_oneof: Some(IxOneof::RemoveKeyIx(RemoveKeyIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenMetadataIx::UpdateAuthority(acc, data) => TokenMetadataIxProto { - ix_oneof: Some(IxOneof::UpdateAuthorityIx(UpdateAuthorityIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenMetadataIx::Emit(acc, data) => TokenMetadataIxProto { - ix_oneof: Some(IxOneof::EmitIx(EmitIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - } - } - } -} diff --git a/crates/parser/src/token_extension_program/extensions/transfer_fee.rs b/crates/parser/src/token_extension_program/extensions/transfer_fee.rs deleted file mode 100644 index 1692ba92..00000000 --- a/crates/parser/src/token_extension_program/extensions/transfer_fee.rs +++ /dev/null @@ -1,408 +0,0 @@ -use spl_token_2022::extension::transfer_fee::instruction::TransferFeeInstruction; -use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; - -use super::helpers::ExtensionIxParser; -use crate::{ - helpers::{check_min_accounts_req, into_vixen_pubkey}, - Result, ResultExt, -}; - -#[derive(Debug)] -pub struct TransferCheckedWithFeeAccounts { - pub source: Pubkey, - pub mint: Pubkey, - pub destination: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} -#[derive(Debug, Clone, Copy)] -pub struct TransferCheckedWithFeeData { - pub amount: u64, - pub fee_amount: u64, - pub decimals: u8, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeTransferFeeConfigAccounts { - pub mint: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeTransferFeeConfigData { - pub transfer_fee_config_authority: Option, - pub withdraw_withheld_authority: Option, - pub transfer_fee_basis_points: u16, - pub maximum_fee: u64, -} - -#[derive(Debug)] -pub struct WithdrawWithheldTokensFromMintAccounts { - pub mint: Pubkey, - pub fee_recipient: Pubkey, - pub withdraw_withheld_authority: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] -pub struct WithdrawWithheldTokensFromAccountsAccounts { - pub mint: Pubkey, - pub fee_recipient: Pubkey, - pub withdraw_withheld_authority: Pubkey, - pub source_accounts: Vec, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct WithdrawWithheldTokensFromAccountsData { - pub num_token_accounts: u8, -} - -#[derive(Debug)] - -pub struct SetTransferFeeAccounts { - pub mint: Pubkey, - pub mint_fee_acc_owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] - -pub struct SetTransferFeeData { - pub transfer_fee_basis_points: u16, - pub maximum_fee: u64, -} - -#[derive(Debug, Clone, Copy)] -pub struct HarvestWithheldTokensToMintAccounts { - pub mint: Pubkey, - pub mint_fee_acc_owner: Pubkey, -} - -#[derive(Debug)] -pub enum TransferFeeIx { - TransferCheckedWithFee(TransferCheckedWithFeeAccounts, TransferCheckedWithFeeData), - InitializeTransferFeeConfig( - InitializeTransferFeeConfigAccounts, - InitializeTransferFeeConfigData, - ), - WithdrawWithheldTokensFromMint(WithdrawWithheldTokensFromMintAccounts), - - WithdrawWithheldTokensFromAccounts( - WithdrawWithheldTokensFromAccountsAccounts, - WithdrawWithheldTokensFromAccountsData, - ), - - HarvestWithheldTokensToMint(HarvestWithheldTokensToMintAccounts), - - SetTransferFee(SetTransferFeeAccounts, SetTransferFeeData), -} - -impl ExtensionIxParser for TransferFeeIx { - #[allow(clippy::too_many_lines)] - fn try_parse_extension_ix(ix: &InstructionUpdate) -> Result { - let accounts_len = ix.accounts.len(); - let ix_type = TransferFeeInstruction::unpack(&ix.data[1..]) - .parse_err("Error unpacking transfer fee instruction data")?; - match ix_type { - TransferFeeInstruction::TransferCheckedWithFee { - amount, - decimals, - fee, - } => { - check_min_accounts_req(accounts_len, 4)?; - Ok(TransferFeeIx::TransferCheckedWithFee( - TransferCheckedWithFeeAccounts { - source: ix.accounts[0], - mint: ix.accounts[1], - destination: ix.accounts[2], - owner: ix.accounts[3], - multisig_signers: ix.accounts[4..].to_vec(), - }, - TransferCheckedWithFeeData { - amount, - fee_amount: fee, - decimals, - }, - )) - }, - - TransferFeeInstruction::InitializeTransferFeeConfig { - transfer_fee_config_authority, - withdraw_withheld_authority, - transfer_fee_basis_points, - maximum_fee, - } => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TransferFeeIx::InitializeTransferFeeConfig( - InitializeTransferFeeConfigAccounts { - mint: ix.accounts[0], - }, - InitializeTransferFeeConfigData { - transfer_fee_config_authority: transfer_fee_config_authority - .map(into_vixen_pubkey) - .into(), - withdraw_withheld_authority: withdraw_withheld_authority - .map(into_vixen_pubkey) - .into(), - transfer_fee_basis_points, - maximum_fee, - }, - )) - }, - - TransferFeeInstruction::WithdrawWithheldTokensFromMint => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TransferFeeIx::WithdrawWithheldTokensFromMint( - WithdrawWithheldTokensFromMintAccounts { - mint: ix.accounts[0], - fee_recipient: ix.accounts[1], - withdraw_withheld_authority: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - }, - )) - }, - - TransferFeeInstruction::WithdrawWithheldTokensFromAccounts { num_token_accounts } => { - check_min_accounts_req(accounts_len, 3 + num_token_accounts as usize)?; - Ok(TransferFeeIx::WithdrawWithheldTokensFromAccounts( - WithdrawWithheldTokensFromAccountsAccounts { - mint: ix.accounts[0], - fee_recipient: ix.accounts[1], - withdraw_withheld_authority: ix.accounts[2], - source_accounts: ix.accounts[3..(3 + num_token_accounts) as usize].to_vec(), - multisig_signers: ix.accounts[(3 + num_token_accounts as usize)..].to_vec(), - }, - WithdrawWithheldTokensFromAccountsData { num_token_accounts }, - )) - }, - - TransferFeeInstruction::HarvestWithheldTokensToMint => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TransferFeeIx::HarvestWithheldTokensToMint( - HarvestWithheldTokensToMintAccounts { - mint: ix.accounts[0], - mint_fee_acc_owner: ix.accounts[1], - }, - )) - }, - - TransferFeeInstruction::SetTransferFee { - transfer_fee_basis_points, - maximum_fee, - } => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TransferFeeIx::SetTransferFee( - SetTransferFeeAccounts { - mint: ix.accounts[0], - mint_fee_acc_owner: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }, - SetTransferFeeData { - transfer_fee_basis_points, - maximum_fee, - }, - )) - }, - } - } -} - -#[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_proto::parser::token_extensions::{ - transfer_fee_ix_proto, HarvestWithheldTokensToMintAccountsProto, - HarvestWithheldTokensToMintIxProto, InitializeTransferFeeConfigAccountsProto, - InitializeTransferFeeConfigDataProto, InitializeTransferFeeConfigIxProto, - SetTransferFeeAccountsProto, SetTransferFeeDataProto, SetTransferFeeIxProto, - TransferCheckedWithFeeAccountsProto, TransferCheckedWithFeeDataProto, - TransferCheckedWithFeeIxProto, TransferFeeIxProto, - WithdrawWithheldTokensFromAccountsAccountsProto, - WithdrawWithheldTokensFromAccountsDataProto, WithdrawWithheldTokensFromAccountsIxProto, - WithdrawWithheldTokensFromMintAccountsProto, WithdrawWithheldTokensFromMintIxProto, - }; - - use super::{ - HarvestWithheldTokensToMintAccounts, InitializeTransferFeeConfigAccounts, - InitializeTransferFeeConfigData, SetTransferFeeAccounts, SetTransferFeeData, - TransferCheckedWithFeeAccounts, TransferCheckedWithFeeData, TransferFeeIx, - WithdrawWithheldTokensFromAccountsAccounts, WithdrawWithheldTokensFromAccountsData, - WithdrawWithheldTokensFromMintAccounts, - }; - use crate::helpers::{ - proto::{FromOptPubkeyToOptString, FromVecPubkeyToVecString}, - IntoProto, - }; - - impl IntoProto for InitializeTransferFeeConfigAccounts { - fn into_proto(self) -> InitializeTransferFeeConfigAccountsProto { - InitializeTransferFeeConfigAccountsProto { - mint: self.mint.to_string(), - } - } - } - - impl IntoProto for TransferCheckedWithFeeAccounts { - fn into_proto(self) -> TransferCheckedWithFeeAccountsProto { - TransferCheckedWithFeeAccountsProto { - source: self.source.to_string(), - mint: self.mint.to_string(), - destination: self.destination.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto - for WithdrawWithheldTokensFromMintAccounts - { - fn into_proto(self) -> WithdrawWithheldTokensFromMintAccountsProto { - WithdrawWithheldTokensFromMintAccountsProto { - mint: self.mint.to_string(), - fee_recipient: self.fee_recipient.to_string(), - withdraw_withheld_authority: self.withdraw_withheld_authority.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto - for WithdrawWithheldTokensFromAccountsAccounts - { - fn into_proto(self) -> WithdrawWithheldTokensFromAccountsAccountsProto { - WithdrawWithheldTokensFromAccountsAccountsProto { - mint: self.mint.to_string(), - fee_recipient: self.fee_recipient.to_string(), - withdraw_withheld_authority: self.withdraw_withheld_authority.to_string(), - source_accounts: self.source_accounts.to_string_vec(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for SetTransferFeeAccounts { - fn into_proto(self) -> SetTransferFeeAccountsProto { - SetTransferFeeAccountsProto { - mint: self.mint.to_string(), - mint_fee_acc_owner: self.mint_fee_acc_owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for TransferCheckedWithFeeData { - fn into_proto(self) -> TransferCheckedWithFeeDataProto { - TransferCheckedWithFeeDataProto { - amount: self.amount, - fee_amount: self.fee_amount, - decimals: self.decimals.into(), - } - } - } - - impl IntoProto for InitializeTransferFeeConfigData { - fn into_proto(self) -> InitializeTransferFeeConfigDataProto { - InitializeTransferFeeConfigDataProto { - transfer_fee_config_authority: self.transfer_fee_config_authority.to_opt_string(), - withdraw_withheld_authority: self.withdraw_withheld_authority.to_opt_string(), - transfer_fee_basis_points: self.transfer_fee_basis_points.into(), - maximum_fee: self.maximum_fee, - } - } - } - - impl IntoProto - for WithdrawWithheldTokensFromAccountsData - { - fn into_proto(self) -> WithdrawWithheldTokensFromAccountsDataProto { - WithdrawWithheldTokensFromAccountsDataProto { - num_token_accounts: self.num_token_accounts.into(), - } - } - } - - impl IntoProto for SetTransferFeeData { - fn into_proto(self) -> SetTransferFeeDataProto { - SetTransferFeeDataProto { - transfer_fee_basis_points: self.transfer_fee_basis_points.into(), - maximum_fee: self.maximum_fee, - } - } - } - - impl IntoProto for HarvestWithheldTokensToMintAccounts { - fn into_proto(self) -> HarvestWithheldTokensToMintAccountsProto { - HarvestWithheldTokensToMintAccountsProto { - mint: self.mint.to_string(), - mint_fee_owner: self.mint_fee_acc_owner.to_string(), - } - } - } - - impl IntoProto for TransferFeeIx { - fn into_proto(self) -> TransferFeeIxProto { - match self { - TransferFeeIx::InitializeTransferFeeConfig(acc, data) => TransferFeeIxProto { - ix_oneof: Some( - transfer_fee_ix_proto::IxOneof::InitializeTransferFeeConfigIx( - InitializeTransferFeeConfigIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - }, - TransferFeeIx::TransferCheckedWithFee(acc, data) => TransferFeeIxProto { - ix_oneof: Some(transfer_fee_ix_proto::IxOneof::TransferCheckedWithFeeIx( - TransferCheckedWithFeeIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - - TransferFeeIx::WithdrawWithheldTokensFromMint(acc) => TransferFeeIxProto { - ix_oneof: Some( - transfer_fee_ix_proto::IxOneof::WithdrawWithheldTokensFromMintIx( - WithdrawWithheldTokensFromMintIxProto { - accounts: Some(acc.into_proto()), - }, - ), - ), - }, - - TransferFeeIx::WithdrawWithheldTokensFromAccounts(acc, data) => { - TransferFeeIxProto { - ix_oneof: Some( - transfer_fee_ix_proto::IxOneof::WithdrawWithheldTokensFromAccountsIx( - WithdrawWithheldTokensFromAccountsIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - ), - ), - } - }, - - TransferFeeIx::HarvestWithheldTokensToMint(acc) => TransferFeeIxProto { - ix_oneof: Some( - transfer_fee_ix_proto::IxOneof::HarvestWithheldTokensToMintIx( - HarvestWithheldTokensToMintIxProto { - accounts: Some(acc.into_proto()), - }, - ), - ), - }, - - TransferFeeIx::SetTransferFee(acc, data) => TransferFeeIxProto { - ix_oneof: Some(transfer_fee_ix_proto::IxOneof::SetTransferFeeIx( - SetTransferFeeIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - } - } - } -} diff --git a/crates/parser/src/token_extension_program/instruction_helpers.rs b/crates/parser/src/token_extension_program/instruction_helpers.rs deleted file mode 100644 index 4f1edf67..00000000 --- a/crates/parser/src/token_extension_program/instruction_helpers.rs +++ /dev/null @@ -1,359 +0,0 @@ -use spl_token_2022::{extension::ExtensionType, instruction::AuthorityType}; -use yellowstone_vixen_core::Pubkey; - -use super::extensions::{ - CommonExtensionIxs, ConfidentaltransferFeeIx, ConfidentaltransferIx, TokenGroupIx, - TokenMetadataIx, TransferFeeIx, -}; -use crate::token_program::{SetAuthorityAccounts, TokenProgramIx}; - -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum TokenExtensionProgramIx { - TokenProgramIx(TokenProgramIx), - SetAuthority(SetAuthorityAccounts, SetAuthorityData), - CreateNativeMint(CreateNativeMintAccounts), - InitializeMintCloseAuthority( - InitializeMintCloseAuthorityAccounts, - InitializeMintCloseAuthorityData, - ), - InitializeNonTransferableMint(InitializeNonTransferableMintAccounts), - Reallocate(ReallocateAccounts, ReallocateData), - InitializePermanentDelegate( - InitializePermanentDelegateAccounts, - InitializePermanentDelegateData, - ), - WithdrawExcessLamports(WithdrawExcessLamportsAccounts), - TransferFeeIx(TransferFeeIx), - ConfidentialTransferIx(ConfidentaltransferIx), - ConfidentialtransferFeeIx(ConfidentaltransferFeeIx), - CpiGuardIx(CommonExtensionIxs), - DefaultAccountStateIx(CommonExtensionIxs), - GroupMemberPointerIx(CommonExtensionIxs), - GroupPointerIx(CommonExtensionIxs), - InterestBearingMintIx(CommonExtensionIxs), - MemoTransferIx(CommonExtensionIxs), - MetadataPointerIx(CommonExtensionIxs), - TransferHookIx(CommonExtensionIxs), - TokenMetadataIx(TokenMetadataIx), - TokenGroupIx(TokenGroupIx), -} - -#[derive(Debug, Clone, Copy)] -pub struct CreateNativeMintAccounts { - pub mint: Pubkey, - pub funding_account: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeMintCloseAuthorityAccounts { - pub mint: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeMintCloseAuthorityData { - pub close_authority: Option, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeNonTransferableMintAccounts { - pub mint: Pubkey, -} - -#[derive(Debug)] -pub struct ReallocateAccounts { - pub account: Pubkey, - pub payer: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug)] -pub struct ReallocateData { - pub extension_types: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializePermanentDelegateAccounts { - pub account: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializePermanentDelegateData { - pub delegate: Pubkey, -} - -#[derive(Debug)] -pub struct WithdrawExcessLamportsAccounts { - pub source_account: Pubkey, - pub destination_account: Pubkey, - pub authority: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone)] -pub struct SetAuthorityData { - pub authority_type: AuthorityType, - pub new_authority: Option, -} - -#[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_proto::parser::{ - token::{SetAuthorityDataProto, SetAuthorityIxProto}, - token_extensions::{ - program_ixs::IxOneof, CpiGuardIxProto, CreateNativeMintAccountsProto, - CreateNativeMintIxProto, DefaultAccountStateIxProto, GroupMemberPointerIxProto, - GroupPointerIxProto, InitializeMintCloseAuthorityAccountsProto, - InitializeMintCloseAuthorityDataProto, InitializeMintCloseAuthorityIxProto, - InitializeNonTransferableMintAccountsProto, InitializeNonTransferableMintIxProto, - InitializePermanentDelegateAccountsProto, InitializePermanentDelegateDataProto, - InitializePermanentDelegateIxProto, InterestBearingMintIxProto, MemoTransferIxProto, - MetadataPointerIxProto, ProgramIxs as TokenExtensionProgramIxProto, - ReallocateAccountsProto, ReallocateDataProto, ReallocateIxProto, TransferHookIxProto, - WithdrawExcessLamportsAccountsProto, WithdrawExcessLamportsIxProto, - }, - }; - - use super::{ - CreateNativeMintAccounts, InitializeMintCloseAuthorityAccounts, - InitializeMintCloseAuthorityData, InitializeNonTransferableMintAccounts, - InitializePermanentDelegateAccounts, InitializePermanentDelegateData, ReallocateAccounts, - ReallocateData, SetAuthorityData, TokenExtensionProgramIx, WithdrawExcessLamportsAccounts, - }; - use crate::helpers::{ - proto::{FromOptPubkeyToOptString, FromVecPubkeyToVecString}, - IntoProto, - }; - - impl IntoProto for WithdrawExcessLamportsAccounts { - fn into_proto(self) -> WithdrawExcessLamportsAccountsProto { - WithdrawExcessLamportsAccountsProto { - source_account: self.source_account.to_string(), - destination_account: self.destination_account.to_string(), - authority: self.authority.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for InitializePermanentDelegateAccounts { - fn into_proto(self) -> InitializePermanentDelegateAccountsProto { - InitializePermanentDelegateAccountsProto { - account: self.account.to_string(), - } - } - } - - impl IntoProto for InitializePermanentDelegateData { - fn into_proto(self) -> InitializePermanentDelegateDataProto { - InitializePermanentDelegateDataProto { - delegate: self.delegate.to_string(), - } - } - } - - impl IntoProto for ReallocateAccounts { - fn into_proto(self) -> ReallocateAccountsProto { - ReallocateAccountsProto { - account: self.account.to_string(), - payer_account: self.payer.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for ReallocateData { - fn into_proto(self) -> ReallocateDataProto { - ReallocateDataProto { - extensions_types: self.extension_types.iter().map(|e| *e as i32).collect(), - } - } - } - - impl IntoProto - for InitializeNonTransferableMintAccounts - { - fn into_proto(self) -> InitializeNonTransferableMintAccountsProto { - InitializeNonTransferableMintAccountsProto { - mint: self.mint.to_string(), - } - } - } - - impl IntoProto for InitializeMintCloseAuthorityAccounts { - fn into_proto(self) -> InitializeMintCloseAuthorityAccountsProto { - InitializeMintCloseAuthorityAccountsProto { - mint: self.mint.to_string(), - } - } - } - - impl IntoProto for InitializeMintCloseAuthorityData { - fn into_proto(self) -> InitializeMintCloseAuthorityDataProto { - InitializeMintCloseAuthorityDataProto { - close_authority: self.close_authority.to_opt_string(), - } - } - } - - impl IntoProto for CreateNativeMintAccounts { - fn into_proto(self) -> CreateNativeMintAccountsProto { - CreateNativeMintAccountsProto { - mint: self.mint.to_string(), - funding_account: self.funding_account.to_string(), - } - } - } - - impl IntoProto for SetAuthorityData { - fn into_proto(self) -> SetAuthorityDataProto { - SetAuthorityDataProto { - authority_type: self.authority_type as i32, - new_authority: self.new_authority.to_opt_string(), - } - } - } - - impl IntoProto for TokenExtensionProgramIx { - #[allow(clippy::too_many_lines)] - fn into_proto(self) -> TokenExtensionProgramIxProto { - match self { - TokenExtensionProgramIx::TransferFeeIx(acc) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::TransferFeeIx(acc.into_proto())), - }, - TokenExtensionProgramIx::TokenMetadataIx(acc) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::TokenMetadataIx(acc.into_proto())), - }, - TokenExtensionProgramIx::TokenGroupIx(acc) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::TokenGroupIx(acc.into_proto())), - }, - TokenExtensionProgramIx::ConfidentialtransferFeeIx(acc) => { - TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::ConfidentialTransferFeeIx(acc.into_proto())), - } - }, - TokenExtensionProgramIx::CpiGuardIx(acc) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::CpiGuardIx(CpiGuardIxProto { - ix: Some(acc.ix.into_proto()), - })), - }, - TokenExtensionProgramIx::DefaultAccountStateIx(acc) => { - TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::DefaultAccountStateIx( - DefaultAccountStateIxProto { - ix: Some(acc.ix.into_proto()), - }, - )), - } - }, - TokenExtensionProgramIx::GroupMemberPointerIx(acc) => { - TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::GroupMemberPointerIx(GroupMemberPointerIxProto { - ix: Some(acc.ix.into_proto()), - })), - } - }, - TokenExtensionProgramIx::GroupPointerIx(acc) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::GroupPointerIx(GroupPointerIxProto { - ix: Some(acc.ix.into_proto()), - })), - }, - - TokenExtensionProgramIx::InterestBearingMintIx(acc) => { - TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::InterestBearingMintIx( - InterestBearingMintIxProto { - ix: Some(acc.ix.into_proto()), - }, - )), - } - }, - TokenExtensionProgramIx::MemoTransferIx(acc) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::MemoTransferIx(MemoTransferIxProto { - ix: Some(acc.ix.into_proto()), - })), - }, - - TokenExtensionProgramIx::MetadataPointerIx(acc) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::MetadataPointerIx(MetadataPointerIxProto { - ix: Some(acc.ix.into_proto()), - })), - }, - - TokenExtensionProgramIx::TransferHookIx(acc) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::TransferHookIx(TransferHookIxProto { - ix: Some(acc.ix.into_proto()), - })), - }, - TokenExtensionProgramIx::TokenProgramIx(acc) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::TokenProgramIx(acc.into_proto())), - }, - - TokenExtensionProgramIx::CreateNativeMint(acc) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::CreateNativeMintIx(CreateNativeMintIxProto { - accounts: Some(acc.into_proto()), - })), - }, - TokenExtensionProgramIx::InitializeMintCloseAuthority(acc, data) => { - TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::InitializeMintCloseAuthorityIx( - InitializeMintCloseAuthorityIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - TokenExtensionProgramIx::InitializeNonTransferableMint(acc) => { - TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::InitializeNonTransferableMintIx( - InitializeNonTransferableMintIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - TokenExtensionProgramIx::Reallocate(acc, data) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::ReallocateIx(ReallocateIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - TokenExtensionProgramIx::InitializePermanentDelegate(acc, data) => { - TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::InitializePermanentDelegateIx( - InitializePermanentDelegateIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - TokenExtensionProgramIx::WithdrawExcessLamports(acc) => { - TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::WithdrawExcessLamportsIx( - WithdrawExcessLamportsIxProto { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - - TokenExtensionProgramIx::ConfidentialTransferIx(acc) => { - TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::ConfidentialTransferIx(acc.into_proto())), - } - }, - TokenExtensionProgramIx::SetAuthority(acc, data) => TokenExtensionProgramIxProto { - ix_oneof: Some(IxOneof::SetAuthority(SetAuthorityIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - } - } - } -} diff --git a/crates/parser/src/token_extension_program/instruction_parser.rs b/crates/parser/src/token_extension_program/instruction_parser.rs deleted file mode 100644 index 8ccd66a2..00000000 --- a/crates/parser/src/token_extension_program/instruction_parser.rs +++ /dev/null @@ -1,316 +0,0 @@ -use helpers::ExtensionIxParser; -use spl_token_2022::instruction::TokenInstruction; -use spl_token_group_interface::instruction::TokenGroupInstruction; -use spl_token_metadata_interface::instruction::TokenMetadataInstruction; -use yellowstone_vixen_core::{ - instruction::InstructionUpdate, ParseError, ParseResult, Parser, Prefilter, ProgramParser, -}; - -use super::{ - extensions::{ - helpers, CommonExtensionIxs, ConfidentaltransferFeeIx, ConfidentaltransferIx, - ExtensionWithCommonIxs, TokenGroupIx, TokenMetadataIx, TransferFeeIx, - }, - instruction_helpers::{ - CreateNativeMintAccounts, InitializeMintCloseAuthorityAccounts, - InitializeMintCloseAuthorityData, InitializeNonTransferableMintAccounts, - InitializePermanentDelegateAccounts, InitializePermanentDelegateData, ReallocateAccounts, - ReallocateData, TokenExtensionProgramIx, WithdrawExcessLamportsAccounts, - }, - SetAuthorityData, -}; -use crate::{ - helpers::{check_min_accounts_req, into_vixen_pubkey}, - token_program::{InstructionParser as TokenProgramIxParser, SetAuthorityAccounts}, - Error, Result, ResultExt, -}; - -#[derive(Debug, Clone, Copy)] -pub struct InstructionParser; - -impl Parser for InstructionParser { - type Input = InstructionUpdate; - type Output = TokenExtensionProgramIx; - - fn id(&self) -> std::borrow::Cow<'static, str> { "token_extensions::InstructionParser".into() } - - fn prefilter(&self) -> Prefilter { - Prefilter::builder() - .transaction_accounts([spl_token_2022::ID]) - .build() - .unwrap() - } - - async fn parse(&self, ix_update: &InstructionUpdate) -> ParseResult { - if ix_update.program.equals_ref(spl_token_2022::ID) { - InstructionParser::parse_impl(ix_update).map_err(|e| ParseError::Other(e.into())) - } else { - Err(ParseError::Filtered) - } - } -} - -impl ProgramParser for InstructionParser { - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { spl_token_2022::ID.to_bytes().into() } -} - -impl InstructionParser { - #[allow(clippy::too_many_lines)] - fn parse_impl(ix: &InstructionUpdate) -> Result { - let accounts_len = ix.accounts.len(); - let ix = match TokenInstruction::unpack(&ix.data) { - Ok(token_ix) => match token_ix { - TokenInstruction::TransferFeeExtension => { - Ok(TokenExtensionProgramIx::TransferFeeIx( - TransferFeeIx::try_parse_extension_ix(ix)?, - )) - }, - TokenInstruction::ConfidentialTransferExtension => { - Ok(TokenExtensionProgramIx::ConfidentialTransferIx( - ConfidentaltransferIx::try_parse_extension_ix(ix)?, - )) - }, - TokenInstruction::ConfidentialTransferFeeExtension => { - Ok(TokenExtensionProgramIx::ConfidentialtransferFeeIx( - ConfidentaltransferFeeIx::try_parse_extension_ix(ix)?, - )) - }, - TokenInstruction::CpiGuardExtension => Ok(TokenExtensionProgramIx::CpiGuardIx( - CommonExtensionIxs::try_parse_extension_ix( - ExtensionWithCommonIxs::CpiGuard, - ix, - )?, - )), - - TokenInstruction::DefaultAccountStateExtension => { - Ok(TokenExtensionProgramIx::DefaultAccountStateIx( - CommonExtensionIxs::try_parse_extension_ix( - ExtensionWithCommonIxs::DefaultAccountState, - ix, - )?, - )) - }, - TokenInstruction::InterestBearingMintExtension => { - Ok(TokenExtensionProgramIx::InterestBearingMintIx( - CommonExtensionIxs::try_parse_extension_ix( - ExtensionWithCommonIxs::InterestBearingMint, - ix, - )?, - )) - }, - TokenInstruction::MemoTransferExtension => { - Ok(TokenExtensionProgramIx::MemoTransferIx( - CommonExtensionIxs::try_parse_extension_ix( - ExtensionWithCommonIxs::MemoTransfer, - ix, - )?, - )) - }, - - TokenInstruction::GroupMemberPointerExtension => { - Ok(TokenExtensionProgramIx::GroupMemberPointerIx( - CommonExtensionIxs::try_parse_extension_ix( - ExtensionWithCommonIxs::GroupMemberPointer, - ix, - )?, - )) - }, - - TokenInstruction::GroupPointerExtension => { - Ok(TokenExtensionProgramIx::GroupPointerIx( - CommonExtensionIxs::try_parse_extension_ix( - ExtensionWithCommonIxs::GroupPointer, - ix, - )?, - )) - }, - - TokenInstruction::MetadataPointerExtension => { - Ok(TokenExtensionProgramIx::MetadataPointerIx( - CommonExtensionIxs::try_parse_extension_ix( - ExtensionWithCommonIxs::MetadataPointer, - ix, - )?, - )) - }, - - TokenInstruction::TransferHookExtension => { - Ok(TokenExtensionProgramIx::TransferHookIx( - CommonExtensionIxs::try_parse_extension_ix( - ExtensionWithCommonIxs::TransferHook, - ix, - )?, - )) - }, - TokenInstruction::SetAuthority { - authority_type, - new_authority, - } => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TokenExtensionProgramIx::SetAuthority( - SetAuthorityAccounts { - account: ix.accounts[0], - current_authority: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }, - SetAuthorityData { - authority_type, - new_authority: new_authority.map(into_vixen_pubkey).into(), - }, - )) - }, - TokenInstruction::CreateNativeMint => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TokenExtensionProgramIx::CreateNativeMint( - CreateNativeMintAccounts { - funding_account: ix.accounts[0], - mint: ix.accounts[1], - }, - )) - }, - - TokenInstruction::InitializeMintCloseAuthority { close_authority } => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TokenExtensionProgramIx::InitializeMintCloseAuthority( - InitializeMintCloseAuthorityAccounts { - mint: ix.accounts[0], - }, - InitializeMintCloseAuthorityData { - close_authority: close_authority.map(into_vixen_pubkey).into(), - }, - )) - }, - - TokenInstruction::InitializeNonTransferableMint => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TokenExtensionProgramIx::InitializeNonTransferableMint( - InitializeNonTransferableMintAccounts { - mint: ix.accounts[0], - }, - )) - }, - - TokenInstruction::Reallocate { extension_types } => { - check_min_accounts_req(accounts_len, 4)?; - Ok(TokenExtensionProgramIx::Reallocate( - ReallocateAccounts { - account: ix.accounts[0], - payer: ix.accounts[1], - owner: ix.accounts[3], - multisig_signers: ix.accounts[4..].to_vec(), - }, - ReallocateData { extension_types }, - )) - }, - - TokenInstruction::InitializePermanentDelegate { delegate } => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TokenExtensionProgramIx::InitializePermanentDelegate( - InitializePermanentDelegateAccounts { - account: ix.accounts[0], - }, - InitializePermanentDelegateData { - delegate: into_vixen_pubkey(delegate), - }, - )) - }, - - TokenInstruction::WithdrawExcessLamports => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenExtensionProgramIx::WithdrawExcessLamports( - WithdrawExcessLamportsAccounts { - source_account: ix.accounts[0], - destination_account: ix.accounts[1], - authority: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - }, - )) - }, - - _ => Ok(TokenExtensionProgramIx::TokenProgramIx( - TokenProgramIxParser::parse_impl(ix).parse_err( - "Error parsing token extension instruction as token instruction", - )?, - )), - }, - Err(e) => { - if TokenMetadataInstruction::unpack(&ix.data).is_ok() { - return Ok(TokenExtensionProgramIx::TokenMetadataIx( - TokenMetadataIx::try_parse_extension_ix(ix)?, - )); - } - - if TokenGroupInstruction::unpack(&ix.data).is_ok() { - return Ok(TokenExtensionProgramIx::TokenGroupIx( - TokenGroupIx::try_parse_extension_ix(ix)?, - )); - } - - Err(Error::from_inner("Error unpacking instruction data", e)) - }, - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = spl_token_2022::ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = spl_token_2022::ID.to_string(), - ix = "error", - error = ?e - ); - }, - } - - ix - } -} - -#[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - use yellowstone_vixen_proto::parser::token_extensions::ProgramIxs as TokenExtensionProgramIxProto; - - use super::InstructionParser; - use crate::helpers::IntoProto; - - impl ParseProto for InstructionParser { - type Message = TokenExtensionProgramIxProto; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} - -#[cfg(test)] -mod tests { - use std::ops::Mul; - - use yellowstone_vixen_mock::tx_fixture; - - use super::{InstructionParser, Parser, TokenExtensionProgramIx}; - use crate::token_program::TokenProgramIx; - #[tokio::test] - async fn test_mint_to_checked_ix_parsing() { - let parser = InstructionParser; - - let ixs = tx_fixture!("44gWEyKUkeUabtJr4eT3CQEkFGrD4jMdwUV6Ew5MR5K3RGizs9iwbkb5Q4T3gnAaSgHxn3ERQ8g5YTXuLP1FrWnt",&parser); - - let TokenExtensionProgramIx::TokenProgramIx(TokenProgramIx::MintToChecked(_accts, data)) = - &ixs[0] - else { - panic!("Invalid Instruction"); - }; - - assert_eq!(data.decimals, 9); - assert_eq!(data.amount, 100.mul(10u64.pow(data.decimals.into()))); - } -} diff --git a/crates/parser/src/token_program/account_parser.rs b/crates/parser/src/token_program/account_parser.rs deleted file mode 100644 index 9a08ac28..00000000 --- a/crates/parser/src/token_program/account_parser.rs +++ /dev/null @@ -1,177 +0,0 @@ -use std::borrow::Cow; - -use spl_token::{ - solana_program::{program_error::ProgramError, program_pack::Pack}, - state::{Account, Mint, Multisig}, -}; -use yellowstone_vixen_core::{ - AccountUpdate, ParseError, ParseResult, Parser, Prefilter, ProgramParser, -}; - -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum TokenProgramState { - TokenAccount(Account), - Mint(Mint), - Multisig(Multisig), -} - -impl TokenProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> ParseResult { - let acc = match data_bytes.len() { - Mint::LEN => Mint::unpack_from_slice(data_bytes) - .map(Self::Mint) - .map_err(Into::into), - Account::LEN => Account::unpack_from_slice(data_bytes) - .map(Self::TokenAccount) - .map_err(Into::into), - Multisig::LEN => Multisig::unpack_from_slice(data_bytes) - .map(Self::Multisig) - .map_err(Into::into), - _ => return Err(ParseError::Filtered), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = spl_token::ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = spl_token::ID.to_string(), - account = "error", - discriminator = ?data_bytes.len(), - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Clone, Copy)] -pub struct AccountParser; - -impl Parser for AccountParser { - type Input = AccountUpdate; - type Output = TokenProgramState; - - fn id(&self) -> Cow<'static, str> { "token_program::AccountParser".into() } - - fn prefilter(&self) -> Prefilter { - Prefilter::builder() - .account_owners([spl_token::ID]) - .build() - .unwrap() - } - - async fn parse(&self, acct: &AccountUpdate) -> ParseResult { - let inner = acct.account.as_ref().ok_or(ProgramError::InvalidArgument)?; - - TokenProgramState::try_unpack(&inner.data) - } -} - -impl ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { spl_token::ID.to_bytes().into() } -} - -#[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - use yellowstone_vixen_proto::parser::token::{ - program_state as token_program_state_proto, MintProto, MultisigProto, - ProgramState as TokenProgramStateProto, TokenAccountProto, - }; - - use super::{Account, AccountParser, Mint, Multisig, TokenProgramState}; - use crate::helpers::{ - proto::{FromCOptionPubkeyToOptString, FromVecPubkeyToVecString}, - IntoProto, - }; - - impl IntoProto for Account { - fn into_proto(self) -> TokenAccountProto { - TokenAccountProto { - mint: self.mint.to_string(), - owner: self.owner.to_string(), - amount: self.amount, - delegate: self.delegate.to_opt_string(), - state: self.state as i32, - is_native: self.is_native.into(), - delegated_amount: self.delegated_amount, - close_authority: self.close_authority.to_opt_string(), - } - } - } - - impl IntoProto for Mint { - fn into_proto(self) -> MintProto { - MintProto { - mint_authority: self.mint_authority.to_opt_string(), - supply: self.supply, - decimals: self.decimals.into(), - is_initialized: self.is_initialized, - freeze_authority: self.freeze_authority.to_opt_string(), - } - } - } - - impl IntoProto for Multisig { - fn into_proto(self) -> MultisigProto { - MultisigProto { - m: self.m.into(), - n: self.n.into(), - is_initialized: self.is_initialized, - signers: self.signers.to_string_vec(), - } - } - } - - impl ParseProto for AccountParser { - type Message = TokenProgramStateProto; - - fn output_into_message(value: Self::Output) -> Self::Message { - let state_oneof = match value { - TokenProgramState::TokenAccount(data) => Some( - token_program_state_proto::StateOneof::TokenAccount(data.into_proto()), - ), - TokenProgramState::Mint(data) => Some(token_program_state_proto::StateOneof::Mint( - data.into_proto(), - )), - TokenProgramState::Multisig(data) => Some( - token_program_state_proto::StateOneof::Multisig(data.into_proto()), - ), - }; - Self::Message { state_oneof } - } - } -} -#[cfg(test)] -mod tests { - use yellowstone_vixen_mock::{account_fixture, run_account_parse, FixtureData}; - - use super::{AccountParser, Parser, TokenProgramState}; - - #[tokio::test] - async fn test_mint_account_parsing() { - let parser = AccountParser; - - let account = account_fixture!("3SmPYPvZfEmroktLiJsgaNENuPEud3Z52zSfLQ1zJdkK", &parser); - - let TokenProgramState::Mint(mint) = account else { - panic!("Invalid Account"); - }; - - assert_eq!(mint.decimals, 10); - } -} diff --git a/crates/parser/src/token_program/instruction_helpers.rs b/crates/parser/src/token_program/instruction_helpers.rs deleted file mode 100644 index 51750e47..00000000 --- a/crates/parser/src/token_program/instruction_helpers.rs +++ /dev/null @@ -1,795 +0,0 @@ -use spl_token::instruction::AuthorityType; -use yellowstone_vixen_core::Pubkey; - -#[derive(Debug, Clone)] -pub struct TransferAccounts { - pub source: Pubkey, - pub destination: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct TransferCheckedData { - pub amount: u64, - pub decimals: u8, -} - -#[derive(Debug, Clone, Copy)] -pub struct TransferData { - pub amount: u64, -} -#[derive(Debug, Clone, Copy)] -pub struct InitializeMintAccounts { - pub mint: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeMintData { - pub decimals: u8, - pub mint_authority: Pubkey, - pub freeze_authority: Option, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeAccountAccounts { - pub account: Pubkey, - pub mint: Pubkey, - pub owner: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeAccount2Accounts { - pub account: Pubkey, - pub mint: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeAccountData2 { - pub owner: Pubkey, -} - -#[derive(Debug, Clone)] -pub struct InitializeMultisigAccounts { - pub multisig: Pubkey, - pub signers: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeMultisigData { - pub m: u8, -} - -#[derive(Debug, Clone)] -pub struct ApproveAccounts { - pub source: Pubkey, - pub delegate: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct ApproveData { - pub amount: u64, -} - -#[derive(Debug, Clone)] -pub struct RevokeAccounts { - pub source: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone)] -pub struct SetAuthorityAccounts { - pub current_authority: Pubkey, - pub account: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone)] -pub struct SetAuthorityData { - pub authority_type: AuthorityType, - pub new_authority: Option, -} - -#[derive(Debug, Clone)] -pub struct MintToAccounts { - pub mint: Pubkey, - pub account: Pubkey, - pub mint_authority: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct MintToData { - pub amount: u64, -} - -#[derive(Debug, Clone)] -pub struct BurnAccounts { - pub account: Pubkey, - pub mint: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct BurnData { - pub amount: u64, -} - -#[derive(Debug, Clone)] -pub struct CloseAccountAccounts { - pub account: Pubkey, - pub destination: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone)] -pub struct FreezeAccountAccounts { - pub account: Pubkey, - pub mint: Pubkey, - pub mint_freeze_authority: Pubkey, - pub multisig_signers: Vec, -} -#[derive(Debug, Clone)] -pub struct ThawAccountAccounts { - pub account: Pubkey, - pub mint: Pubkey, - pub mint_freeze_authority: Pubkey, - pub multisig_signers: Vec, -} -#[derive(Debug, Clone)] -pub struct TransferCheckedAccounts { - pub source: Pubkey, - pub mint: Pubkey, - pub destination: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone)] -pub struct ApproveCheckedAccounts { - pub source: Pubkey, - pub mint: Pubkey, - pub delegate: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct ApproveCheckedData { - pub amount: u64, - pub decimals: u8, -} - -#[derive(Debug, Clone)] -pub struct MintToCheckedAccounts { - pub mint: Pubkey, - pub account: Pubkey, - pub mint_authority: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct MintToCheckedData { - pub amount: u64, - pub decimals: u8, -} - -#[derive(Debug, Clone)] -pub struct BurnCheckedAccounts { - pub account: Pubkey, - pub mint: Pubkey, - pub owner: Pubkey, - pub multisig_signers: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct BurnCheckedData { - pub amount: u64, - pub decimals: u8, -} - -#[derive(Debug, Clone, Copy)] -pub struct SyncNativeAccounts { - pub account: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct GetAccountDataSizeAccounts { - pub mint: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct InitializeImmutableOwnerAccounts { - pub account: Pubkey, -} -#[derive(Debug, Clone, Copy)] -pub struct AmountToUiAmountAccounts { - pub mint: Pubkey, -} - -#[derive(Debug, Clone, Copy)] -pub struct AmountToUiAmountData { - pub amount: u64, -} - -#[derive(Debug, Clone, Copy)] -pub struct UiAmountToAmountAccounts { - pub mint: Pubkey, -} - -#[derive(Debug, Clone)] -pub struct UiAmountToAmountData { - pub ui_amount: String, -} - -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum TokenProgramIx { - Transfer(TransferAccounts, TransferData), - InitializeMint(InitializeMintAccounts, InitializeMintData), - InitializeAccount(InitializeAccountAccounts), - InitializeAccount2(InitializeAccount2Accounts, InitializeAccountData2), - InitializeAccount3(InitializeAccount2Accounts, InitializeAccountData2), - InitializeMultisig(InitializeMultisigAccounts, InitializeMultisigData), - Approve(ApproveAccounts, ApproveData), - Revoke(RevokeAccounts), - SetAuthority(SetAuthorityAccounts, SetAuthorityData), - MintTo(MintToAccounts, MintToData), - Burn(BurnAccounts, BurnData), - CloseAccount(CloseAccountAccounts), - FreezeAccount(FreezeAccountAccounts), - ThawAccount(ThawAccountAccounts), - TransferChecked(TransferCheckedAccounts, TransferCheckedData), - ApproveChecked(ApproveCheckedAccounts, ApproveCheckedData), - MintToChecked(MintToCheckedAccounts, MintToCheckedData), - BurnChecked(BurnCheckedAccounts, BurnCheckedData), - SyncNative(SyncNativeAccounts), - GetAccountDataSize(GetAccountDataSizeAccounts), - InitializeImmutableOwner(InitializeImmutableOwnerAccounts), - AmountToUiAmount(AmountToUiAmountAccounts, AmountToUiAmountData), - UiAmountToAmount(UiAmountToAmountAccounts, UiAmountToAmountData), -} - -#[cfg(feature = "proto")] -pub mod proto_parser { - use yellowstone_vixen_proto::parser::token::{ - program_ixs::IxOneof, AmountToUiAmountAccountsProto, AmountToUiAmountDataProto, - AmountToUiAmountIxProto, ApproveAccountsProto, ApproveCheckedAccountsProto, - ApproveCheckedDataProto, ApproveCheckedIxProto, ApproveDataProto, ApproveIxProto, - BurnAccountsProto, BurnCheckedAccountsProto, BurnCheckedDataProto, BurnCheckedIxProto, - BurnDataProto, BurnIxProto, CloseAccountAccountsProto, CloseAccountIxProto, - FreezeAccountAccountsProto, FreezeAccountIxProto, GetAccountDataSizeAccountsProto, - GetAccountDataSizeIxProto, InitializeAccount2AccountsProto, InitializeAccount2IxProto, - InitializeAccount3IxProto, InitializeAccountAccountsProto, InitializeAccountData2Proto, - InitializeAccountIxProto, InitializeImmutableOwnerAccountsProto, - InitializeImmutableOwnerIxProto, InitializeMintAccountsProto, InitializeMintDataProto, - InitializeMintIxProto, InitializeMultisigAccountsProto, InitializeMultisigDataProto, - InitializeMultisigIxProto, MintToAccountsProto, MintToCheckedAccountsProto, - MintToCheckedDataProto, MintToCheckedIxProto, MintToDataProto, MintToIxProto, - ProgramIxs as TokenProgramIxProto, RevokeAccountsProto, RevokeIxProto, - SetAuthorityAccountsProto, SetAuthorityDataProto, SetAuthorityIxProto, - SyncNativeAccountsProto, SyncNativeIxProto, ThawAccountAccountsProto, ThawAccountIxProto, - TransferAccountsProto, TransferCheckedAccountsProto, TransferCheckedDataProto, - TransferCheckedIxProto, TransferDataProto, TransferIxProto, UiAmountToAmountAccountsProto, - UiAmountToAmountDataProto, UiAmountToAmountIxProto, - }; - - use super::{ - AmountToUiAmountAccounts, AmountToUiAmountData, ApproveAccounts, ApproveCheckedAccounts, - ApproveCheckedData, ApproveData, BurnAccounts, BurnCheckedAccounts, BurnCheckedData, - BurnData, CloseAccountAccounts, FreezeAccountAccounts, GetAccountDataSizeAccounts, - InitializeAccount2Accounts, InitializeAccountAccounts, InitializeAccountData2, - InitializeImmutableOwnerAccounts, InitializeMintAccounts, InitializeMintData, - InitializeMultisigAccounts, InitializeMultisigData, MintToAccounts, MintToCheckedAccounts, - MintToCheckedData, MintToData, RevokeAccounts, SetAuthorityAccounts, SetAuthorityData, - SyncNativeAccounts, ThawAccountAccounts, TokenProgramIx, TransferAccounts, - TransferCheckedAccounts, TransferCheckedData, TransferData, UiAmountToAmountAccounts, - UiAmountToAmountData, - }; - use crate::helpers::{ - proto::{FromOptPubkeyToOptString, FromVecPubkeyToVecString}, - IntoProto, - }; - - impl IntoProto for TransferAccounts { - fn into_proto(self) -> TransferAccountsProto { - TransferAccountsProto { - source: self.source.to_string(), - destination: self.destination.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for TransferData { - fn into_proto(self) -> TransferDataProto { - TransferDataProto { - amount: self.amount, - } - } - } - - impl IntoProto for InitializeMintAccounts { - fn into_proto(self) -> InitializeMintAccountsProto { - InitializeMintAccountsProto { - mint: self.mint.to_string(), - } - } - } - - impl IntoProto for InitializeMintData { - fn into_proto(self) -> InitializeMintDataProto { - InitializeMintDataProto { - decimals: self.decimals.into(), - mint_authority: self.mint_authority.to_opt_string(), - freeze_authority: self.freeze_authority.to_opt_string(), - } - } - } - - impl IntoProto for InitializeAccountAccounts { - fn into_proto(self) -> InitializeAccountAccountsProto { - InitializeAccountAccountsProto { - account: self.account.to_string(), - mint: self.mint.to_string(), - owner: self.owner.to_string(), - } - } - } - - impl IntoProto for InitializeAccount2Accounts { - fn into_proto(self) -> InitializeAccount2AccountsProto { - InitializeAccount2AccountsProto { - account: self.account.to_string(), - mint: self.mint.to_string(), - } - } - } - - impl IntoProto for InitializeAccountData2 { - fn into_proto(self) -> InitializeAccountData2Proto { - InitializeAccountData2Proto { - owner: self.owner.to_string(), - } - } - } - - impl IntoProto for InitializeMultisigAccounts { - fn into_proto(self) -> InitializeMultisigAccountsProto { - InitializeMultisigAccountsProto { - multisig: self.multisig.to_string(), - signers: self.signers.to_string_vec(), - } - } - } - - impl IntoProto for InitializeMultisigData { - fn into_proto(self) -> InitializeMultisigDataProto { - InitializeMultisigDataProto { m: self.m.into() } - } - } - - impl IntoProto for ApproveAccounts { - fn into_proto(self) -> ApproveAccountsProto { - ApproveAccountsProto { - source: self.source.to_string(), - delegate: self.delegate.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for ApproveData { - fn into_proto(self) -> ApproveDataProto { - ApproveDataProto { - amount: self.amount, - } - } - } - - impl IntoProto for RevokeAccounts { - fn into_proto(self) -> RevokeAccountsProto { - RevokeAccountsProto { - source: self.source.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for SetAuthorityAccounts { - fn into_proto(self) -> SetAuthorityAccountsProto { - SetAuthorityAccountsProto { - current_authority: self.current_authority.to_string(), - account: self.account.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for SetAuthorityData { - fn into_proto(self) -> SetAuthorityDataProto { - SetAuthorityDataProto { - authority_type: self.authority_type as i32, - new_authority: self.new_authority.to_opt_string(), - } - } - } - - impl IntoProto for MintToAccounts { - fn into_proto(self) -> MintToAccountsProto { - MintToAccountsProto { - mint: self.mint.to_string(), - account: self.account.to_string(), - mint_authority: self.mint_authority.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for MintToData { - fn into_proto(self) -> MintToDataProto { - MintToDataProto { - amount: self.amount, - } - } - } - - impl IntoProto for BurnAccounts { - fn into_proto(self) -> BurnAccountsProto { - BurnAccountsProto { - account: self.account.to_string(), - mint: self.mint.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for BurnData { - fn into_proto(self) -> BurnDataProto { - BurnDataProto { - amount: self.amount, - } - } - } - - impl IntoProto for CloseAccountAccounts { - fn into_proto(self) -> CloseAccountAccountsProto { - CloseAccountAccountsProto { - account: self.account.to_string(), - destination: self.destination.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for FreezeAccountAccounts { - fn into_proto(self) -> FreezeAccountAccountsProto { - FreezeAccountAccountsProto { - account: self.account.to_string(), - mint: self.mint.to_string(), - mint_freeze_authority: self.mint_freeze_authority.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for ThawAccountAccounts { - fn into_proto(self) -> ThawAccountAccountsProto { - ThawAccountAccountsProto { - account: self.account.to_string(), - mint: self.mint.to_string(), - mint_freeze_authority: self.mint_freeze_authority.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for TransferCheckedAccounts { - fn into_proto(self) -> TransferCheckedAccountsProto { - TransferCheckedAccountsProto { - source: self.source.to_string(), - mint: self.mint.to_string(), - destination: self.destination.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for TransferCheckedData { - fn into_proto(self) -> TransferCheckedDataProto { - TransferCheckedDataProto { - amount: self.amount, - decimals: self.decimals.into(), - } - } - } - - impl IntoProto for ApproveCheckedAccounts { - fn into_proto(self) -> ApproveCheckedAccountsProto { - ApproveCheckedAccountsProto { - source: self.source.to_string(), - mint: self.mint.to_string(), - delegate: self.delegate.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for ApproveCheckedData { - fn into_proto(self) -> ApproveCheckedDataProto { - ApproveCheckedDataProto { - amount: self.amount, - decimals: self.decimals.into(), - } - } - } - - impl IntoProto for MintToCheckedAccounts { - fn into_proto(self) -> MintToCheckedAccountsProto { - MintToCheckedAccountsProto { - mint: self.mint.to_string(), - account: self.account.to_string(), - mint_authority: self.mint_authority.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for MintToCheckedData { - fn into_proto(self) -> MintToCheckedDataProto { - MintToCheckedDataProto { - amount: self.amount, - decimals: self.decimals.into(), - } - } - } - - impl IntoProto for BurnCheckedAccounts { - fn into_proto(self) -> BurnCheckedAccountsProto { - BurnCheckedAccountsProto { - account: self.account.to_string(), - mint: self.mint.to_string(), - owner: self.owner.to_string(), - multisig_signers: self.multisig_signers.to_string_vec(), - } - } - } - - impl IntoProto for BurnCheckedData { - fn into_proto(self) -> BurnCheckedDataProto { - BurnCheckedDataProto { - amount: self.amount, - decimals: self.decimals.into(), - } - } - } - - impl IntoProto for SyncNativeAccounts { - fn into_proto(self) -> SyncNativeAccountsProto { - SyncNativeAccountsProto { - account: self.account.to_string(), - } - } - } - - impl IntoProto for GetAccountDataSizeAccounts { - fn into_proto(self) -> GetAccountDataSizeAccountsProto { - GetAccountDataSizeAccountsProto { - mint: self.mint.to_string(), - } - } - } - - impl IntoProto for InitializeImmutableOwnerAccounts { - fn into_proto(self) -> InitializeImmutableOwnerAccountsProto { - InitializeImmutableOwnerAccountsProto { - account: self.account.to_string(), - } - } - } - - impl IntoProto for AmountToUiAmountAccounts { - fn into_proto(self) -> AmountToUiAmountAccountsProto { - AmountToUiAmountAccountsProto { - mint: self.mint.to_string(), - } - } - } - - impl IntoProto for AmountToUiAmountData { - fn into_proto(self) -> AmountToUiAmountDataProto { - AmountToUiAmountDataProto { - amount: self.amount, - } - } - } - - impl IntoProto for UiAmountToAmountAccounts { - fn into_proto(self) -> UiAmountToAmountAccountsProto { - UiAmountToAmountAccountsProto { - mint: self.mint.to_string(), - } - } - } - - impl IntoProto for UiAmountToAmountData { - fn into_proto(self) -> UiAmountToAmountDataProto { - UiAmountToAmountDataProto { - ui_amount: self.ui_amount, - } - } - } - impl IntoProto for TokenProgramIx { - #[allow(clippy::too_many_lines)] - fn into_proto(self) -> TokenProgramIxProto { - match self { - TokenProgramIx::Transfer(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::Transfer(TransferIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - TokenProgramIx::InitializeMint(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::InitializeMint(InitializeMintIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::InitializeAccount(acc) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::InitializeAccount(InitializeAccountIxProto { - accounts: Some(acc.into_proto()), - data: None, - })), - }, - - TokenProgramIx::InitializeAccount2(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::InitializeAccount2(InitializeAccount2IxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::InitializeAccount3(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::InitializeAccount3(InitializeAccount3IxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::InitializeMultisig(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::InitializeMultisig(InitializeMultisigIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::Approve(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::Approve(ApproveIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::Revoke(acc) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::Revoke(RevokeIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - TokenProgramIx::SetAuthority(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::SetAuthority(SetAuthorityIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::MintTo(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::MintTo(MintToIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::Burn(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::Burn(BurnIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::CloseAccount(acc) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::CloseAccount(CloseAccountIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - TokenProgramIx::FreezeAccount(acc) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::FreezeAccount(FreezeAccountIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - TokenProgramIx::ThawAccount(acc) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::ThawAccount(ThawAccountIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - TokenProgramIx::TransferChecked(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::TransferChecked(TransferCheckedIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::ApproveChecked(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::ApproveChecked(ApproveCheckedIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::MintToChecked(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::MintToChecked(MintToCheckedIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::BurnChecked(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::BurnChecked(BurnCheckedIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::SyncNative(acc) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::SyncNative(SyncNativeIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - TokenProgramIx::GetAccountDataSize(acc) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::GetAccountDataSize(GetAccountDataSizeIxProto { - accounts: Some(acc.into_proto()), - })), - }, - - TokenProgramIx::InitializeImmutableOwner(acc) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::InitializeImmutableOwner( - InitializeImmutableOwnerIxProto { - accounts: Some(acc.into_proto()), - }, - )), - }, - - TokenProgramIx::AmountToUiAmount(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::AmountToUiAmount(AmountToUiAmountIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - - TokenProgramIx::UiAmountToAmount(acc, data) => TokenProgramIxProto { - ix_oneof: Some(IxOneof::UiAmountToAmount(UiAmountToAmountIxProto { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - } - } - } -} diff --git a/crates/parser/src/token_program/instruction_parser.rs b/crates/parser/src/token_program/instruction_parser.rs deleted file mode 100644 index e56de5e3..00000000 --- a/crates/parser/src/token_program/instruction_parser.rs +++ /dev/null @@ -1,415 +0,0 @@ -use spl_token::instruction::TokenInstruction; -use yellowstone_vixen_core::{ - instruction::InstructionUpdate, ParseError, ParseResult, Parser, Prefilter, ProgramParser, -}; - -#[allow(clippy::wildcard_imports)] -use super::instruction_helpers::*; -use crate::{ - helpers::{check_min_accounts_req, into_vixen_pubkey}, - Result, ResultExt, -}; - -#[derive(Debug, Clone, Copy)] -pub struct InstructionParser; - -impl Parser for InstructionParser { - type Input = InstructionUpdate; - type Output = TokenProgramIx; - - fn id(&self) -> std::borrow::Cow<'static, str> { "token_program::InstructionParser".into() } - - fn prefilter(&self) -> Prefilter { - Prefilter::builder() - .transaction_accounts([spl_token::ID]) - .build() - .unwrap() - } - - async fn parse(&self, ix_update: &InstructionUpdate) -> ParseResult { - if ix_update.program.equals_ref(spl_token::ID) { - InstructionParser::parse_impl(ix_update).map_err(|e| ParseError::Other(e.into())) - } else { - Err(ParseError::Filtered) - } - } -} - -impl ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { spl_token::ID.to_bytes().into() } -} - -impl InstructionParser { - #[allow(clippy::too_many_lines)] - pub(crate) fn parse_impl(ix: &InstructionUpdate) -> Result { - let ix_type = TokenInstruction::unpack(&ix.data) - .parse_err("Error unpacking token instruction data")?; - let accounts_len = ix.accounts.len(); - let ix = match ix_type { - TokenInstruction::Transfer { amount } => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::Transfer( - TransferAccounts { - source: ix.accounts[0], - destination: ix.accounts[1], - owner: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - }, - TransferData { amount }, - )) - }, - TokenInstruction::InitializeAccount => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::InitializeAccount( - InitializeAccountAccounts { - account: ix.accounts[0], - mint: ix.accounts[1], - owner: ix.accounts[2], - }, - )) - }, - TokenInstruction::InitializeMint { - decimals, - mint_authority, - freeze_authority, - } => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TokenProgramIx::InitializeMint( - InitializeMintAccounts { - mint: ix.accounts[0], - }, - InitializeMintData { - decimals, - mint_authority: into_vixen_pubkey(mint_authority), - freeze_authority: freeze_authority.map(into_vixen_pubkey).into(), - }, - )) - }, - TokenInstruction::InitializeMint2 { - decimals, - mint_authority, - freeze_authority, - } => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TokenProgramIx::InitializeMint( - InitializeMintAccounts { - mint: ix.accounts[0], - }, - InitializeMintData { - decimals, - mint_authority: into_vixen_pubkey(mint_authority), - freeze_authority: freeze_authority.map(into_vixen_pubkey).into(), - }, - )) - }, - - TokenInstruction::InitializeAccount2 { owner } => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TokenProgramIx::InitializeAccount2( - InitializeAccount2Accounts { - account: ix.accounts[0], - mint: ix.accounts[1], - }, - InitializeAccountData2 { - owner: into_vixen_pubkey(owner), - }, - )) - }, - - TokenInstruction::InitializeAccount3 { owner } => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TokenProgramIx::InitializeAccount3( - InitializeAccount2Accounts { - account: ix.accounts[0], - mint: ix.accounts[1], - }, - InitializeAccountData2 { - owner: into_vixen_pubkey(owner), - }, - )) - }, - TokenInstruction::InitializeMultisig { m } => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::InitializeMultisig( - InitializeMultisigAccounts { - multisig: ix.accounts[0], - signers: ix.accounts[2..].to_vec(), - }, - InitializeMultisigData { m }, - )) - }, - - TokenInstruction::InitializeMultisig2 { m } => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TokenProgramIx::InitializeMultisig( - InitializeMultisigAccounts { - multisig: ix.accounts[0], - signers: ix.accounts[1..].to_vec(), - }, - InitializeMultisigData { m }, - )) - }, - - TokenInstruction::Approve { amount } => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::Approve( - ApproveAccounts { - source: ix.accounts[0], - delegate: ix.accounts[1], - owner: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - }, - ApproveData { amount }, - )) - }, - - TokenInstruction::Revoke => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TokenProgramIx::Revoke(RevokeAccounts { - source: ix.accounts[0], - owner: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - })) - }, - - TokenInstruction::SetAuthority { - authority_type, - new_authority, - } => { - check_min_accounts_req(accounts_len, 2)?; - Ok(TokenProgramIx::SetAuthority( - SetAuthorityAccounts { - account: ix.accounts[0], - current_authority: ix.accounts[1], - multisig_signers: ix.accounts[2..].to_vec(), - }, - SetAuthorityData { - authority_type, - new_authority: new_authority.map(into_vixen_pubkey).into(), - }, - )) - }, - - TokenInstruction::MintTo { amount } => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::MintTo( - MintToAccounts { - mint: ix.accounts[0], - account: ix.accounts[1], - mint_authority: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - }, - MintToData { amount }, - )) - }, - - TokenInstruction::Burn { amount } => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::Burn( - BurnAccounts { - account: ix.accounts[0], - mint: ix.accounts[1], - owner: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - }, - BurnData { amount }, - )) - }, - - TokenInstruction::CloseAccount => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::CloseAccount(CloseAccountAccounts { - account: ix.accounts[0], - destination: ix.accounts[1], - owner: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - })) - }, - - TokenInstruction::FreezeAccount => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::FreezeAccount(FreezeAccountAccounts { - account: ix.accounts[0], - mint: ix.accounts[1], - mint_freeze_authority: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - })) - }, - - TokenInstruction::ThawAccount => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::ThawAccount(ThawAccountAccounts { - account: ix.accounts[0], - mint: ix.accounts[1], - mint_freeze_authority: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - })) - }, - - TokenInstruction::TransferChecked { amount, decimals } => { - check_min_accounts_req(accounts_len, 4)?; - Ok(TokenProgramIx::TransferChecked( - TransferCheckedAccounts { - source: ix.accounts[0], - mint: ix.accounts[1], - destination: ix.accounts[2], - owner: ix.accounts[3], - multisig_signers: ix.accounts[4..].to_vec(), - }, - TransferCheckedData { amount, decimals }, - )) - }, - - TokenInstruction::ApproveChecked { amount, decimals } => { - check_min_accounts_req(accounts_len, 4)?; - Ok(TokenProgramIx::ApproveChecked( - ApproveCheckedAccounts { - source: ix.accounts[0], - mint: ix.accounts[1], - delegate: ix.accounts[2], - owner: ix.accounts[3], - multisig_signers: ix.accounts[4..].to_vec(), - }, - ApproveCheckedData { amount, decimals }, - )) - }, - - TokenInstruction::MintToChecked { amount, decimals } => { - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::MintToChecked( - MintToCheckedAccounts { - mint: ix.accounts[0], - account: ix.accounts[1], - mint_authority: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - }, - MintToCheckedData { amount, decimals }, - )) - }, - - TokenInstruction::BurnChecked { amount, decimals } => { - //TODO : this ix needs 3 accounts , but only 1 account is available in the instruction - check_min_accounts_req(accounts_len, 3)?; - Ok(TokenProgramIx::BurnChecked( - BurnCheckedAccounts { - account: ix.accounts[0], - mint: ix.accounts[1], - owner: ix.accounts[2], - multisig_signers: ix.accounts[3..].to_vec(), - }, - BurnCheckedData { amount, decimals }, - )) - }, - - TokenInstruction::SyncNative => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TokenProgramIx::SyncNative(SyncNativeAccounts { - account: ix.accounts[0], - })) - }, - - TokenInstruction::GetAccountDataSize => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TokenProgramIx::GetAccountDataSize( - GetAccountDataSizeAccounts { - mint: ix.accounts[0], - }, - )) - }, - - TokenInstruction::InitializeImmutableOwner => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TokenProgramIx::InitializeImmutableOwner( - InitializeImmutableOwnerAccounts { - account: ix.accounts[0], - }, - )) - }, - - TokenInstruction::AmountToUiAmount { amount } => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TokenProgramIx::AmountToUiAmount( - AmountToUiAmountAccounts { - mint: ix.accounts[0], - }, - AmountToUiAmountData { amount }, - )) - }, - - TokenInstruction::UiAmountToAmount { ui_amount } => { - check_min_accounts_req(accounts_len, 1)?; - Ok(TokenProgramIx::UiAmountToAmount( - UiAmountToAmountAccounts { - mint: ix.accounts[0], - }, - UiAmountToAmountData { - ui_amount: ui_amount.into(), - }, - )) - }, - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = spl_token::ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = spl_token::ID.to_string(), - ix = "error", - // discriminator = ix_type, - error = ?e - ); - }, - } - - ix - } -} - -#[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - use yellowstone_vixen_proto::parser::token::ProgramIxs as TokenProgramIxProto; - - use super::InstructionParser; - use crate::helpers::IntoProto; - - impl ParseProto for InstructionParser { - type Message = TokenProgramIxProto; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} - -#[cfg(test)] -mod tests { - use std::ops::Mul; - - use yellowstone_vixen_mock::tx_fixture; - - use super::*; - - #[tokio::test] - async fn test_mint_to_checked_ix_parsing() { - let parser = InstructionParser; - - let ixs = tx_fixture!("55kpnRufcX9Fo44oRBXtrkxPRww4UWJKxCpgBV39kzAAag8oyJbd9Y3YWdQQUi3TBqtrhjgsMGb9Nw8bUxy7j5rt",&parser); - - let TokenProgramIx::MintToChecked(_accts, data) = &ixs[0] else { - panic!("Invalid Instruction"); - }; - - assert_eq!(data.decimals, 10); - assert_eq!(data.amount, 10.mul(10u64.pow(data.decimals.into()))); - } -} diff --git a/crates/proc-macro/src/render.rs b/crates/proc-macro/src/render.rs index b2aa5fb3..8b890bed 100644 --- a/crates/proc-macro/src/render.rs +++ b/crates/proc-macro/src/render.rs @@ -1,16 +1,15 @@ use base64::{engine::general_purpose::STANDARD, Engine}; use codama_nodes::{ CamelCaseString, DefaultValueStrategy, DiscriminatorNode, EnumVariantTypeNode, - InstructionInputValueNode, NestedTypeNode, NestedTypeNodeTrait, Number, NumberFormat, RootNode, - TypeNode, ValueNode, + InstructionInputValueNode, NestedTypeNode, Number, NumberFormat, RootNode, TypeNode, ValueNode, }; use proc_macro2::TokenStream; use quote::{format_ident, quote}; pub fn render_vixen_parser(idl: &RootNode) -> TokenStream { let program_mod_ident = format_ident!("{}", to_snake_case(&idl.program.name)); - let program_public_key = &idl.program.public_key; + let program_pubkey = render_program_pubkey(&idl.program.public_key); let defined_types = render_defined_types(&idl.program.defined_types); let accounts = render_accounts(&idl.program.accounts); let instructions = render_instructions(&idl.program.instructions); @@ -23,7 +22,7 @@ pub fn render_vixen_parser(idl: &RootNode) -> TokenStream { use borsh::{BorshDeserialize, BorshSerialize}; use yellowstone_vixen_parser::prelude::*; - const ID: solana_pubkey::Pubkey = solana_pubkey::pubkey!(#program_public_key); + const ID: yellowstone_vixen_parser::Pubkey = #program_pubkey; #defined_types #accounts @@ -34,133 +33,143 @@ pub fn render_vixen_parser(idl: &RootNode) -> TokenStream { } } +fn render_program_pubkey(pubkey: &String) -> TokenStream { + let decoded = match bs58::decode(pubkey).into_vec() { + Ok(bytes) => bytes, + Err(_) => { + return quote! { + compile_error!(concat!("Invalid base58 pubkey: ", #pubkey)); + }; + }, + }; + + if decoded.len() != 32 { + let len = decoded.len(); + return quote! { + compile_error!(concat!( + "Invalid pubkey length: expected 32 bytes, got ", + stringify!(#len), + " bytes for pubkey: ", + #pubkey + )); + }; + } + + let bytes_tokens = decoded.iter().map(|&b| quote! { #b }); + + quote! { + { + const BYTES: [u8; 32] = [#(#bytes_tokens),*]; + yellowstone_vixen_parser::prelude::KeyBytes::<32>(BYTES) + } + } +} + fn render_defined_types(defined_types: &[codama_nodes::DefinedTypeNode]) -> TokenStream { - let sections: Vec = defined_types - .iter() - .map(|defined_type| { - let defined_type_ident = format_ident!("{}", to_pascal_case(&defined_type.name)); - - match &defined_type.r#type { - TypeNode::Struct(struct_type) => { - let fields = quoted_fields(&struct_type.fields); - quote! { - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] - pub struct #defined_type_ident { - #(#fields,)* - } - } - }, - TypeNode::Enum(_) => { - let ty = quoted_type_node(&defined_type.r#type); - quote! { - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] - pub enum #defined_type_ident #ty - } - }, - _ => { - let ty = quoted_type_node(&defined_type.r#type); - quote! { - pub type #defined_type_ident = #ty; + let sections = defined_types.iter().map(|defined_type| { + let ident = format_ident!("{}", to_pascal_case(&defined_type.name)); + + match &defined_type.r#type { + TypeNode::Struct(struct_type) => { + let fields = quoted_fields(&struct_type.fields); + quote! { + #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] + pub struct #ident { + #(#fields),* } - }, - } - }) - .collect(); + } + }, + TypeNode::Enum(_) => { + let ty = quoted_type_node(&defined_type.r#type); + quote! { + #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] + pub enum #ident { #ty } + } + }, + _ => { + let ty = quoted_type_node(&defined_type.r#type); + quote! { + pub type #ident = #ty; + } + }, + } + }); quote! { #(#sections)* } } fn render_accounts(accounts: &[codama_nodes::AccountNode]) -> TokenStream { - let sections: Vec = accounts - .iter() - .map(|account| { - let struct_ident = format_ident!("{}", to_pascal_case(&account.name)); - let fields = match &account.data { - codama_nodes::NestedTypeNode::Value(struct_type) => { - quoted_fields(&struct_type.fields) - }, - _ => vec![], - }; - let len_const = account - .size - .map(|size| quote! { pub const LEN: usize = #size; }); - - quote! { - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] - pub struct #struct_ident { - #(#fields,)* - } + let sections = accounts.iter().map(|account| { + let struct_ident = format_ident!("{}", to_pascal_case(&account.name)); + let fields = match &account.data { + codama_nodes::NestedTypeNode::Value(struct_type) => quoted_fields(&struct_type.fields), + _ => Vec::new(), + }; + let len_const = account + .size + .map(|size| quote! { pub const LEN: usize = #size; }); + + quote! { + #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] + pub struct #struct_ident { + #(#fields),* + } - impl #struct_ident { - #len_const + impl #struct_ident { + #len_const - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) } } - }) - .collect(); + } + }); quote! { #(#sections)* } } fn render_instructions(instructions: &[codama_nodes::InstructionNode]) -> TokenStream { - let sections: Vec = instructions - .iter() - .map(|instruction| { - let instruction_name_accounts_ident = - format_ident!("{}Accounts", to_pascal_case(&instruction.name)); - let instruction_name_args_ident = - format_ident!("{}Args", to_pascal_case(&instruction.name)); + let sections = instructions.iter().map(|instruction| { + let accounts_ident = format_ident!("{}Accounts", to_pascal_case(&instruction.name)); + let args_ident = format_ident!("{}Args", to_pascal_case(&instruction.name)); - let instruction_accounts_fields: Vec = instruction - .accounts - .iter() - .map(|account| { - let field_ident = format_ident!("{}", to_snake_case(&account.name)); - quote! { pub #field_ident: yellowstone_vixen_parser::prelude::Pubkey } - }) - .collect(); - - let instruction_args_fields: Vec = instruction - .arguments - .iter() - .filter_map(|argument| { - if let Some(DefaultValueStrategy::Omitted) = argument.default_value_strategy { - return None; - } + let accounts_fields = instruction.accounts.iter().map(|account| { + let field_ident = format_ident!("{}", to_snake_case(&account.name)); + quote! { pub #field_ident: yellowstone_vixen_parser::Pubkey } + }); - let field_name_ident = format_ident!("{}", to_snake_case(&argument.name)); - let field_value_stream = quoted_type_node(&argument.r#type); + let args_fields = instruction.arguments.iter().filter_map(|argument| { + if argument.default_value_strategy == Some(DefaultValueStrategy::Omitted) { + return None; + } + let name_ident = format_ident!("{}", to_snake_case(&argument.name)); + let ty = quoted_type_node(&argument.r#type); - Some(quote! { pub #field_name_ident: #field_value_stream }) - }) - .collect(); + Some(quote! { pub #name_ident: #ty }) + }); - quote! { - #[derive(Clone, Debug, Eq, PartialEq)] - pub struct #instruction_name_accounts_ident { - #(#instruction_accounts_fields,)* - } + quote! { + #[derive(Clone, Debug, Eq, PartialEq)] + pub struct #accounts_ident { + #(#accounts_fields),* + } - #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] - pub struct #instruction_name_args_ident { - #(#instruction_args_fields,)* - } + #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] + pub struct #args_ident { + #(#args_fields),* + } - impl #instruction_name_args_ident { - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } + impl #args_ident { + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) } } - }) - .collect(); + } + }); quote! { #(#sections)* } } @@ -170,121 +179,109 @@ fn render_account_parser( accounts: &[codama_nodes::AccountNode], ) -> TokenStream { let pascal_program_name = to_pascal_case(program_name); - let account_state_ident = format_ident!("{}Account", pascal_program_name); + let account_enum_ident = format_ident!("{}Account", pascal_program_name); let parser_id = format!("{}::AccountParser", pascal_program_name); let parser_error_msg = format!("Unknown account for program {}", **program_name); - let account_enum_fields: Vec = accounts - .iter() - .map(|account| { - let account_ident = format_ident!("{}", to_pascal_case(&account.name)); - quote! { #account_ident(#account_ident) } - }) - .collect(); - - let account_matches: Vec = accounts - .iter() - .filter_map(|account| { - let discrimintator = match account.discriminators.first() { - Some(d) => d, - None => return None, - }; - - let account_ident = format_ident!("{}", to_pascal_case(&account.name)); - - match discrimintator { - DiscriminatorNode::Constant(node) => { - let offset = node.offset; - let value = match node.constant.value.as_ref() { - ValueNode::Number(node) => match node.number { - Number::UnsignedInteger(integer) => integer, - _ => { - return None; - } - }, - _ => { - return None; - } - }; + let account_enum_fields = accounts.iter().map(|account| { + let account_ident = format_ident!("{}", to_pascal_case(&account.name)); + quote! { #account_ident(#account_ident) } + }); - Some(quote! { - if let Some(discriminator) = data.get(#offset) { - if discriminator == #value { - return Ok(#account_state_ident::#account_ident(#account_ident::from_bytes(&data)?)); - } + let account_matches = accounts.iter().filter_map(|account| { + let discriminator = account.discriminators.first()?; + + let account_ident = format_ident!("{}", to_pascal_case(&account.name)); + + Some(match discriminator { + DiscriminatorNode::Constant(node) => { + let offset = node.offset; + let value = match node.constant.value.as_ref() { + ValueNode::Number(nn) => match nn.number { + Number::UnsignedInteger(integer) => integer, + _ => return None, + }, + _ => return None, + }; + + quote! { + if let Some(discriminator) = data.get(#offset) { + if discriminator == #value { + return Ok(#account_enum_ident::#account_ident(#account_ident::from_bytes(&data)?)); } - }) + } } - DiscriminatorNode::Field(node) => { - let offset = node.offset; - if let NestedTypeNode::Value(struct_node) = &account.data { - struct_node - .fields - .iter() - .find(|f| f.name == node.name) - .and_then(|field| { - let size = match &field.r#type { - TypeNode::FixedSize(fixed_size_node) => fixed_size_node.size, - _ => return None, - }; - field.default_value.as_ref().and_then(|value| match value { - ValueNode::Bytes(bytes) => { - let discriminator = match bytes.encoding { - codama_nodes::BytesEncoding::Base16 => { - hex::decode(&bytes.data) - .expect("Failed to decode base16 (hex) bytes") - } - codama_nodes::BytesEncoding::Base58 => { - bs58::decode(&bytes.data) - .into_vec() - .expect("Failed to decode base58 bytes") - } - codama_nodes::BytesEncoding::Base64 => STANDARD - .decode(&bytes.data) - .expect("Failed to decode base64 bytes"), - codama_nodes::BytesEncoding::Utf8 => { - bytes.data.as_bytes().to_vec() - } - }; + } + DiscriminatorNode::Field(node) => { + let offset = node.offset; + if let NestedTypeNode::Value(struct_node) = &account.data { + match struct_node + .fields + .iter() + .find(|f| f.name == node.name) + .and_then(|field| { + let size = match &field.r#type { + TypeNode::FixedSize(fixed_size_node) => fixed_size_node.size, + _ => return None, + }; + field.default_value.as_ref().and_then(|value| match value { + ValueNode::Bytes(bytes) => { + let discriminator = match bytes.encoding { + codama_nodes::BytesEncoding::Base16 => { + hex::decode(&bytes.data) + .expect("Failed to decode base16 (hex) bytes") + } + codama_nodes::BytesEncoding::Base58 => { + bs58::decode(&bytes.data) + .into_vec() + .expect("Failed to decode base58 bytes") + } + codama_nodes::BytesEncoding::Base64 => STANDARD + .decode(&bytes.data) + .expect("Failed to decode base64 bytes"), + codama_nodes::BytesEncoding::Utf8 => { + bytes.data.as_bytes().to_vec() + } + }; - let end = offset + size; + let end = offset + size; - Some(quote! { - if let Some(slice) = data.get(#offset..#end) { - if slice == &[#(#discriminator),*] { - return Ok(#account_state_ident::#account_ident(#account_ident::from_bytes(&data[#end..])?)); - } + Some(quote! { + if let Some(slice) = data.get(#offset..#end) { + if slice == &[#(#discriminator),*] { + return Ok(#account_enum_ident::#account_ident(#account_ident::from_bytes(&data[#end..])?)); } - }) - } - ValueNode::Constant(_constant) => None, - _ => None, - }) + } + }) + } + _ => None, }) - } else { - None + }) { + Some(token_stream) => token_stream, + None => return None, } + } else { + return None; } - DiscriminatorNode::Size(node) => { - let size = node.size; - - Some(quote! { - if data.len() == #size { - return Ok(#account_state_ident::#account_ident(#account_ident::from_bytes(&data)?)); - } - }) + } + DiscriminatorNode::Size(node) => { + let size = node.size; + quote! { + if data.len() == #size { + return Ok(#account_enum_ident::#account_ident(#account_ident::from_bytes(&data)?)); + } } } }) - .collect(); + }); quote! { #[derive(Debug)] - pub enum #account_state_ident { - #(#account_enum_fields,)* + pub enum #account_enum_ident { + #(#account_enum_fields),* } - impl #account_state_ident { + impl #account_enum_ident { pub fn try_unpack(data: &[u8]) -> ParseResult { #(#account_matches)* @@ -297,7 +294,7 @@ fn render_account_parser( impl Parser for AccountParser { type Input = AccountUpdate; - type Output = #account_state_ident; + type Output = #account_enum_ident; fn id(&self) -> std::borrow::Cow<'static, str> { #parser_id.into() @@ -317,9 +314,9 @@ fn render_account_parser( let inner = acct .account .as_ref() - .ok_or(ProgramError::InvalidArgument)?; + .ok_or_else(|| ParseError::from("Unable to unwrap account ref".to_owned()))?; - #account_state_ident::try_unpack(&inner.data) + #account_enum_ident::try_unpack(&inner.data) } } } @@ -330,132 +327,133 @@ fn render_instruction_parser( instructions: &[codama_nodes::InstructionNode], ) -> TokenStream { let pascal_program_name = to_pascal_case(program_name); - let program_instruction_ident = format_ident!("{}Instruction", pascal_program_name); - let program_instruction_id = format!("{}::InstructionParser", pascal_program_name); - - let instruction_enum_fields: Vec = instructions - .iter() - .map(|instruction| { - let instruction_ident = format_ident!("{}", to_pascal_case(&instruction.name)); - let instruction_accounts_ident = format_ident!("{}Accounts", instruction_ident); - let instruction_args_ident = format_ident!("{}Args", instruction_ident); - - quote! { #instruction_ident(#instruction_accounts_ident, #instruction_args_ident) } - }) - .collect(); - - let instruction_matches: Vec = instructions - .iter() - .filter_map(|instruction| { - let discrimintator = match instruction.discriminators.first() { - Some(d) => d, - None => return None, - }; + let instruction_enum_ident = format_ident!("{}Instruction", pascal_program_name); + let instruction_parser_id = format!("{}::InstructionParser", pascal_program_name); + + let instruction_enum_fields = instructions.iter().map(|instruction| { + let instr_ident = format_ident!("{}", to_pascal_case(&instruction.name)); + let instr_accounts_ident = format_ident!("{}Accounts", instr_ident); + let instr_args_ident = format_ident!("{}Args", instr_ident); + quote! { + #instr_ident { + accounts: #instr_accounts_ident, + args: #instr_args_ident, + } + } + }); - let instruction_ident = format_ident!("{}", to_pascal_case(&instruction.name)); - let instruction_args_ident = format_ident!("{}Args", instruction_ident); - let instruction_accounts_ident = format_ident!("{}Accounts", instruction_ident); + let instruction_matches = instructions.iter().filter_map(|instruction| { + let discriminator = instruction.discriminators.first()?; + let instr_ident = format_ident!("{}", to_pascal_case(&instruction.name)); + let instr_args_ident = format_ident!("{}Args", instr_ident); + let instr_accounts_ident = format_ident!("{}Accounts", instr_ident); - let instruction_accounts_fields: Vec = instruction + let instr_accounts_fields = + instruction .accounts .iter() .enumerate() - .map(|(index, account)| { + .map(|(idx, account)| { let field = format_ident!("{}", to_snake_case(&account.name)); - quote! { #field: accounts[#index] } - }) - .collect(); - let instruction_accounts = quote! { - #instruction_accounts_ident { - #(#instruction_accounts_fields,)* - } - }; + quote! { #field: accounts[#idx] } + }); - match discrimintator { - DiscriminatorNode::Constant(node) => { - let offset = node.offset; - let value = match node.constant.value.as_ref() { - ValueNode::Number(node) => match node.number { - Number::UnsignedInteger(integer) => integer, - _ => { - return None; - } - }, - _ => { - return None; - } - }; + let instr_accounts = quote! { + #instr_accounts_ident { + #(#instr_accounts_fields),* + } + }; - Some(quote! { - if let Some(discriminator) = data.get(#offset) { - if discriminator == #value { - return Ok(#program_instruction_ident::#instruction_ident(#instruction_accounts, #instruction_args_ident::from_bytes(&data)?)); - } + Some(match discriminator { + DiscriminatorNode::Constant(node) => { + let offset = node.offset; + let value = match node.constant.value.as_ref() { + ValueNode::Number(nn) => match nn.number { + Number::UnsignedInteger(integer) => integer, + _ => return None, + }, + _ => return None, + }; + + quote! { + if let Some(discriminator) = data.get(#offset) { + if discriminator == #value { + return Ok(#instruction_enum_ident::#instr_ident { + accounts: #instr_accounts, + args: #instr_args_ident::from_bytes(&data)?, + }); } - }) + } } - DiscriminatorNode::Field(node) => { - let offset = node.offset; - instruction.arguments - .iter() - .find(|f| f.name == node.name) - .and_then(|field| { - let size = match &field.r#type { - TypeNode::FixedSize(fixed_size_node) => fixed_size_node.size, - _ => return None, - }; - field.default_value.as_ref().and_then(|value| match value { - InstructionInputValueNode::Bytes(bytes) => { - let discriminator = match bytes.encoding { - codama_nodes::BytesEncoding::Base16 => { - hex::decode(&bytes.data) - .expect("Failed to decode base16 (hex) bytes") - } - codama_nodes::BytesEncoding::Base58 => { - bs58::decode(&bytes.data) - .into_vec() - .expect("Failed to decode base58 bytes") - } - codama_nodes::BytesEncoding::Base64 => STANDARD - .decode(&bytes.data) - .expect("Failed to decode base64 bytes"), - codama_nodes::BytesEncoding::Utf8 => { - bytes.data.as_bytes().to_vec() - } - }; - let end = offset + size; - - Some(quote! { - if let Some(slice) = data.get(#offset..#end) { - if slice == &[#(#discriminator),*] { - return Ok(#program_instruction_ident::#instruction_ident(#instruction_accounts, #instruction_args_ident::from_bytes(&data[#end..])?)); - } + }, + DiscriminatorNode::Field(node) => { + let offset = node.offset; + match instruction + .arguments + .iter() + .find(|f| f.name == node.name) + .and_then(|field| { + let size = match &field.r#type { + TypeNode::FixedSize(fixed_size_node) => fixed_size_node.size, + _ => return None, + }; + field.default_value.as_ref().and_then(|value| match value { + InstructionInputValueNode::Bytes(bytes) => { + let discriminator = match bytes.encoding { + codama_nodes::BytesEncoding::Base16 => hex::decode(&bytes.data) + .expect("Failed to decode base16 (hex) bytes"), + codama_nodes::BytesEncoding::Base58 => { + bs58::decode(&bytes.data) + .into_vec() + .expect("Failed to decode base58 bytes") + }, + codama_nodes::BytesEncoding::Base64 => STANDARD + .decode(&bytes.data) + .expect("Failed to decode base64 bytes"), + codama_nodes::BytesEncoding::Utf8 => { + bytes.data.as_bytes().to_vec() + }, + }; + let end = offset + size; + + Some(quote! { + if let Some(slice) = data.get(#offset..#end) { + if slice == &[#(#discriminator),*] { + return Ok(#instruction_enum_ident::#instr_ident { + accounts: #instr_accounts, + args: #instr_args_ident::from_bytes(&data[#end..])?, + }); } - }) - } - InstructionInputValueNode::Constant(_constant) => None, - _ => None, - }) + } + }) + }, + _ => None, }) + }) { + Some(token_stream) => token_stream, + None => return None, } - DiscriminatorNode::Size(node) => { - let size = node.size; - - Some(quote! { - if data.len() == #size { - return Ok(#program_instruction_ident::#instruction_ident(#instruction_accounts, #instruction_args_ident::from_bytes(&data)?)); - } - }) + }, + DiscriminatorNode::Size(node) => { + let size = node.size; + + quote! { + if data.len() == #size { + return Ok(#instruction_enum_ident::#instr_ident { + accounts: #instr_accounts, + args: #instr_args_ident::from_bytes(&data)?, + }); + } } - } + }, }) - .collect(); + }); quote! { #[derive(Debug)] - pub enum #program_instruction_ident { - #(#instruction_enum_fields,)* + pub enum #instruction_enum_ident { + #(#instruction_enum_fields),* } #[derive(Debug, Copy, Clone)] @@ -463,10 +461,10 @@ fn render_instruction_parser( impl Parser for InstructionParser { type Input = instruction::InstructionUpdate; - type Output = #program_instruction_ident; + type Output = #instruction_enum_ident; fn id(&self) -> std::borrow::Cow<'static, str> { - #program_instruction_id.into() + #instruction_parser_id.into() } fn prefilter(&self) -> Prefilter { @@ -496,45 +494,38 @@ fn render_instruction_parser( fn quoted_type_node(type_node: &codama_nodes::TypeNode) -> TokenStream { use TypeNode::*; match type_node { - String(_) => quote! { String }, - SizePrefix(_prefix) => { - quote! { String } - }, + String(_) | SizePrefix(_) => quote! { String }, Number(num) => quoted_number_type(num), - PublicKey(_) => quote! { Pubkey }, + PublicKey(_) => quote! { yellowstone_vixen_parser::Pubkey }, Boolean(_) => quote! { bool }, Option(option_node) => { - let inner_ty = quoted_type_node(&option_node.item); - quote! { Option<#inner_ty> } + let item = quoted_type_node(&option_node.item); + quote! { Option<#item> } }, - Tuple(node) => quoted_tuple_type(node), - Enum(node) => quoted_enum_type(node), + Tuple(tuple_node) => quoted_tuple_type(tuple_node), + Enum(enum_node) => quoted_enum_type(enum_node), Link(node) => { let ident = format_ident!("{}", to_pascal_case(&node.name)); quote! { #ident } }, - Array(node) => quoted_array_type(node), - Map(node) => { - let k = quoted_type_node(&node.key); - let v = quoted_type_node(&node.value); + Array(array_node) => quoted_array_type(array_node), + Map(map_node) => { + let k = quoted_type_node(&map_node.key); + let v = quoted_type_node(&map_node.value); quote! { std::collections::HashMap<#k, #v> } }, - Set(node) => { - let ty = quoted_type_node(&node.item); + Set(set_node) => { + let ty = quoted_type_node(&set_node.item); quote! { std::collections::HashSet<#ty> } }, - Bytes(_) => { - quote! { Vec } - }, + Bytes(_) => quote! { Vec }, FixedSize(node) => quoted_type_node(&node.r#type), - RemainderOption(_) | ZeroableOption(_) => { - quote! { Option<()> } - }, + RemainderOption(_) | ZeroableOption(_) => quote! { Option<()> }, Struct(struct_type) => { let fields = quoted_fields(&struct_type.fields); quote! { { - #(#fields,)* + #(#fields),* } } }, @@ -543,26 +534,27 @@ fn quoted_type_node(type_node: &codama_nodes::TypeNode) -> TokenStream { } fn quoted_number_type(num: &codama_nodes::NumberTypeNode) -> TokenStream { + use NumberFormat::*; match num.format { - NumberFormat::U8 => quote! { u8 }, - NumberFormat::U16 => quote! { u16 }, - NumberFormat::U32 => quote! { u32 }, - NumberFormat::U64 => quote! { u64 }, - NumberFormat::U128 => quote! { u128 }, - NumberFormat::I8 => quote! { i8 }, - NumberFormat::I16 => quote! { i16 }, - NumberFormat::I32 => quote! { i32 }, - NumberFormat::I64 => quote! { i64 }, - NumberFormat::I128 => quote! { i128 }, - NumberFormat::F32 => quote! { f32 }, - NumberFormat::F64 => quote! { f64 }, - NumberFormat::ShortU16 => quote! { u16 }, + U8 => quote! { u8 }, + U16 => quote! { u16 }, + U32 => quote! { u32 }, + U64 => quote! { u64 }, + U128 => quote! { u128 }, + I8 => quote! { i8 }, + I16 => quote! { i16 }, + I32 => quote! { i32 }, + I64 => quote! { i64 }, + I128 => quote! { i128 }, + F32 => quote! { f32 }, + F64 => quote! { f64 }, + ShortU16 => quote! { u16 }, } } fn quoted_tuple_type(node: &codama_nodes::TupleTypeNode) -> TokenStream { - let streams: Vec<_> = node.items.iter().map(quoted_type_node).collect(); - quote! { ( #(#streams),* ) } + let types = node.items.iter().map(quoted_type_node); + quote! { ( #(#types),* ) } } fn quoted_enum_type(node: &codama_nodes::EnumTypeNode) -> TokenStream { @@ -573,24 +565,27 @@ fn quoted_enum_type(node: &codama_nodes::EnumTypeNode) -> TokenStream { }, EnumVariantTypeNode::Tuple(v) => { let ident = format_ident!("{}", to_pascal_case(&v.name)); - if let codama_nodes::NestedTypeNode::Value(tuple_type) = &v.tuple { - let inner_types = tuple_type.items.iter().map(quoted_type_node); - quote! { #ident( #(#inner_types),* ), } - } else { - panic!("Expected TupleTypeNode::Value in EnumTupleVariantTypeNode.tuple"); + match &v.tuple { + codama_nodes::NestedTypeNode::Value(tuple_type) => { + let inner_types = tuple_type.items.iter().map(quoted_type_node); + + quote! { #ident( #(#inner_types),* ), } + }, + _ => panic!("Expected TupleTypeNode::Value in EnumTupleVariantTypeNode.tuple"), } }, EnumVariantTypeNode::Struct(v) => { let ident = format_ident!("{}", to_pascal_case(&v.name)); - if let codama_nodes::NestedTypeNode::Value(struct_type) = &v.r#struct { - let fields = struct_type.fields.iter().map(|f| { - let field_ident = format_ident!("{}", to_snake_case(&f.name)); - let ty = quoted_type_node(&f.r#type); - quote! { #field_ident: #ty } - }); - quote! { #ident { #(#fields),* }, } - } else { - panic!("Expected StructTypeNode::Value in EnumStructVariantTypeNode.r#struct"); + match &v.r#struct { + codama_nodes::NestedTypeNode::Value(struct_type) => { + let fields = struct_type.fields.iter().map(|f| { + let field_ident = format_ident!("{}", to_snake_case(&f.name)); + let ty = quoted_type_node(&f.r#type); + quote! { #field_ident: #ty } + }); + quote! { #ident { #(#fields),* }, } + }, + _ => panic!("Expected StructTypeNode::Value in EnumStructVariantTypeNode.r#struct"), } }, }); @@ -604,24 +599,9 @@ fn quoted_array_type(node: &codama_nodes::ArrayTypeNode) -> TokenStream { let n = fixed.value; quote! { [#ty; #n] } }, - codama_nodes::CountNode::Remainder(_) => { + codama_nodes::CountNode::Remainder(_) | codama_nodes::CountNode::Prefixed(_) => { quote! { Vec<#ty> } }, - codama_nodes::CountNode::Prefixed(prefix) => { - let number_type = prefix.prefix.get_nested_type_node(); - match number_type.format { - NumberFormat::U8 - | NumberFormat::U16 - | NumberFormat::U32 - | NumberFormat::U64 - | NumberFormat::ShortU16 => { - quote! { Vec<#ty> } - }, - _ => { - quote! { Vec<#ty> } - }, - } - }, } } @@ -629,20 +609,19 @@ fn quoted_fields(fields: &[codama_nodes::StructFieldTypeNode]) -> Vec String { - let mut out = String::new(); + let mut out = String::with_capacity(s.len()); for (i, ch) in s.chars().enumerate() { if ch.is_uppercase() && i != 0 { out.push('_'); @@ -654,10 +633,10 @@ fn to_snake_case(s: &CamelCaseString) -> String { fn to_pascal_case(s: &CamelCaseString) -> String { let s = s.as_str(); - if let Some(first) = s.chars().next() { + if let Some((first, rest)) = s.chars().next().map(|first| (first, &s[1..])) { let mut result = String::with_capacity(s.len()); result.push(first.to_ascii_uppercase()); - result.push_str(&s[1..]); + result.push_str(rest); result } else { String::new() @@ -699,14 +678,17 @@ mod tests { use borsh::{BorshDeserialize, BorshSerialize}; use yellowstone_vixen_parser::prelude::*; - const ID: solana_pubkey::Pubkey = solana_pubkey::pubkey!(""); + const ID: yellowstone_vixen_parser::Pubkey = { + const BYTES: [u8; 32] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + yellowstone_vixen_parser::Pubkey::from(BYTES) + }; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] pub struct MyAccount { pub name: String, pub age: u8, pub level: Option, - pub teammate: Pubkey, + pub teammate: yellowstone_vixen_parser::Pubkey, } impl MyAccount { #[inline(always)] @@ -749,7 +731,7 @@ mod tests { let inner = acct .account .as_ref() - .ok_or(ProgramError::InvalidArgument)?; + .ok_or(ParseError::from("Unable to unwrap account".to_into()))?; TestAccount::try_unpack(&inner.data) } } diff --git a/crates/proto/build.rs b/crates/proto/build.rs index af5e3702..6385dd94 100644 --- a/crates/proto/build.rs +++ b/crates/proto/build.rs @@ -3,29 +3,12 @@ use std::{env, path::PathBuf}; fn main() { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - #[cfg(feature = "parser")] - { - std::env::set_var("PROTOC", protobuf_src::protoc()); - // token - prost_build::Config::new() - .enable_type_names() - // .protoc_arg("--experimental_allow_proto3_optional") - .file_descriptor_set_path(out_dir.join("vixen.parser.token.bin")) - .compile_protos(&["proto/token.proto"], &["proto"]) - .unwrap(); - - // token extensions - prost_build::Config::new() - .enable_type_names() - // .protoc_arg("--experimental_allow_proto3_optional") - .file_descriptor_set_path(out_dir.join("vixen.parser.token_extensions.bin")) - .compile_protos(&["proto/token_extensions.proto"], &["proto"]) - .unwrap(); - } - #[cfg(feature = "stream")] { - std::env::set_var("PROTOC", protobuf_src::protoc()); + unsafe { + std::env::set_var("PROTOC", protobuf_src::protoc()); + } + tonic_build::configure() .file_descriptor_set_path(out_dir.join("stream_descriptor.bin")) .compile_protos(&["proto/stream.proto"], &["proto"]) diff --git a/crates/pump-swaps-parser/Cargo.toml b/crates/pump-swaps-parser/Cargo.toml deleted file mode 100644 index a3a0e3f8..00000000 --- a/crates/pump-swaps-parser/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "yellowstone-vixen-pump-swaps-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Pump Swaps program" -license.workspace = true -repository.workspace = true -authors.workspace = true - - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info.workspace = true -solana-cpi.workspace = true -solana-decode-error.workspace = true -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction.workspace = true -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true \ No newline at end of file diff --git a/crates/pump-swaps-parser/build.rs b/crates/pump-swaps-parser/build.rs deleted file mode 100644 index d10a4582..00000000 --- a/crates/pump-swaps-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/pump_swaps.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/pump-swaps-parser/idl.json b/crates/pump-swaps-parser/idl.json deleted file mode 100644 index dd8bd93a..00000000 --- a/crates/pump-swaps-parser/idl.json +++ /dev/null @@ -1,2152 +0,0 @@ -{ - "address": "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA", - "metadata": { - "name": "pump_amm", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "buy", - "discriminator": [102, 6, 61, 18, 1, 218, 235, 234], - "accounts": [ - { - "name": "pool" - }, - { - "name": "user", - "writable": true, - "signer": true - }, - { - "name": "global_config" - }, - { - "name": "base_mint", - "relations": ["pool"] - }, - { - "name": "quote_mint", - "relations": ["pool"] - }, - { - "name": "user_base_token_account", - "writable": true - }, - { - "name": "user_quote_token_account", - "writable": true - }, - { - "name": "pool_base_token_account", - "writable": true, - "relations": ["pool"] - }, - { - "name": "pool_quote_token_account", - "writable": true, - "relations": ["pool"] - }, - { - "name": "protocol_fee_recipient" - }, - { - "name": "protocol_fee_recipient_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "protocol_fee_recipient" - }, - { - "kind": "account", - "path": "quote_token_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, - 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, - 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, - 89 - ] - } - } - }, - { - "name": "base_token_program" - }, - { - "name": "quote_token_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "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": "coin_creator_vault_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "coin_creator_vault_authority" - }, - { - "kind": "account", - "path": "quote_token_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, - 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, - 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, - 89 - ] - } - } - }, - { - "name": "coin_creator_vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, 114, 101, 97, 116, 111, 114, 95, 118, - 97, 117, 108, 116 - ] - }, - { - "kind": "account", - "path": "pool.coin_creator", - "account": "Pool" - } - ] - } - } - ], - "args": [ - { - "name": "base_amount_out", - "type": "u64" - }, - { - "name": "max_quote_amount_in", - "type": "u64" - } - ] - }, - { - "name": "collect_coin_creator_fee", - "discriminator": [160, 57, 89, 42, 181, 139, 43, 66], - "accounts": [ - { - "name": "quote_mint" - }, - { - "name": "quote_token_program" - }, - { - "name": "coin_creator", - "signer": true - }, - { - "name": "coin_creator_vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, 114, 101, 97, 116, 111, 114, 95, 118, - 97, 117, 108, 116 - ] - }, - { - "kind": "account", - "path": "coin_creator" - } - ] - } - }, - { - "name": "coin_creator_vault_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "coin_creator_vault_authority" - }, - { - "kind": "account", - "path": "quote_token_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, - 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, - 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, - 89 - ] - } - } - }, - { - "name": "coin_creator_token_account", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, 95, 101, 118, 101, 110, 116, 95, 97, - 117, 116, 104, 111, 114, 105, 116, 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "create_config", - "discriminator": [201, 207, 243, 114, 75, 111, 47, 189], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "address": "8LWu7QM2dGR1G8nKDHthckea57bkCzXyBTAKPJUBDHo8" - }, - { - "name": "global_config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 103, 108, 111, 98, 97, 108, 95, 99, 111, - 110, 102, 105, 103 - ] - } - ] - } - }, - { - "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": "lp_fee_basis_points", - "type": "u64" - }, - { - "name": "protocol_fee_basis_points", - "type": "u64" - }, - { - "name": "protocol_fee_recipients", - "type": { - "array": ["pubkey", 8] - } - }, - { - "name": "coin_creator_fee_basis_points", - "type": "u64" - } - ] - }, - { - "name": "create_pool", - "discriminator": [233, 146, 209, 142, 207, 104, 64, 188], - "accounts": [ - { - "name": "pool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [112, 111, 111, 108] - }, - { - "kind": "arg", - "path": "index" - }, - { - "kind": "account", - "path": "creator" - }, - { - "kind": "account", - "path": "base_mint" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "global_config" - }, - { - "name": "creator", - "writable": true, - "signer": true - }, - { - "name": "base_mint" - }, - { - "name": "quote_mint" - }, - { - "name": "lp_mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, 111, 111, 108, 95, 108, 112, 95, 109, - 105, 110, 116 - ] - }, - { - "kind": "account", - "path": "pool" - } - ] - } - }, - { - "name": "user_base_token_account", - "writable": true - }, - { - "name": "user_quote_token_account", - "writable": true - }, - { - "name": "user_pool_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "creator" - }, - { - "kind": "account", - "path": "token_2022_program" - }, - { - "kind": "account", - "path": "lp_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, - 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, - 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, - 89 - ] - } - } - }, - { - "name": "pool_base_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "pool" - }, - { - "kind": "account", - "path": "base_token_program" - }, - { - "kind": "account", - "path": "base_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, - 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, - 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, - 89 - ] - } - } - }, - { - "name": "pool_quote_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "pool" - }, - { - "kind": "account", - "path": "quote_token_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, - 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, - 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, - 89 - ] - } - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_2022_program", - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "base_token_program" - }, - { - "name": "quote_token_program" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, 95, 101, 118, 101, 110, 116, 95, 97, - 117, 116, 104, 111, 114, 105, 116, 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "index", - "type": "u16" - }, - { - "name": "base_amount_in", - "type": "u64" - }, - { - "name": "quote_amount_in", - "type": "u64" - }, - { - "name": "coin_creator", - "type": "pubkey" - } - ] - }, - { - "name": "deposit", - "discriminator": [242, 35, 198, 137, 82, 225, 242, 182], - "accounts": [ - { - "name": "pool", - "writable": true - }, - { - "name": "global_config" - }, - { - "name": "user", - "signer": true - }, - { - "name": "base_mint", - "relations": ["pool"] - }, - { - "name": "quote_mint", - "relations": ["pool"] - }, - { - "name": "lp_mint", - "writable": true, - "relations": ["pool"] - }, - { - "name": "user_base_token_account", - "writable": true - }, - { - "name": "user_quote_token_account", - "writable": true - }, - { - "name": "user_pool_token_account", - "writable": true - }, - { - "name": "pool_base_token_account", - "writable": true, - "relations": ["pool"] - }, - { - "name": "pool_quote_token_account", - "writable": true, - "relations": ["pool"] - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_2022_program", - "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": "lp_token_amount_out", - "type": "u64" - }, - { - "name": "max_base_amount_in", - "type": "u64" - }, - { - "name": "max_quote_amount_in", - "type": "u64" - } - ] - }, - { - "name": "disable", - "discriminator": [185, 173, 187, 90, 216, 15, 238, 233], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": ["global_config"] - }, - { - "name": "global_config", - "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": "disable_create_pool", - "type": "bool" - }, - { - "name": "disable_deposit", - "type": "bool" - }, - { - "name": "disable_withdraw", - "type": "bool" - }, - { - "name": "disable_buy", - "type": "bool" - }, - { - "name": "disable_sell", - "type": "bool" - } - ] - }, - { - "name": "extend_account", - "discriminator": [234, 102, 194, 203, 150, 72, 62, 229], - "accounts": [ - { - "name": "account", - "writable": true - }, - { - "name": "user", - "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": "sell", - "discriminator": [51, 230, 133, 164, 1, 127, 131, 173], - "accounts": [ - { - "name": "pool" - }, - { - "name": "user", - "writable": true, - "signer": true - }, - { - "name": "global_config" - }, - { - "name": "base_mint", - "relations": ["pool"] - }, - { - "name": "quote_mint", - "relations": ["pool"] - }, - { - "name": "user_base_token_account", - "writable": true - }, - { - "name": "user_quote_token_account", - "writable": true - }, - { - "name": "pool_base_token_account", - "writable": true, - "relations": ["pool"] - }, - { - "name": "pool_quote_token_account", - "writable": true, - "relations": ["pool"] - }, - { - "name": "protocol_fee_recipient" - }, - { - "name": "protocol_fee_recipient_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "protocol_fee_recipient" - }, - { - "kind": "account", - "path": "quote_token_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, - 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, - 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, - 89 - ] - } - } - }, - { - "name": "base_token_program" - }, - { - "name": "quote_token_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "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": "coin_creator_vault_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "coin_creator_vault_authority" - }, - { - "kind": "account", - "path": "quote_token_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, - 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, - 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, - 89 - ] - } - } - }, - { - "name": "coin_creator_vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, 114, 101, 97, 116, 111, 114, 95, 118, - 97, 117, 108, 116 - ] - }, - { - "kind": "account", - "path": "pool.coin_creator", - "account": "Pool" - } - ] - } - } - ], - "args": [ - { - "name": "base_amount_in", - "type": "u64" - }, - { - "name": "min_quote_amount_out", - "type": "u64" - } - ] - }, - { - "name": "set_coin_creator", - "docs": [ - "Sets Pool::coin_creator from Metaplex metadata creator or BondingCurve::creator" - ], - "discriminator": [210, 149, 128, 45, 188, 58, 78, 175], - "accounts": [ - { - "name": "pool", - "writable": true - }, - { - "name": "metadata", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [109, 101, 116, 97, 100, 97, 116, 97] - }, - { - "kind": "const", - "value": [ - 11, 112, 101, 177, 227, 209, 124, 69, 56, - 157, 82, 127, 107, 4, 195, 205, 88, 184, - 108, 115, 26, 160, 253, 181, 73, 182, 209, - 188, 3, 248, 41, 70 - ] - }, - { - "kind": "account", - "path": "pool.base_mint", - "account": "Pool" - } - ], - "program": { - "kind": "const", - "value": [ - 11, 112, 101, 177, 227, 209, 124, 69, 56, 157, - 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, - 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, - 41, 70 - ] - } - } - }, - { - "name": "bonding_curve", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, 111, 110, 100, 105, 110, 103, 45, 99, - 117, 114, 118, 101 - ] - }, - { - "kind": "account", - "path": "pool.base_mint", - "account": "Pool" - } - ], - "program": { - "kind": "const", - "value": [ - 1, 86, 224, 246, 147, 102, 90, 207, 68, 219, 21, - 104, 191, 23, 91, 170, 81, 137, 203, 151, 245, - 210, 255, 59, 101, 93, 43, 182, 253, 109, 24, - 176 - ] - } - } - }, - { - "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": "update_admin", - "discriminator": [161, 176, 40, 213, 60, 184, 179, 228], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": ["global_config"] - }, - { - "name": "global_config", - "writable": true - }, - { - "name": "new_admin" - }, - { - "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": "update_fee_config", - "discriminator": [104, 184, 103, 242, 88, 151, 107, 20], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": ["global_config"] - }, - { - "name": "global_config", - "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": "lp_fee_basis_points", - "type": "u64" - }, - { - "name": "protocol_fee_basis_points", - "type": "u64" - }, - { - "name": "protocol_fee_recipients", - "type": { - "array": ["pubkey", 8] - } - }, - { - "name": "coin_creator_fee_basis_points", - "type": "u64" - } - ] - }, - { - "name": "withdraw", - "discriminator": [183, 18, 70, 156, 148, 109, 161, 34], - "accounts": [ - { - "name": "pool", - "writable": true - }, - { - "name": "global_config" - }, - { - "name": "user", - "signer": true - }, - { - "name": "base_mint", - "relations": ["pool"] - }, - { - "name": "quote_mint", - "relations": ["pool"] - }, - { - "name": "lp_mint", - "writable": true, - "relations": ["pool"] - }, - { - "name": "user_base_token_account", - "writable": true - }, - { - "name": "user_quote_token_account", - "writable": true - }, - { - "name": "user_pool_token_account", - "writable": true - }, - { - "name": "pool_base_token_account", - "writable": true, - "relations": ["pool"] - }, - { - "name": "pool_quote_token_account", - "writable": true, - "relations": ["pool"] - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_2022_program", - "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": "lp_token_amount_in", - "type": "u64" - }, - { - "name": "min_base_amount_out", - "type": "u64" - }, - { - "name": "min_quote_amount_out", - "type": "u64" - } - ] - } - ], - "accounts": [ - { - "name": "BondingCurve", - "discriminator": [23, 183, 248, 55, 96, 216, 172, 96] - }, - { - "name": "GlobalConfig", - "discriminator": [149, 8, 156, 202, 160, 252, 176, 217] - }, - { - "name": "Pool", - "discriminator": [241, 154, 109, 4, 17, 177, 109, 188] - } - ], - "events": [ - { - "name": "BuyEvent", - "discriminator": [103, 244, 82, 31, 44, 245, 119, 119] - }, - { - "name": "CollectCoinCreatorFeeEvent", - "discriminator": [232, 245, 194, 238, 234, 218, 58, 89] - }, - { - "name": "CreateConfigEvent", - "discriminator": [107, 52, 89, 129, 55, 226, 81, 22] - }, - { - "name": "CreatePoolEvent", - "discriminator": [177, 49, 12, 210, 160, 118, 167, 116] - }, - { - "name": "DepositEvent", - "discriminator": [120, 248, 61, 83, 31, 142, 107, 144] - }, - { - "name": "DisableEvent", - "discriminator": [107, 253, 193, 76, 228, 202, 27, 104] - }, - { - "name": "ExtendAccountEvent", - "discriminator": [97, 97, 215, 144, 93, 146, 22, 124] - }, - { - "name": "SellEvent", - "discriminator": [62, 47, 55, 10, 165, 3, 220, 42] - }, - { - "name": "SetBondingCurveCoinCreatorEvent", - "discriminator": [242, 231, 235, 102, 65, 99, 189, 211] - }, - { - "name": "SetMetaplexCoinCreatorEvent", - "discriminator": [150, 107, 199, 123, 124, 207, 102, 228] - }, - { - "name": "UpdateAdminEvent", - "discriminator": [225, 152, 171, 87, 246, 63, 66, 234] - }, - { - "name": "UpdateFeeConfigEvent", - "discriminator": [90, 23, 65, 35, 62, 244, 188, 208] - }, - { - "name": "WithdrawEvent", - "discriminator": [22, 9, 133, 26, 160, 44, 71, 192] - } - ], - "errors": [ - { - "code": 6000, - "name": "FeeBasisPointsExceedsMaximum" - }, - { - "code": 6001, - "name": "ZeroBaseAmount" - }, - { - "code": 6002, - "name": "ZeroQuoteAmount" - }, - { - "code": 6003, - "name": "TooLittlePoolTokenLiquidity" - }, - { - "code": 6004, - "name": "ExceededSlippage" - }, - { - "code": 6005, - "name": "InvalidAdmin" - }, - { - "code": 6006, - "name": "UnsupportedBaseMint" - }, - { - "code": 6007, - "name": "UnsupportedQuoteMint" - }, - { - "code": 6008, - "name": "InvalidBaseMint" - }, - { - "code": 6009, - "name": "InvalidQuoteMint" - }, - { - "code": 6010, - "name": "InvalidLpMint" - }, - { - "code": 6011, - "name": "AllProtocolFeeRecipientsShouldBeNonZero" - }, - { - "code": 6012, - "name": "UnsortedNotUniqueProtocolFeeRecipients" - }, - { - "code": 6013, - "name": "InvalidProtocolFeeRecipient" - }, - { - "code": 6014, - "name": "InvalidPoolBaseTokenAccount" - }, - { - "code": 6015, - "name": "InvalidPoolQuoteTokenAccount" - }, - { - "code": 6016, - "name": "BuyMoreBaseAmountThanPoolReserves" - }, - { - "code": 6017, - "name": "DisabledCreatePool" - }, - { - "code": 6018, - "name": "DisabledDeposit" - }, - { - "code": 6019, - "name": "DisabledWithdraw" - }, - { - "code": 6020, - "name": "DisabledBuy" - }, - { - "code": 6021, - "name": "DisabledSell" - }, - { - "code": 6022, - "name": "SameMint" - }, - { - "code": 6023, - "name": "Overflow" - }, - { - "code": 6024, - "name": "Truncation" - }, - { - "code": 6025, - "name": "DivisionByZero" - }, - { - "code": 6026, - "name": "NewSizeLessThanCurrentSize" - }, - { - "code": 6027, - "name": "AccountTypeNotSupported" - }, - { - "code": 6028, - "name": "OnlyCanonicalPumpPoolsCanHaveCoinCreator" - } - ], - "types": [ - { - "name": "BondingCurve", - "type": { - "kind": "struct", - "fields": [ - { - "name": "virtual_token_reserves", - "type": "u64" - }, - { - "name": "virtual_sol_reserves", - "type": "u64" - }, - { - "name": "real_token_reserves", - "type": "u64" - }, - { - "name": "real_sol_reserves", - "type": "u64" - }, - { - "name": "token_total_supply", - "type": "u64" - }, - { - "name": "complete", - "type": "bool" - }, - { - "name": "creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "BuyEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "base_amount_out", - "type": "u64" - }, - { - "name": "max_quote_amount_in", - "type": "u64" - }, - { - "name": "user_base_token_reserves", - "type": "u64" - }, - { - "name": "user_quote_token_reserves", - "type": "u64" - }, - { - "name": "pool_base_token_reserves", - "type": "u64" - }, - { - "name": "pool_quote_token_reserves", - "type": "u64" - }, - { - "name": "quote_amount_in", - "type": "u64" - }, - { - "name": "lp_fee_basis_points", - "type": "u64" - }, - { - "name": "lp_fee", - "type": "u64" - }, - { - "name": "protocol_fee_basis_points", - "type": "u64" - }, - { - "name": "protocol_fee", - "type": "u64" - }, - { - "name": "quote_amount_in_with_lp_fee", - "type": "u64" - }, - { - "name": "user_quote_amount_in", - "type": "u64" - }, - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "user_base_token_account", - "type": "pubkey" - }, - { - "name": "user_quote_token_account", - "type": "pubkey" - }, - { - "name": "protocol_fee_recipient", - "type": "pubkey" - }, - { - "name": "protocol_fee_recipient_token_account", - "type": "pubkey" - }, - { - "name": "coin_creator", - "type": "pubkey" - }, - { - "name": "coin_creator_fee_basis_points", - "type": "u64" - }, - { - "name": "coin_creator_fee", - "type": "u64" - } - ] - } - }, - { - "name": "CollectCoinCreatorFeeEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "coin_creator", - "type": "pubkey" - }, - { - "name": "coin_creator_fee", - "type": "u64" - }, - { - "name": "coin_creator_vault_ata", - "type": "pubkey" - }, - { - "name": "coin_creator_token_account", - "type": "pubkey" - } - ] - } - }, - { - "name": "CreateConfigEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "admin", - "type": "pubkey" - }, - { - "name": "lp_fee_basis_points", - "type": "u64" - }, - { - "name": "protocol_fee_basis_points", - "type": "u64" - }, - { - "name": "protocol_fee_recipients", - "type": { - "array": ["pubkey", 8] - } - }, - { - "name": "coin_creator_fee_basis_points", - "type": "u64" - } - ] - } - }, - { - "name": "CreatePoolEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "index", - "type": "u16" - }, - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "base_mint", - "type": "pubkey" - }, - { - "name": "quote_mint", - "type": "pubkey" - }, - { - "name": "base_mint_decimals", - "type": "u8" - }, - { - "name": "quote_mint_decimals", - "type": "u8" - }, - { - "name": "base_amount_in", - "type": "u64" - }, - { - "name": "quote_amount_in", - "type": "u64" - }, - { - "name": "pool_base_amount", - "type": "u64" - }, - { - "name": "pool_quote_amount", - "type": "u64" - }, - { - "name": "minimum_liquidity", - "type": "u64" - }, - { - "name": "initial_liquidity", - "type": "u64" - }, - { - "name": "lp_token_amount_out", - "type": "u64" - }, - { - "name": "pool_bump", - "type": "u8" - }, - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "lp_mint", - "type": "pubkey" - }, - { - "name": "user_base_token_account", - "type": "pubkey" - }, - { - "name": "user_quote_token_account", - "type": "pubkey" - }, - { - "name": "coin_creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "DepositEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "lp_token_amount_out", - "type": "u64" - }, - { - "name": "max_base_amount_in", - "type": "u64" - }, - { - "name": "max_quote_amount_in", - "type": "u64" - }, - { - "name": "user_base_token_reserves", - "type": "u64" - }, - { - "name": "user_quote_token_reserves", - "type": "u64" - }, - { - "name": "pool_base_token_reserves", - "type": "u64" - }, - { - "name": "pool_quote_token_reserves", - "type": "u64" - }, - { - "name": "base_amount_in", - "type": "u64" - }, - { - "name": "quote_amount_in", - "type": "u64" - }, - { - "name": "lp_mint_supply", - "type": "u64" - }, - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "user_base_token_account", - "type": "pubkey" - }, - { - "name": "user_quote_token_account", - "type": "pubkey" - }, - { - "name": "user_pool_token_account", - "type": "pubkey" - } - ] - } - }, - { - "name": "DisableEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "admin", - "type": "pubkey" - }, - { - "name": "disable_create_pool", - "type": "bool" - }, - { - "name": "disable_deposit", - "type": "bool" - }, - { - "name": "disable_withdraw", - "type": "bool" - }, - { - "name": "disable_buy", - "type": "bool" - }, - { - "name": "disable_sell", - "type": "bool" - } - ] - } - }, - { - "name": "ExtendAccountEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "account", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "current_size", - "type": "u64" - }, - { - "name": "new_size", - "type": "u64" - } - ] - } - }, - { - "name": "GlobalConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "admin", - "docs": ["The admin pubkey"], - "type": "pubkey" - }, - { - "name": "lp_fee_basis_points", - "docs": ["The lp fee in basis points (0.01%)"], - "type": "u64" - }, - { - "name": "protocol_fee_basis_points", - "docs": ["The protocol fee in basis points (0.01%)"], - "type": "u64" - }, - { - "name": "disable_flags", - "docs": [ - "Flags to disable certain functionality", - "bit 0 - Disable create pool", - "bit 1 - Disable deposit", - "bit 2 - Disable withdraw", - "bit 3 - Disable buy", - "bit 4 - Disable sell" - ], - "type": "u8" - }, - { - "name": "protocol_fee_recipients", - "docs": ["Addresses of the protocol fee recipients"], - "type": { - "array": ["pubkey", 8] - } - }, - { - "name": "coin_creator_fee_basis_points", - "docs": [ - "The coin creator fee in basis points (0.01%)" - ], - "type": "u64" - } - ] - } - }, - { - "name": "Pool", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_bump", - "type": "u8" - }, - { - "name": "index", - "type": "u16" - }, - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "base_mint", - "type": "pubkey" - }, - { - "name": "quote_mint", - "type": "pubkey" - }, - { - "name": "lp_mint", - "type": "pubkey" - }, - { - "name": "pool_base_token_account", - "type": "pubkey" - }, - { - "name": "pool_quote_token_account", - "type": "pubkey" - }, - { - "name": "lp_supply", - "docs": [ - "True circulating supply without burns and lock-ups" - ], - "type": "u64" - }, - { - "name": "coin_creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "SellEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "base_amount_in", - "type": "u64" - }, - { - "name": "min_quote_amount_out", - "type": "u64" - }, - { - "name": "user_base_token_reserves", - "type": "u64" - }, - { - "name": "user_quote_token_reserves", - "type": "u64" - }, - { - "name": "pool_base_token_reserves", - "type": "u64" - }, - { - "name": "pool_quote_token_reserves", - "type": "u64" - }, - { - "name": "quote_amount_out", - "type": "u64" - }, - { - "name": "lp_fee_basis_points", - "type": "u64" - }, - { - "name": "lp_fee", - "type": "u64" - }, - { - "name": "protocol_fee_basis_points", - "type": "u64" - }, - { - "name": "protocol_fee", - "type": "u64" - }, - { - "name": "quote_amount_out_without_lp_fee", - "type": "u64" - }, - { - "name": "user_quote_amount_out", - "type": "u64" - }, - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "user_base_token_account", - "type": "pubkey" - }, - { - "name": "user_quote_token_account", - "type": "pubkey" - }, - { - "name": "protocol_fee_recipient", - "type": "pubkey" - }, - { - "name": "protocol_fee_recipient_token_account", - "type": "pubkey" - }, - { - "name": "coin_creator", - "type": "pubkey" - }, - { - "name": "coin_creator_fee_basis_points", - "type": "u64" - }, - { - "name": "coin_creator_fee", - "type": "u64" - } - ] - } - }, - { - "name": "SetBondingCurveCoinCreatorEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "base_mint", - "type": "pubkey" - }, - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "bonding_curve", - "type": "pubkey" - }, - { - "name": "coin_creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "SetMetaplexCoinCreatorEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "base_mint", - "type": "pubkey" - }, - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "metadata", - "type": "pubkey" - }, - { - "name": "coin_creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "UpdateAdminEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "admin", - "type": "pubkey" - }, - { - "name": "new_admin", - "type": "pubkey" - } - ] - } - }, - { - "name": "UpdateFeeConfigEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "admin", - "type": "pubkey" - }, - { - "name": "lp_fee_basis_points", - "type": "u64" - }, - { - "name": "protocol_fee_basis_points", - "type": "u64" - }, - { - "name": "protocol_fee_recipients", - "type": { - "array": ["pubkey", 8] - } - }, - { - "name": "coin_creator_fee_basis_points", - "type": "u64" - } - ] - } - }, - { - "name": "WithdrawEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "lp_token_amount_in", - "type": "u64" - }, - { - "name": "min_base_amount_out", - "type": "u64" - }, - { - "name": "min_quote_amount_out", - "type": "u64" - }, - { - "name": "user_base_token_reserves", - "type": "u64" - }, - { - "name": "user_quote_token_reserves", - "type": "u64" - }, - { - "name": "pool_base_token_reserves", - "type": "u64" - }, - { - "name": "pool_quote_token_reserves", - "type": "u64" - }, - { - "name": "base_amount_out", - "type": "u64" - }, - { - "name": "quote_amount_out", - "type": "u64" - }, - { - "name": "lp_mint_supply", - "type": "u64" - }, - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "user_base_token_account", - "type": "pubkey" - }, - { - "name": "user_quote_token_account", - "type": "pubkey" - }, - { - "name": "user_pool_token_account", - "type": "pubkey" - } - ] - } - } - ] -} diff --git a/crates/pump-swaps-parser/proto/pump_swaps.proto b/crates/pump-swaps-parser/proto/pump_swaps.proto deleted file mode 100644 index 703bc76a..00000000 --- a/crates/pump-swaps-parser/proto/pump_swaps.proto +++ /dev/null @@ -1,519 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.pump_swaps; - -message BuyIx { - BuyIxAccounts accounts = 1; - BuyIxData data = 2; -} - -message CollectCoinCreatorFeeIx { - CollectCoinCreatorFeeIxAccounts accounts = 1; -} - -message CreateConfigIx { - CreateConfigIxAccounts accounts = 1; - CreateConfigIxData data = 2; -} - -message CreatePoolIx { - CreatePoolIxAccounts accounts = 1; - CreatePoolIxData data = 2; -} - -message DepositIx { - DepositIxAccounts accounts = 1; - DepositIxData data = 2; -} - -message DisableIx { - DisableIxAccounts accounts = 1; - DisableIxData data = 2; -} - -message ExtendAccountIx { - ExtendAccountIxAccounts accounts = 1; -} - -message SellIx { - SellIxAccounts accounts = 1; - SellIxData data = 2; -} - -message SetCoinCreatorIx { - SetCoinCreatorIxAccounts accounts = 1; -} - -message UpdateAdminIx { - UpdateAdminIxAccounts accounts = 1; -} - -message UpdateFeeConfigIx { - UpdateFeeConfigIxAccounts accounts = 1; - UpdateFeeConfigIxData data = 2; -} - -message WithdrawIx { - WithdrawIxAccounts accounts = 1; - WithdrawIxData data = 2; -} - - -message BuyEvent { - int64 timestamp = 1; - uint64 base_amount_out = 2; - uint64 max_quote_amount_in = 3; - uint64 user_base_token_reserves = 4; - uint64 user_quote_token_reserves = 5; - uint64 pool_base_token_reserves = 6; - uint64 pool_quote_token_reserves = 7; - uint64 quote_amount_in = 8; - uint64 lp_fee_basis_points = 9; - uint64 lp_fee = 10; - uint64 protocol_fee_basis_points = 11; - uint64 protocol_fee = 12; - uint64 quote_amount_in_with_lp_fee = 13; - uint64 user_quote_amount_in = 14; - string pool = 15; - string user = 16; - string user_base_token_account = 17; - string user_quote_token_account = 18; - string protocol_fee_recipient = 19; - string protocol_fee_recipient_token_account = 20; - string coin_creator = 21; - uint64 coin_creator_fee_basis_points = 22; - uint64 coin_creator_fee = 23; -} - -message CollectCoinCreatorFeeEvent { - int64 timestamp = 1; - string coin_creator = 2; - uint64 coin_creator_fee = 3; - string coin_creator_vault_ata = 4; - string coin_creator_token_account = 5; -} - -message CreateConfigEvent { - int64 timestamp = 1; - string admin = 2; - uint64 lp_fee_basis_points = 3; - uint64 protocol_fee_basis_points = 4; - repeated string protocol_fee_recipients = 5; - uint64 coin_creator_fee_basis_points = 6; -} - -message CreatePoolEvent { - int64 timestamp = 1; - uint32 index = 2; - string creator = 3; - string base_mint = 4; - string quote_mint = 5; - uint32 base_mint_decimals = 6; - uint32 quote_mint_decimals = 7; - uint64 base_amount_in = 8; - uint64 quote_amount_in = 9; - uint64 pool_base_amount = 10; - uint64 pool_quote_amount = 11; - uint64 minimum_liquidity = 12; - uint64 initial_liquidity = 13; - uint64 lp_token_amount_out = 14; - uint32 pool_bump = 15; - string pool = 16; - string lp_mint = 17; - string user_base_token_account = 18; - string user_quote_token_account = 19; - string coin_creator = 20; -} - -message DepositEvent { - int64 timestamp = 1; - uint64 lp_token_amount_out = 2; - uint64 max_base_amount_in = 3; - uint64 max_quote_amount_in = 4; - uint64 user_base_token_reserves = 5; - uint64 user_quote_token_reserves = 6; - uint64 pool_base_token_reserves = 7; - uint64 pool_quote_token_reserves = 8; - uint64 base_amount_in = 9; - uint64 quote_amount_in = 10; - uint64 lp_mint_supply = 11; - string pool = 12; - string user = 13; - string user_base_token_account = 14; - string user_quote_token_account = 15; - string user_pool_token_account = 16; -} - -message DisableEvent { - int64 timestamp = 1; - string admin = 2; - bool disable_create_pool = 3; - bool disable_deposit = 4; - bool disable_withdraw = 5; - bool disable_buy = 6; - bool disable_sell = 7; -} - -message ExtendAccountEvent { - int64 timestamp = 1; - string account = 2; - string user = 3; - uint64 current_size = 4; - uint64 new_size = 5; -} - -message SellEvent { - int64 timestamp = 1; - uint64 base_amount_in = 2; - uint64 min_quote_amount_out = 3; - uint64 user_base_token_reserves = 4; - uint64 user_quote_token_reserves = 5; - uint64 pool_base_token_reserves = 6; - uint64 pool_quote_token_reserves = 7; - uint64 quote_amount_out = 8; - uint64 lp_fee_basis_points = 9; - uint64 lp_fee = 10; - uint64 protocol_fee_basis_points = 11; - uint64 protocol_fee = 12; - uint64 quote_amount_out_without_lp_fee = 13; - uint64 user_quote_amount_out = 14; - string pool = 15; - string user = 16; - string user_base_token_account = 17; - string user_quote_token_account = 18; - string protocol_fee_recipient = 19; - string protocol_fee_recipient_token_account = 20; - string coin_creator = 21; - uint64 coin_creator_fee_basis_points = 22; - uint64 coin_creator_fee = 23; -} - -message SetBondingCurveCoinCreatorEvent { - int64 timestamp = 1; - string base_mint = 2; - string pool = 3; - string bonding_curve = 4; - string coin_creator = 5; -} - -message SetMetaplexCoinCreatorEvent { - int64 timestamp = 1; - string base_mint = 2; - string pool = 3; - string metadata = 4; - string coin_creator = 5; -} - -message UpdateAdminEvent { - int64 timestamp = 1; - string admin = 2; - string new_admin = 3; -} - -message UpdateFeeConfigEvent { - int64 timestamp = 1; - string admin = 2; - uint64 lp_fee_basis_points = 3; - uint64 protocol_fee_basis_points = 4; - repeated string protocol_fee_recipients = 5; - uint64 coin_creator_fee_basis_points = 6; -} - -message WithdrawEvent { - int64 timestamp = 1; - uint64 lp_token_amount_in = 2; - uint64 min_base_amount_out = 3; - uint64 min_quote_amount_out = 4; - uint64 user_base_token_reserves = 5; - uint64 user_quote_token_reserves = 6; - uint64 pool_base_token_reserves = 7; - uint64 pool_quote_token_reserves = 8; - uint64 base_amount_out = 9; - uint64 quote_amount_out = 10; - uint64 lp_mint_supply = 11; - string pool = 12; - string user = 13; - string user_base_token_account = 14; - string user_quote_token_account = 15; - string user_pool_token_account = 16; -} - - -message BondingCurve { - uint64 virtual_token_reserves = 1; - uint64 virtual_sol_reserves = 2; - uint64 real_token_reserves = 3; - uint64 real_sol_reserves = 4; - uint64 token_total_supply = 5; - bool complete = 6; - string creator = 7; -} - -message GlobalConfig { - string admin = 1; - uint64 lp_fee_basis_points = 2; - uint64 protocol_fee_basis_points = 3; - uint32 disable_flags = 4; - repeated string protocol_fee_recipients = 5; - uint64 coin_creator_fee_basis_points = 6; -} - -message Pool { - uint32 pool_bump = 1; - uint32 index = 2; - string creator = 3; - string base_mint = 4; - string quote_mint = 5; - string lp_mint = 6; - string pool_base_token_account = 7; - string pool_quote_token_account = 8; - uint64 lp_supply = 9; - string coin_creator = 10; -} - - -message BuyIxAccounts { - string pool = 1; - string user = 2; - string global_config = 3; - string base_mint = 4; - string quote_mint = 5; - string user_base_token_account = 6; - string user_quote_token_account = 7; - string pool_base_token_account = 8; - string pool_quote_token_account = 9; - string protocol_fee_recipient = 10; - string protocol_fee_recipient_token_account = 11; - string base_token_program = 12; - string quote_token_program = 13; - string system_program = 14; - string associated_token_program = 15; - string event_authority = 16; - string program = 17; - string coin_creator_vault_ata = 18; - string coin_creator_vault_authority = 19; -} - -message BuyIxData { - uint64 base_amount_out = 1; - uint64 max_quote_amount_in = 2; -} - -message CollectCoinCreatorFeeIxAccounts { - string quote_mint = 1; - string quote_token_program = 2; - string coin_creator = 3; - string coin_creator_vault_authority = 4; - string coin_creator_vault_ata = 5; - string coin_creator_token_account = 6; - string event_authority = 7; - string program = 8; -} - - -message CreateConfigIxAccounts { - string admin = 1; - string global_config = 2; - string system_program = 3; - string event_authority = 4; - string program = 5; -} - -message CreateConfigIxData { - uint64 lp_fee_basis_points = 1; - uint64 protocol_fee_basis_points = 2; - repeated string protocol_fee_recipients = 3; - uint64 coin_creator_fee_basis_points = 4; -} - -message CreatePoolIxAccounts { - string pool = 1; - string global_config = 2; - string creator = 3; - string base_mint = 4; - string quote_mint = 5; - string lp_mint = 6; - string user_base_token_account = 7; - string user_quote_token_account = 8; - string user_pool_token_account = 9; - string pool_base_token_account = 10; - string pool_quote_token_account = 11; - string system_program = 12; - string token2022_program = 13; - string base_token_program = 14; - string quote_token_program = 15; - string associated_token_program = 16; - string event_authority = 17; - string program = 18; -} - -message CreatePoolIxData { - uint32 index = 1; - uint64 base_amount_in = 2; - uint64 quote_amount_in = 3; - string coin_creator = 4; -} - -message DepositIxAccounts { - string pool = 1; - string global_config = 2; - string user = 3; - string base_mint = 4; - string quote_mint = 5; - string lp_mint = 6; - string user_base_token_account = 7; - string user_quote_token_account = 8; - string user_pool_token_account = 9; - string pool_base_token_account = 10; - string pool_quote_token_account = 11; - string token_program = 12; - string token2022_program = 13; - string event_authority = 14; - string program = 15; -} - -message DepositIxData { - uint64 lp_token_amount_out = 1; - uint64 max_base_amount_in = 2; - uint64 max_quote_amount_in = 3; -} - -message DisableIxAccounts { - string admin = 1; - string global_config = 2; - string event_authority = 3; - string program = 4; -} - -message DisableIxData { - bool disable_create_pool = 1; - bool disable_deposit = 2; - bool disable_withdraw = 3; - bool disable_buy = 4; - bool disable_sell = 5; -} - -message ExtendAccountIxAccounts { - string account = 1; - string user = 2; - string system_program = 3; - string event_authority = 4; - string program = 5; -} - - -message SellIxAccounts { - string pool = 1; - string user = 2; - string global_config = 3; - string base_mint = 4; - string quote_mint = 5; - string user_base_token_account = 6; - string user_quote_token_account = 7; - string pool_base_token_account = 8; - string pool_quote_token_account = 9; - string protocol_fee_recipient = 10; - string protocol_fee_recipient_token_account = 11; - string base_token_program = 12; - string quote_token_program = 13; - string system_program = 14; - string associated_token_program = 15; - string event_authority = 16; - string program = 17; - string coin_creator_vault_ata = 18; - string coin_creator_vault_authority = 19; -} - -message SellIxData { - uint64 base_amount_in = 1; - uint64 min_quote_amount_out = 2; -} - -message SetCoinCreatorIxAccounts { - string pool = 1; - string metadata = 2; - string bonding_curve = 3; - string event_authority = 4; - string program = 5; -} - - -message UpdateAdminIxAccounts { - string admin = 1; - string global_config = 2; - string new_admin = 3; - string event_authority = 4; - string program = 5; -} - - -message UpdateFeeConfigIxAccounts { - string admin = 1; - string global_config = 2; - string event_authority = 3; - string program = 4; -} - -message UpdateFeeConfigIxData { - uint64 lp_fee_basis_points = 1; - uint64 protocol_fee_basis_points = 2; - repeated string protocol_fee_recipients = 3; - uint64 coin_creator_fee_basis_points = 4; -} - -message WithdrawIxAccounts { - string pool = 1; - string global_config = 2; - string user = 3; - string base_mint = 4; - string quote_mint = 5; - string lp_mint = 6; - string user_base_token_account = 7; - string user_quote_token_account = 8; - string user_pool_token_account = 9; - string pool_base_token_account = 10; - string pool_quote_token_account = 11; - string token_program = 12; - string token2022_program = 13; - string event_authority = 14; - string program = 15; -} - -message WithdrawIxData { - uint64 lp_token_amount_in = 1; - uint64 min_base_amount_out = 2; - uint64 min_quote_amount_out = 3; -} - - -message ProgramState { - oneof state_oneof { - BondingCurve bonding_curve = 1; - GlobalConfig global_config = 2; - Pool pool = 3; - } -} - -message ProgramIxs { - oneof ix_oneof { - BuyIx buy = 1; - CollectCoinCreatorFeeIx collect_coin_creator_fee = 2; - CreateConfigIx create_config = 3; - CreatePoolIx create_pool = 4; - DepositIx deposit = 5; - DisableIx disable = 6; - ExtendAccountIx extend_account = 7; - SellIx sell = 8; - SetCoinCreatorIx set_coin_creator = 9; - UpdateAdminIx update_admin = 10; - UpdateFeeConfigIx update_fee_config = 11; - WithdrawIx withdraw = 12; - } -} - diff --git a/crates/pump-swaps-parser/src/custom_impl/mod.rs b/crates/pump-swaps-parser/src/custom_impl/mod.rs deleted file mode 100644 index e9f09b9f..00000000 --- a/crates/pump-swaps-parser/src/custom_impl/mod.rs +++ /dev/null @@ -1 +0,0 @@ -//! Placeholder for custom impls that are not overriden by the generated code. diff --git a/crates/pump-swaps-parser/src/generated_parser/accounts_parser.rs b/crates/pump-swaps-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index dcf9516a..00000000 --- a/crates/pump-swaps-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,194 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{BondingCurve, GlobalConfig, Pool}, - deserialize_checked, ID, -}; - -/// PumpAmm Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum PumpAmmProgramState { - BondingCurve(BondingCurve), - GlobalConfig(GlobalConfig), - Pool(Pool), -} - -impl PumpAmmProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [23, 183, 248, 55, 96, 216, 172, 96] => Ok(PumpAmmProgramState::BondingCurve( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [149, 8, 156, 202, 160, 252, 176, 217] => Ok(PumpAmmProgramState::GlobalConfig( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [241, 154, 109, 4, 17, 177, 109, 188] => Ok(PumpAmmProgramState::Pool( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = PumpAmmProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "pump_amm::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = PumpAmmProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, BondingCurve, PumpAmmProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for BondingCurve { - fn into_proto(self) -> proto_def::BondingCurve { - proto_def::BondingCurve { - virtual_token_reserves: self.virtual_token_reserves, - virtual_sol_reserves: self.virtual_sol_reserves, - real_token_reserves: self.real_token_reserves, - real_sol_reserves: self.real_sol_reserves, - token_total_supply: self.token_total_supply, - complete: self.complete, - creator: self.creator.to_string(), - } - } - } - use super::GlobalConfig; - impl IntoProto for GlobalConfig { - fn into_proto(self) -> proto_def::GlobalConfig { - proto_def::GlobalConfig { - admin: self.admin.to_string(), - lp_fee_basis_points: self.lp_fee_basis_points, - protocol_fee_basis_points: self.protocol_fee_basis_points, - disable_flags: self.disable_flags.into(), - protocol_fee_recipients: self - .protocol_fee_recipients - .into_iter() - .map(|x| x.to_string()) - .collect(), - coin_creator_fee_basis_points: self.coin_creator_fee_basis_points, - } - } - } - use super::Pool; - impl IntoProto for Pool { - fn into_proto(self) -> proto_def::Pool { - proto_def::Pool { - pool_bump: self.pool_bump.into(), - index: self.index.into(), - creator: self.creator.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - pool_base_token_account: self.pool_base_token_account.to_string(), - pool_quote_token_account: self.pool_quote_token_account.to_string(), - lp_supply: self.lp_supply, - coin_creator: self.coin_creator.to_string(), - } - } - } - - impl IntoProto for PumpAmmProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - PumpAmmProgramState::BondingCurve(data) => { - proto_def::program_state::StateOneof::BondingCurve(data.into_proto()) - }, - PumpAmmProgramState::GlobalConfig(data) => { - proto_def::program_state::StateOneof::GlobalConfig(data.into_proto()) - }, - PumpAmmProgramState::Pool(data) => { - proto_def::program_state::StateOneof::Pool(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/pump-swaps-parser/src/generated_parser/instructions_parser.rs b/crates/pump-swaps-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index 62dc4b43..00000000 --- a/crates/pump-swaps-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,838 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - Buy as BuyIxAccounts, BuyInstructionArgs as BuyIxData, - CollectCoinCreatorFee as CollectCoinCreatorFeeIxAccounts, - CreateConfig as CreateConfigIxAccounts, CreateConfigInstructionArgs as CreateConfigIxData, - CreatePool as CreatePoolIxAccounts, CreatePoolInstructionArgs as CreatePoolIxData, - Deposit as DepositIxAccounts, DepositInstructionArgs as DepositIxData, - Disable as DisableIxAccounts, DisableInstructionArgs as DisableIxData, - ExtendAccount as ExtendAccountIxAccounts, Sell as SellIxAccounts, - SellInstructionArgs as SellIxData, SetCoinCreator as SetCoinCreatorIxAccounts, - UpdateAdmin as UpdateAdminIxAccounts, UpdateFeeConfig as UpdateFeeConfigIxAccounts, - UpdateFeeConfigInstructionArgs as UpdateFeeConfigIxData, Withdraw as WithdrawIxAccounts, - WithdrawInstructionArgs as WithdrawIxData, - }, - ID, -}; - -/// PumpAmm Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum PumpAmmProgramIx { - Buy(BuyIxAccounts, BuyIxData), - CollectCoinCreatorFee(CollectCoinCreatorFeeIxAccounts), - CreateConfig(CreateConfigIxAccounts, CreateConfigIxData), - CreatePool(CreatePoolIxAccounts, CreatePoolIxData), - Deposit(DepositIxAccounts, DepositIxData), - Disable(DisableIxAccounts, DisableIxData), - ExtendAccount(ExtendAccountIxAccounts), - Sell(SellIxAccounts, SellIxData), - SetCoinCreator(SetCoinCreatorIxAccounts), - UpdateAdmin(UpdateAdminIxAccounts), - UpdateFeeConfig(UpdateFeeConfigIxAccounts, UpdateFeeConfigIxData), - Withdraw(WithdrawIxAccounts, WithdrawIxData), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = PumpAmmProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "PumpAmm::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [102, 6, 61, 18, 1, 218, 235, 234] => { - let expected_accounts_len = 19; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = BuyIxAccounts { - pool: next_account(accounts)?, - user: next_account(accounts)?, - global_config: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - user_base_token_account: next_account(accounts)?, - user_quote_token_account: next_account(accounts)?, - pool_base_token_account: next_account(accounts)?, - pool_quote_token_account: next_account(accounts)?, - protocol_fee_recipient: next_account(accounts)?, - protocol_fee_recipient_token_account: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - coin_creator_vault_ata: next_account(accounts)?, - coin_creator_vault_authority: next_account(accounts)?, - }; - let de_ix_data: BuyIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpAmmProgramIx::Buy(ix_accounts, de_ix_data)) - }, - [160, 57, 89, 42, 181, 139, 43, 66] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectCoinCreatorFeeIxAccounts { - quote_mint: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - coin_creator: next_account(accounts)?, - coin_creator_vault_authority: next_account(accounts)?, - coin_creator_vault_ata: next_account(accounts)?, - coin_creator_token_account: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(PumpAmmProgramIx::CollectCoinCreatorFee(ix_accounts)) - }, - [201, 207, 243, 114, 75, 111, 47, 189] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateConfigIxAccounts { - admin: next_account(accounts)?, - global_config: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: CreateConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpAmmProgramIx::CreateConfig(ix_accounts, de_ix_data)) - }, - [233, 146, 209, 142, 207, 104, 64, 188] => { - let expected_accounts_len = 18; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreatePoolIxAccounts { - pool: next_account(accounts)?, - global_config: next_account(accounts)?, - creator: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_base_token_account: next_account(accounts)?, - user_quote_token_account: next_account(accounts)?, - user_pool_token_account: next_account(accounts)?, - pool_base_token_account: next_account(accounts)?, - pool_quote_token_account: next_account(accounts)?, - system_program: next_account(accounts)?, - token2022_program: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: CreatePoolIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpAmmProgramIx::CreatePool(ix_accounts, de_ix_data)) - }, - [242, 35, 198, 137, 82, 225, 242, 182] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DepositIxAccounts { - pool: next_account(accounts)?, - global_config: next_account(accounts)?, - user: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_base_token_account: next_account(accounts)?, - user_quote_token_account: next_account(accounts)?, - user_pool_token_account: next_account(accounts)?, - pool_base_token_account: next_account(accounts)?, - pool_quote_token_account: next_account(accounts)?, - token_program: next_account(accounts)?, - token2022_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: DepositIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpAmmProgramIx::Deposit(ix_accounts, de_ix_data)) - }, - [185, 173, 187, 90, 216, 15, 238, 233] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DisableIxAccounts { - admin: next_account(accounts)?, - global_config: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: DisableIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpAmmProgramIx::Disable(ix_accounts, de_ix_data)) - }, - [234, 102, 194, 203, 150, 72, 62, 229] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ExtendAccountIxAccounts { - account: next_account(accounts)?, - user: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(PumpAmmProgramIx::ExtendAccount(ix_accounts)) - }, - [51, 230, 133, 164, 1, 127, 131, 173] => { - let expected_accounts_len = 19; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SellIxAccounts { - pool: next_account(accounts)?, - user: next_account(accounts)?, - global_config: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - user_base_token_account: next_account(accounts)?, - user_quote_token_account: next_account(accounts)?, - pool_base_token_account: next_account(accounts)?, - pool_quote_token_account: next_account(accounts)?, - protocol_fee_recipient: next_account(accounts)?, - protocol_fee_recipient_token_account: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - coin_creator_vault_ata: next_account(accounts)?, - coin_creator_vault_authority: next_account(accounts)?, - }; - let de_ix_data: SellIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpAmmProgramIx::Sell(ix_accounts, de_ix_data)) - }, - [210, 149, 128, 45, 188, 58, 78, 175] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetCoinCreatorIxAccounts { - pool: next_account(accounts)?, - metadata: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(PumpAmmProgramIx::SetCoinCreator(ix_accounts)) - }, - [161, 176, 40, 213, 60, 184, 179, 228] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateAdminIxAccounts { - admin: next_account(accounts)?, - global_config: next_account(accounts)?, - new_admin: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(PumpAmmProgramIx::UpdateAdmin(ix_accounts)) - }, - [104, 184, 103, 242, 88, 151, 107, 20] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateFeeConfigIxAccounts { - admin: next_account(accounts)?, - global_config: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: UpdateFeeConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpAmmProgramIx::UpdateFeeConfig(ix_accounts, de_ix_data)) - }, - [183, 18, 70, 156, 148, 109, 161, 34] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawIxAccounts { - pool: next_account(accounts)?, - global_config: next_account(accounts)?, - user: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_base_token_account: next_account(accounts)?, - user_quote_token_account: next_account(accounts)?, - user_pool_token_account: next_account(accounts)?, - pool_base_token_account: next_account(accounts)?, - pool_quote_token_account: next_account(accounts)?, - token_program: next_account(accounts)?, - token2022_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: WithdrawIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpAmmProgramIx::Withdraw(ix_accounts, de_ix_data)) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{BuyIxAccounts, InstructionParser, PumpAmmProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for BuyIxAccounts { - fn into_proto(self) -> proto_def::BuyIxAccounts { - proto_def::BuyIxAccounts { - pool: self.pool.to_string(), - user: self.user.to_string(), - global_config: self.global_config.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - user_base_token_account: self.user_base_token_account.to_string(), - user_quote_token_account: self.user_quote_token_account.to_string(), - pool_base_token_account: self.pool_base_token_account.to_string(), - pool_quote_token_account: self.pool_quote_token_account.to_string(), - protocol_fee_recipient: self.protocol_fee_recipient.to_string(), - protocol_fee_recipient_token_account: self - .protocol_fee_recipient_token_account - .to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - system_program: self.system_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - coin_creator_vault_ata: self.coin_creator_vault_ata.to_string(), - coin_creator_vault_authority: self.coin_creator_vault_authority.to_string(), - } - } - } - use super::BuyIxData; - impl IntoProto for BuyIxData { - fn into_proto(self) -> proto_def::BuyIxData { - proto_def::BuyIxData { - base_amount_out: self.base_amount_out, - max_quote_amount_in: self.max_quote_amount_in, - } - } - } - use super::CollectCoinCreatorFeeIxAccounts; - impl IntoProto for CollectCoinCreatorFeeIxAccounts { - fn into_proto(self) -> proto_def::CollectCoinCreatorFeeIxAccounts { - proto_def::CollectCoinCreatorFeeIxAccounts { - quote_mint: self.quote_mint.to_string(), - quote_token_program: self.quote_token_program.to_string(), - coin_creator: self.coin_creator.to_string(), - coin_creator_vault_authority: self.coin_creator_vault_authority.to_string(), - coin_creator_vault_ata: self.coin_creator_vault_ata.to_string(), - coin_creator_token_account: self.coin_creator_token_account.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateConfigIxAccounts; - impl IntoProto for CreateConfigIxAccounts { - fn into_proto(self) -> proto_def::CreateConfigIxAccounts { - proto_def::CreateConfigIxAccounts { - admin: self.admin.to_string(), - global_config: self.global_config.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateConfigIxData; - impl IntoProto for CreateConfigIxData { - fn into_proto(self) -> proto_def::CreateConfigIxData { - proto_def::CreateConfigIxData { - lp_fee_basis_points: self.lp_fee_basis_points, - protocol_fee_basis_points: self.protocol_fee_basis_points, - protocol_fee_recipients: self - .protocol_fee_recipients - .into_iter() - .map(|x| x.to_string()) - .collect(), - coin_creator_fee_basis_points: self.coin_creator_fee_basis_points, - } - } - } - use super::CreatePoolIxAccounts; - impl IntoProto for CreatePoolIxAccounts { - fn into_proto(self) -> proto_def::CreatePoolIxAccounts { - proto_def::CreatePoolIxAccounts { - pool: self.pool.to_string(), - global_config: self.global_config.to_string(), - creator: self.creator.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - user_base_token_account: self.user_base_token_account.to_string(), - user_quote_token_account: self.user_quote_token_account.to_string(), - user_pool_token_account: self.user_pool_token_account.to_string(), - pool_base_token_account: self.pool_base_token_account.to_string(), - pool_quote_token_account: self.pool_quote_token_account.to_string(), - system_program: self.system_program.to_string(), - token2022_program: self.token2022_program.to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreatePoolIxData; - impl IntoProto for CreatePoolIxData { - fn into_proto(self) -> proto_def::CreatePoolIxData { - proto_def::CreatePoolIxData { - index: self.index.into(), - base_amount_in: self.base_amount_in, - quote_amount_in: self.quote_amount_in, - coin_creator: self.coin_creator.to_string(), - } - } - } - use super::DepositIxAccounts; - impl IntoProto for DepositIxAccounts { - fn into_proto(self) -> proto_def::DepositIxAccounts { - proto_def::DepositIxAccounts { - pool: self.pool.to_string(), - global_config: self.global_config.to_string(), - user: self.user.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - user_base_token_account: self.user_base_token_account.to_string(), - user_quote_token_account: self.user_quote_token_account.to_string(), - user_pool_token_account: self.user_pool_token_account.to_string(), - pool_base_token_account: self.pool_base_token_account.to_string(), - pool_quote_token_account: self.pool_quote_token_account.to_string(), - token_program: self.token_program.to_string(), - token2022_program: self.token2022_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::DepositIxData; - impl IntoProto for DepositIxData { - fn into_proto(self) -> proto_def::DepositIxData { - proto_def::DepositIxData { - lp_token_amount_out: self.lp_token_amount_out, - max_base_amount_in: self.max_base_amount_in, - max_quote_amount_in: self.max_quote_amount_in, - } - } - } - use super::DisableIxAccounts; - impl IntoProto for DisableIxAccounts { - fn into_proto(self) -> proto_def::DisableIxAccounts { - proto_def::DisableIxAccounts { - admin: self.admin.to_string(), - global_config: self.global_config.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::DisableIxData; - impl IntoProto for DisableIxData { - fn into_proto(self) -> proto_def::DisableIxData { - proto_def::DisableIxData { - disable_create_pool: self.disable_create_pool, - disable_deposit: self.disable_deposit, - disable_withdraw: self.disable_withdraw, - disable_buy: self.disable_buy, - disable_sell: self.disable_sell, - } - } - } - use super::ExtendAccountIxAccounts; - impl IntoProto for ExtendAccountIxAccounts { - fn into_proto(self) -> proto_def::ExtendAccountIxAccounts { - proto_def::ExtendAccountIxAccounts { - account: self.account.to_string(), - user: self.user.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SellIxAccounts; - impl IntoProto for SellIxAccounts { - fn into_proto(self) -> proto_def::SellIxAccounts { - proto_def::SellIxAccounts { - pool: self.pool.to_string(), - user: self.user.to_string(), - global_config: self.global_config.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - user_base_token_account: self.user_base_token_account.to_string(), - user_quote_token_account: self.user_quote_token_account.to_string(), - pool_base_token_account: self.pool_base_token_account.to_string(), - pool_quote_token_account: self.pool_quote_token_account.to_string(), - protocol_fee_recipient: self.protocol_fee_recipient.to_string(), - protocol_fee_recipient_token_account: self - .protocol_fee_recipient_token_account - .to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - system_program: self.system_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - coin_creator_vault_ata: self.coin_creator_vault_ata.to_string(), - coin_creator_vault_authority: self.coin_creator_vault_authority.to_string(), - } - } - } - use super::SellIxData; - impl IntoProto for SellIxData { - fn into_proto(self) -> proto_def::SellIxData { - proto_def::SellIxData { - base_amount_in: self.base_amount_in, - min_quote_amount_out: self.min_quote_amount_out, - } - } - } - use super::SetCoinCreatorIxAccounts; - impl IntoProto for SetCoinCreatorIxAccounts { - fn into_proto(self) -> proto_def::SetCoinCreatorIxAccounts { - proto_def::SetCoinCreatorIxAccounts { - pool: self.pool.to_string(), - metadata: self.metadata.to_string(), - bonding_curve: self.bonding_curve.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateAdminIxAccounts; - impl IntoProto for UpdateAdminIxAccounts { - fn into_proto(self) -> proto_def::UpdateAdminIxAccounts { - proto_def::UpdateAdminIxAccounts { - admin: self.admin.to_string(), - global_config: self.global_config.to_string(), - new_admin: self.new_admin.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateFeeConfigIxAccounts; - impl IntoProto for UpdateFeeConfigIxAccounts { - fn into_proto(self) -> proto_def::UpdateFeeConfigIxAccounts { - proto_def::UpdateFeeConfigIxAccounts { - admin: self.admin.to_string(), - global_config: self.global_config.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::UpdateFeeConfigIxData; - impl IntoProto for UpdateFeeConfigIxData { - fn into_proto(self) -> proto_def::UpdateFeeConfigIxData { - proto_def::UpdateFeeConfigIxData { - lp_fee_basis_points: self.lp_fee_basis_points, - protocol_fee_basis_points: self.protocol_fee_basis_points, - protocol_fee_recipients: self - .protocol_fee_recipients - .into_iter() - .map(|x| x.to_string()) - .collect(), - coin_creator_fee_basis_points: self.coin_creator_fee_basis_points, - } - } - } - use super::WithdrawIxAccounts; - impl IntoProto for WithdrawIxAccounts { - fn into_proto(self) -> proto_def::WithdrawIxAccounts { - proto_def::WithdrawIxAccounts { - pool: self.pool.to_string(), - global_config: self.global_config.to_string(), - user: self.user.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - user_base_token_account: self.user_base_token_account.to_string(), - user_quote_token_account: self.user_quote_token_account.to_string(), - user_pool_token_account: self.user_pool_token_account.to_string(), - pool_base_token_account: self.pool_base_token_account.to_string(), - pool_quote_token_account: self.pool_quote_token_account.to_string(), - token_program: self.token_program.to_string(), - token2022_program: self.token2022_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::WithdrawIxData; - impl IntoProto for WithdrawIxData { - fn into_proto(self) -> proto_def::WithdrawIxData { - proto_def::WithdrawIxData { - lp_token_amount_in: self.lp_token_amount_in, - min_base_amount_out: self.min_base_amount_out, - min_quote_amount_out: self.min_quote_amount_out, - } - } - } - - impl IntoProto for PumpAmmProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - PumpAmmProgramIx::Buy(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Buy(proto_def::BuyIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - PumpAmmProgramIx::CollectCoinCreatorFee(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectCoinCreatorFee( - proto_def::CollectCoinCreatorFeeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - PumpAmmProgramIx::CreateConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateConfig( - proto_def::CreateConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - PumpAmmProgramIx::CreatePool(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreatePool( - proto_def::CreatePoolIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - PumpAmmProgramIx::Deposit(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Deposit( - proto_def::DepositIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - PumpAmmProgramIx::Disable(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Disable( - proto_def::DisableIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - PumpAmmProgramIx::ExtendAccount(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ExtendAccount( - proto_def::ExtendAccountIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - PumpAmmProgramIx::Sell(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Sell(proto_def::SellIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - PumpAmmProgramIx::SetCoinCreator(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetCoinCreator( - proto_def::SetCoinCreatorIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - PumpAmmProgramIx::UpdateAdmin(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateAdmin( - proto_def::UpdateAdminIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - PumpAmmProgramIx::UpdateFeeConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateFeeConfig( - proto_def::UpdateFeeConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - PumpAmmProgramIx::Withdraw(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Withdraw( - proto_def::WithdrawIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/pump-swaps-parser/src/generated_parser/mod.rs b/crates/pump-swaps-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/pump-swaps-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/pump-swaps-parser/src/generated_parser/proto_helpers.rs b/crates/pump-swaps-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index edc05f5d..00000000 --- a/crates/pump-swaps-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,255 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::BuyEvent}; - impl IntoProto for BuyEvent { - fn into_proto(self) -> proto_def::BuyEvent { - proto_def::BuyEvent { - timestamp: self.timestamp, - base_amount_out: self.base_amount_out, - max_quote_amount_in: self.max_quote_amount_in, - user_base_token_reserves: self.user_base_token_reserves, - user_quote_token_reserves: self.user_quote_token_reserves, - pool_base_token_reserves: self.pool_base_token_reserves, - pool_quote_token_reserves: self.pool_quote_token_reserves, - quote_amount_in: self.quote_amount_in, - lp_fee_basis_points: self.lp_fee_basis_points, - lp_fee: self.lp_fee, - protocol_fee_basis_points: self.protocol_fee_basis_points, - protocol_fee: self.protocol_fee, - quote_amount_in_with_lp_fee: self.quote_amount_in_with_lp_fee, - user_quote_amount_in: self.user_quote_amount_in, - pool: self.pool.to_string(), - user: self.user.to_string(), - user_base_token_account: self.user_base_token_account.to_string(), - user_quote_token_account: self.user_quote_token_account.to_string(), - protocol_fee_recipient: self.protocol_fee_recipient.to_string(), - protocol_fee_recipient_token_account: self - .protocol_fee_recipient_token_account - .to_string(), - coin_creator: self.coin_creator.to_string(), - coin_creator_fee_basis_points: self.coin_creator_fee_basis_points, - coin_creator_fee: self.coin_creator_fee, - } - } - } - use crate::types::CollectCoinCreatorFeeEvent; - impl IntoProto for CollectCoinCreatorFeeEvent { - fn into_proto(self) -> proto_def::CollectCoinCreatorFeeEvent { - proto_def::CollectCoinCreatorFeeEvent { - timestamp: self.timestamp, - coin_creator: self.coin_creator.to_string(), - coin_creator_fee: self.coin_creator_fee, - coin_creator_vault_ata: self.coin_creator_vault_ata.to_string(), - coin_creator_token_account: self.coin_creator_token_account.to_string(), - } - } - } - use crate::types::CreateConfigEvent; - impl IntoProto for CreateConfigEvent { - fn into_proto(self) -> proto_def::CreateConfigEvent { - proto_def::CreateConfigEvent { - timestamp: self.timestamp, - admin: self.admin.to_string(), - lp_fee_basis_points: self.lp_fee_basis_points, - protocol_fee_basis_points: self.protocol_fee_basis_points, - protocol_fee_recipients: self - .protocol_fee_recipients - .into_iter() - .map(|x| x.to_string()) - .collect(), - coin_creator_fee_basis_points: self.coin_creator_fee_basis_points, - } - } - } - use crate::types::CreatePoolEvent; - impl IntoProto for CreatePoolEvent { - fn into_proto(self) -> proto_def::CreatePoolEvent { - proto_def::CreatePoolEvent { - timestamp: self.timestamp, - index: self.index.into(), - creator: self.creator.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - base_mint_decimals: self.base_mint_decimals.into(), - quote_mint_decimals: self.quote_mint_decimals.into(), - base_amount_in: self.base_amount_in, - quote_amount_in: self.quote_amount_in, - pool_base_amount: self.pool_base_amount, - pool_quote_amount: self.pool_quote_amount, - minimum_liquidity: self.minimum_liquidity, - initial_liquidity: self.initial_liquidity, - lp_token_amount_out: self.lp_token_amount_out, - pool_bump: self.pool_bump.into(), - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - user_base_token_account: self.user_base_token_account.to_string(), - user_quote_token_account: self.user_quote_token_account.to_string(), - coin_creator: self.coin_creator.to_string(), - } - } - } - use crate::types::DepositEvent; - impl IntoProto for DepositEvent { - fn into_proto(self) -> proto_def::DepositEvent { - proto_def::DepositEvent { - timestamp: self.timestamp, - lp_token_amount_out: self.lp_token_amount_out, - max_base_amount_in: self.max_base_amount_in, - max_quote_amount_in: self.max_quote_amount_in, - user_base_token_reserves: self.user_base_token_reserves, - user_quote_token_reserves: self.user_quote_token_reserves, - pool_base_token_reserves: self.pool_base_token_reserves, - pool_quote_token_reserves: self.pool_quote_token_reserves, - base_amount_in: self.base_amount_in, - quote_amount_in: self.quote_amount_in, - lp_mint_supply: self.lp_mint_supply, - pool: self.pool.to_string(), - user: self.user.to_string(), - user_base_token_account: self.user_base_token_account.to_string(), - user_quote_token_account: self.user_quote_token_account.to_string(), - user_pool_token_account: self.user_pool_token_account.to_string(), - } - } - } - use crate::types::DisableEvent; - impl IntoProto for DisableEvent { - fn into_proto(self) -> proto_def::DisableEvent { - proto_def::DisableEvent { - timestamp: self.timestamp, - admin: self.admin.to_string(), - disable_create_pool: self.disable_create_pool, - disable_deposit: self.disable_deposit, - disable_withdraw: self.disable_withdraw, - disable_buy: self.disable_buy, - disable_sell: self.disable_sell, - } - } - } - use crate::types::ExtendAccountEvent; - impl IntoProto for ExtendAccountEvent { - fn into_proto(self) -> proto_def::ExtendAccountEvent { - proto_def::ExtendAccountEvent { - timestamp: self.timestamp, - account: self.account.to_string(), - user: self.user.to_string(), - current_size: self.current_size, - new_size: self.new_size, - } - } - } - use crate::types::SellEvent; - impl IntoProto for SellEvent { - fn into_proto(self) -> proto_def::SellEvent { - proto_def::SellEvent { - timestamp: self.timestamp, - base_amount_in: self.base_amount_in, - min_quote_amount_out: self.min_quote_amount_out, - user_base_token_reserves: self.user_base_token_reserves, - user_quote_token_reserves: self.user_quote_token_reserves, - pool_base_token_reserves: self.pool_base_token_reserves, - pool_quote_token_reserves: self.pool_quote_token_reserves, - quote_amount_out: self.quote_amount_out, - lp_fee_basis_points: self.lp_fee_basis_points, - lp_fee: self.lp_fee, - protocol_fee_basis_points: self.protocol_fee_basis_points, - protocol_fee: self.protocol_fee, - quote_amount_out_without_lp_fee: self.quote_amount_out_without_lp_fee, - user_quote_amount_out: self.user_quote_amount_out, - pool: self.pool.to_string(), - user: self.user.to_string(), - user_base_token_account: self.user_base_token_account.to_string(), - user_quote_token_account: self.user_quote_token_account.to_string(), - protocol_fee_recipient: self.protocol_fee_recipient.to_string(), - protocol_fee_recipient_token_account: self - .protocol_fee_recipient_token_account - .to_string(), - coin_creator: self.coin_creator.to_string(), - coin_creator_fee_basis_points: self.coin_creator_fee_basis_points, - coin_creator_fee: self.coin_creator_fee, - } - } - } - use crate::types::SetBondingCurveCoinCreatorEvent; - impl IntoProto for SetBondingCurveCoinCreatorEvent { - fn into_proto(self) -> proto_def::SetBondingCurveCoinCreatorEvent { - proto_def::SetBondingCurveCoinCreatorEvent { - timestamp: self.timestamp, - base_mint: self.base_mint.to_string(), - pool: self.pool.to_string(), - bonding_curve: self.bonding_curve.to_string(), - coin_creator: self.coin_creator.to_string(), - } - } - } - use crate::types::SetMetaplexCoinCreatorEvent; - impl IntoProto for SetMetaplexCoinCreatorEvent { - fn into_proto(self) -> proto_def::SetMetaplexCoinCreatorEvent { - proto_def::SetMetaplexCoinCreatorEvent { - timestamp: self.timestamp, - base_mint: self.base_mint.to_string(), - pool: self.pool.to_string(), - metadata: self.metadata.to_string(), - coin_creator: self.coin_creator.to_string(), - } - } - } - use crate::types::UpdateAdminEvent; - impl IntoProto for UpdateAdminEvent { - fn into_proto(self) -> proto_def::UpdateAdminEvent { - proto_def::UpdateAdminEvent { - timestamp: self.timestamp, - admin: self.admin.to_string(), - new_admin: self.new_admin.to_string(), - } - } - } - use crate::types::UpdateFeeConfigEvent; - impl IntoProto for UpdateFeeConfigEvent { - fn into_proto(self) -> proto_def::UpdateFeeConfigEvent { - proto_def::UpdateFeeConfigEvent { - timestamp: self.timestamp, - admin: self.admin.to_string(), - lp_fee_basis_points: self.lp_fee_basis_points, - protocol_fee_basis_points: self.protocol_fee_basis_points, - protocol_fee_recipients: self - .protocol_fee_recipients - .into_iter() - .map(|x| x.to_string()) - .collect(), - coin_creator_fee_basis_points: self.coin_creator_fee_basis_points, - } - } - } - use crate::types::WithdrawEvent; - impl IntoProto for WithdrawEvent { - fn into_proto(self) -> proto_def::WithdrawEvent { - proto_def::WithdrawEvent { - timestamp: self.timestamp, - lp_token_amount_in: self.lp_token_amount_in, - min_base_amount_out: self.min_base_amount_out, - min_quote_amount_out: self.min_quote_amount_out, - user_base_token_reserves: self.user_base_token_reserves, - user_quote_token_reserves: self.user_quote_token_reserves, - pool_base_token_reserves: self.pool_base_token_reserves, - pool_quote_token_reserves: self.pool_quote_token_reserves, - base_amount_out: self.base_amount_out, - quote_amount_out: self.quote_amount_out, - lp_mint_supply: self.lp_mint_supply, - pool: self.pool.to_string(), - user: self.user.to_string(), - user_base_token_account: self.user_base_token_account.to_string(), - user_quote_token_account: self.user_quote_token_account.to_string(), - user_pool_token_account: self.user_pool_token_account.to_string(), - } - } - } -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/accounts/bonding_curve.rs b/crates/pump-swaps-parser/src/generated_sdk/accounts/bonding_curve.rs deleted file mode 100644 index 45c195a3..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/accounts/bonding_curve.rs +++ /dev/null @@ -1,138 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BondingCurve { - pub discriminator: [u8; 8], - pub virtual_token_reserves: u64, - pub virtual_sol_reserves: u64, - pub real_token_reserves: u64, - pub real_sol_reserves: u64, - pub token_total_supply: u64, - pub complete: bool, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, -} - -impl BondingCurve { - pub const LEN: usize = 81; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for BondingCurve { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_bonding_curve(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = BondingCurve::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_bonding_curve(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = BondingCurve::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for BondingCurve { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for BondingCurve {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for BondingCurve { - fn owner() -> Pubkey { crate::PUMP_AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for BondingCurve {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for BondingCurve { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/accounts/global_config.rs b/crates/pump-swaps-parser/src/generated_sdk/accounts/global_config.rs deleted file mode 100644 index 8ef420ee..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/accounts/global_config.rs +++ /dev/null @@ -1,148 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct GlobalConfig { - pub discriminator: [u8; 8], - /// The admin pubkey - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub admin: Pubkey, - /// The lp fee in basis points (0.01%) - pub lp_fee_basis_points: u64, - /// The protocol fee in basis points (0.01%) - pub protocol_fee_basis_points: u64, - /// Flags to disable certain functionality - /// bit 0 - Disable create pool - /// bit 1 - Disable deposit - /// bit 2 - Disable withdraw - /// bit 3 - Disable buy - /// bit 4 - Disable sell - pub disable_flags: u8, - /// Addresses of the protocol fee recipients - pub protocol_fee_recipients: [Pubkey; 8], - /// The coin creator fee in basis points (0.01%) - pub coin_creator_fee_basis_points: u64, -} - -impl GlobalConfig { - pub const LEN: usize = 321; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for GlobalConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_global_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_global_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_global_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = GlobalConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_global_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_global_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_global_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = GlobalConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for GlobalConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for GlobalConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for GlobalConfig { - fn owner() -> Pubkey { crate::PUMP_AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for GlobalConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for GlobalConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/accounts/mod.rs b/crates/pump-swaps-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index ec4fa857..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#bonding_curve; -pub(crate) mod r#global_config; -pub(crate) mod r#pool; - -pub use self::{r#bonding_curve::*, r#global_config::*, r#pool::*}; diff --git a/crates/pump-swaps-parser/src/generated_sdk/accounts/pool.rs b/crates/pump-swaps-parser/src/generated_sdk/accounts/pool.rs deleted file mode 100644 index b8d42243..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/accounts/pool.rs +++ /dev/null @@ -1,166 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Pool { - pub discriminator: [u8; 8], - pub pool_bump: u8, - pub index: u16, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub quote_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lp_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_base_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_quote_token_account: Pubkey, - /// True circulating supply without burns and lock-ups - pub lp_supply: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub coin_creator: Pubkey, -} - -impl Pool { - pub const LEN: usize = 243; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Pool { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_pool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_pool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_pool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Pool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_pool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_pool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_pool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Pool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Pool { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Pool {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Pool { - fn owner() -> Pubkey { crate::PUMP_AMM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Pool {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Pool { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/errors/mod.rs b/crates/pump-swaps-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 2eeaa4f3..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod pump_amm; - -pub use self::pump_amm::PumpAmmError; diff --git a/crates/pump-swaps-parser/src/generated_sdk/errors/pump_amm.rs b/crates/pump-swaps-parser/src/generated_sdk/errors/pump_amm.rs deleted file mode 100644 index a9147ede..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/errors/pump_amm.rs +++ /dev/null @@ -1,112 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum PumpAmmError { - /// 6000 - - #[error("")] - FeeBasisPointsExceedsMaximum = 0x1770, - /// 6001 - - #[error("")] - ZeroBaseAmount = 0x1771, - /// 6002 - - #[error("")] - ZeroQuoteAmount = 0x1772, - /// 6003 - - #[error("")] - TooLittlePoolTokenLiquidity = 0x1773, - /// 6004 - - #[error("")] - ExceededSlippage = 0x1774, - /// 6005 - - #[error("")] - InvalidAdmin = 0x1775, - /// 6006 - - #[error("")] - UnsupportedBaseMint = 0x1776, - /// 6007 - - #[error("")] - UnsupportedQuoteMint = 0x1777, - /// 6008 - - #[error("")] - InvalidBaseMint = 0x1778, - /// 6009 - - #[error("")] - InvalidQuoteMint = 0x1779, - /// 6010 - - #[error("")] - InvalidLpMint = 0x177a, - /// 6011 - - #[error("")] - AllProtocolFeeRecipientsShouldBeNonZero = 0x177b, - /// 6012 - - #[error("")] - UnsortedNotUniqueProtocolFeeRecipients = 0x177c, - /// 6013 - - #[error("")] - InvalidProtocolFeeRecipient = 0x177d, - /// 6014 - - #[error("")] - InvalidPoolBaseTokenAccount = 0x177e, - /// 6015 - - #[error("")] - InvalidPoolQuoteTokenAccount = 0x177f, - /// 6016 - - #[error("")] - BuyMoreBaseAmountThanPoolReserves = 0x1780, - /// 6017 - - #[error("")] - DisabledCreatePool = 0x1781, - /// 6018 - - #[error("")] - DisabledDeposit = 0x1782, - /// 6019 - - #[error("")] - DisabledWithdraw = 0x1783, - /// 6020 - - #[error("")] - DisabledBuy = 0x1784, - /// 6021 - - #[error("")] - DisabledSell = 0x1785, - /// 6022 - - #[error("")] - SameMint = 0x1786, - /// 6023 - - #[error("")] - Overflow = 0x1787, - /// 6024 - - #[error("")] - Truncation = 0x1788, - /// 6025 - - #[error("")] - DivisionByZero = 0x1789, - /// 6026 - - #[error("")] - NewSizeLessThanCurrentSize = 0x178a, - /// 6027 - - #[error("")] - AccountTypeNotSupported = 0x178b, - /// 6028 - - #[error("")] - OnlyCanonicalPumpPoolsCanHaveCoinCreator = 0x178c, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for PumpAmmError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for PumpAmmError { - fn type_of() -> &'static str { "PumpAmmError" } -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/buy.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/buy.rs deleted file mode 100644 index f7158361..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/buy.rs +++ /dev/null @@ -1,1128 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Buy { - pub pool: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub base_mint: solana_pubkey::Pubkey, - - pub quote_mint: solana_pubkey::Pubkey, - - pub user_base_token_account: solana_pubkey::Pubkey, - - pub user_quote_token_account: solana_pubkey::Pubkey, - - pub pool_base_token_account: solana_pubkey::Pubkey, - - pub pool_quote_token_account: solana_pubkey::Pubkey, - - pub protocol_fee_recipient: solana_pubkey::Pubkey, - - pub protocol_fee_recipient_token_account: solana_pubkey::Pubkey, - - pub base_token_program: solana_pubkey::Pubkey, - - pub quote_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, - - pub coin_creator_vault_ata: solana_pubkey::Pubkey, - - pub coin_creator_vault_authority: solana_pubkey::Pubkey, -} - -impl Buy { - pub fn instruction(&self, args: BuyInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: BuyInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(19 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.user, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.protocol_fee_recipient, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_fee_recipient_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.coin_creator_vault_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.coin_creator_vault_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&BuyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyInstructionData { - discriminator: [u8; 8], -} - -impl BuyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [102, 6, 61, 18, 1, 218, 235, 234], - } - } -} - -impl Default for BuyInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyInstructionArgs { - pub base_amount_out: u64, - pub max_quote_amount_in: u64, -} - -/// Instruction builder for `Buy`. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[writable, signer]` user -/// 2. `[]` global_config -/// 3. `[]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` user_base_token_account -/// 6. `[writable]` user_quote_token_account -/// 7. `[writable]` pool_base_token_account -/// 8. `[writable]` pool_quote_token_account -/// 9. `[]` protocol_fee_recipient -/// 10. `[writable]` protocol_fee_recipient_token_account -/// 11. `[]` base_token_program -/// 12. `[]` quote_token_program -/// 13. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 14. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 15. `[]` event_authority -/// 16. `[]` program -/// 17. `[writable]` coin_creator_vault_ata -/// 18. `[]` coin_creator_vault_authority -#[derive(Clone, Debug, Default)] -pub struct BuyBuilder { - pool: Option, - user: Option, - global_config: Option, - base_mint: Option, - quote_mint: Option, - user_base_token_account: Option, - user_quote_token_account: Option, - pool_base_token_account: Option, - pool_quote_token_account: Option, - protocol_fee_recipient: Option, - protocol_fee_recipient_token_account: Option, - base_token_program: Option, - quote_token_program: Option, - system_program: Option, - associated_token_program: Option, - event_authority: Option, - program: Option, - coin_creator_vault_ata: Option, - coin_creator_vault_authority: Option, - base_amount_out: Option, - max_quote_amount_in: Option, - __remaining_accounts: Vec, -} - -impl BuyBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn user_base_token_account( - &mut self, - user_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_base_token_account = Some(user_base_token_account); - self - } - - #[inline(always)] - pub fn user_quote_token_account( - &mut self, - user_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_quote_token_account = Some(user_quote_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient( - &mut self, - protocol_fee_recipient: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_fee_recipient = Some(protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient_token_account( - &mut self, - protocol_fee_recipient_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_fee_recipient_token_account = Some(protocol_fee_recipient_token_account); - self - } - - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn coin_creator_vault_ata( - &mut self, - coin_creator_vault_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.coin_creator_vault_ata = Some(coin_creator_vault_ata); - self - } - - #[inline(always)] - pub fn coin_creator_vault_authority( - &mut self, - coin_creator_vault_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.coin_creator_vault_authority = Some(coin_creator_vault_authority); - self - } - - #[inline(always)] - pub fn base_amount_out(&mut self, base_amount_out: u64) -> &mut Self { - self.base_amount_out = Some(base_amount_out); - self - } - - #[inline(always)] - pub fn max_quote_amount_in(&mut self, max_quote_amount_in: u64) -> &mut Self { - self.max_quote_amount_in = Some(max_quote_amount_in); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Buy { - pool: self.pool.expect("pool is not set"), - user: self.user.expect("user is not set"), - global_config: self.global_config.expect("global_config is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - user_base_token_account: self - .user_base_token_account - .expect("user_base_token_account is not set"), - user_quote_token_account: self - .user_quote_token_account - .expect("user_quote_token_account is not set"), - pool_base_token_account: self - .pool_base_token_account - .expect("pool_base_token_account is not set"), - pool_quote_token_account: self - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - protocol_fee_recipient: self - .protocol_fee_recipient - .expect("protocol_fee_recipient is not set"), - protocol_fee_recipient_token_account: self - .protocol_fee_recipient_token_account - .expect("protocol_fee_recipient_token_account is not set"), - base_token_program: self - .base_token_program - .expect("base_token_program is not set"), - quote_token_program: self - .quote_token_program - .expect("quote_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - coin_creator_vault_ata: self - .coin_creator_vault_ata - .expect("coin_creator_vault_ata is not set"), - coin_creator_vault_authority: self - .coin_creator_vault_authority - .expect("coin_creator_vault_authority is not set"), - }; - let args = BuyInstructionArgs { - base_amount_out: self - .base_amount_out - .clone() - .expect("base_amount_out is not set"), - max_quote_amount_in: self - .max_quote_amount_in - .clone() - .expect("max_quote_amount_in is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `buy` CPI accounts. -pub struct BuyCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_ata: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `buy` CPI instruction. -pub struct BuyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_ata: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: BuyInstructionArgs, -} - -impl<'a, 'b> BuyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: BuyCpiAccounts<'a, 'b>, - args: BuyInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - user: accounts.user, - global_config: accounts.global_config, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - user_base_token_account: accounts.user_base_token_account, - user_quote_token_account: accounts.user_quote_token_account, - pool_base_token_account: accounts.pool_base_token_account, - pool_quote_token_account: accounts.pool_quote_token_account, - protocol_fee_recipient: accounts.protocol_fee_recipient, - protocol_fee_recipient_token_account: accounts.protocol_fee_recipient_token_account, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - system_program: accounts.system_program, - associated_token_program: accounts.associated_token_program, - event_authority: accounts.event_authority, - program: accounts.program, - coin_creator_vault_ata: accounts.coin_creator_vault_ata, - coin_creator_vault_authority: accounts.coin_creator_vault_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(19 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.user.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.protocol_fee_recipient.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_fee_recipient_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.coin_creator_vault_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.coin_creator_vault_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&BuyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(20 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.user_base_token_account.clone()); - account_infos.push(self.user_quote_token_account.clone()); - account_infos.push(self.pool_base_token_account.clone()); - account_infos.push(self.pool_quote_token_account.clone()); - account_infos.push(self.protocol_fee_recipient.clone()); - account_infos.push(self.protocol_fee_recipient_token_account.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - account_infos.push(self.coin_creator_vault_ata.clone()); - account_infos.push(self.coin_creator_vault_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Buy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[writable, signer]` user -/// 2. `[]` global_config -/// 3. `[]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` user_base_token_account -/// 6. `[writable]` user_quote_token_account -/// 7. `[writable]` pool_base_token_account -/// 8. `[writable]` pool_quote_token_account -/// 9. `[]` protocol_fee_recipient -/// 10. `[writable]` protocol_fee_recipient_token_account -/// 11. `[]` base_token_program -/// 12. `[]` quote_token_program -/// 13. `[]` system_program -/// 14. `[]` associated_token_program -/// 15. `[]` event_authority -/// 16. `[]` program -/// 17. `[writable]` coin_creator_vault_ata -/// 18. `[]` coin_creator_vault_authority -#[derive(Clone, Debug)] -pub struct BuyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> BuyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(BuyCpiBuilderInstruction { - __program: program, - pool: None, - user: None, - global_config: None, - base_mint: None, - quote_mint: None, - user_base_token_account: None, - user_quote_token_account: None, - pool_base_token_account: None, - pool_quote_token_account: None, - protocol_fee_recipient: None, - protocol_fee_recipient_token_account: None, - base_token_program: None, - quote_token_program: None, - system_program: None, - associated_token_program: None, - event_authority: None, - program: None, - coin_creator_vault_ata: None, - coin_creator_vault_authority: None, - base_amount_out: None, - max_quote_amount_in: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn user_base_token_account( - &mut self, - user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_base_token_account = Some(user_base_token_account); - self - } - - #[inline(always)] - pub fn user_quote_token_account( - &mut self, - user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_quote_token_account = Some(user_quote_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient( - &mut self, - protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_fee_recipient = Some(protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient_token_account( - &mut self, - protocol_fee_recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_fee_recipient_token_account = - Some(protocol_fee_recipient_token_account); - self - } - - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn coin_creator_vault_ata( - &mut self, - coin_creator_vault_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_creator_vault_ata = Some(coin_creator_vault_ata); - self - } - - #[inline(always)] - pub fn coin_creator_vault_authority( - &mut self, - coin_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_creator_vault_authority = Some(coin_creator_vault_authority); - self - } - - #[inline(always)] - pub fn base_amount_out(&mut self, base_amount_out: u64) -> &mut Self { - self.instruction.base_amount_out = Some(base_amount_out); - self - } - - #[inline(always)] - pub fn max_quote_amount_in(&mut self, max_quote_amount_in: u64) -> &mut Self { - self.instruction.max_quote_amount_in = Some(max_quote_amount_in); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = BuyInstructionArgs { - base_amount_out: self - .instruction - .base_amount_out - .clone() - .expect("base_amount_out is not set"), - max_quote_amount_in: self - .instruction - .max_quote_amount_in - .clone() - .expect("max_quote_amount_in is not set"), - }; - let instruction = BuyCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - user: self.instruction.user.expect("user is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - user_base_token_account: self - .instruction - .user_base_token_account - .expect("user_base_token_account is not set"), - - user_quote_token_account: self - .instruction - .user_quote_token_account - .expect("user_quote_token_account is not set"), - - pool_base_token_account: self - .instruction - .pool_base_token_account - .expect("pool_base_token_account is not set"), - - pool_quote_token_account: self - .instruction - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - - protocol_fee_recipient: self - .instruction - .protocol_fee_recipient - .expect("protocol_fee_recipient is not set"), - - protocol_fee_recipient_token_account: self - .instruction - .protocol_fee_recipient_token_account - .expect("protocol_fee_recipient_token_account is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - - coin_creator_vault_ata: self - .instruction - .coin_creator_vault_ata - .expect("coin_creator_vault_ata is not set"), - - coin_creator_vault_authority: self - .instruction - .coin_creator_vault_authority - .expect("coin_creator_vault_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct BuyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_fee_recipient: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_fee_recipient_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_creator_vault_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_creator_vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - base_amount_out: Option, - max_quote_amount_in: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/collect_coin_creator_fee.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/collect_coin_creator_fee.rs deleted file mode 100644 index 7714395b..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/collect_coin_creator_fee.rs +++ /dev/null @@ -1,585 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CollectCoinCreatorFee { - pub quote_mint: solana_pubkey::Pubkey, - - pub quote_token_program: solana_pubkey::Pubkey, - - pub coin_creator: solana_pubkey::Pubkey, - - pub coin_creator_vault_authority: solana_pubkey::Pubkey, - - pub coin_creator_vault_ata: solana_pubkey::Pubkey, - - pub coin_creator_token_account: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CollectCoinCreatorFee { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.coin_creator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.coin_creator_vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.coin_creator_vault_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.coin_creator_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CollectCoinCreatorFeeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectCoinCreatorFeeInstructionData { - discriminator: [u8; 8], -} - -impl CollectCoinCreatorFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [160, 57, 89, 42, 181, 139, 43, 66], - } - } -} - -impl Default for CollectCoinCreatorFeeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CollectCoinCreatorFee`. -/// -/// ### Accounts: -/// -/// 0. `[]` quote_mint -/// 1. `[]` quote_token_program -/// 2. `[signer]` coin_creator -/// 3. `[]` coin_creator_vault_authority -/// 4. `[writable]` coin_creator_vault_ata -/// 5. `[writable]` coin_creator_token_account -/// 6. `[]` event_authority -/// 7. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CollectCoinCreatorFeeBuilder { - quote_mint: Option, - quote_token_program: Option, - coin_creator: Option, - coin_creator_vault_authority: Option, - coin_creator_vault_ata: Option, - coin_creator_token_account: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CollectCoinCreatorFeeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn coin_creator(&mut self, coin_creator: solana_pubkey::Pubkey) -> &mut Self { - self.coin_creator = Some(coin_creator); - self - } - - #[inline(always)] - pub fn coin_creator_vault_authority( - &mut self, - coin_creator_vault_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.coin_creator_vault_authority = Some(coin_creator_vault_authority); - self - } - - #[inline(always)] - pub fn coin_creator_vault_ata( - &mut self, - coin_creator_vault_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.coin_creator_vault_ata = Some(coin_creator_vault_ata); - self - } - - #[inline(always)] - pub fn coin_creator_token_account( - &mut self, - coin_creator_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.coin_creator_token_account = Some(coin_creator_token_account); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectCoinCreatorFee { - quote_mint: self.quote_mint.expect("quote_mint is not set"), - quote_token_program: self - .quote_token_program - .expect("quote_token_program is not set"), - coin_creator: self.coin_creator.expect("coin_creator is not set"), - coin_creator_vault_authority: self - .coin_creator_vault_authority - .expect("coin_creator_vault_authority is not set"), - coin_creator_vault_ata: self - .coin_creator_vault_ata - .expect("coin_creator_vault_ata is not set"), - coin_creator_token_account: self - .coin_creator_token_account - .expect("coin_creator_token_account is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `collect_coin_creator_fee` CPI accounts. -pub struct CollectCoinCreatorFeeCpiAccounts<'a, 'b> { - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_ata: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_coin_creator_fee` CPI instruction. -pub struct CollectCoinCreatorFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_ata: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CollectCoinCreatorFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectCoinCreatorFeeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - quote_mint: accounts.quote_mint, - quote_token_program: accounts.quote_token_program, - coin_creator: accounts.coin_creator, - coin_creator_vault_authority: accounts.coin_creator_vault_authority, - coin_creator_vault_ata: accounts.coin_creator_vault_ata, - coin_creator_token_account: accounts.coin_creator_token_account, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.coin_creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.coin_creator_vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.coin_creator_vault_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.coin_creator_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CollectCoinCreatorFeeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.coin_creator.clone()); - account_infos.push(self.coin_creator_vault_authority.clone()); - account_infos.push(self.coin_creator_vault_ata.clone()); - account_infos.push(self.coin_creator_token_account.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectCoinCreatorFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` quote_mint -/// 1. `[]` quote_token_program -/// 2. `[signer]` coin_creator -/// 3. `[]` coin_creator_vault_authority -/// 4. `[writable]` coin_creator_vault_ata -/// 5. `[writable]` coin_creator_token_account -/// 6. `[]` event_authority -/// 7. `[]` program -#[derive(Clone, Debug)] -pub struct CollectCoinCreatorFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectCoinCreatorFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectCoinCreatorFeeCpiBuilderInstruction { - __program: program, - quote_mint: None, - quote_token_program: None, - coin_creator: None, - coin_creator_vault_authority: None, - coin_creator_vault_ata: None, - coin_creator_token_account: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn coin_creator( - &mut self, - coin_creator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_creator = Some(coin_creator); - self - } - - #[inline(always)] - pub fn coin_creator_vault_authority( - &mut self, - coin_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_creator_vault_authority = Some(coin_creator_vault_authority); - self - } - - #[inline(always)] - pub fn coin_creator_vault_ata( - &mut self, - coin_creator_vault_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_creator_vault_ata = Some(coin_creator_vault_ata); - self - } - - #[inline(always)] - pub fn coin_creator_token_account( - &mut self, - coin_creator_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_creator_token_account = Some(coin_creator_token_account); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CollectCoinCreatorFeeCpi { - __program: self.instruction.__program, - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - coin_creator: self - .instruction - .coin_creator - .expect("coin_creator is not set"), - - coin_creator_vault_authority: self - .instruction - .coin_creator_vault_authority - .expect("coin_creator_vault_authority is not set"), - - coin_creator_vault_ata: self - .instruction - .coin_creator_vault_ata - .expect("coin_creator_vault_ata is not set"), - - coin_creator_token_account: self - .instruction - .coin_creator_token_account - .expect("coin_creator_token_account is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectCoinCreatorFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_creator: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_creator_vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_creator_vault_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_creator_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/create_config.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/create_config.rs deleted file mode 100644 index 74c1b883..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/create_config.rs +++ /dev/null @@ -1,568 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct CreateConfig { - pub admin: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreateConfig { - pub fn instruction( - &self, - args: CreateConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigInstructionData { - discriminator: [u8; 8], -} - -impl CreateConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [201, 207, 243, 114, 75, 111, 47, 189], - } - } -} - -impl Default for CreateConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigInstructionArgs { - pub lp_fee_basis_points: u64, - pub protocol_fee_basis_points: u64, - pub protocol_fee_recipients: [Pubkey; 8], - pub coin_creator_fee_basis_points: u64, -} - -/// Instruction builder for `CreateConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer, optional]` admin (default to `8LWu7QM2dGR1G8nKDHthckea57bkCzXyBTAKPJUBDHo8`) -/// 1. `[writable]` global_config -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreateConfigBuilder { - admin: Option, - global_config: Option, - system_program: Option, - event_authority: Option, - program: Option, - lp_fee_basis_points: Option, - protocol_fee_basis_points: Option, - protocol_fee_recipients: Option<[Pubkey; 8]>, - coin_creator_fee_basis_points: Option, - __remaining_accounts: Vec, -} - -impl CreateConfigBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to '8LWu7QM2dGR1G8nKDHthckea57bkCzXyBTAKPJUBDHo8']` - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn lp_fee_basis_points(&mut self, lp_fee_basis_points: u64) -> &mut Self { - self.lp_fee_basis_points = Some(lp_fee_basis_points); - self - } - - #[inline(always)] - pub fn protocol_fee_basis_points(&mut self, protocol_fee_basis_points: u64) -> &mut Self { - self.protocol_fee_basis_points = Some(protocol_fee_basis_points); - self - } - - #[inline(always)] - pub fn protocol_fee_recipients(&mut self, protocol_fee_recipients: [Pubkey; 8]) -> &mut Self { - self.protocol_fee_recipients = Some(protocol_fee_recipients); - self - } - - #[inline(always)] - pub fn coin_creator_fee_basis_points( - &mut self, - coin_creator_fee_basis_points: u64, - ) -> &mut Self { - self.coin_creator_fee_basis_points = Some(coin_creator_fee_basis_points); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateConfig { - admin: self.admin.unwrap_or(solana_pubkey::pubkey!( - "8LWu7QM2dGR1G8nKDHthckea57bkCzXyBTAKPJUBDHo8" - )), - global_config: self.global_config.expect("global_config is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = CreateConfigInstructionArgs { - lp_fee_basis_points: self - .lp_fee_basis_points - .clone() - .expect("lp_fee_basis_points is not set"), - protocol_fee_basis_points: self - .protocol_fee_basis_points - .clone() - .expect("protocol_fee_basis_points is not set"), - protocol_fee_recipients: self - .protocol_fee_recipients - .clone() - .expect("protocol_fee_recipients is not set"), - coin_creator_fee_basis_points: self - .coin_creator_fee_basis_points - .clone() - .expect("coin_creator_fee_basis_points is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_config` CPI accounts. -pub struct CreateConfigCpiAccounts<'a, 'b> { - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_config` CPI instruction. -pub struct CreateConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateConfigInstructionArgs, -} - -impl<'a, 'b> CreateConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateConfigCpiAccounts<'a, 'b>, - args: CreateConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - admin: accounts.admin, - global_config: accounts.global_config, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` admin -/// 1. `[writable]` global_config -/// 2. `[]` system_program -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct CreateConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateConfigCpiBuilderInstruction { - __program: program, - admin: None, - global_config: None, - system_program: None, - event_authority: None, - program: None, - lp_fee_basis_points: None, - protocol_fee_basis_points: None, - protocol_fee_recipients: None, - coin_creator_fee_basis_points: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn lp_fee_basis_points(&mut self, lp_fee_basis_points: u64) -> &mut Self { - self.instruction.lp_fee_basis_points = Some(lp_fee_basis_points); - self - } - - #[inline(always)] - pub fn protocol_fee_basis_points(&mut self, protocol_fee_basis_points: u64) -> &mut Self { - self.instruction.protocol_fee_basis_points = Some(protocol_fee_basis_points); - self - } - - #[inline(always)] - pub fn protocol_fee_recipients(&mut self, protocol_fee_recipients: [Pubkey; 8]) -> &mut Self { - self.instruction.protocol_fee_recipients = Some(protocol_fee_recipients); - self - } - - #[inline(always)] - pub fn coin_creator_fee_basis_points( - &mut self, - coin_creator_fee_basis_points: u64, - ) -> &mut Self { - self.instruction.coin_creator_fee_basis_points = Some(coin_creator_fee_basis_points); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateConfigInstructionArgs { - lp_fee_basis_points: self - .instruction - .lp_fee_basis_points - .clone() - .expect("lp_fee_basis_points is not set"), - protocol_fee_basis_points: self - .instruction - .protocol_fee_basis_points - .clone() - .expect("protocol_fee_basis_points is not set"), - protocol_fee_recipients: self - .instruction - .protocol_fee_recipients - .clone() - .expect("protocol_fee_recipients is not set"), - coin_creator_fee_basis_points: self - .instruction - .coin_creator_fee_basis_points - .clone() - .expect("coin_creator_fee_basis_points is not set"), - }; - let instruction = CreateConfigCpi { - __program: self.instruction.__program, - - admin: self.instruction.admin.expect("admin is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_fee_basis_points: Option, - protocol_fee_basis_points: Option, - protocol_fee_recipients: Option<[Pubkey; 8]>, - coin_creator_fee_basis_points: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/create_pool.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/create_pool.rs deleted file mode 100644 index 660e9bfb..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/create_pool.rs +++ /dev/null @@ -1,1103 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct CreatePool { - pub pool: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - - pub base_mint: solana_pubkey::Pubkey, - - pub quote_mint: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub user_base_token_account: solana_pubkey::Pubkey, - - pub user_quote_token_account: solana_pubkey::Pubkey, - - pub user_pool_token_account: solana_pubkey::Pubkey, - - pub pool_base_token_account: solana_pubkey::Pubkey, - - pub pool_quote_token_account: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token2022_program: solana_pubkey::Pubkey, - - pub base_token_program: solana_pubkey::Pubkey, - - pub quote_token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CreatePool { - pub fn instruction(&self, args: CreatePoolInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreatePoolInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.creator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_pool_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreatePoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePoolInstructionData { - discriminator: [u8; 8], -} - -impl CreatePoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [233, 146, 209, 142, 207, 104, 64, 188], - } - } -} - -impl Default for CreatePoolInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePoolInstructionArgs { - pub index: u16, - pub base_amount_in: u64, - pub quote_amount_in: u64, - pub coin_creator: Pubkey, -} - -/// Instruction builder for `CreatePool`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` global_config -/// 2. `[writable, signer]` creator -/// 3. `[]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` lp_mint -/// 6. `[writable]` user_base_token_account -/// 7. `[writable]` user_quote_token_account -/// 8. `[writable]` user_pool_token_account -/// 9. `[writable]` pool_base_token_account -/// 10. `[writable]` pool_quote_token_account -/// 11. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 12. `[optional]` token2022_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 13. `[]` base_token_program -/// 14. `[]` quote_token_program -/// 15. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 16. `[]` event_authority -/// 17. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreatePoolBuilder { - pool: Option, - global_config: Option, - creator: Option, - base_mint: Option, - quote_mint: Option, - lp_mint: Option, - user_base_token_account: Option, - user_quote_token_account: Option, - user_pool_token_account: Option, - pool_base_token_account: Option, - pool_quote_token_account: Option, - system_program: Option, - token2022_program: Option, - base_token_program: Option, - quote_token_program: Option, - associated_token_program: Option, - event_authority: Option, - program: Option, - index: Option, - base_amount_in: Option, - quote_amount_in: Option, - coin_creator: Option, - __remaining_accounts: Vec, -} - -impl CreatePoolBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn user_base_token_account( - &mut self, - user_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_base_token_account = Some(user_base_token_account); - self - } - - #[inline(always)] - pub fn user_quote_token_account( - &mut self, - user_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_quote_token_account = Some(user_quote_token_account); - self - } - - #[inline(always)] - pub fn user_pool_token_account( - &mut self, - user_pool_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_pool_token_account = Some(user_pool_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u16) -> &mut Self { - self.index = Some(index); - self - } - - #[inline(always)] - pub fn base_amount_in(&mut self, base_amount_in: u64) -> &mut Self { - self.base_amount_in = Some(base_amount_in); - self - } - - #[inline(always)] - pub fn quote_amount_in(&mut self, quote_amount_in: u64) -> &mut Self { - self.quote_amount_in = Some(quote_amount_in); - self - } - - #[inline(always)] - pub fn coin_creator(&mut self, coin_creator: Pubkey) -> &mut Self { - self.coin_creator = Some(coin_creator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreatePool { - pool: self.pool.expect("pool is not set"), - global_config: self.global_config.expect("global_config is not set"), - creator: self.creator.expect("creator is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_base_token_account: self - .user_base_token_account - .expect("user_base_token_account is not set"), - user_quote_token_account: self - .user_quote_token_account - .expect("user_quote_token_account is not set"), - user_pool_token_account: self - .user_pool_token_account - .expect("user_pool_token_account is not set"), - pool_base_token_account: self - .pool_base_token_account - .expect("pool_base_token_account is not set"), - pool_quote_token_account: self - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token2022_program: self.token2022_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - base_token_program: self - .base_token_program - .expect("base_token_program is not set"), - quote_token_program: self - .quote_token_program - .expect("quote_token_program is not set"), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = CreatePoolInstructionArgs { - index: self.index.clone().expect("index is not set"), - base_amount_in: self - .base_amount_in - .clone() - .expect("base_amount_in is not set"), - quote_amount_in: self - .quote_amount_in - .clone() - .expect("quote_amount_in is not set"), - coin_creator: self.coin_creator.clone().expect("coin_creator is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_pool` CPI accounts. -pub struct CreatePoolCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_pool` CPI instruction. -pub struct CreatePoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreatePoolInstructionArgs, -} - -impl<'a, 'b> CreatePoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreatePoolCpiAccounts<'a, 'b>, - args: CreatePoolInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - global_config: accounts.global_config, - creator: accounts.creator, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - lp_mint: accounts.lp_mint, - user_base_token_account: accounts.user_base_token_account, - user_quote_token_account: accounts.user_quote_token_account, - user_pool_token_account: accounts.user_pool_token_account, - pool_base_token_account: accounts.pool_base_token_account, - pool_quote_token_account: accounts.pool_quote_token_account, - system_program: accounts.system_program, - token2022_program: accounts.token2022_program, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - associated_token_program: accounts.associated_token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_pool_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreatePoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(19 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_base_token_account.clone()); - account_infos.push(self.user_quote_token_account.clone()); - account_infos.push(self.user_pool_token_account.clone()); - account_infos.push(self.pool_base_token_account.clone()); - account_infos.push(self.pool_quote_token_account.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token2022_program.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreatePool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` global_config -/// 2. `[writable, signer]` creator -/// 3. `[]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` lp_mint -/// 6. `[writable]` user_base_token_account -/// 7. `[writable]` user_quote_token_account -/// 8. `[writable]` user_pool_token_account -/// 9. `[writable]` pool_base_token_account -/// 10. `[writable]` pool_quote_token_account -/// 11. `[]` system_program -/// 12. `[]` token2022_program -/// 13. `[]` base_token_program -/// 14. `[]` quote_token_program -/// 15. `[]` associated_token_program -/// 16. `[]` event_authority -/// 17. `[]` program -#[derive(Clone, Debug)] -pub struct CreatePoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreatePoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreatePoolCpiBuilderInstruction { - __program: program, - pool: None, - global_config: None, - creator: None, - base_mint: None, - quote_mint: None, - lp_mint: None, - user_base_token_account: None, - user_quote_token_account: None, - user_pool_token_account: None, - pool_base_token_account: None, - pool_quote_token_account: None, - system_program: None, - token2022_program: None, - base_token_program: None, - quote_token_program: None, - associated_token_program: None, - event_authority: None, - program: None, - index: None, - base_amount_in: None, - quote_amount_in: None, - coin_creator: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn user_base_token_account( - &mut self, - user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_base_token_account = Some(user_base_token_account); - self - } - - #[inline(always)] - pub fn user_quote_token_account( - &mut self, - user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_quote_token_account = Some(user_quote_token_account); - self - } - - #[inline(always)] - pub fn user_pool_token_account( - &mut self, - user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_pool_token_account = Some(user_pool_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u16) -> &mut Self { - self.instruction.index = Some(index); - self - } - - #[inline(always)] - pub fn base_amount_in(&mut self, base_amount_in: u64) -> &mut Self { - self.instruction.base_amount_in = Some(base_amount_in); - self - } - - #[inline(always)] - pub fn quote_amount_in(&mut self, quote_amount_in: u64) -> &mut Self { - self.instruction.quote_amount_in = Some(quote_amount_in); - self - } - - #[inline(always)] - pub fn coin_creator(&mut self, coin_creator: Pubkey) -> &mut Self { - self.instruction.coin_creator = Some(coin_creator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreatePoolInstructionArgs { - index: self.instruction.index.clone().expect("index is not set"), - base_amount_in: self - .instruction - .base_amount_in - .clone() - .expect("base_amount_in is not set"), - quote_amount_in: self - .instruction - .quote_amount_in - .clone() - .expect("quote_amount_in is not set"), - coin_creator: self - .instruction - .coin_creator - .clone() - .expect("coin_creator is not set"), - }; - let instruction = CreatePoolCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_base_token_account: self - .instruction - .user_base_token_account - .expect("user_base_token_account is not set"), - - user_quote_token_account: self - .instruction - .user_quote_token_account - .expect("user_quote_token_account is not set"), - - user_pool_token_account: self - .instruction - .user_pool_token_account - .expect("user_pool_token_account is not set"), - - pool_base_token_account: self - .instruction - .pool_base_token_account - .expect("pool_base_token_account is not set"), - - pool_quote_token_account: self - .instruction - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreatePoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_pool_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - index: Option, - base_amount_in: Option, - quote_amount_in: Option, - coin_creator: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/deposit.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/deposit.rs deleted file mode 100644 index 38b7d737..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/deposit.rs +++ /dev/null @@ -1,953 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Deposit { - pub pool: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub base_mint: solana_pubkey::Pubkey, - - pub quote_mint: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub user_base_token_account: solana_pubkey::Pubkey, - - pub user_quote_token_account: solana_pubkey::Pubkey, - - pub user_pool_token_account: solana_pubkey::Pubkey, - - pub pool_base_token_account: solana_pubkey::Pubkey, - - pub pool_quote_token_account: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token2022_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Deposit { - pub fn instruction(&self, args: DepositInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DepositInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_pool_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DepositInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositInstructionData { - discriminator: [u8; 8], -} - -impl DepositInstructionData { - pub fn new() -> Self { - Self { - discriminator: [242, 35, 198, 137, 82, 225, 242, 182], - } - } -} - -impl Default for DepositInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositInstructionArgs { - pub lp_token_amount_out: u64, - pub max_base_amount_in: u64, - pub max_quote_amount_in: u64, -} - -/// Instruction builder for `Deposit`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` global_config -/// 2. `[signer]` user -/// 3. `[]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` lp_mint -/// 6. `[writable]` user_base_token_account -/// 7. `[writable]` user_quote_token_account -/// 8. `[writable]` user_pool_token_account -/// 9. `[writable]` pool_base_token_account -/// 10. `[writable]` pool_quote_token_account -/// 11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 12. `[optional]` token2022_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct DepositBuilder { - pool: Option, - global_config: Option, - user: Option, - base_mint: Option, - quote_mint: Option, - lp_mint: Option, - user_base_token_account: Option, - user_quote_token_account: Option, - user_pool_token_account: Option, - pool_base_token_account: Option, - pool_quote_token_account: Option, - token_program: Option, - token2022_program: Option, - event_authority: Option, - program: Option, - lp_token_amount_out: Option, - max_base_amount_in: Option, - max_quote_amount_in: Option, - __remaining_accounts: Vec, -} - -impl DepositBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn user_base_token_account( - &mut self, - user_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_base_token_account = Some(user_base_token_account); - self - } - - #[inline(always)] - pub fn user_quote_token_account( - &mut self, - user_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_quote_token_account = Some(user_quote_token_account); - self - } - - #[inline(always)] - pub fn user_pool_token_account( - &mut self, - user_pool_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_pool_token_account = Some(user_pool_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn lp_token_amount_out(&mut self, lp_token_amount_out: u64) -> &mut Self { - self.lp_token_amount_out = Some(lp_token_amount_out); - self - } - - #[inline(always)] - pub fn max_base_amount_in(&mut self, max_base_amount_in: u64) -> &mut Self { - self.max_base_amount_in = Some(max_base_amount_in); - self - } - - #[inline(always)] - pub fn max_quote_amount_in(&mut self, max_quote_amount_in: u64) -> &mut Self { - self.max_quote_amount_in = Some(max_quote_amount_in); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Deposit { - pool: self.pool.expect("pool is not set"), - global_config: self.global_config.expect("global_config is not set"), - user: self.user.expect("user is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_base_token_account: self - .user_base_token_account - .expect("user_base_token_account is not set"), - user_quote_token_account: self - .user_quote_token_account - .expect("user_quote_token_account is not set"), - user_pool_token_account: self - .user_pool_token_account - .expect("user_pool_token_account is not set"), - pool_base_token_account: self - .pool_base_token_account - .expect("pool_base_token_account is not set"), - pool_quote_token_account: self - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token2022_program: self.token2022_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = DepositInstructionArgs { - lp_token_amount_out: self - .lp_token_amount_out - .clone() - .expect("lp_token_amount_out is not set"), - max_base_amount_in: self - .max_base_amount_in - .clone() - .expect("max_base_amount_in is not set"), - max_quote_amount_in: self - .max_quote_amount_in - .clone() - .expect("max_quote_amount_in is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `deposit` CPI accounts. -pub struct DepositCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `deposit` CPI instruction. -pub struct DepositCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DepositInstructionArgs, -} - -impl<'a, 'b> DepositCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DepositCpiAccounts<'a, 'b>, - args: DepositInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - global_config: accounts.global_config, - user: accounts.user, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - lp_mint: accounts.lp_mint, - user_base_token_account: accounts.user_base_token_account, - user_quote_token_account: accounts.user_quote_token_account, - user_pool_token_account: accounts.user_pool_token_account, - pool_base_token_account: accounts.pool_base_token_account, - pool_quote_token_account: accounts.pool_quote_token_account, - token_program: accounts.token_program, - token2022_program: accounts.token2022_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_pool_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DepositInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_base_token_account.clone()); - account_infos.push(self.user_quote_token_account.clone()); - account_infos.push(self.user_pool_token_account.clone()); - account_infos.push(self.pool_base_token_account.clone()); - account_infos.push(self.pool_quote_token_account.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token2022_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Deposit` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` global_config -/// 2. `[signer]` user -/// 3. `[]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` lp_mint -/// 6. `[writable]` user_base_token_account -/// 7. `[writable]` user_quote_token_account -/// 8. `[writable]` user_pool_token_account -/// 9. `[writable]` pool_base_token_account -/// 10. `[writable]` pool_quote_token_account -/// 11. `[]` token_program -/// 12. `[]` token2022_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct DepositCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DepositCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DepositCpiBuilderInstruction { - __program: program, - pool: None, - global_config: None, - user: None, - base_mint: None, - quote_mint: None, - lp_mint: None, - user_base_token_account: None, - user_quote_token_account: None, - user_pool_token_account: None, - pool_base_token_account: None, - pool_quote_token_account: None, - token_program: None, - token2022_program: None, - event_authority: None, - program: None, - lp_token_amount_out: None, - max_base_amount_in: None, - max_quote_amount_in: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn user_base_token_account( - &mut self, - user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_base_token_account = Some(user_base_token_account); - self - } - - #[inline(always)] - pub fn user_quote_token_account( - &mut self, - user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_quote_token_account = Some(user_quote_token_account); - self - } - - #[inline(always)] - pub fn user_pool_token_account( - &mut self, - user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_pool_token_account = Some(user_pool_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn lp_token_amount_out(&mut self, lp_token_amount_out: u64) -> &mut Self { - self.instruction.lp_token_amount_out = Some(lp_token_amount_out); - self - } - - #[inline(always)] - pub fn max_base_amount_in(&mut self, max_base_amount_in: u64) -> &mut Self { - self.instruction.max_base_amount_in = Some(max_base_amount_in); - self - } - - #[inline(always)] - pub fn max_quote_amount_in(&mut self, max_quote_amount_in: u64) -> &mut Self { - self.instruction.max_quote_amount_in = Some(max_quote_amount_in); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DepositInstructionArgs { - lp_token_amount_out: self - .instruction - .lp_token_amount_out - .clone() - .expect("lp_token_amount_out is not set"), - max_base_amount_in: self - .instruction - .max_base_amount_in - .clone() - .expect("max_base_amount_in is not set"), - max_quote_amount_in: self - .instruction - .max_quote_amount_in - .clone() - .expect("max_quote_amount_in is not set"), - }; - let instruction = DepositCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - user: self.instruction.user.expect("user is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_base_token_account: self - .instruction - .user_base_token_account - .expect("user_base_token_account is not set"), - - user_quote_token_account: self - .instruction - .user_quote_token_account - .expect("user_quote_token_account is not set"), - - user_pool_token_account: self - .instruction - .user_pool_token_account - .expect("user_pool_token_account is not set"), - - pool_base_token_account: self - .instruction - .pool_base_token_account - .expect("pool_base_token_account is not set"), - - pool_quote_token_account: self - .instruction - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DepositCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_pool_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_token_amount_out: Option, - max_base_amount_in: Option, - max_quote_amount_in: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/disable.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/disable.rs deleted file mode 100644 index 0987f736..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/disable.rs +++ /dev/null @@ -1,534 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Disable { - pub admin: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Disable { - pub fn instruction(&self, args: DisableInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DisableInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DisableInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DisableInstructionData { - discriminator: [u8; 8], -} - -impl DisableInstructionData { - pub fn new() -> Self { - Self { - discriminator: [185, 173, 187, 90, 216, 15, 238, 233], - } - } -} - -impl Default for DisableInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DisableInstructionArgs { - pub disable_create_pool: bool, - pub disable_deposit: bool, - pub disable_withdraw: bool, - pub disable_buy: bool, - pub disable_sell: bool, -} - -/// Instruction builder for `Disable`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` admin -/// 1. `[writable]` global_config -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug, Default)] -pub struct DisableBuilder { - admin: Option, - global_config: Option, - event_authority: Option, - program: Option, - disable_create_pool: Option, - disable_deposit: Option, - disable_withdraw: Option, - disable_buy: Option, - disable_sell: Option, - __remaining_accounts: Vec, -} - -impl DisableBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn disable_create_pool(&mut self, disable_create_pool: bool) -> &mut Self { - self.disable_create_pool = Some(disable_create_pool); - self - } - - #[inline(always)] - pub fn disable_deposit(&mut self, disable_deposit: bool) -> &mut Self { - self.disable_deposit = Some(disable_deposit); - self - } - - #[inline(always)] - pub fn disable_withdraw(&mut self, disable_withdraw: bool) -> &mut Self { - self.disable_withdraw = Some(disable_withdraw); - self - } - - #[inline(always)] - pub fn disable_buy(&mut self, disable_buy: bool) -> &mut Self { - self.disable_buy = Some(disable_buy); - self - } - - #[inline(always)] - pub fn disable_sell(&mut self, disable_sell: bool) -> &mut Self { - self.disable_sell = Some(disable_sell); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Disable { - admin: self.admin.expect("admin is not set"), - global_config: self.global_config.expect("global_config is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = DisableInstructionArgs { - disable_create_pool: self - .disable_create_pool - .clone() - .expect("disable_create_pool is not set"), - disable_deposit: self - .disable_deposit - .clone() - .expect("disable_deposit is not set"), - disable_withdraw: self - .disable_withdraw - .clone() - .expect("disable_withdraw is not set"), - disable_buy: self.disable_buy.clone().expect("disable_buy is not set"), - disable_sell: self.disable_sell.clone().expect("disable_sell is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `disable` CPI accounts. -pub struct DisableCpiAccounts<'a, 'b> { - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `disable` CPI instruction. -pub struct DisableCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DisableInstructionArgs, -} - -impl<'a, 'b> DisableCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DisableCpiAccounts<'a, 'b>, - args: DisableInstructionArgs, - ) -> Self { - Self { - __program: program, - admin: accounts.admin, - global_config: accounts.global_config, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DisableInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Disable` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` admin -/// 1. `[writable]` global_config -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug)] -pub struct DisableCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DisableCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DisableCpiBuilderInstruction { - __program: program, - admin: None, - global_config: None, - event_authority: None, - program: None, - disable_create_pool: None, - disable_deposit: None, - disable_withdraw: None, - disable_buy: None, - disable_sell: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn disable_create_pool(&mut self, disable_create_pool: bool) -> &mut Self { - self.instruction.disable_create_pool = Some(disable_create_pool); - self - } - - #[inline(always)] - pub fn disable_deposit(&mut self, disable_deposit: bool) -> &mut Self { - self.instruction.disable_deposit = Some(disable_deposit); - self - } - - #[inline(always)] - pub fn disable_withdraw(&mut self, disable_withdraw: bool) -> &mut Self { - self.instruction.disable_withdraw = Some(disable_withdraw); - self - } - - #[inline(always)] - pub fn disable_buy(&mut self, disable_buy: bool) -> &mut Self { - self.instruction.disable_buy = Some(disable_buy); - self - } - - #[inline(always)] - pub fn disable_sell(&mut self, disable_sell: bool) -> &mut Self { - self.instruction.disable_sell = Some(disable_sell); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DisableInstructionArgs { - disable_create_pool: self - .instruction - .disable_create_pool - .clone() - .expect("disable_create_pool is not set"), - disable_deposit: self - .instruction - .disable_deposit - .clone() - .expect("disable_deposit is not set"), - disable_withdraw: self - .instruction - .disable_withdraw - .clone() - .expect("disable_withdraw is not set"), - disable_buy: self - .instruction - .disable_buy - .clone() - .expect("disable_buy is not set"), - disable_sell: self - .instruction - .disable_sell - .clone() - .expect("disable_sell is not set"), - }; - let instruction = DisableCpi { - __program: self.instruction.__program, - - admin: self.instruction.admin.expect("admin is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DisableCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - disable_create_pool: Option, - disable_deposit: Option, - disable_withdraw: Option, - disable_buy: Option, - disable_sell: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/extend_account.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/extend_account.rs deleted file mode 100644 index b03b3084..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/extend_account.rs +++ /dev/null @@ -1,432 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ExtendAccount { - pub account: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ExtendAccount { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.account, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ExtendAccountInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ExtendAccountInstructionData { - discriminator: [u8; 8], -} - -impl ExtendAccountInstructionData { - pub fn new() -> Self { - Self { - discriminator: [234, 102, 194, 203, 150, 72, 62, 229], - } - } -} - -impl Default for ExtendAccountInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ExtendAccount`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` account -/// 1. `[signer]` user -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ExtendAccountBuilder { - account: Option, - user: Option, - system_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl ExtendAccountBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn account(&mut self, account: solana_pubkey::Pubkey) -> &mut Self { - self.account = Some(account); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ExtendAccount { - account: self.account.expect("account is not set"), - user: self.user.expect("user is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `extend_account` CPI accounts. -pub struct ExtendAccountCpiAccounts<'a, 'b> { - pub account: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `extend_account` CPI instruction. -pub struct ExtendAccountCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub account: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ExtendAccountCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ExtendAccountCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - account: accounts.account, - user: accounts.user, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ExtendAccountInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.account.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ExtendAccount` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` account -/// 1. `[signer]` user -/// 2. `[]` system_program -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct ExtendAccountCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ExtendAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ExtendAccountCpiBuilderInstruction { - __program: program, - account: None, - user: None, - system_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn account(&mut self, account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.account = Some(account); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ExtendAccountCpi { - __program: self.instruction.__program, - - account: self.instruction.account.expect("account is not set"), - - user: self.instruction.user.expect("user is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ExtendAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - account: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/mod.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index 10375ea6..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#buy; -pub(crate) mod r#collect_coin_creator_fee; -pub(crate) mod r#create_config; -pub(crate) mod r#create_pool; -pub(crate) mod r#deposit; -pub(crate) mod r#disable; -pub(crate) mod r#extend_account; -pub(crate) mod r#sell; -pub(crate) mod r#set_coin_creator; -pub(crate) mod r#update_admin; -pub(crate) mod r#update_fee_config; -pub(crate) mod r#withdraw; - -pub use self::{ - r#buy::*, r#collect_coin_creator_fee::*, r#create_config::*, r#create_pool::*, r#deposit::*, - r#disable::*, r#extend_account::*, r#sell::*, r#set_coin_creator::*, r#update_admin::*, - r#update_fee_config::*, r#withdraw::*, -}; diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/sell.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/sell.rs deleted file mode 100644 index 1c95cf72..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/sell.rs +++ /dev/null @@ -1,1128 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Sell { - pub pool: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub base_mint: solana_pubkey::Pubkey, - - pub quote_mint: solana_pubkey::Pubkey, - - pub user_base_token_account: solana_pubkey::Pubkey, - - pub user_quote_token_account: solana_pubkey::Pubkey, - - pub pool_base_token_account: solana_pubkey::Pubkey, - - pub pool_quote_token_account: solana_pubkey::Pubkey, - - pub protocol_fee_recipient: solana_pubkey::Pubkey, - - pub protocol_fee_recipient_token_account: solana_pubkey::Pubkey, - - pub base_token_program: solana_pubkey::Pubkey, - - pub quote_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, - - pub coin_creator_vault_ata: solana_pubkey::Pubkey, - - pub coin_creator_vault_authority: solana_pubkey::Pubkey, -} - -impl Sell { - pub fn instruction(&self, args: SellInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SellInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(19 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.user, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.protocol_fee_recipient, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_fee_recipient_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.coin_creator_vault_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.coin_creator_vault_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SellInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellInstructionData { - discriminator: [u8; 8], -} - -impl SellInstructionData { - pub fn new() -> Self { - Self { - discriminator: [51, 230, 133, 164, 1, 127, 131, 173], - } - } -} - -impl Default for SellInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellInstructionArgs { - pub base_amount_in: u64, - pub min_quote_amount_out: u64, -} - -/// Instruction builder for `Sell`. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[writable, signer]` user -/// 2. `[]` global_config -/// 3. `[]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` user_base_token_account -/// 6. `[writable]` user_quote_token_account -/// 7. `[writable]` pool_base_token_account -/// 8. `[writable]` pool_quote_token_account -/// 9. `[]` protocol_fee_recipient -/// 10. `[writable]` protocol_fee_recipient_token_account -/// 11. `[]` base_token_program -/// 12. `[]` quote_token_program -/// 13. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 14. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 15. `[]` event_authority -/// 16. `[]` program -/// 17. `[writable]` coin_creator_vault_ata -/// 18. `[]` coin_creator_vault_authority -#[derive(Clone, Debug, Default)] -pub struct SellBuilder { - pool: Option, - user: Option, - global_config: Option, - base_mint: Option, - quote_mint: Option, - user_base_token_account: Option, - user_quote_token_account: Option, - pool_base_token_account: Option, - pool_quote_token_account: Option, - protocol_fee_recipient: Option, - protocol_fee_recipient_token_account: Option, - base_token_program: Option, - quote_token_program: Option, - system_program: Option, - associated_token_program: Option, - event_authority: Option, - program: Option, - coin_creator_vault_ata: Option, - coin_creator_vault_authority: Option, - base_amount_in: Option, - min_quote_amount_out: Option, - __remaining_accounts: Vec, -} - -impl SellBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn user_base_token_account( - &mut self, - user_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_base_token_account = Some(user_base_token_account); - self - } - - #[inline(always)] - pub fn user_quote_token_account( - &mut self, - user_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_quote_token_account = Some(user_quote_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient( - &mut self, - protocol_fee_recipient: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_fee_recipient = Some(protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient_token_account( - &mut self, - protocol_fee_recipient_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_fee_recipient_token_account = Some(protocol_fee_recipient_token_account); - self - } - - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn coin_creator_vault_ata( - &mut self, - coin_creator_vault_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.coin_creator_vault_ata = Some(coin_creator_vault_ata); - self - } - - #[inline(always)] - pub fn coin_creator_vault_authority( - &mut self, - coin_creator_vault_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.coin_creator_vault_authority = Some(coin_creator_vault_authority); - self - } - - #[inline(always)] - pub fn base_amount_in(&mut self, base_amount_in: u64) -> &mut Self { - self.base_amount_in = Some(base_amount_in); - self - } - - #[inline(always)] - pub fn min_quote_amount_out(&mut self, min_quote_amount_out: u64) -> &mut Self { - self.min_quote_amount_out = Some(min_quote_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Sell { - pool: self.pool.expect("pool is not set"), - user: self.user.expect("user is not set"), - global_config: self.global_config.expect("global_config is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - user_base_token_account: self - .user_base_token_account - .expect("user_base_token_account is not set"), - user_quote_token_account: self - .user_quote_token_account - .expect("user_quote_token_account is not set"), - pool_base_token_account: self - .pool_base_token_account - .expect("pool_base_token_account is not set"), - pool_quote_token_account: self - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - protocol_fee_recipient: self - .protocol_fee_recipient - .expect("protocol_fee_recipient is not set"), - protocol_fee_recipient_token_account: self - .protocol_fee_recipient_token_account - .expect("protocol_fee_recipient_token_account is not set"), - base_token_program: self - .base_token_program - .expect("base_token_program is not set"), - quote_token_program: self - .quote_token_program - .expect("quote_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - coin_creator_vault_ata: self - .coin_creator_vault_ata - .expect("coin_creator_vault_ata is not set"), - coin_creator_vault_authority: self - .coin_creator_vault_authority - .expect("coin_creator_vault_authority is not set"), - }; - let args = SellInstructionArgs { - base_amount_in: self - .base_amount_in - .clone() - .expect("base_amount_in is not set"), - min_quote_amount_out: self - .min_quote_amount_out - .clone() - .expect("min_quote_amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `sell` CPI accounts. -pub struct SellCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_ata: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `sell` CPI instruction. -pub struct SellCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_fee_recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_ata: &'b solana_account_info::AccountInfo<'a>, - - pub coin_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SellInstructionArgs, -} - -impl<'a, 'b> SellCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SellCpiAccounts<'a, 'b>, - args: SellInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - user: accounts.user, - global_config: accounts.global_config, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - user_base_token_account: accounts.user_base_token_account, - user_quote_token_account: accounts.user_quote_token_account, - pool_base_token_account: accounts.pool_base_token_account, - pool_quote_token_account: accounts.pool_quote_token_account, - protocol_fee_recipient: accounts.protocol_fee_recipient, - protocol_fee_recipient_token_account: accounts.protocol_fee_recipient_token_account, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - system_program: accounts.system_program, - associated_token_program: accounts.associated_token_program, - event_authority: accounts.event_authority, - program: accounts.program, - coin_creator_vault_ata: accounts.coin_creator_vault_ata, - coin_creator_vault_authority: accounts.coin_creator_vault_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(19 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.user.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.protocol_fee_recipient.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_fee_recipient_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.coin_creator_vault_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.coin_creator_vault_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SellInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(20 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.user_base_token_account.clone()); - account_infos.push(self.user_quote_token_account.clone()); - account_infos.push(self.pool_base_token_account.clone()); - account_infos.push(self.pool_quote_token_account.clone()); - account_infos.push(self.protocol_fee_recipient.clone()); - account_infos.push(self.protocol_fee_recipient_token_account.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - account_infos.push(self.coin_creator_vault_ata.clone()); - account_infos.push(self.coin_creator_vault_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Sell` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` pool -/// 1. `[writable, signer]` user -/// 2. `[]` global_config -/// 3. `[]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` user_base_token_account -/// 6. `[writable]` user_quote_token_account -/// 7. `[writable]` pool_base_token_account -/// 8. `[writable]` pool_quote_token_account -/// 9. `[]` protocol_fee_recipient -/// 10. `[writable]` protocol_fee_recipient_token_account -/// 11. `[]` base_token_program -/// 12. `[]` quote_token_program -/// 13. `[]` system_program -/// 14. `[]` associated_token_program -/// 15. `[]` event_authority -/// 16. `[]` program -/// 17. `[writable]` coin_creator_vault_ata -/// 18. `[]` coin_creator_vault_authority -#[derive(Clone, Debug)] -pub struct SellCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SellCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SellCpiBuilderInstruction { - __program: program, - pool: None, - user: None, - global_config: None, - base_mint: None, - quote_mint: None, - user_base_token_account: None, - user_quote_token_account: None, - pool_base_token_account: None, - pool_quote_token_account: None, - protocol_fee_recipient: None, - protocol_fee_recipient_token_account: None, - base_token_program: None, - quote_token_program: None, - system_program: None, - associated_token_program: None, - event_authority: None, - program: None, - coin_creator_vault_ata: None, - coin_creator_vault_authority: None, - base_amount_in: None, - min_quote_amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn user_base_token_account( - &mut self, - user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_base_token_account = Some(user_base_token_account); - self - } - - #[inline(always)] - pub fn user_quote_token_account( - &mut self, - user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_quote_token_account = Some(user_quote_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient( - &mut self, - protocol_fee_recipient: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_fee_recipient = Some(protocol_fee_recipient); - self - } - - #[inline(always)] - pub fn protocol_fee_recipient_token_account( - &mut self, - protocol_fee_recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_fee_recipient_token_account = - Some(protocol_fee_recipient_token_account); - self - } - - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn coin_creator_vault_ata( - &mut self, - coin_creator_vault_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_creator_vault_ata = Some(coin_creator_vault_ata); - self - } - - #[inline(always)] - pub fn coin_creator_vault_authority( - &mut self, - coin_creator_vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_creator_vault_authority = Some(coin_creator_vault_authority); - self - } - - #[inline(always)] - pub fn base_amount_in(&mut self, base_amount_in: u64) -> &mut Self { - self.instruction.base_amount_in = Some(base_amount_in); - self - } - - #[inline(always)] - pub fn min_quote_amount_out(&mut self, min_quote_amount_out: u64) -> &mut Self { - self.instruction.min_quote_amount_out = Some(min_quote_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SellInstructionArgs { - base_amount_in: self - .instruction - .base_amount_in - .clone() - .expect("base_amount_in is not set"), - min_quote_amount_out: self - .instruction - .min_quote_amount_out - .clone() - .expect("min_quote_amount_out is not set"), - }; - let instruction = SellCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - user: self.instruction.user.expect("user is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - user_base_token_account: self - .instruction - .user_base_token_account - .expect("user_base_token_account is not set"), - - user_quote_token_account: self - .instruction - .user_quote_token_account - .expect("user_quote_token_account is not set"), - - pool_base_token_account: self - .instruction - .pool_base_token_account - .expect("pool_base_token_account is not set"), - - pool_quote_token_account: self - .instruction - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - - protocol_fee_recipient: self - .instruction - .protocol_fee_recipient - .expect("protocol_fee_recipient is not set"), - - protocol_fee_recipient_token_account: self - .instruction - .protocol_fee_recipient_token_account - .expect("protocol_fee_recipient_token_account is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - - coin_creator_vault_ata: self - .instruction - .coin_creator_vault_ata - .expect("coin_creator_vault_ata is not set"), - - coin_creator_vault_authority: self - .instruction - .coin_creator_vault_authority - .expect("coin_creator_vault_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SellCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_fee_recipient: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_fee_recipient_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_creator_vault_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_creator_vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - base_amount_in: Option, - min_quote_amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/set_coin_creator.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/set_coin_creator.rs deleted file mode 100644 index a184e609..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/set_coin_creator.rs +++ /dev/null @@ -1,427 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetCoinCreator { - pub pool: solana_pubkey::Pubkey, - - pub metadata: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SetCoinCreator { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetCoinCreatorInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetCoinCreatorInstructionData { - discriminator: [u8; 8], -} - -impl SetCoinCreatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [210, 149, 128, 45, 188, 58, 78, 175], - } - } -} - -impl Default for SetCoinCreatorInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetCoinCreator`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` metadata -/// 2. `[]` bonding_curve -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SetCoinCreatorBuilder { - pool: Option, - metadata: Option, - bonding_curve: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl SetCoinCreatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: solana_pubkey::Pubkey) -> &mut Self { - self.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetCoinCreator { - pool: self.pool.expect("pool is not set"), - metadata: self.metadata.expect("metadata is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_coin_creator` CPI accounts. -pub struct SetCoinCreatorCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_coin_creator` CPI instruction. -pub struct SetCoinCreatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetCoinCreatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetCoinCreatorCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - metadata: accounts.metadata, - bonding_curve: accounts.bonding_curve, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetCoinCreatorInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.metadata.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetCoinCreator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` metadata -/// 2. `[]` bonding_curve -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct SetCoinCreatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetCoinCreatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetCoinCreatorCpiBuilderInstruction { - __program: program, - pool: None, - metadata: None, - bonding_curve: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetCoinCreatorCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - metadata: self.instruction.metadata.expect("metadata is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetCoinCreatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/update_admin.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/update_admin.rs deleted file mode 100644 index e0ee0503..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/update_admin.rs +++ /dev/null @@ -1,432 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateAdmin { - pub admin: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub new_admin: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl UpdateAdmin { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_admin, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&UpdateAdminInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateAdminInstructionData { - discriminator: [u8; 8], -} - -impl UpdateAdminInstructionData { - pub fn new() -> Self { - Self { - discriminator: [161, 176, 40, 213, 60, 184, 179, 228], - } - } -} - -impl Default for UpdateAdminInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `UpdateAdmin`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` admin -/// 1. `[writable]` global_config -/// 2. `[]` new_admin -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct UpdateAdminBuilder { - admin: Option, - global_config: Option, - new_admin: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl UpdateAdminBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn new_admin(&mut self, new_admin: solana_pubkey::Pubkey) -> &mut Self { - self.new_admin = Some(new_admin); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateAdmin { - admin: self.admin.expect("admin is not set"), - global_config: self.global_config.expect("global_config is not set"), - new_admin: self.new_admin.expect("new_admin is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `update_admin` CPI accounts. -pub struct UpdateAdminCpiAccounts<'a, 'b> { - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub new_admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_admin` CPI instruction. -pub struct UpdateAdminCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub new_admin: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> UpdateAdminCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateAdminCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - admin: accounts.admin, - global_config: accounts.global_config, - new_admin: accounts.new_admin, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_admin.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&UpdateAdminInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.new_admin.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateAdmin` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` admin -/// 1. `[writable]` global_config -/// 2. `[]` new_admin -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct UpdateAdminCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateAdminCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateAdminCpiBuilderInstruction { - __program: program, - admin: None, - global_config: None, - new_admin: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn new_admin(&mut self, new_admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.new_admin = Some(new_admin); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = UpdateAdminCpi { - __program: self.instruction.__program, - - admin: self.instruction.admin.expect("admin is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - new_admin: self.instruction.new_admin.expect("new_admin is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateAdminCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - new_admin: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/update_fee_config.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/update_fee_config.rs deleted file mode 100644 index f97ce4c4..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/update_fee_config.rs +++ /dev/null @@ -1,525 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateFeeConfig { - pub admin: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl UpdateFeeConfig { - pub fn instruction( - &self, - args: UpdateFeeConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateFeeConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateFeeConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateFeeConfigInstructionData { - discriminator: [u8; 8], -} - -impl UpdateFeeConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [104, 184, 103, 242, 88, 151, 107, 20], - } - } -} - -impl Default for UpdateFeeConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateFeeConfigInstructionArgs { - pub lp_fee_basis_points: u64, - pub protocol_fee_basis_points: u64, - pub protocol_fee_recipients: [Pubkey; 8], - pub coin_creator_fee_basis_points: u64, -} - -/// Instruction builder for `UpdateFeeConfig`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` admin -/// 1. `[writable]` global_config -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug, Default)] -pub struct UpdateFeeConfigBuilder { - admin: Option, - global_config: Option, - event_authority: Option, - program: Option, - lp_fee_basis_points: Option, - protocol_fee_basis_points: Option, - protocol_fee_recipients: Option<[Pubkey; 8]>, - coin_creator_fee_basis_points: Option, - __remaining_accounts: Vec, -} - -impl UpdateFeeConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn lp_fee_basis_points(&mut self, lp_fee_basis_points: u64) -> &mut Self { - self.lp_fee_basis_points = Some(lp_fee_basis_points); - self - } - - #[inline(always)] - pub fn protocol_fee_basis_points(&mut self, protocol_fee_basis_points: u64) -> &mut Self { - self.protocol_fee_basis_points = Some(protocol_fee_basis_points); - self - } - - #[inline(always)] - pub fn protocol_fee_recipients(&mut self, protocol_fee_recipients: [Pubkey; 8]) -> &mut Self { - self.protocol_fee_recipients = Some(protocol_fee_recipients); - self - } - - #[inline(always)] - pub fn coin_creator_fee_basis_points( - &mut self, - coin_creator_fee_basis_points: u64, - ) -> &mut Self { - self.coin_creator_fee_basis_points = Some(coin_creator_fee_basis_points); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateFeeConfig { - admin: self.admin.expect("admin is not set"), - global_config: self.global_config.expect("global_config is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = UpdateFeeConfigInstructionArgs { - lp_fee_basis_points: self - .lp_fee_basis_points - .clone() - .expect("lp_fee_basis_points is not set"), - protocol_fee_basis_points: self - .protocol_fee_basis_points - .clone() - .expect("protocol_fee_basis_points is not set"), - protocol_fee_recipients: self - .protocol_fee_recipients - .clone() - .expect("protocol_fee_recipients is not set"), - coin_creator_fee_basis_points: self - .coin_creator_fee_basis_points - .clone() - .expect("coin_creator_fee_basis_points is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_fee_config` CPI accounts. -pub struct UpdateFeeConfigCpiAccounts<'a, 'b> { - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_fee_config` CPI instruction. -pub struct UpdateFeeConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateFeeConfigInstructionArgs, -} - -impl<'a, 'b> UpdateFeeConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateFeeConfigCpiAccounts<'a, 'b>, - args: UpdateFeeConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - admin: accounts.admin, - global_config: accounts.global_config, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateFeeConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateFeeConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` admin -/// 1. `[writable]` global_config -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug)] -pub struct UpdateFeeConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateFeeConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateFeeConfigCpiBuilderInstruction { - __program: program, - admin: None, - global_config: None, - event_authority: None, - program: None, - lp_fee_basis_points: None, - protocol_fee_basis_points: None, - protocol_fee_recipients: None, - coin_creator_fee_basis_points: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn lp_fee_basis_points(&mut self, lp_fee_basis_points: u64) -> &mut Self { - self.instruction.lp_fee_basis_points = Some(lp_fee_basis_points); - self - } - - #[inline(always)] - pub fn protocol_fee_basis_points(&mut self, protocol_fee_basis_points: u64) -> &mut Self { - self.instruction.protocol_fee_basis_points = Some(protocol_fee_basis_points); - self - } - - #[inline(always)] - pub fn protocol_fee_recipients(&mut self, protocol_fee_recipients: [Pubkey; 8]) -> &mut Self { - self.instruction.protocol_fee_recipients = Some(protocol_fee_recipients); - self - } - - #[inline(always)] - pub fn coin_creator_fee_basis_points( - &mut self, - coin_creator_fee_basis_points: u64, - ) -> &mut Self { - self.instruction.coin_creator_fee_basis_points = Some(coin_creator_fee_basis_points); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateFeeConfigInstructionArgs { - lp_fee_basis_points: self - .instruction - .lp_fee_basis_points - .clone() - .expect("lp_fee_basis_points is not set"), - protocol_fee_basis_points: self - .instruction - .protocol_fee_basis_points - .clone() - .expect("protocol_fee_basis_points is not set"), - protocol_fee_recipients: self - .instruction - .protocol_fee_recipients - .clone() - .expect("protocol_fee_recipients is not set"), - coin_creator_fee_basis_points: self - .instruction - .coin_creator_fee_basis_points - .clone() - .expect("coin_creator_fee_basis_points is not set"), - }; - let instruction = UpdateFeeConfigCpi { - __program: self.instruction.__program, - - admin: self.instruction.admin.expect("admin is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateFeeConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_fee_basis_points: Option, - protocol_fee_basis_points: Option, - protocol_fee_recipients: Option<[Pubkey; 8]>, - coin_creator_fee_basis_points: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/instructions/withdraw.rs b/crates/pump-swaps-parser/src/generated_sdk/instructions/withdraw.rs deleted file mode 100644 index 74776d0f..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/instructions/withdraw.rs +++ /dev/null @@ -1,953 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Withdraw { - pub pool: solana_pubkey::Pubkey, - - pub global_config: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub base_mint: solana_pubkey::Pubkey, - - pub quote_mint: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub user_base_token_account: solana_pubkey::Pubkey, - - pub user_quote_token_account: solana_pubkey::Pubkey, - - pub user_pool_token_account: solana_pubkey::Pubkey, - - pub pool_base_token_account: solana_pubkey::Pubkey, - - pub pool_quote_token_account: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token2022_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Withdraw { - pub fn instruction(&self, args: WithdrawInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: WithdrawInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_pool_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawInstructionData { - pub fn new() -> Self { - Self { - discriminator: [183, 18, 70, 156, 148, 109, 161, 34], - } - } -} - -impl Default for WithdrawInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawInstructionArgs { - pub lp_token_amount_in: u64, - pub min_base_amount_out: u64, - pub min_quote_amount_out: u64, -} - -/// Instruction builder for `Withdraw`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` global_config -/// 2. `[signer]` user -/// 3. `[]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` lp_mint -/// 6. `[writable]` user_base_token_account -/// 7. `[writable]` user_quote_token_account -/// 8. `[writable]` user_pool_token_account -/// 9. `[writable]` pool_base_token_account -/// 10. `[writable]` pool_quote_token_account -/// 11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 12. `[optional]` token2022_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct WithdrawBuilder { - pool: Option, - global_config: Option, - user: Option, - base_mint: Option, - quote_mint: Option, - lp_mint: Option, - user_base_token_account: Option, - user_quote_token_account: Option, - user_pool_token_account: Option, - pool_base_token_account: Option, - pool_quote_token_account: Option, - token_program: Option, - token2022_program: Option, - event_authority: Option, - program: Option, - lp_token_amount_in: Option, - min_base_amount_out: Option, - min_quote_amount_out: Option, - __remaining_accounts: Vec, -} - -impl WithdrawBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn user_base_token_account( - &mut self, - user_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_base_token_account = Some(user_base_token_account); - self - } - - #[inline(always)] - pub fn user_quote_token_account( - &mut self, - user_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_quote_token_account = Some(user_quote_token_account); - self - } - - #[inline(always)] - pub fn user_pool_token_account( - &mut self, - user_pool_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_pool_token_account = Some(user_pool_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn lp_token_amount_in(&mut self, lp_token_amount_in: u64) -> &mut Self { - self.lp_token_amount_in = Some(lp_token_amount_in); - self - } - - #[inline(always)] - pub fn min_base_amount_out(&mut self, min_base_amount_out: u64) -> &mut Self { - self.min_base_amount_out = Some(min_base_amount_out); - self - } - - #[inline(always)] - pub fn min_quote_amount_out(&mut self, min_quote_amount_out: u64) -> &mut Self { - self.min_quote_amount_out = Some(min_quote_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Withdraw { - pool: self.pool.expect("pool is not set"), - global_config: self.global_config.expect("global_config is not set"), - user: self.user.expect("user is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_base_token_account: self - .user_base_token_account - .expect("user_base_token_account is not set"), - user_quote_token_account: self - .user_quote_token_account - .expect("user_quote_token_account is not set"), - user_pool_token_account: self - .user_pool_token_account - .expect("user_pool_token_account is not set"), - pool_base_token_account: self - .pool_base_token_account - .expect("pool_base_token_account is not set"), - pool_quote_token_account: self - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token2022_program: self.token2022_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = WithdrawInstructionArgs { - lp_token_amount_in: self - .lp_token_amount_in - .clone() - .expect("lp_token_amount_in is not set"), - min_base_amount_out: self - .min_base_amount_out - .clone() - .expect("min_base_amount_out is not set"), - min_quote_amount_out: self - .min_quote_amount_out - .clone() - .expect("min_quote_amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw` CPI accounts. -pub struct WithdrawCpiAccounts<'a, 'b> { - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw` CPI instruction. -pub struct WithdrawCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub global_config: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: WithdrawInstructionArgs, -} - -impl<'a, 'b> WithdrawCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawCpiAccounts<'a, 'b>, - args: WithdrawInstructionArgs, - ) -> Self { - Self { - __program: program, - pool: accounts.pool, - global_config: accounts.global_config, - user: accounts.user, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - lp_mint: accounts.lp_mint, - user_base_token_account: accounts.user_base_token_account, - user_quote_token_account: accounts.user_quote_token_account, - user_pool_token_account: accounts.user_pool_token_account, - pool_base_token_account: accounts.pool_base_token_account, - pool_quote_token_account: accounts.pool_quote_token_account, - token_program: accounts.token_program, - token2022_program: accounts.token2022_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_pool_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_AMM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_base_token_account.clone()); - account_infos.push(self.user_quote_token_account.clone()); - account_infos.push(self.user_pool_token_account.clone()); - account_infos.push(self.pool_base_token_account.clone()); - account_infos.push(self.pool_quote_token_account.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token2022_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Withdraw` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool -/// 1. `[]` global_config -/// 2. `[signer]` user -/// 3. `[]` base_mint -/// 4. `[]` quote_mint -/// 5. `[writable]` lp_mint -/// 6. `[writable]` user_base_token_account -/// 7. `[writable]` user_quote_token_account -/// 8. `[writable]` user_pool_token_account -/// 9. `[writable]` pool_base_token_account -/// 10. `[writable]` pool_quote_token_account -/// 11. `[]` token_program -/// 12. `[]` token2022_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct WithdrawCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawCpiBuilderInstruction { - __program: program, - pool: None, - global_config: None, - user: None, - base_mint: None, - quote_mint: None, - lp_mint: None, - user_base_token_account: None, - user_quote_token_account: None, - user_pool_token_account: None, - pool_base_token_account: None, - pool_quote_token_account: None, - token_program: None, - token2022_program: None, - event_authority: None, - program: None, - lp_token_amount_in: None, - min_base_amount_out: None, - min_quote_amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn user_base_token_account( - &mut self, - user_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_base_token_account = Some(user_base_token_account); - self - } - - #[inline(always)] - pub fn user_quote_token_account( - &mut self, - user_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_quote_token_account = Some(user_quote_token_account); - self - } - - #[inline(always)] - pub fn user_pool_token_account( - &mut self, - user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_pool_token_account = Some(user_pool_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn lp_token_amount_in(&mut self, lp_token_amount_in: u64) -> &mut Self { - self.instruction.lp_token_amount_in = Some(lp_token_amount_in); - self - } - - #[inline(always)] - pub fn min_base_amount_out(&mut self, min_base_amount_out: u64) -> &mut Self { - self.instruction.min_base_amount_out = Some(min_base_amount_out); - self - } - - #[inline(always)] - pub fn min_quote_amount_out(&mut self, min_quote_amount_out: u64) -> &mut Self { - self.instruction.min_quote_amount_out = Some(min_quote_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = WithdrawInstructionArgs { - lp_token_amount_in: self - .instruction - .lp_token_amount_in - .clone() - .expect("lp_token_amount_in is not set"), - min_base_amount_out: self - .instruction - .min_base_amount_out - .clone() - .expect("min_base_amount_out is not set"), - min_quote_amount_out: self - .instruction - .min_quote_amount_out - .clone() - .expect("min_quote_amount_out is not set"), - }; - let instruction = WithdrawCpi { - __program: self.instruction.__program, - - pool: self.instruction.pool.expect("pool is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - user: self.instruction.user.expect("user is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_base_token_account: self - .instruction - .user_base_token_account - .expect("user_base_token_account is not set"), - - user_quote_token_account: self - .instruction - .user_quote_token_account - .expect("user_quote_token_account is not set"), - - user_pool_token_account: self - .instruction - .user_pool_token_account - .expect("user_pool_token_account is not set"), - - pool_base_token_account: self - .instruction - .pool_base_token_account - .expect("pool_base_token_account is not set"), - - pool_quote_token_account: self - .instruction - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_pool_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_token_amount_in: Option, - min_base_amount_out: Option, - min_quote_amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/mod.rs b/crates/pump-swaps-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/pump-swaps-parser/src/generated_sdk/programs.rs b/crates/pump-swaps-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 84cf8d4d..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `pump_amm` program ID. -pub const PUMP_AMM_ID: Pubkey = pubkey!("pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"); diff --git a/crates/pump-swaps-parser/src/generated_sdk/shared.rs b/crates/pump-swaps-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/buy_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/buy_event.rs deleted file mode 100644 index 97ea2e64..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/buy_event.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyEvent { - pub timestamp: i64, - pub base_amount_out: u64, - pub max_quote_amount_in: u64, - pub user_base_token_reserves: u64, - pub user_quote_token_reserves: u64, - pub pool_base_token_reserves: u64, - pub pool_quote_token_reserves: u64, - pub quote_amount_in: u64, - pub lp_fee_basis_points: u64, - pub lp_fee: u64, - pub protocol_fee_basis_points: u64, - pub protocol_fee: u64, - pub quote_amount_in_with_lp_fee: u64, - pub user_quote_amount_in: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_base_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_quote_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_fee_recipient: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_fee_recipient_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub coin_creator: Pubkey, - pub coin_creator_fee_basis_points: u64, - pub coin_creator_fee: u64, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/collect_coin_creator_fee_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/collect_coin_creator_fee_event.rs deleted file mode 100644 index 03f7b951..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/collect_coin_creator_fee_event.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectCoinCreatorFeeEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub coin_creator: Pubkey, - pub coin_creator_fee: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub coin_creator_vault_ata: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub coin_creator_token_account: Pubkey, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/create_config_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/create_config_event.rs deleted file mode 100644 index 18515f2f..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/create_config_event.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub admin: Pubkey, - pub lp_fee_basis_points: u64, - pub protocol_fee_basis_points: u64, - pub protocol_fee_recipients: [Pubkey; 8], - pub coin_creator_fee_basis_points: u64, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/create_pool_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/create_pool_event.rs deleted file mode 100644 index 16ecb3c7..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/create_pool_event.rs +++ /dev/null @@ -1,66 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePoolEvent { - pub timestamp: i64, - pub index: u16, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub quote_mint: Pubkey, - pub base_mint_decimals: u8, - pub quote_mint_decimals: u8, - pub base_amount_in: u64, - pub quote_amount_in: u64, - pub pool_base_amount: u64, - pub pool_quote_amount: u64, - pub minimum_liquidity: u64, - pub initial_liquidity: u64, - pub lp_token_amount_out: u64, - pub pool_bump: u8, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lp_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_base_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_quote_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub coin_creator: Pubkey, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/deposit_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/deposit_event.rs deleted file mode 100644 index 89960b66..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/deposit_event.rs +++ /dev/null @@ -1,50 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositEvent { - pub timestamp: i64, - pub lp_token_amount_out: u64, - pub max_base_amount_in: u64, - pub max_quote_amount_in: u64, - pub user_base_token_reserves: u64, - pub user_quote_token_reserves: u64, - pub pool_base_token_reserves: u64, - pub pool_quote_token_reserves: u64, - pub base_amount_in: u64, - pub quote_amount_in: u64, - pub lp_mint_supply: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_base_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_quote_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_pool_token_account: Pubkey, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/disable_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/disable_event.rs deleted file mode 100644 index cd6d466b..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/disable_event.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DisableEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub admin: Pubkey, - pub disable_create_pool: bool, - pub disable_deposit: bool, - pub disable_withdraw: bool, - pub disable_buy: bool, - pub disable_sell: bool, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/extend_account_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/extend_account_event.rs deleted file mode 100644 index 348e8c82..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/extend_account_event.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ExtendAccountEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user: Pubkey, - pub current_size: u64, - pub new_size: u64, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/mod.rs b/crates/pump-swaps-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index e57bc3d8..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#buy_event; -pub(crate) mod r#collect_coin_creator_fee_event; -pub(crate) mod r#create_config_event; -pub(crate) mod r#create_pool_event; -pub(crate) mod r#deposit_event; -pub(crate) mod r#disable_event; -pub(crate) mod r#extend_account_event; -pub(crate) mod r#sell_event; -pub(crate) mod r#set_bonding_curve_coin_creator_event; -pub(crate) mod r#set_metaplex_coin_creator_event; -pub(crate) mod r#update_admin_event; -pub(crate) mod r#update_fee_config_event; -pub(crate) mod r#withdraw_event; - -pub use self::{ - r#buy_event::*, r#collect_coin_creator_fee_event::*, r#create_config_event::*, - r#create_pool_event::*, r#deposit_event::*, r#disable_event::*, r#extend_account_event::*, - r#sell_event::*, r#set_bonding_curve_coin_creator_event::*, - r#set_metaplex_coin_creator_event::*, r#update_admin_event::*, r#update_fee_config_event::*, - r#withdraw_event::*, -}; diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/sell_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/sell_event.rs deleted file mode 100644 index 94f39b37..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/sell_event.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellEvent { - pub timestamp: i64, - pub base_amount_in: u64, - pub min_quote_amount_out: u64, - pub user_base_token_reserves: u64, - pub user_quote_token_reserves: u64, - pub pool_base_token_reserves: u64, - pub pool_quote_token_reserves: u64, - pub quote_amount_out: u64, - pub lp_fee_basis_points: u64, - pub lp_fee: u64, - pub protocol_fee_basis_points: u64, - pub protocol_fee: u64, - pub quote_amount_out_without_lp_fee: u64, - pub user_quote_amount_out: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_base_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_quote_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_fee_recipient: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_fee_recipient_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub coin_creator: Pubkey, - pub coin_creator_fee_basis_points: u64, - pub coin_creator_fee: u64, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/set_bonding_curve_coin_creator_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/set_bonding_curve_coin_creator_event.rs deleted file mode 100644 index bbb1948f..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/set_bonding_curve_coin_creator_event.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetBondingCurveCoinCreatorEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub bonding_curve: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub coin_creator: Pubkey, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/set_metaplex_coin_creator_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/set_metaplex_coin_creator_event.rs deleted file mode 100644 index 27528614..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/set_metaplex_coin_creator_event.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetMetaplexCoinCreatorEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub metadata: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub coin_creator: Pubkey, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/update_admin_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/update_admin_event.rs deleted file mode 100644 index f3973136..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/update_admin_event.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateAdminEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub admin: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub new_admin: Pubkey, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/update_fee_config_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/update_fee_config_event.rs deleted file mode 100644 index 4cee1761..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/update_fee_config_event.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateFeeConfigEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub admin: Pubkey, - pub lp_fee_basis_points: u64, - pub protocol_fee_basis_points: u64, - pub protocol_fee_recipients: [Pubkey; 8], - pub coin_creator_fee_basis_points: u64, -} diff --git a/crates/pump-swaps-parser/src/generated_sdk/types/withdraw_event.rs b/crates/pump-swaps-parser/src/generated_sdk/types/withdraw_event.rs deleted file mode 100644 index 50b04519..00000000 --- a/crates/pump-swaps-parser/src/generated_sdk/types/withdraw_event.rs +++ /dev/null @@ -1,50 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawEvent { - pub timestamp: i64, - pub lp_token_amount_in: u64, - pub min_base_amount_out: u64, - pub min_quote_amount_out: u64, - pub user_base_token_reserves: u64, - pub user_quote_token_reserves: u64, - pub pool_base_token_reserves: u64, - pub pool_quote_token_reserves: u64, - pub base_amount_out: u64, - pub quote_amount_out: u64, - pub lp_mint_supply: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_base_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_quote_token_account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user_pool_token_account: Pubkey, -} diff --git a/crates/pump-swaps-parser/src/lib.rs b/crates/pump-swaps-parser/src/lib.rs deleted file mode 100644 index 458c44a1..00000000 --- a/crates/pump-swaps-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = PUMP_AMM_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.pump_swaps"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/pumpfun-parser/Cargo.toml b/crates/pumpfun-parser/Cargo.toml deleted file mode 100644 index b688a05b..00000000 --- a/crates/pumpfun-parser/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "yellowstone-vixen-pumpfun-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Pumpfun program" -license.workspace = true -repository.workspace = true -authors.workspace = true - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info.workspace = true -solana-cpi.workspace = true -solana-decode-error.workspace = true -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction.workspace = true -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true \ No newline at end of file diff --git a/crates/pumpfun-parser/build.rs b/crates/pumpfun-parser/build.rs deleted file mode 100644 index 35211f1a..00000000 --- a/crates/pumpfun-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/pumpfun.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/pumpfun-parser/idl.json b/crates/pumpfun-parser/idl.json deleted file mode 100644 index 160ba581..00000000 --- a/crates/pumpfun-parser/idl.json +++ /dev/null @@ -1,1958 +0,0 @@ -{ - "address": "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P", - "metadata": { - "name": "pump", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "buy", - "docs": ["Buys tokens from a bonding curve."], - "discriminator": [102, 6, 61, 18, 1, 218, 235, 234], - "accounts": [ - { - "name": "global", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [103, 108, 111, 98, 97, 108] - } - ] - } - }, - { - "name": "fee_recipient", - "writable": true - }, - { - "name": "mint" - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, 111, 110, 100, 105, 110, 103, 45, 99, - 117, 114, 118, 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "associated_bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "bonding_curve" - }, - { - "kind": "const", - "value": [ - 6, 221, 246, 225, 215, 101, 161, 147, 217, - 203, 225, 70, 206, 235, 121, 172, 28, 180, - 133, 237, 95, 91, 55, 145, 58, 140, 245, - 133, 126, 255, 0, 169 - ] - }, - { - "kind": "account", - "path": "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": "associated_user", - "writable": true - }, - { - "name": "user", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "creator_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, 114, 101, 97, 116, 111, 114, 45, 118, - 97, 117, 108, 116 - ] - }, - { - "kind": "account", - "path": "bonding_curve.creator", - "account": "BondingCurve" - } - ] - } - }, - { - "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", - "type": "u64" - }, - { - "name": "max_sol_cost", - "type": "u64" - } - ] - }, - { - "name": "collect_creator_fee", - "docs": [ - "Collects creator_fee from creator_vault to the coin creator account" - ], - "discriminator": [20, 22, 86, 123, 198, 28, 219, 132], - "accounts": [ - { - "name": "creator", - "writable": true, - "signer": true - }, - { - "name": "creator_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, 114, 101, 97, 116, 111, 114, 45, 118, - 97, 117, 108, 116 - ] - }, - { - "kind": "account", - "path": "creator" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, 95, 101, 118, 101, 110, 116, 95, 97, - 117, 116, 104, 111, 114, 105, 116, 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "create", - "docs": ["Creates a new coin and bonding curve."], - "discriminator": [24, 30, 200, 40, 5, 28, 7, 119], - "accounts": [ - { - "name": "mint", - "writable": true, - "signer": true - }, - { - "name": "mint_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, 105, 110, 116, 45, 97, 117, 116, 104, - 111, 114, 105, 116, 121 - ] - } - ] - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, 111, 110, 100, 105, 110, 103, 45, 99, - 117, 114, 118, 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "associated_bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "bonding_curve" - }, - { - "kind": "const", - "value": [ - 6, 221, 246, 225, 215, 101, 161, 147, 217, - 203, 225, 70, 206, 235, 121, 172, 28, 180, - 133, 237, 95, 91, 55, 145, 58, 140, 245, - 133, 126, 255, 0, 169 - ] - }, - { - "kind": "account", - "path": "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": "global", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [103, 108, 111, 98, 97, 108] - } - ] - } - }, - { - "name": "mpl_token_metadata", - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - }, - { - "name": "metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [109, 101, 116, 97, 100, 97, 116, 97] - }, - { - "kind": "const", - "value": [ - 11, 112, 101, 177, 227, 209, 124, 69, 56, - 157, 82, 127, 107, 4, 195, 205, 88, 184, - 108, 115, 26, 160, 253, 181, 73, 182, 209, - 188, 3, 248, 41, 70 - ] - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "account", - "path": "mpl_token_metadata" - } - } - }, - { - "name": "user", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "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": "name", - "type": "string" - }, - { - "name": "symbol", - "type": "string" - }, - { - "name": "uri", - "type": "string" - }, - { - "name": "creator", - "type": "pubkey" - } - ] - }, - { - "name": "extend_account", - "docs": ["Extends the size of program-owned accounts"], - "discriminator": [234, 102, 194, 203, 150, 72, 62, 229], - "accounts": [ - { - "name": "account", - "writable": true - }, - { - "name": "user", - "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": "initialize", - "docs": ["Creates the global state."], - "discriminator": [175, 175, 109, 31, 13, 152, 155, 237], - "accounts": [ - { - "name": "global", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [103, 108, 111, 98, 97, 108] - } - ] - } - }, - { - "name": "user", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "migrate", - "docs": [ - "Migrates liquidity to pump_amm if the bonding curve is complete" - ], - "discriminator": [155, 234, 231, 146, 236, 158, 162, 30], - "accounts": [ - { - "name": "global", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [103, 108, 111, 98, 97, 108] - } - ] - } - }, - { - "name": "withdraw_authority", - "writable": true, - "relations": ["global"] - }, - { - "name": "mint" - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, 111, 110, 100, 105, 110, 103, 45, 99, - 117, 114, 118, 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "associated_bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "bonding_curve" - }, - { - "kind": "const", - "value": [ - 6, 221, 246, 225, 215, 101, 161, 147, 217, - 203, 225, 70, 206, 235, 121, 172, 28, 180, - 133, 237, 95, 91, 55, 145, 58, 140, 245, - 133, 126, 255, 0, 169 - ] - }, - { - "kind": "account", - "path": "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": "user", - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "pump_amm", - "address": "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA" - }, - { - "name": "pool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [112, 111, 111, 108] - }, - { - "kind": "const", - "value": [0, 0] - }, - { - "kind": "account", - "path": "pool_authority" - }, - { - "kind": "account", - "path": "mint" - }, - { - "kind": "account", - "path": "wsol_mint" - } - ], - "program": { - "kind": "account", - "path": "pump_amm" - } - } - }, - { - "name": "pool_authority", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, 111, 111, 108, 45, 97, 117, 116, 104, - 111, 114, 105, 116, 121 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "pool_authority_mint_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "pool_authority" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "account", - "path": "associated_token_program" - } - } - }, - { - "name": "pool_authority_wsol_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "pool_authority" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "wsol_mint" - } - ], - "program": { - "kind": "account", - "path": "associated_token_program" - } - } - }, - { - "name": "amm_global_config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 103, 108, 111, 98, 97, 108, 95, 99, 111, - 110, 102, 105, 103 - ] - } - ], - "program": { - "kind": "account", - "path": "pump_amm" - } - } - }, - { - "name": "wsol_mint", - "address": "So11111111111111111111111111111111111111112" - }, - { - "name": "lp_mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, 111, 111, 108, 95, 108, 112, 95, 109, - 105, 110, 116 - ] - }, - { - "kind": "account", - "path": "pool" - } - ], - "program": { - "kind": "account", - "path": "pump_amm" - } - } - }, - { - "name": "user_pool_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "pool_authority" - }, - { - "kind": "account", - "path": "token_2022_program" - }, - { - "kind": "account", - "path": "lp_mint" - } - ], - "program": { - "kind": "account", - "path": "associated_token_program" - } - } - }, - { - "name": "pool_base_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "pool" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "account", - "path": "associated_token_program" - } - } - }, - { - "name": "pool_quote_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "pool" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "wsol_mint" - } - ], - "program": { - "kind": "account", - "path": "associated_token_program" - } - } - }, - { - "name": "token_2022_program", - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "pump_amm_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": "account", - "path": "pump_amm" - } - } - }, - { - "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": "sell", - "docs": ["Sells tokens into a bonding curve."], - "discriminator": [51, 230, 133, 164, 1, 127, 131, 173], - "accounts": [ - { - "name": "global", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [103, 108, 111, 98, 97, 108] - } - ] - } - }, - { - "name": "fee_recipient", - "writable": true - }, - { - "name": "mint" - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, 111, 110, 100, 105, 110, 103, 45, 99, - 117, 114, 118, 101 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "associated_bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "bonding_curve" - }, - { - "kind": "const", - "value": [ - 6, 221, 246, 225, 215, 101, 161, 147, 217, - 203, 225, 70, 206, 235, 121, 172, 28, 180, - 133, 237, 95, 91, 55, 145, 58, 140, 245, - 133, 126, 255, 0, 169 - ] - }, - { - "kind": "account", - "path": "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": "associated_user", - "writable": true - }, - { - "name": "user", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "creator_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, 114, 101, 97, 116, 111, 114, 45, 118, - 97, 117, 108, 116 - ] - }, - { - "kind": "account", - "path": "bonding_curve.creator", - "account": "BondingCurve" - } - ] - } - }, - { - "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": "amount", - "type": "u64" - }, - { - "name": "min_sol_output", - "type": "u64" - } - ] - }, - { - "name": "set_creator", - "docs": [ - "Allows Global::set_creator_authority to set the bonding curve creator from Metaplex metadata or input argument" - ], - "discriminator": [254, 148, 255, 112, 207, 142, 170, 165], - "accounts": [ - { - "name": "set_creator_authority", - "signer": true, - "relations": ["global"] - }, - { - "name": "global", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [103, 108, 111, 98, 97, 108] - } - ] - } - }, - { - "name": "mint" - }, - { - "name": "metadata", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [109, 101, 116, 97, 100, 97, 116, 97] - }, - { - "kind": "const", - "value": [ - 11, 112, 101, 177, 227, 209, 124, 69, 56, - 157, 82, 127, 107, 4, 195, 205, 88, 184, - 108, 115, 26, 160, 253, 181, 73, 182, 209, - 188, 3, 248, 41, 70 - ] - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 11, 112, 101, 177, 227, 209, 124, 69, 56, 157, - 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, - 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, - 41, 70 - ] - } - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, 111, 110, 100, 105, 110, 103, 45, 99, - 117, 114, 118, 101 - ] - }, - { - "kind": "account", - "path": "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": "creator", - "type": "pubkey" - } - ] - }, - { - "name": "set_metaplex_creator", - "docs": [ - "Syncs the bonding curve creator with the Metaplex metadata creator if it exists" - ], - "discriminator": [138, 96, 174, 217, 48, 85, 197, 246], - "accounts": [ - { - "name": "mint" - }, - { - "name": "metadata", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [109, 101, 116, 97, 100, 97, 116, 97] - }, - { - "kind": "const", - "value": [ - 11, 112, 101, 177, 227, 209, 124, 69, 56, - 157, 82, 127, 107, 4, 195, 205, 88, 184, - 108, 115, 26, 160, 253, 181, 73, 182, 209, - 188, 3, 248, 41, 70 - ] - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 11, 112, 101, 177, 227, 209, 124, 69, 56, 157, - 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, - 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, - 41, 70 - ] - } - } - }, - { - "name": "bonding_curve", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, 111, 110, 100, 105, 110, 103, 45, 99, - 117, 114, 118, 101 - ] - }, - { - "kind": "account", - "path": "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": "set_params", - "docs": ["Sets the global state parameters."], - "discriminator": [27, 234, 178, 52, 147, 2, 187, 141], - "accounts": [ - { - "name": "global", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [103, 108, 111, 98, 97, 108] - } - ] - } - }, - { - "name": "authority", - "writable": true, - "signer": true, - "relations": ["global"] - }, - { - "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": "initial_virtual_token_reserves", - "type": "u64" - }, - { - "name": "initial_virtual_sol_reserves", - "type": "u64" - }, - { - "name": "initial_real_token_reserves", - "type": "u64" - }, - { - "name": "token_total_supply", - "type": "u64" - }, - { - "name": "fee_basis_points", - "type": "u64" - }, - { - "name": "withdraw_authority", - "type": "pubkey" - }, - { - "name": "enable_migrate", - "type": "bool" - }, - { - "name": "pool_migration_fee", - "type": "u64" - }, - { - "name": "creator_fee_basis_points", - "type": "u64" - }, - { - "name": "set_creator_authority", - "type": "pubkey" - } - ] - }, - { - "name": "update_global_authority", - "discriminator": [227, 181, 74, 196, 208, 21, 97, 213], - "accounts": [ - { - "name": "global", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [103, 108, 111, 98, 97, 108] - } - ] - } - }, - { - "name": "authority", - "signer": true, - "relations": ["global"] - }, - { - "name": "new_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": [] - } - ], - "accounts": [ - { - "name": "BondingCurve", - "discriminator": [23, 183, 248, 55, 96, 216, 172, 96] - }, - { - "name": "Global", - "discriminator": [167, 232, 232, 177, 200, 108, 114, 127] - } - ], - "events": [ - { - "name": "CollectCreatorFeeEvent", - "discriminator": [122, 2, 127, 1, 14, 191, 12, 175] - }, - { - "name": "CompleteEvent", - "discriminator": [95, 114, 97, 156, 212, 46, 152, 8] - }, - { - "name": "CompletePumpAmmMigrationEvent", - "discriminator": [189, 233, 93, 185, 92, 148, 234, 148] - }, - { - "name": "CreateEvent", - "discriminator": [27, 114, 169, 77, 222, 235, 99, 118] - }, - { - "name": "ExtendAccountEvent", - "discriminator": [97, 97, 215, 144, 93, 146, 22, 124] - }, - { - "name": "SetCreatorEvent", - "discriminator": [237, 52, 123, 37, 245, 251, 72, 210] - }, - { - "name": "SetMetaplexCreatorEvent", - "discriminator": [142, 203, 6, 32, 127, 105, 191, 162] - }, - { - "name": "SetParamsEvent", - "discriminator": [223, 195, 159, 246, 62, 48, 143, 131] - }, - { - "name": "TradeEvent", - "discriminator": [189, 219, 127, 211, 78, 230, 97, 238] - }, - { - "name": "UpdateGlobalAuthorityEvent", - "discriminator": [182, 195, 137, 42, 35, 206, 207, 247] - } - ], - "errors": [ - { - "code": 6000, - "name": "NotAuthorized", - "msg": "The given account is not authorized to execute this instruction." - }, - { - "code": 6001, - "name": "AlreadyInitialized", - "msg": "The program is already initialized." - }, - { - "code": 6002, - "name": "TooMuchSolRequired", - "msg": "slippage: Too much SOL required to buy the given amount of tokens." - }, - { - "code": 6003, - "name": "TooLittleSolReceived", - "msg": "slippage: Too little SOL received to sell the given amount of tokens." - }, - { - "code": 6004, - "name": "MintDoesNotMatchBondingCurve", - "msg": "The mint does not match the bonding curve." - }, - { - "code": 6005, - "name": "BondingCurveComplete", - "msg": "The bonding curve has completed and liquidity migrated to raydium." - }, - { - "code": 6006, - "name": "BondingCurveNotComplete", - "msg": "The bonding curve has not completed." - }, - { - "code": 6007, - "name": "NotInitialized", - "msg": "The program is not initialized." - }, - { - "code": 6008, - "name": "WithdrawTooFrequent", - "msg": "Withdraw too frequent" - }, - { - "code": 6009, - "name": "NewSizeShouldBeGreaterThanCurrentSize", - "msg": "new_size should be > current_size" - }, - { - "code": 6010, - "name": "AccountTypeNotSupported", - "msg": "Account type not supported" - }, - { - "code": 6011, - "name": "InitialRealTokenReservesShouldBeLessThanTokenTotalSupply", - "msg": "initial_real_token_reserves should be less than token_total_supply" - }, - { - "code": 6012, - "name": "InitialVirtualTokenReservesShouldBeGreaterThanInitialRealTokenReserves", - "msg": "initial_virtual_token_reserves should be greater than initial_real_token_reserves" - }, - { - "code": 6013, - "name": "FeeBasisPointsGreaterThanMaximum", - "msg": "fee_basis_points greater than maximum" - }, - { - "code": 6014, - "name": "AllZerosWithdrawAuthority", - "msg": "Withdraw authority cannot be set to System Program ID" - }, - { - "code": 6015, - "name": "PoolMigrationFeeShouldBeLessThanFinalRealSolReserves", - "msg": "pool_migration_fee should be less than final_real_sol_reserves" - }, - { - "code": 6016, - "name": "PoolMigrationFeeShouldBeGreaterThanCreatorFeePlusMaxMigrateFees", - "msg": "pool_migration_fee should be greater than creator_fee + MAX_MIGRATE_FEES" - }, - { - "code": 6017, - "name": "DisabledWithdraw", - "msg": "Migrate instruction is disabled" - }, - { - "code": 6018, - "name": "DisabledMigrate", - "msg": "Migrate instruction is disabled" - }, - { - "code": 6019, - "name": "InvalidCreator", - "msg": "Invalid creator pubkey" - }, - { - "code": 6020, - "name": "BuyZeroAmount", - "msg": "Buy zero amount" - }, - { - "code": 6021, - "name": "NotEnoughTokensToBuy", - "msg": "Not enough tokens to buy" - }, - { - "code": 6022, - "name": "SellZeroAmount", - "msg": "Sell zero amount" - }, - { - "code": 6023, - "name": "NotEnoughTokensToSell", - "msg": "Not enough tokens to sell" - }, - { - "code": 6024, - "name": "Overflow", - "msg": "Overflow" - }, - { - "code": 6025, - "name": "Truncation", - "msg": "Truncation" - }, - { - "code": 6026, - "name": "DivisionByZero", - "msg": "Division by zero" - }, - { - "code": 6027, - "name": "NotEnoughRemainingAccounts", - "msg": "Not enough remaining accounts" - }, - { - "code": 6028, - "name": "AllFeeRecipientsShouldBeNonZero", - "msg": "All fee recipients should be non-zero" - }, - { - "code": 6029, - "name": "UnsortedNotUniqueFeeRecipients", - "msg": "Unsorted or not unique fee recipients" - }, - { - "code": 6030, - "name": "CreatorShouldNotBeZero", - "msg": "Creator should not be zero" - } - ], - "types": [ - { - "name": "BondingCurve", - "type": { - "kind": "struct", - "fields": [ - { - "name": "virtual_token_reserves", - "type": "u64" - }, - { - "name": "virtual_sol_reserves", - "type": "u64" - }, - { - "name": "real_token_reserves", - "type": "u64" - }, - { - "name": "real_sol_reserves", - "type": "u64" - }, - { - "name": "token_total_supply", - "type": "u64" - }, - { - "name": "complete", - "type": "bool" - }, - { - "name": "creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "CollectCreatorFeeEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "creator_fee", - "type": "u64" - } - ] - } - }, - { - "name": "CompleteEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "user", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "bonding_curve", - "type": "pubkey" - }, - { - "name": "timestamp", - "type": "i64" - } - ] - } - }, - { - "name": "CompletePumpAmmMigrationEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "user", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "mint_amount", - "type": "u64" - }, - { - "name": "sol_amount", - "type": "u64" - }, - { - "name": "pool_migration_fee", - "type": "u64" - }, - { - "name": "bonding_curve", - "type": "pubkey" - }, - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "pool", - "type": "pubkey" - } - ] - } - }, - { - "name": "CreateEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "name", - "type": "string" - }, - { - "name": "symbol", - "type": "string" - }, - { - "name": "uri", - "type": "string" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "bonding_curve", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "virtual_token_reserves", - "type": "u64" - }, - { - "name": "virtual_sol_reserves", - "type": "u64" - }, - { - "name": "real_token_reserves", - "type": "u64" - }, - { - "name": "token_total_supply", - "type": "u64" - } - ] - } - }, - { - "name": "ExtendAccountEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "current_size", - "type": "u64" - }, - { - "name": "new_size", - "type": "u64" - }, - { - "name": "timestamp", - "type": "i64" - } - ] - } - }, - { - "name": "Global", - "type": { - "kind": "struct", - "fields": [ - { - "name": "initialized", - "docs": ["Unused"], - "type": "bool" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "fee_recipient", - "type": "pubkey" - }, - { - "name": "initial_virtual_token_reserves", - "type": "u64" - }, - { - "name": "initial_virtual_sol_reserves", - "type": "u64" - }, - { - "name": "initial_real_token_reserves", - "type": "u64" - }, - { - "name": "token_total_supply", - "type": "u64" - }, - { - "name": "fee_basis_points", - "type": "u64" - }, - { - "name": "withdraw_authority", - "type": "pubkey" - }, - { - "name": "enable_migrate", - "docs": ["Unused"], - "type": "bool" - }, - { - "name": "pool_migration_fee", - "type": "u64" - }, - { - "name": "creator_fee_basis_points", - "type": "u64" - }, - { - "name": "fee_recipients", - "type": { - "array": ["pubkey", 7] - } - }, - { - "name": "set_creator_authority", - "type": "pubkey" - } - ] - } - }, - { - "name": "SetCreatorEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "bonding_curve", - "type": "pubkey" - }, - { - "name": "creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "SetMetaplexCreatorEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "bonding_curve", - "type": "pubkey" - }, - { - "name": "metadata", - "type": "pubkey" - }, - { - "name": "creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "SetParamsEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "initial_virtual_token_reserves", - "type": "u64" - }, - { - "name": "initial_virtual_sol_reserves", - "type": "u64" - }, - { - "name": "initial_real_token_reserves", - "type": "u64" - }, - { - "name": "final_real_sol_reserves", - "type": "u64" - }, - { - "name": "token_total_supply", - "type": "u64" - }, - { - "name": "fee_basis_points", - "type": "u64" - }, - { - "name": "withdraw_authority", - "type": "pubkey" - }, - { - "name": "enable_migrate", - "type": "bool" - }, - { - "name": "pool_migration_fee", - "type": "u64" - }, - { - "name": "creator_fee_basis_points", - "type": "u64" - }, - { - "name": "fee_recipients", - "type": { - "array": ["pubkey", 8] - } - }, - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "set_creator_authority", - "type": "pubkey" - } - ] - } - }, - { - "name": "TradeEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "sol_amount", - "type": "u64" - }, - { - "name": "token_amount", - "type": "u64" - }, - { - "name": "is_buy", - "type": "bool" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "timestamp", - "type": "i64" - }, - { - "name": "virtual_sol_reserves", - "type": "u64" - }, - { - "name": "virtual_token_reserves", - "type": "u64" - }, - { - "name": "real_sol_reserves", - "type": "u64" - }, - { - "name": "real_token_reserves", - "type": "u64" - }, - { - "name": "fee_recipient", - "type": "pubkey" - }, - { - "name": "fee_basis_points", - "type": "u64" - }, - { - "name": "fee", - "type": "u64" - }, - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "creator_fee_basis_points", - "type": "u64" - }, - { - "name": "creator_fee", - "type": "u64" - } - ] - } - }, - { - "name": "UpdateGlobalAuthorityEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "global", - "type": "pubkey" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "new_authority", - "type": "pubkey" - }, - { - "name": "timestamp", - "type": "i64" - } - ] - } - } - ] -} diff --git a/crates/pumpfun-parser/proto/pumpfun.proto b/crates/pumpfun-parser/proto/pumpfun.proto deleted file mode 100644 index 7c73a067..00000000 --- a/crates/pumpfun-parser/proto/pumpfun.proto +++ /dev/null @@ -1,386 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.pumpfun; - -message BuyIx { - BuyIxAccounts accounts = 1; - BuyIxData data = 2; -} - -message CollectCreatorFeeIx { - CollectCreatorFeeIxAccounts accounts = 1; -} - -message CreateIx { - CreateIxAccounts accounts = 1; - CreateIxData data = 2; -} - -message ExtendAccountIx { - ExtendAccountIxAccounts accounts = 1; -} - -message InitializeIx { - InitializeIxAccounts accounts = 1; -} - -message MigrateIx { - MigrateIxAccounts accounts = 1; -} - -message SellIx { - SellIxAccounts accounts = 1; - SellIxData data = 2; -} - -message SetCreatorIx { - SetCreatorIxAccounts accounts = 1; - SetCreatorIxData data = 2; -} - -message SetMetaplexCreatorIx { - SetMetaplexCreatorIxAccounts accounts = 1; -} - -message SetParamsIx { - SetParamsIxAccounts accounts = 1; - SetParamsIxData data = 2; -} - -message UpdateGlobalAuthorityIx { - UpdateGlobalAuthorityIxAccounts accounts = 1; -} - - -message CollectCreatorFeeEvent { - int64 timestamp = 1; - string creator = 2; - uint64 creator_fee = 3; -} - -message CompleteEvent { - string user = 1; - string mint = 2; - string bonding_curve = 3; - int64 timestamp = 4; -} - -message CompletePumpAmmMigrationEvent { - string user = 1; - string mint = 2; - uint64 mint_amount = 3; - uint64 sol_amount = 4; - uint64 pool_migration_fee = 5; - string bonding_curve = 6; - int64 timestamp = 7; - string pool = 8; -} - -message CreateEvent { - string name = 1; - string symbol = 2; - string uri = 3; - string mint = 4; - string bonding_curve = 5; - string user = 6; - string creator = 7; - int64 timestamp = 8; - uint64 virtual_token_reserves = 9; - uint64 virtual_sol_reserves = 10; - uint64 real_token_reserves = 11; - uint64 token_total_supply = 12; -} - -message ExtendAccountEvent { - string account = 1; - string user = 2; - uint64 current_size = 3; - uint64 new_size = 4; - int64 timestamp = 5; -} - -message SetCreatorEvent { - int64 timestamp = 1; - string mint = 2; - string bonding_curve = 3; - string creator = 4; -} - -message SetMetaplexCreatorEvent { - int64 timestamp = 1; - string mint = 2; - string bonding_curve = 3; - string metadata = 4; - string creator = 5; -} - -message SetParamsEvent { - uint64 initial_virtual_token_reserves = 1; - uint64 initial_virtual_sol_reserves = 2; - uint64 initial_real_token_reserves = 3; - uint64 final_real_sol_reserves = 4; - uint64 token_total_supply = 5; - uint64 fee_basis_points = 6; - string withdraw_authority = 7; - bool enable_migrate = 8; - uint64 pool_migration_fee = 9; - uint64 creator_fee_basis_points = 10; - repeated string fee_recipients = 11; - int64 timestamp = 12; - string set_creator_authority = 13; -} - -message TradeEvent { - string mint = 1; - uint64 sol_amount = 2; - uint64 token_amount = 3; - bool is_buy = 4; - string user = 5; - int64 timestamp = 6; - uint64 virtual_sol_reserves = 7; - uint64 virtual_token_reserves = 8; - uint64 real_sol_reserves = 9; - uint64 real_token_reserves = 10; - string fee_recipient = 11; - uint64 fee_basis_points = 12; - uint64 fee = 13; - string creator = 14; - uint64 creator_fee_basis_points = 15; - uint64 creator_fee = 16; -} - -message UpdateGlobalAuthorityEvent { - string global = 1; - string authority = 2; - string new_authority = 3; - int64 timestamp = 4; -} - - -message BondingCurve { - uint64 virtual_token_reserves = 1; - uint64 virtual_sol_reserves = 2; - uint64 real_token_reserves = 3; - uint64 real_sol_reserves = 4; - uint64 token_total_supply = 5; - bool complete = 6; - string creator = 7; -} - -message Global { - bool initialized = 1; - string authority = 2; - string fee_recipient = 3; - uint64 initial_virtual_token_reserves = 4; - uint64 initial_virtual_sol_reserves = 5; - uint64 initial_real_token_reserves = 6; - uint64 token_total_supply = 7; - uint64 fee_basis_points = 8; - string withdraw_authority = 9; - bool enable_migrate = 10; - uint64 pool_migration_fee = 11; - uint64 creator_fee_basis_points = 12; - repeated string fee_recipients = 13; - string set_creator_authority = 14; -} - - -message BuyIxAccounts { - string global = 1; - string fee_recipient = 2; - string mint = 3; - string bonding_curve = 4; - string associated_bonding_curve = 5; - string associated_user = 6; - string user = 7; - string system_program = 8; - string token_program = 9; - string creator_vault = 10; - string event_authority = 11; - string program = 12; -} - -message BuyIxData { - uint64 amount = 1; - uint64 max_sol_cost = 2; -} - -message CollectCreatorFeeIxAccounts { - string creator = 1; - string creator_vault = 2; - string system_program = 3; - string event_authority = 4; - string program = 5; -} - - -message CreateIxAccounts { - string mint = 1; - string mint_authority = 2; - string bonding_curve = 3; - string associated_bonding_curve = 4; - string global = 5; - string mpl_token_metadata = 6; - string metadata = 7; - string user = 8; - string system_program = 9; - string token_program = 10; - string associated_token_program = 11; - string rent = 12; - string event_authority = 13; - string program = 14; -} - -message CreateIxData { - string name = 1; - string symbol = 2; - string uri = 3; - string creator = 4; -} - -message ExtendAccountIxAccounts { - string account = 1; - string user = 2; - string system_program = 3; - string event_authority = 4; - string program = 5; -} - - -message InitializeIxAccounts { - string global = 1; - string user = 2; - string system_program = 3; -} - - -message MigrateIxAccounts { - string global = 1; - string withdraw_authority = 2; - string mint = 3; - string bonding_curve = 4; - string associated_bonding_curve = 5; - string user = 6; - string system_program = 7; - string token_program = 8; - string pump_amm = 9; - string pool = 10; - string pool_authority = 11; - string pool_authority_mint_account = 12; - string pool_authority_wsol_account = 13; - string amm_global_config = 14; - string wsol_mint = 15; - string lp_mint = 16; - string user_pool_token_account = 17; - string pool_base_token_account = 18; - string pool_quote_token_account = 19; - string token2022_program = 20; - string associated_token_program = 21; - string pump_amm_event_authority = 22; - string event_authority = 23; - string program = 24; -} - - -message SellIxAccounts { - string global = 1; - string fee_recipient = 2; - string mint = 3; - string bonding_curve = 4; - string associated_bonding_curve = 5; - string associated_user = 6; - string user = 7; - string system_program = 8; - string creator_vault = 9; - string token_program = 10; - string event_authority = 11; - string program = 12; -} - -message SellIxData { - uint64 amount = 1; - uint64 min_sol_output = 2; -} - -message SetCreatorIxAccounts { - string set_creator_authority = 1; - string global = 2; - string mint = 3; - string metadata = 4; - string bonding_curve = 5; - string event_authority = 6; - string program = 7; -} - -message SetCreatorIxData { - string creator = 1; -} - -message SetMetaplexCreatorIxAccounts { - string mint = 1; - string metadata = 2; - string bonding_curve = 3; - string event_authority = 4; - string program = 5; -} - - -message SetParamsIxAccounts { - string global = 1; - string authority = 2; - string event_authority = 3; - string program = 4; -} - -message SetParamsIxData { - uint64 initial_virtual_token_reserves = 1; - uint64 initial_virtual_sol_reserves = 2; - uint64 initial_real_token_reserves = 3; - uint64 token_total_supply = 4; - uint64 fee_basis_points = 5; - string withdraw_authority = 6; - bool enable_migrate = 7; - uint64 pool_migration_fee = 8; - uint64 creator_fee_basis_points = 9; - string set_creator_authority = 10; -} - -message UpdateGlobalAuthorityIxAccounts { - string global = 1; - string authority = 2; - string new_authority = 3; - string event_authority = 4; - string program = 5; -} - - - -message ProgramState { - oneof state_oneof { - BondingCurve bonding_curve = 1; - Global global = 2; - } -} - -message ProgramIxs { - oneof ix_oneof { - BuyIx buy = 1; - CollectCreatorFeeIx collect_creator_fee = 2; - CreateIx create = 3; - ExtendAccountIx extend_account = 4; - InitializeIx initialize = 5; - MigrateIx migrate = 6; - SellIx sell = 7; - SetCreatorIx set_creator = 8; - SetMetaplexCreatorIx set_metaplex_creator = 9; - SetParamsIx set_params = 10; - UpdateGlobalAuthorityIx update_global_authority = 11; - } -} - diff --git a/crates/pumpfun-parser/src/custom_impl/mod.rs b/crates/pumpfun-parser/src/custom_impl/mod.rs deleted file mode 100644 index e9f09b9f..00000000 --- a/crates/pumpfun-parser/src/custom_impl/mod.rs +++ /dev/null @@ -1 +0,0 @@ -//! Placeholder for custom impls that are not overriden by the generated code. diff --git a/crates/pumpfun-parser/src/generated_parser/accounts_parser.rs b/crates/pumpfun-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index 2fec6f5b..00000000 --- a/crates/pumpfun-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,178 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{BondingCurve, Global}, - deserialize_checked, ID, -}; - -/// Pump Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum PumpProgramState { - BondingCurve(BondingCurve), - Global(Global), -} - -impl PumpProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [23, 183, 248, 55, 96, 216, 172, 96] => Ok(PumpProgramState::BondingCurve( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [167, 232, 232, 177, 200, 108, 114, 127] => Ok(PumpProgramState::Global( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = PumpProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "pump::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = PumpProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, BondingCurve, PumpProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for BondingCurve { - fn into_proto(self) -> proto_def::BondingCurve { - proto_def::BondingCurve { - virtual_token_reserves: self.virtual_token_reserves, - virtual_sol_reserves: self.virtual_sol_reserves, - real_token_reserves: self.real_token_reserves, - real_sol_reserves: self.real_sol_reserves, - token_total_supply: self.token_total_supply, - complete: self.complete, - creator: self.creator.to_string(), - } - } - } - use super::Global; - impl IntoProto for Global { - fn into_proto(self) -> proto_def::Global { - proto_def::Global { - initialized: self.initialized, - authority: self.authority.to_string(), - fee_recipient: self.fee_recipient.to_string(), - initial_virtual_token_reserves: self.initial_virtual_token_reserves, - initial_virtual_sol_reserves: self.initial_virtual_sol_reserves, - initial_real_token_reserves: self.initial_real_token_reserves, - token_total_supply: self.token_total_supply, - fee_basis_points: self.fee_basis_points, - withdraw_authority: self.withdraw_authority.to_string(), - enable_migrate: self.enable_migrate, - pool_migration_fee: self.pool_migration_fee, - creator_fee_basis_points: self.creator_fee_basis_points, - fee_recipients: self - .fee_recipients - .into_iter() - .map(|x| x.to_string()) - .collect(), - set_creator_authority: self.set_creator_authority.to_string(), - } - } - } - - impl IntoProto for PumpProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - PumpProgramState::BondingCurve(data) => { - proto_def::program_state::StateOneof::BondingCurve(data.into_proto()) - }, - PumpProgramState::Global(data) => { - proto_def::program_state::StateOneof::Global(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/pumpfun-parser/src/generated_parser/instructions_parser.rs b/crates/pumpfun-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index cb42b4b8..00000000 --- a/crates/pumpfun-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,714 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - Buy as BuyIxAccounts, BuyInstructionArgs as BuyIxData, - CollectCreatorFee as CollectCreatorFeeIxAccounts, Create as CreateIxAccounts, - CreateInstructionArgs as CreateIxData, ExtendAccount as ExtendAccountIxAccounts, - Initialize as InitializeIxAccounts, Migrate as MigrateIxAccounts, Sell as SellIxAccounts, - SellInstructionArgs as SellIxData, SetCreator as SetCreatorIxAccounts, - SetCreatorInstructionArgs as SetCreatorIxData, - SetMetaplexCreator as SetMetaplexCreatorIxAccounts, SetParams as SetParamsIxAccounts, - SetParamsInstructionArgs as SetParamsIxData, - UpdateGlobalAuthority as UpdateGlobalAuthorityIxAccounts, - }, - ID, -}; - -/// Pump Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -#[allow(clippy::large_enum_variant)] -pub enum PumpProgramIx { - Buy(BuyIxAccounts, BuyIxData), - CollectCreatorFee(CollectCreatorFeeIxAccounts), - Create(CreateIxAccounts, CreateIxData), - ExtendAccount(ExtendAccountIxAccounts), - Initialize(InitializeIxAccounts), - Migrate(MigrateIxAccounts), - Sell(SellIxAccounts, SellIxData), - SetCreator(SetCreatorIxAccounts, SetCreatorIxData), - SetMetaplexCreator(SetMetaplexCreatorIxAccounts), - SetParams(SetParamsIxAccounts, SetParamsIxData), - UpdateGlobalAuthority(UpdateGlobalAuthorityIxAccounts), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = PumpProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "Pump::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [102, 6, 61, 18, 1, 218, 235, 234] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = BuyIxAccounts { - global: next_account(accounts)?, - fee_recipient: next_account(accounts)?, - mint: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - associated_bonding_curve: next_account(accounts)?, - associated_user: next_account(accounts)?, - user: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - creator_vault: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: BuyIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpProgramIx::Buy(ix_accounts, de_ix_data)) - }, - [20, 22, 86, 123, 198, 28, 219, 132] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectCreatorFeeIxAccounts { - creator: next_account(accounts)?, - creator_vault: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(PumpProgramIx::CollectCreatorFee(ix_accounts)) - }, - [24, 30, 200, 40, 5, 28, 7, 119] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateIxAccounts { - mint: next_account(accounts)?, - mint_authority: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - associated_bonding_curve: next_account(accounts)?, - global: next_account(accounts)?, - mpl_token_metadata: next_account(accounts)?, - metadata: next_account(accounts)?, - user: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - rent: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: CreateIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpProgramIx::Create(ix_accounts, de_ix_data)) - }, - [234, 102, 194, 203, 150, 72, 62, 229] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ExtendAccountIxAccounts { - account: next_account(accounts)?, - user: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(PumpProgramIx::ExtendAccount(ix_accounts)) - }, - [175, 175, 109, 31, 13, 152, 155, 237] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeIxAccounts { - global: next_account(accounts)?, - user: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(PumpProgramIx::Initialize(ix_accounts)) - }, - [155, 234, 231, 146, 236, 158, 162, 30] => { - let expected_accounts_len = 24; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrateIxAccounts { - global: next_account(accounts)?, - withdraw_authority: next_account(accounts)?, - mint: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - associated_bonding_curve: next_account(accounts)?, - user: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - pump_amm: next_account(accounts)?, - pool: next_account(accounts)?, - pool_authority: next_account(accounts)?, - pool_authority_mint_account: next_account(accounts)?, - pool_authority_wsol_account: next_account(accounts)?, - amm_global_config: next_account(accounts)?, - wsol_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - user_pool_token_account: next_account(accounts)?, - pool_base_token_account: next_account(accounts)?, - pool_quote_token_account: next_account(accounts)?, - token2022_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - pump_amm_event_authority: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(PumpProgramIx::Migrate(ix_accounts)) - }, - [51, 230, 133, 164, 1, 127, 131, 173] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SellIxAccounts { - global: next_account(accounts)?, - fee_recipient: next_account(accounts)?, - mint: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - associated_bonding_curve: next_account(accounts)?, - associated_user: next_account(accounts)?, - user: next_account(accounts)?, - system_program: next_account(accounts)?, - creator_vault: next_account(accounts)?, - token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SellIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpProgramIx::Sell(ix_accounts, de_ix_data)) - }, - [254, 148, 255, 112, 207, 142, 170, 165] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetCreatorIxAccounts { - set_creator_authority: next_account(accounts)?, - global: next_account(accounts)?, - mint: next_account(accounts)?, - metadata: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SetCreatorIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpProgramIx::SetCreator(ix_accounts, de_ix_data)) - }, - [138, 96, 174, 217, 48, 85, 197, 246] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetMetaplexCreatorIxAccounts { - mint: next_account(accounts)?, - metadata: next_account(accounts)?, - bonding_curve: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(PumpProgramIx::SetMetaplexCreator(ix_accounts)) - }, - [27, 234, 178, 52, 147, 2, 187, 141] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetParamsIxAccounts { - global: next_account(accounts)?, - authority: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SetParamsIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(PumpProgramIx::SetParams(ix_accounts, de_ix_data)) - }, - [227, 181, 74, 196, 208, 21, 97, 213] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateGlobalAuthorityIxAccounts { - global: next_account(accounts)?, - authority: next_account(accounts)?, - new_authority: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - Ok(PumpProgramIx::UpdateGlobalAuthority(ix_accounts)) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{BuyIxAccounts, InstructionParser, PumpProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for BuyIxAccounts { - fn into_proto(self) -> proto_def::BuyIxAccounts { - proto_def::BuyIxAccounts { - global: self.global.to_string(), - fee_recipient: self.fee_recipient.to_string(), - mint: self.mint.to_string(), - bonding_curve: self.bonding_curve.to_string(), - associated_bonding_curve: self.associated_bonding_curve.to_string(), - associated_user: self.associated_user.to_string(), - user: self.user.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - creator_vault: self.creator_vault.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::BuyIxData; - impl IntoProto for BuyIxData { - fn into_proto(self) -> proto_def::BuyIxData { - proto_def::BuyIxData { - amount: self.amount, - max_sol_cost: self.max_sol_cost, - } - } - } - use super::CollectCreatorFeeIxAccounts; - impl IntoProto for CollectCreatorFeeIxAccounts { - fn into_proto(self) -> proto_def::CollectCreatorFeeIxAccounts { - proto_def::CollectCreatorFeeIxAccounts { - creator: self.creator.to_string(), - creator_vault: self.creator_vault.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateIxAccounts; - impl IntoProto for CreateIxAccounts { - fn into_proto(self) -> proto_def::CreateIxAccounts { - proto_def::CreateIxAccounts { - mint: self.mint.to_string(), - mint_authority: self.mint_authority.to_string(), - bonding_curve: self.bonding_curve.to_string(), - associated_bonding_curve: self.associated_bonding_curve.to_string(), - global: self.global.to_string(), - mpl_token_metadata: self.mpl_token_metadata.to_string(), - metadata: self.metadata.to_string(), - user: self.user.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - rent: self.rent.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::CreateIxData; - impl IntoProto for CreateIxData { - fn into_proto(self) -> proto_def::CreateIxData { - proto_def::CreateIxData { - name: self.name, - symbol: self.symbol, - uri: self.uri, - creator: self.creator.to_string(), - } - } - } - use super::ExtendAccountIxAccounts; - impl IntoProto for ExtendAccountIxAccounts { - fn into_proto(self) -> proto_def::ExtendAccountIxAccounts { - proto_def::ExtendAccountIxAccounts { - account: self.account.to_string(), - user: self.user.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeIxAccounts; - impl IntoProto for InitializeIxAccounts { - fn into_proto(self) -> proto_def::InitializeIxAccounts { - proto_def::InitializeIxAccounts { - global: self.global.to_string(), - user: self.user.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::MigrateIxAccounts; - impl IntoProto for MigrateIxAccounts { - fn into_proto(self) -> proto_def::MigrateIxAccounts { - proto_def::MigrateIxAccounts { - global: self.global.to_string(), - withdraw_authority: self.withdraw_authority.to_string(), - mint: self.mint.to_string(), - bonding_curve: self.bonding_curve.to_string(), - associated_bonding_curve: self.associated_bonding_curve.to_string(), - user: self.user.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - pump_amm: self.pump_amm.to_string(), - pool: self.pool.to_string(), - pool_authority: self.pool_authority.to_string(), - pool_authority_mint_account: self.pool_authority_mint_account.to_string(), - pool_authority_wsol_account: self.pool_authority_wsol_account.to_string(), - amm_global_config: self.amm_global_config.to_string(), - wsol_mint: self.wsol_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - user_pool_token_account: self.user_pool_token_account.to_string(), - pool_base_token_account: self.pool_base_token_account.to_string(), - pool_quote_token_account: self.pool_quote_token_account.to_string(), - token2022_program: self.token2022_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - pump_amm_event_authority: self.pump_amm_event_authority.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SellIxAccounts; - impl IntoProto for SellIxAccounts { - fn into_proto(self) -> proto_def::SellIxAccounts { - proto_def::SellIxAccounts { - global: self.global.to_string(), - fee_recipient: self.fee_recipient.to_string(), - mint: self.mint.to_string(), - bonding_curve: self.bonding_curve.to_string(), - associated_bonding_curve: self.associated_bonding_curve.to_string(), - associated_user: self.associated_user.to_string(), - user: self.user.to_string(), - system_program: self.system_program.to_string(), - creator_vault: self.creator_vault.to_string(), - token_program: self.token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SellIxData; - impl IntoProto for SellIxData { - fn into_proto(self) -> proto_def::SellIxData { - proto_def::SellIxData { - amount: self.amount, - min_sol_output: self.min_sol_output, - } - } - } - use super::SetCreatorIxAccounts; - impl IntoProto for SetCreatorIxAccounts { - fn into_proto(self) -> proto_def::SetCreatorIxAccounts { - proto_def::SetCreatorIxAccounts { - set_creator_authority: self.set_creator_authority.to_string(), - global: self.global.to_string(), - mint: self.mint.to_string(), - metadata: self.metadata.to_string(), - bonding_curve: self.bonding_curve.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SetCreatorIxData; - impl IntoProto for SetCreatorIxData { - fn into_proto(self) -> proto_def::SetCreatorIxData { - proto_def::SetCreatorIxData { - creator: self.creator.to_string(), - } - } - } - use super::SetMetaplexCreatorIxAccounts; - impl IntoProto for SetMetaplexCreatorIxAccounts { - fn into_proto(self) -> proto_def::SetMetaplexCreatorIxAccounts { - proto_def::SetMetaplexCreatorIxAccounts { - mint: self.mint.to_string(), - metadata: self.metadata.to_string(), - bonding_curve: self.bonding_curve.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SetParamsIxAccounts; - impl IntoProto for SetParamsIxAccounts { - fn into_proto(self) -> proto_def::SetParamsIxAccounts { - proto_def::SetParamsIxAccounts { - global: self.global.to_string(), - authority: self.authority.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SetParamsIxData; - impl IntoProto for SetParamsIxData { - fn into_proto(self) -> proto_def::SetParamsIxData { - proto_def::SetParamsIxData { - initial_virtual_token_reserves: self.initial_virtual_token_reserves, - initial_virtual_sol_reserves: self.initial_virtual_sol_reserves, - initial_real_token_reserves: self.initial_real_token_reserves, - token_total_supply: self.token_total_supply, - fee_basis_points: self.fee_basis_points, - withdraw_authority: self.withdraw_authority.to_string(), - enable_migrate: self.enable_migrate, - pool_migration_fee: self.pool_migration_fee, - creator_fee_basis_points: self.creator_fee_basis_points, - set_creator_authority: self.set_creator_authority.to_string(), - } - } - } - use super::UpdateGlobalAuthorityIxAccounts; - impl IntoProto for UpdateGlobalAuthorityIxAccounts { - fn into_proto(self) -> proto_def::UpdateGlobalAuthorityIxAccounts { - proto_def::UpdateGlobalAuthorityIxAccounts { - global: self.global.to_string(), - authority: self.authority.to_string(), - new_authority: self.new_authority.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - - impl IntoProto for PumpProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - PumpProgramIx::Buy(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Buy(proto_def::BuyIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - PumpProgramIx::CollectCreatorFee(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectCreatorFee( - proto_def::CollectCreatorFeeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - PumpProgramIx::Create(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Create( - proto_def::CreateIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - PumpProgramIx::ExtendAccount(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ExtendAccount( - proto_def::ExtendAccountIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - PumpProgramIx::Initialize(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Initialize( - proto_def::InitializeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - PumpProgramIx::Migrate(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Migrate( - proto_def::MigrateIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - PumpProgramIx::Sell(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Sell(proto_def::SellIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - PumpProgramIx::SetCreator(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetCreator( - proto_def::SetCreatorIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - PumpProgramIx::SetMetaplexCreator(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetMetaplexCreator( - proto_def::SetMetaplexCreatorIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - PumpProgramIx::SetParams(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetParams( - proto_def::SetParamsIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - PumpProgramIx::UpdateGlobalAuthority(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateGlobalAuthority( - proto_def::UpdateGlobalAuthorityIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/pumpfun-parser/src/generated_parser/mod.rs b/crates/pumpfun-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/pumpfun-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/pumpfun-parser/src/generated_parser/proto_helpers.rs b/crates/pumpfun-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index 9f56779d..00000000 --- a/crates/pumpfun-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,160 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::CollectCreatorFeeEvent}; - impl IntoProto for CollectCreatorFeeEvent { - fn into_proto(self) -> proto_def::CollectCreatorFeeEvent { - proto_def::CollectCreatorFeeEvent { - timestamp: self.timestamp, - creator: self.creator.to_string(), - creator_fee: self.creator_fee, - } - } - } - use crate::types::CompleteEvent; - impl IntoProto for CompleteEvent { - fn into_proto(self) -> proto_def::CompleteEvent { - proto_def::CompleteEvent { - user: self.user.to_string(), - mint: self.mint.to_string(), - bonding_curve: self.bonding_curve.to_string(), - timestamp: self.timestamp, - } - } - } - use crate::types::CompletePumpAmmMigrationEvent; - impl IntoProto for CompletePumpAmmMigrationEvent { - fn into_proto(self) -> proto_def::CompletePumpAmmMigrationEvent { - proto_def::CompletePumpAmmMigrationEvent { - user: self.user.to_string(), - mint: self.mint.to_string(), - mint_amount: self.mint_amount, - sol_amount: self.sol_amount, - pool_migration_fee: self.pool_migration_fee, - bonding_curve: self.bonding_curve.to_string(), - timestamp: self.timestamp, - pool: self.pool.to_string(), - } - } - } - use crate::types::CreateEvent; - impl IntoProto for CreateEvent { - fn into_proto(self) -> proto_def::CreateEvent { - proto_def::CreateEvent { - name: self.name, - symbol: self.symbol, - uri: self.uri, - mint: self.mint.to_string(), - bonding_curve: self.bonding_curve.to_string(), - user: self.user.to_string(), - creator: self.creator.to_string(), - timestamp: self.timestamp, - virtual_token_reserves: self.virtual_token_reserves, - virtual_sol_reserves: self.virtual_sol_reserves, - real_token_reserves: self.real_token_reserves, - token_total_supply: self.token_total_supply, - } - } - } - use crate::types::ExtendAccountEvent; - impl IntoProto for ExtendAccountEvent { - fn into_proto(self) -> proto_def::ExtendAccountEvent { - proto_def::ExtendAccountEvent { - account: self.account.to_string(), - user: self.user.to_string(), - current_size: self.current_size, - new_size: self.new_size, - timestamp: self.timestamp, - } - } - } - use crate::types::SetCreatorEvent; - impl IntoProto for SetCreatorEvent { - fn into_proto(self) -> proto_def::SetCreatorEvent { - proto_def::SetCreatorEvent { - timestamp: self.timestamp, - mint: self.mint.to_string(), - bonding_curve: self.bonding_curve.to_string(), - creator: self.creator.to_string(), - } - } - } - use crate::types::SetMetaplexCreatorEvent; - impl IntoProto for SetMetaplexCreatorEvent { - fn into_proto(self) -> proto_def::SetMetaplexCreatorEvent { - proto_def::SetMetaplexCreatorEvent { - timestamp: self.timestamp, - mint: self.mint.to_string(), - bonding_curve: self.bonding_curve.to_string(), - metadata: self.metadata.to_string(), - creator: self.creator.to_string(), - } - } - } - use crate::types::SetParamsEvent; - impl IntoProto for SetParamsEvent { - fn into_proto(self) -> proto_def::SetParamsEvent { - proto_def::SetParamsEvent { - initial_virtual_token_reserves: self.initial_virtual_token_reserves, - initial_virtual_sol_reserves: self.initial_virtual_sol_reserves, - initial_real_token_reserves: self.initial_real_token_reserves, - final_real_sol_reserves: self.final_real_sol_reserves, - token_total_supply: self.token_total_supply, - fee_basis_points: self.fee_basis_points, - withdraw_authority: self.withdraw_authority.to_string(), - enable_migrate: self.enable_migrate, - pool_migration_fee: self.pool_migration_fee, - creator_fee_basis_points: self.creator_fee_basis_points, - fee_recipients: self - .fee_recipients - .into_iter() - .map(|x| x.to_string()) - .collect(), - timestamp: self.timestamp, - set_creator_authority: self.set_creator_authority.to_string(), - } - } - } - use crate::types::TradeEvent; - impl IntoProto for TradeEvent { - fn into_proto(self) -> proto_def::TradeEvent { - proto_def::TradeEvent { - mint: self.mint.to_string(), - sol_amount: self.sol_amount, - token_amount: self.token_amount, - is_buy: self.is_buy, - user: self.user.to_string(), - timestamp: self.timestamp, - virtual_sol_reserves: self.virtual_sol_reserves, - virtual_token_reserves: self.virtual_token_reserves, - real_sol_reserves: self.real_sol_reserves, - real_token_reserves: self.real_token_reserves, - fee_recipient: self.fee_recipient.to_string(), - fee_basis_points: self.fee_basis_points, - fee: self.fee, - creator: self.creator.to_string(), - creator_fee_basis_points: self.creator_fee_basis_points, - creator_fee: self.creator_fee, - } - } - } - use crate::types::UpdateGlobalAuthorityEvent; - impl IntoProto for UpdateGlobalAuthorityEvent { - fn into_proto(self) -> proto_def::UpdateGlobalAuthorityEvent { - proto_def::UpdateGlobalAuthorityEvent { - global: self.global.to_string(), - authority: self.authority.to_string(), - new_authority: self.new_authority.to_string(), - timestamp: self.timestamp, - } - } - } -} diff --git a/crates/pumpfun-parser/src/generated_sdk/accounts/bonding_curve.rs b/crates/pumpfun-parser/src/generated_sdk/accounts/bonding_curve.rs deleted file mode 100644 index d939259d..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/accounts/bonding_curve.rs +++ /dev/null @@ -1,138 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BondingCurve { - pub discriminator: [u8; 8], - pub virtual_token_reserves: u64, - pub virtual_sol_reserves: u64, - pub real_token_reserves: u64, - pub real_sol_reserves: u64, - pub token_total_supply: u64, - pub complete: bool, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, -} - -impl BondingCurve { - pub const LEN: usize = 81; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for BondingCurve { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_bonding_curve(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = BondingCurve::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_bonding_curve(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_bonding_curve( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = BondingCurve::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for BondingCurve { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for BondingCurve {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for BondingCurve { - fn owner() -> Pubkey { crate::PUMP_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for BondingCurve {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for BondingCurve { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/pumpfun-parser/src/generated_sdk/accounts/global.rs b/crates/pumpfun-parser/src/generated_sdk/accounts/global.rs deleted file mode 100644 index fe361ab1..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/accounts/global.rs +++ /dev/null @@ -1,159 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Global { - pub discriminator: [u8; 8], - /// Unused - pub initialized: bool, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_recipient: Pubkey, - pub initial_virtual_token_reserves: u64, - pub initial_virtual_sol_reserves: u64, - pub initial_real_token_reserves: u64, - pub token_total_supply: u64, - pub fee_basis_points: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub withdraw_authority: Pubkey, - /// Unused - pub enable_migrate: bool, - pub pool_migration_fee: u64, - pub creator_fee_basis_points: u64, - pub fee_recipients: [Pubkey; 7], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub set_creator_authority: Pubkey, -} - -impl Global { - pub const LEN: usize = 418; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Global { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_global( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_global(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_global( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Global::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_global( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_global(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_global( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Global::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Global { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Global {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Global { - fn owner() -> Pubkey { crate::PUMP_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Global {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Global { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/pumpfun-parser/src/generated_sdk/accounts/mod.rs b/crates/pumpfun-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index 44a9d746..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#bonding_curve; -pub(crate) mod r#global; - -pub use self::{r#bonding_curve::*, r#global::*}; diff --git a/crates/pumpfun-parser/src/generated_sdk/errors/mod.rs b/crates/pumpfun-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index f4fd10fa..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod pump; - -pub use self::pump::PumpError; diff --git a/crates/pumpfun-parser/src/generated_sdk/errors/pump.rs b/crates/pumpfun-parser/src/generated_sdk/errors/pump.rs deleted file mode 100644 index 66dd6b46..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/errors/pump.rs +++ /dev/null @@ -1,118 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum PumpError { - /// 6000 - The given account is not authorized to execute this instruction. - #[error("The given account is not authorized to execute this instruction.")] - NotAuthorized = 0x1770, - /// 6001 - The program is already initialized. - #[error("The program is already initialized.")] - AlreadyInitialized = 0x1771, - /// 6002 - slippage: Too much SOL required to buy the given amount of tokens. - #[error("slippage: Too much SOL required to buy the given amount of tokens.")] - TooMuchSolRequired = 0x1772, - /// 6003 - slippage: Too little SOL received to sell the given amount of tokens. - #[error("slippage: Too little SOL received to sell the given amount of tokens.")] - TooLittleSolReceived = 0x1773, - /// 6004 - The mint does not match the bonding curve. - #[error("The mint does not match the bonding curve.")] - MintDoesNotMatchBondingCurve = 0x1774, - /// 6005 - The bonding curve has completed and liquidity migrated to raydium. - #[error("The bonding curve has completed and liquidity migrated to raydium.")] - BondingCurveComplete = 0x1775, - /// 6006 - The bonding curve has not completed. - #[error("The bonding curve has not completed.")] - BondingCurveNotComplete = 0x1776, - /// 6007 - The program is not initialized. - #[error("The program is not initialized.")] - NotInitialized = 0x1777, - /// 6008 - Withdraw too frequent - #[error("Withdraw too frequent")] - WithdrawTooFrequent = 0x1778, - /// 6009 - new_size should be > current_size - #[error("new_size should be > current_size")] - NewSizeShouldBeGreaterThanCurrentSize = 0x1779, - /// 6010 - Account type not supported - #[error("Account type not supported")] - AccountTypeNotSupported = 0x177a, - /// 6011 - initial_real_token_reserves should be less than token_total_supply - #[error("initial_real_token_reserves should be less than token_total_supply")] - InitialRealTokenReservesShouldBeLessThanTokenTotalSupply = 0x177b, - /// 6012 - initial_virtual_token_reserves should be greater than initial_real_token_reserves - #[error("initial_virtual_token_reserves should be greater than initial_real_token_reserves")] - InitialVirtualTokenReservesShouldBeGreaterThanInitialRealTokenReserves = 0x177c, - /// 6013 - fee_basis_points greater than maximum - #[error("fee_basis_points greater than maximum")] - FeeBasisPointsGreaterThanMaximum = 0x177d, - /// 6014 - Withdraw authority cannot be set to System Program ID - #[error("Withdraw authority cannot be set to System Program ID")] - AllZerosWithdrawAuthority = 0x177e, - /// 6015 - pool_migration_fee should be less than final_real_sol_reserves - #[error("pool_migration_fee should be less than final_real_sol_reserves")] - PoolMigrationFeeShouldBeLessThanFinalRealSolReserves = 0x177f, - /// 6016 - pool_migration_fee should be greater than creator_fee + MAX_MIGRATE_FEES - #[error("pool_migration_fee should be greater than creator_fee + MAX_MIGRATE_FEES")] - PoolMigrationFeeShouldBeGreaterThanCreatorFeePlusMaxMigrateFees = 0x1780, - /// 6017 - Migrate instruction is disabled - #[error("Migrate instruction is disabled")] - DisabledWithdraw = 0x1781, - /// 6018 - Migrate instruction is disabled - #[error("Migrate instruction is disabled")] - DisabledMigrate = 0x1782, - /// 6019 - Invalid creator pubkey - #[error("Invalid creator pubkey")] - InvalidCreator = 0x1783, - /// 6020 - Buy zero amount - #[error("Buy zero amount")] - BuyZeroAmount = 0x1784, - /// 6021 - Not enough tokens to buy - #[error("Not enough tokens to buy")] - NotEnoughTokensToBuy = 0x1785, - /// 6022 - Sell zero amount - #[error("Sell zero amount")] - SellZeroAmount = 0x1786, - /// 6023 - Not enough tokens to sell - #[error("Not enough tokens to sell")] - NotEnoughTokensToSell = 0x1787, - /// 6024 - Overflow - #[error("Overflow")] - Overflow = 0x1788, - /// 6025 - Truncation - #[error("Truncation")] - Truncation = 0x1789, - /// 6026 - Division by zero - #[error("Division by zero")] - DivisionByZero = 0x178a, - /// 6027 - Not enough remaining accounts - #[error("Not enough remaining accounts")] - NotEnoughRemainingAccounts = 0x178b, - /// 6028 - All fee recipients should be non-zero - #[error("All fee recipients should be non-zero")] - AllFeeRecipientsShouldBeNonZero = 0x178c, - /// 6029 - Unsorted or not unique fee recipients - #[error("Unsorted or not unique fee recipients")] - UnsortedNotUniqueFeeRecipients = 0x178d, - /// 6030 - Creator should not be zero - #[error("Creator should not be zero")] - CreatorShouldNotBeZero = 0x178e, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for PumpError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for PumpError { - fn type_of() -> &'static str { "PumpError" } -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/buy.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/buy.rs deleted file mode 100644 index ec164aba..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/buy.rs +++ /dev/null @@ -1,784 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Buy { - pub global: solana_pubkey::Pubkey, - - pub fee_recipient: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub associated_bonding_curve: solana_pubkey::Pubkey, - - pub associated_user: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub creator_vault: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Buy { - pub fn instruction(&self, args: BuyInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: BuyInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_recipient, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.associated_bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.associated_user, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.user, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&BuyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyInstructionData { - discriminator: [u8; 8], -} - -impl BuyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [102, 6, 61, 18, 1, 218, 235, 234], - } - } -} - -impl Default for BuyInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyInstructionArgs { - pub amount: u64, - pub max_sol_cost: u64, -} - -/// Instruction builder for `Buy`. -/// -/// ### Accounts: -/// -/// 0. `[]` global -/// 1. `[writable]` fee_recipient -/// 2. `[]` mint -/// 3. `[writable]` bonding_curve -/// 4. `[writable]` associated_bonding_curve -/// 5. `[writable]` associated_user -/// 6. `[writable, signer]` user -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[writable]` creator_vault -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug, Default)] -pub struct BuyBuilder { - global: Option, - fee_recipient: Option, - mint: Option, - bonding_curve: Option, - associated_bonding_curve: Option, - associated_user: Option, - user: Option, - system_program: Option, - token_program: Option, - creator_vault: Option, - event_authority: Option, - program: Option, - amount: Option, - max_sol_cost: Option, - __remaining_accounts: Vec, -} - -impl BuyBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn global(&mut self, global: solana_pubkey::Pubkey) -> &mut Self { - self.global = Some(global); - self - } - - #[inline(always)] - pub fn fee_recipient(&mut self, fee_recipient: solana_pubkey::Pubkey) -> &mut Self { - self.fee_recipient = Some(fee_recipient); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn associated_bonding_curve( - &mut self, - associated_bonding_curve: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_bonding_curve = Some(associated_bonding_curve); - self - } - - #[inline(always)] - pub fn associated_user(&mut self, associated_user: solana_pubkey::Pubkey) -> &mut Self { - self.associated_user = Some(associated_user); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn creator_vault(&mut self, creator_vault: solana_pubkey::Pubkey) -> &mut Self { - self.creator_vault = Some(creator_vault); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn max_sol_cost(&mut self, max_sol_cost: u64) -> &mut Self { - self.max_sol_cost = Some(max_sol_cost); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Buy { - global: self.global.expect("global is not set"), - fee_recipient: self.fee_recipient.expect("fee_recipient is not set"), - mint: self.mint.expect("mint is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - associated_bonding_curve: self - .associated_bonding_curve - .expect("associated_bonding_curve is not set"), - associated_user: self.associated_user.expect("associated_user is not set"), - user: self.user.expect("user is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - creator_vault: self.creator_vault.expect("creator_vault is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = BuyInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - max_sol_cost: self.max_sol_cost.clone().expect("max_sol_cost is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `buy` CPI accounts. -pub struct BuyCpiAccounts<'a, 'b> { - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_user: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub creator_vault: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `buy` CPI instruction. -pub struct BuyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_user: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub creator_vault: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: BuyInstructionArgs, -} - -impl<'a, 'b> BuyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: BuyCpiAccounts<'a, 'b>, - args: BuyInstructionArgs, - ) -> Self { - Self { - __program: program, - global: accounts.global, - fee_recipient: accounts.fee_recipient, - mint: accounts.mint, - bonding_curve: accounts.bonding_curve, - associated_bonding_curve: accounts.associated_bonding_curve, - associated_user: accounts.associated_user, - user: accounts.user, - system_program: accounts.system_program, - token_program: accounts.token_program, - creator_vault: accounts.creator_vault, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_recipient.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.associated_bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.associated_user.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.user.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&BuyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.global.clone()); - account_infos.push(self.fee_recipient.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.associated_bonding_curve.clone()); - account_infos.push(self.associated_user.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.creator_vault.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Buy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` global -/// 1. `[writable]` fee_recipient -/// 2. `[]` mint -/// 3. `[writable]` bonding_curve -/// 4. `[writable]` associated_bonding_curve -/// 5. `[writable]` associated_user -/// 6. `[writable, signer]` user -/// 7. `[]` system_program -/// 8. `[]` token_program -/// 9. `[writable]` creator_vault -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug)] -pub struct BuyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> BuyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(BuyCpiBuilderInstruction { - __program: program, - global: None, - fee_recipient: None, - mint: None, - bonding_curve: None, - associated_bonding_curve: None, - associated_user: None, - user: None, - system_program: None, - token_program: None, - creator_vault: None, - event_authority: None, - program: None, - amount: None, - max_sol_cost: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn global(&mut self, global: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.global = Some(global); - self - } - - #[inline(always)] - pub fn fee_recipient( - &mut self, - fee_recipient: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_recipient = Some(fee_recipient); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn associated_bonding_curve( - &mut self, - associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_bonding_curve = Some(associated_bonding_curve); - self - } - - #[inline(always)] - pub fn associated_user( - &mut self, - associated_user: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_user = Some(associated_user); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn creator_vault( - &mut self, - creator_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_vault = Some(creator_vault); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn max_sol_cost(&mut self, max_sol_cost: u64) -> &mut Self { - self.instruction.max_sol_cost = Some(max_sol_cost); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = BuyInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - max_sol_cost: self - .instruction - .max_sol_cost - .clone() - .expect("max_sol_cost is not set"), - }; - let instruction = BuyCpi { - __program: self.instruction.__program, - - global: self.instruction.global.expect("global is not set"), - - fee_recipient: self - .instruction - .fee_recipient - .expect("fee_recipient is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - associated_bonding_curve: self - .instruction - .associated_bonding_curve - .expect("associated_bonding_curve is not set"), - - associated_user: self - .instruction - .associated_user - .expect("associated_user is not set"), - - user: self.instruction.user.expect("user is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - creator_vault: self - .instruction - .creator_vault - .expect("creator_vault is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct BuyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - global: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_recipient: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_user: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - max_sol_cost: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/collect_creator_fee.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/collect_creator_fee.rs deleted file mode 100644 index 544e115a..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/collect_creator_fee.rs +++ /dev/null @@ -1,439 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CollectCreatorFee { - pub creator: solana_pubkey::Pubkey, - - pub creator_vault: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl CollectCreatorFee { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.creator, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CollectCreatorFeeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectCreatorFeeInstructionData { - discriminator: [u8; 8], -} - -impl CollectCreatorFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [20, 22, 86, 123, 198, 28, 219, 132], - } - } -} - -impl Default for CollectCreatorFeeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CollectCreatorFee`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[writable]` creator_vault -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CollectCreatorFeeBuilder { - creator: Option, - creator_vault: Option, - system_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl CollectCreatorFeeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn creator_vault(&mut self, creator_vault: solana_pubkey::Pubkey) -> &mut Self { - self.creator_vault = Some(creator_vault); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectCreatorFee { - creator: self.creator.expect("creator is not set"), - creator_vault: self.creator_vault.expect("creator_vault is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `collect_creator_fee` CPI accounts. -pub struct CollectCreatorFeeCpiAccounts<'a, 'b> { - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub creator_vault: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_creator_fee` CPI instruction. -pub struct CollectCreatorFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub creator_vault: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CollectCreatorFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectCreatorFeeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - creator: accounts.creator, - creator_vault: accounts.creator_vault, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CollectCreatorFeeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.creator_vault.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectCreatorFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[writable]` creator_vault -/// 2. `[]` system_program -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct CollectCreatorFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectCreatorFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectCreatorFeeCpiBuilderInstruction { - __program: program, - creator: None, - creator_vault: None, - system_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn creator_vault( - &mut self, - creator_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_vault = Some(creator_vault); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CollectCreatorFeeCpi { - __program: self.instruction.__program, - - creator: self.instruction.creator.expect("creator is not set"), - - creator_vault: self - .instruction - .creator_vault - .expect("creator_vault is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectCreatorFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/create.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/create.rs deleted file mode 100644 index 67508303..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/create.rs +++ /dev/null @@ -1,896 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct Create { - pub mint: solana_pubkey::Pubkey, - - pub mint_authority: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub associated_bonding_curve: solana_pubkey::Pubkey, - - pub global: solana_pubkey::Pubkey, - - pub mpl_token_metadata: solana_pubkey::Pubkey, - - pub metadata: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Create { - pub fn instruction(&self, args: CreateInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.mint, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.associated_bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mpl_token_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.metadata, false)); - accounts.push(solana_instruction::AccountMeta::new(self.user, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateInstructionData { - discriminator: [u8; 8], -} - -impl CreateInstructionData { - pub fn new() -> Self { - Self { - discriminator: [24, 30, 200, 40, 5, 28, 7, 119], - } - } -} - -impl Default for CreateInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateInstructionArgs { - pub name: String, - pub symbol: String, - pub uri: String, - pub creator: Pubkey, -} - -/// Instruction builder for `Create`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` mint -/// 1. `[]` mint_authority -/// 2. `[writable]` bonding_curve -/// 3. `[writable]` associated_bonding_curve -/// 4. `[]` global -/// 5. `[optional]` mpl_token_metadata (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -/// 6. `[writable]` metadata -/// 7. `[writable, signer]` user -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 10. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 11. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug, Default)] -pub struct CreateBuilder { - mint: Option, - mint_authority: Option, - bonding_curve: Option, - associated_bonding_curve: Option, - global: Option, - mpl_token_metadata: Option, - metadata: Option, - user: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - rent: Option, - event_authority: Option, - program: Option, - name: Option, - symbol: Option, - uri: Option, - creator: Option, - __remaining_accounts: Vec, -} - -impl CreateBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn mint_authority(&mut self, mint_authority: solana_pubkey::Pubkey) -> &mut Self { - self.mint_authority = Some(mint_authority); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn associated_bonding_curve( - &mut self, - associated_bonding_curve: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_bonding_curve = Some(associated_bonding_curve); - self - } - - #[inline(always)] - pub fn global(&mut self, global: solana_pubkey::Pubkey) -> &mut Self { - self.global = Some(global); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - #[inline(always)] - pub fn mpl_token_metadata(&mut self, mpl_token_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mpl_token_metadata = Some(mpl_token_metadata); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: solana_pubkey::Pubkey) -> &mut Self { - self.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.name = Some(name); - self - } - - #[inline(always)] - pub fn symbol(&mut self, symbol: String) -> &mut Self { - self.symbol = Some(symbol); - self - } - - #[inline(always)] - pub fn uri(&mut self, uri: String) -> &mut Self { - self.uri = Some(uri); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Create { - mint: self.mint.expect("mint is not set"), - mint_authority: self.mint_authority.expect("mint_authority is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - associated_bonding_curve: self - .associated_bonding_curve - .expect("associated_bonding_curve is not set"), - global: self.global.expect("global is not set"), - mpl_token_metadata: self.mpl_token_metadata.unwrap_or(solana_pubkey::pubkey!( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - )), - metadata: self.metadata.expect("metadata is not set"), - user: self.user.expect("user is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = CreateInstructionArgs { - name: self.name.clone().expect("name is not set"), - symbol: self.symbol.clone().expect("symbol is not set"), - uri: self.uri.clone().expect("uri is not set"), - creator: self.creator.clone().expect("creator is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create` CPI accounts. -pub struct CreateCpiAccounts<'a, 'b> { - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub mint_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub mpl_token_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create` CPI instruction. -pub struct CreateCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub mint_authority: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub mpl_token_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateInstructionArgs, -} - -impl<'a, 'b> CreateCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateCpiAccounts<'a, 'b>, - args: CreateInstructionArgs, - ) -> Self { - Self { - __program: program, - mint: accounts.mint, - mint_authority: accounts.mint_authority, - bonding_curve: accounts.bonding_curve, - associated_bonding_curve: accounts.associated_bonding_curve, - global: accounts.global, - mpl_token_metadata: accounts.mpl_token_metadata, - metadata: accounts.metadata, - user: accounts.user, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - rent: accounts.rent, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.mint.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.associated_bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mpl_token_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.user.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.mint_authority.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.associated_bonding_curve.clone()); - account_infos.push(self.global.clone()); - account_infos.push(self.mpl_token_metadata.clone()); - account_infos.push(self.metadata.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Create` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` mint -/// 1. `[]` mint_authority -/// 2. `[writable]` bonding_curve -/// 3. `[writable]` associated_bonding_curve -/// 4. `[]` global -/// 5. `[]` mpl_token_metadata -/// 6. `[writable]` metadata -/// 7. `[writable, signer]` user -/// 8. `[]` system_program -/// 9. `[]` token_program -/// 10. `[]` associated_token_program -/// 11. `[]` rent -/// 12. `[]` event_authority -/// 13. `[]` program -#[derive(Clone, Debug)] -pub struct CreateCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateCpiBuilderInstruction { - __program: program, - mint: None, - mint_authority: None, - bonding_curve: None, - associated_bonding_curve: None, - global: None, - mpl_token_metadata: None, - metadata: None, - user: None, - system_program: None, - token_program: None, - associated_token_program: None, - rent: None, - event_authority: None, - program: None, - name: None, - symbol: None, - uri: None, - creator: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn mint_authority( - &mut self, - mint_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_authority = Some(mint_authority); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn associated_bonding_curve( - &mut self, - associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_bonding_curve = Some(associated_bonding_curve); - self - } - - #[inline(always)] - pub fn global(&mut self, global: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.global = Some(global); - self - } - - #[inline(always)] - pub fn mpl_token_metadata( - &mut self, - mpl_token_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mpl_token_metadata = Some(mpl_token_metadata); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.instruction.name = Some(name); - self - } - - #[inline(always)] - pub fn symbol(&mut self, symbol: String) -> &mut Self { - self.instruction.symbol = Some(symbol); - self - } - - #[inline(always)] - pub fn uri(&mut self, uri: String) -> &mut Self { - self.instruction.uri = Some(uri); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: Pubkey) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateInstructionArgs { - name: self.instruction.name.clone().expect("name is not set"), - symbol: self.instruction.symbol.clone().expect("symbol is not set"), - uri: self.instruction.uri.clone().expect("uri is not set"), - creator: self - .instruction - .creator - .clone() - .expect("creator is not set"), - }; - let instruction = CreateCpi { - __program: self.instruction.__program, - - mint: self.instruction.mint.expect("mint is not set"), - - mint_authority: self - .instruction - .mint_authority - .expect("mint_authority is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - associated_bonding_curve: self - .instruction - .associated_bonding_curve - .expect("associated_bonding_curve is not set"), - - global: self.instruction.global.expect("global is not set"), - - mpl_token_metadata: self - .instruction - .mpl_token_metadata - .expect("mpl_token_metadata is not set"), - - metadata: self.instruction.metadata.expect("metadata is not set"), - - user: self.instruction.user.expect("user is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - global: Option<&'b solana_account_info::AccountInfo<'a>>, - mpl_token_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - name: Option, - symbol: Option, - uri: Option, - creator: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/extend_account.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/extend_account.rs deleted file mode 100644 index 20c68b3b..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/extend_account.rs +++ /dev/null @@ -1,432 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ExtendAccount { - pub account: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl ExtendAccount { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.account, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ExtendAccountInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ExtendAccountInstructionData { - discriminator: [u8; 8], -} - -impl ExtendAccountInstructionData { - pub fn new() -> Self { - Self { - discriminator: [234, 102, 194, 203, 150, 72, 62, 229], - } - } -} - -impl Default for ExtendAccountInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ExtendAccount`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` account -/// 1. `[signer]` user -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct ExtendAccountBuilder { - account: Option, - user: Option, - system_program: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl ExtendAccountBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn account(&mut self, account: solana_pubkey::Pubkey) -> &mut Self { - self.account = Some(account); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ExtendAccount { - account: self.account.expect("account is not set"), - user: self.user.expect("user is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `extend_account` CPI accounts. -pub struct ExtendAccountCpiAccounts<'a, 'b> { - pub account: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `extend_account` CPI instruction. -pub struct ExtendAccountCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub account: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ExtendAccountCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ExtendAccountCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - account: accounts.account, - user: accounts.user, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ExtendAccountInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.account.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ExtendAccount` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` account -/// 1. `[signer]` user -/// 2. `[]` system_program -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct ExtendAccountCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ExtendAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ExtendAccountCpiBuilderInstruction { - __program: program, - account: None, - user: None, - system_program: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn account(&mut self, account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.account = Some(account); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ExtendAccountCpi { - __program: self.instruction.__program, - - account: self.instruction.account.expect("account is not set"), - - user: self.instruction.user.expect("user is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ExtendAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - account: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/initialize.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/initialize.rs deleted file mode 100644 index d8cea9c7..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/initialize.rs +++ /dev/null @@ -1,349 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Initialize { - pub global: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl Initialize { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.global, false)); - accounts.push(solana_instruction::AccountMeta::new(self.user, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionData { - discriminator: [u8; 8], -} - -impl InitializeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [175, 175, 109, 31, 13, 152, 155, 237], - } - } -} - -impl Default for InitializeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `Initialize`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` global -/// 1. `[writable, signer]` user -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeBuilder { - global: Option, - user: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl InitializeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn global(&mut self, global: solana_pubkey::Pubkey) -> &mut Self { - self.global = Some(global); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Initialize { - global: self.global.expect("global is not set"), - user: self.user.expect("user is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize` CPI accounts. -pub struct InitializeCpiAccounts<'a, 'b> { - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize` CPI instruction. -pub struct InitializeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - global: accounts.global, - user: accounts.user, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.global.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.user.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.global.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Initialize` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` global -/// 1. `[writable, signer]` user -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCpiBuilderInstruction { - __program: program, - global: None, - user: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn global(&mut self, global: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.global = Some(global); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializeCpi { - __program: self.instruction.__program, - - global: self.instruction.global.expect("global is not set"), - - user: self.instruction.user.expect("user is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - global: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/migrate.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/migrate.rs deleted file mode 100644 index 26003c4f..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/migrate.rs +++ /dev/null @@ -1,1250 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Migrate { - pub global: solana_pubkey::Pubkey, - - pub withdraw_authority: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub associated_bonding_curve: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub pump_amm: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub pool_authority: solana_pubkey::Pubkey, - - pub pool_authority_mint_account: solana_pubkey::Pubkey, - - pub pool_authority_wsol_account: solana_pubkey::Pubkey, - - pub amm_global_config: solana_pubkey::Pubkey, - - pub wsol_mint: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub user_pool_token_account: solana_pubkey::Pubkey, - - pub pool_base_token_account: solana_pubkey::Pubkey, - - pub pool_quote_token_account: solana_pubkey::Pubkey, - - pub token2022_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub pump_amm_event_authority: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Migrate { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(24 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.withdraw_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.associated_bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pump_amm, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_authority_mint_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_authority_wsol_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.wsol_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_pool_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_base_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_quote_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token2022_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pump_amm_event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigrateInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateInstructionData { - discriminator: [u8; 8], -} - -impl MigrateInstructionData { - pub fn new() -> Self { - Self { - discriminator: [155, 234, 231, 146, 236, 158, 162, 30], - } - } -} - -impl Default for MigrateInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `Migrate`. -/// -/// ### Accounts: -/// -/// 0. `[]` global -/// 1. `[writable]` withdraw_authority -/// 2. `[]` mint -/// 3. `[writable]` bonding_curve -/// 4. `[writable]` associated_bonding_curve -/// 5. `[signer]` user -/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 8. `[optional]` pump_amm (default to `pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA`) -/// 9. `[writable]` pool -/// 10. `[writable]` pool_authority -/// 11. `[writable]` pool_authority_mint_account -/// 12. `[writable]` pool_authority_wsol_account -/// 13. `[]` amm_global_config -/// 14. `[optional]` wsol_mint (default to `So11111111111111111111111111111111111111112`) -/// 15. `[writable]` lp_mint -/// 16. `[writable]` user_pool_token_account -/// 17. `[writable]` pool_base_token_account -/// 18. `[writable]` pool_quote_token_account -/// 19. `[optional]` token2022_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 20. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 21. `[]` pump_amm_event_authority -/// 22. `[]` event_authority -/// 23. `[]` program -#[derive(Clone, Debug, Default)] -pub struct MigrateBuilder { - global: Option, - withdraw_authority: Option, - mint: Option, - bonding_curve: Option, - associated_bonding_curve: Option, - user: Option, - system_program: Option, - token_program: Option, - pump_amm: Option, - pool: Option, - pool_authority: Option, - pool_authority_mint_account: Option, - pool_authority_wsol_account: Option, - amm_global_config: Option, - wsol_mint: Option, - lp_mint: Option, - user_pool_token_account: Option, - pool_base_token_account: Option, - pool_quote_token_account: Option, - token2022_program: Option, - associated_token_program: Option, - pump_amm_event_authority: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl MigrateBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn global(&mut self, global: solana_pubkey::Pubkey) -> &mut Self { - self.global = Some(global); - self - } - - #[inline(always)] - pub fn withdraw_authority(&mut self, withdraw_authority: solana_pubkey::Pubkey) -> &mut Self { - self.withdraw_authority = Some(withdraw_authority); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn associated_bonding_curve( - &mut self, - associated_bonding_curve: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_bonding_curve = Some(associated_bonding_curve); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA']` - #[inline(always)] - pub fn pump_amm(&mut self, pump_amm: solana_pubkey::Pubkey) -> &mut Self { - self.pump_amm = Some(pump_amm); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self { - self.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool_authority_mint_account( - &mut self, - pool_authority_mint_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_authority_mint_account = Some(pool_authority_mint_account); - self - } - - #[inline(always)] - pub fn pool_authority_wsol_account( - &mut self, - pool_authority_wsol_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_authority_wsol_account = Some(pool_authority_wsol_account); - self - } - - #[inline(always)] - pub fn amm_global_config(&mut self, amm_global_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_global_config = Some(amm_global_config); - self - } - - /// `[optional account, default to 'So11111111111111111111111111111111111111112']` - #[inline(always)] - pub fn wsol_mint(&mut self, wsol_mint: solana_pubkey::Pubkey) -> &mut Self { - self.wsol_mint = Some(wsol_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn user_pool_token_account( - &mut self, - user_pool_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_pool_token_account = Some(user_pool_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - #[inline(always)] - pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self { - self.token2022_program = Some(token2022_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn pump_amm_event_authority( - &mut self, - pump_amm_event_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pump_amm_event_authority = Some(pump_amm_event_authority); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Migrate { - global: self.global.expect("global is not set"), - withdraw_authority: self - .withdraw_authority - .expect("withdraw_authority is not set"), - mint: self.mint.expect("mint is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - associated_bonding_curve: self - .associated_bonding_curve - .expect("associated_bonding_curve is not set"), - user: self.user.expect("user is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - pump_amm: self.pump_amm.unwrap_or(solana_pubkey::pubkey!( - "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA" - )), - pool: self.pool.expect("pool is not set"), - pool_authority: self.pool_authority.expect("pool_authority is not set"), - pool_authority_mint_account: self - .pool_authority_mint_account - .expect("pool_authority_mint_account is not set"), - pool_authority_wsol_account: self - .pool_authority_wsol_account - .expect("pool_authority_wsol_account is not set"), - amm_global_config: self - .amm_global_config - .expect("amm_global_config is not set"), - wsol_mint: self.wsol_mint.unwrap_or(solana_pubkey::pubkey!( - "So11111111111111111111111111111111111111112" - )), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - user_pool_token_account: self - .user_pool_token_account - .expect("user_pool_token_account is not set"), - pool_base_token_account: self - .pool_base_token_account - .expect("pool_base_token_account is not set"), - pool_quote_token_account: self - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - token2022_program: self.token2022_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - pump_amm_event_authority: self - .pump_amm_event_authority - .expect("pump_amm_event_authority is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migrate` CPI accounts. -pub struct MigrateCpiAccounts<'a, 'b> { - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub withdraw_authority: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub pump_amm: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority_mint_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority_wsol_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_global_config: &'b solana_account_info::AccountInfo<'a>, - - pub wsol_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub pump_amm_event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migrate` CPI instruction. -pub struct MigrateCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub withdraw_authority: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub pump_amm: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority_mint_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_authority_wsol_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_global_config: &'b solana_account_info::AccountInfo<'a>, - - pub wsol_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub token2022_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub pump_amm_event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrateCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrateCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - global: accounts.global, - withdraw_authority: accounts.withdraw_authority, - mint: accounts.mint, - bonding_curve: accounts.bonding_curve, - associated_bonding_curve: accounts.associated_bonding_curve, - user: accounts.user, - system_program: accounts.system_program, - token_program: accounts.token_program, - pump_amm: accounts.pump_amm, - pool: accounts.pool, - pool_authority: accounts.pool_authority, - pool_authority_mint_account: accounts.pool_authority_mint_account, - pool_authority_wsol_account: accounts.pool_authority_wsol_account, - amm_global_config: accounts.amm_global_config, - wsol_mint: accounts.wsol_mint, - lp_mint: accounts.lp_mint, - user_pool_token_account: accounts.user_pool_token_account, - pool_base_token_account: accounts.pool_base_token_account, - pool_quote_token_account: accounts.pool_quote_token_account, - token2022_program: accounts.token2022_program, - associated_token_program: accounts.associated_token_program, - pump_amm_event_authority: accounts.pump_amm_event_authority, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(24 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.withdraw_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.associated_bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pump_amm.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_authority_mint_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_authority_wsol_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.wsol_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_pool_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_base_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_quote_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token2022_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pump_amm_event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigrateInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(25 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.global.clone()); - account_infos.push(self.withdraw_authority.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.associated_bonding_curve.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.pump_amm.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.pool_authority.clone()); - account_infos.push(self.pool_authority_mint_account.clone()); - account_infos.push(self.pool_authority_wsol_account.clone()); - account_infos.push(self.amm_global_config.clone()); - account_infos.push(self.wsol_mint.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.user_pool_token_account.clone()); - account_infos.push(self.pool_base_token_account.clone()); - account_infos.push(self.pool_quote_token_account.clone()); - account_infos.push(self.token2022_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.pump_amm_event_authority.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Migrate` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` global -/// 1. `[writable]` withdraw_authority -/// 2. `[]` mint -/// 3. `[writable]` bonding_curve -/// 4. `[writable]` associated_bonding_curve -/// 5. `[signer]` user -/// 6. `[]` system_program -/// 7. `[]` token_program -/// 8. `[]` pump_amm -/// 9. `[writable]` pool -/// 10. `[writable]` pool_authority -/// 11. `[writable]` pool_authority_mint_account -/// 12. `[writable]` pool_authority_wsol_account -/// 13. `[]` amm_global_config -/// 14. `[]` wsol_mint -/// 15. `[writable]` lp_mint -/// 16. `[writable]` user_pool_token_account -/// 17. `[writable]` pool_base_token_account -/// 18. `[writable]` pool_quote_token_account -/// 19. `[]` token2022_program -/// 20. `[]` associated_token_program -/// 21. `[]` pump_amm_event_authority -/// 22. `[]` event_authority -/// 23. `[]` program -#[derive(Clone, Debug)] -pub struct MigrateCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrateCpiBuilderInstruction { - __program: program, - global: None, - withdraw_authority: None, - mint: None, - bonding_curve: None, - associated_bonding_curve: None, - user: None, - system_program: None, - token_program: None, - pump_amm: None, - pool: None, - pool_authority: None, - pool_authority_mint_account: None, - pool_authority_wsol_account: None, - amm_global_config: None, - wsol_mint: None, - lp_mint: None, - user_pool_token_account: None, - pool_base_token_account: None, - pool_quote_token_account: None, - token2022_program: None, - associated_token_program: None, - pump_amm_event_authority: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn global(&mut self, global: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.global = Some(global); - self - } - - #[inline(always)] - pub fn withdraw_authority( - &mut self, - withdraw_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.withdraw_authority = Some(withdraw_authority); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn associated_bonding_curve( - &mut self, - associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_bonding_curve = Some(associated_bonding_curve); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn pump_amm(&mut self, pump_amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pump_amm = Some(pump_amm); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn pool_authority( - &mut self, - pool_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority = Some(pool_authority); - self - } - - #[inline(always)] - pub fn pool_authority_mint_account( - &mut self, - pool_authority_mint_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority_mint_account = Some(pool_authority_mint_account); - self - } - - #[inline(always)] - pub fn pool_authority_wsol_account( - &mut self, - pool_authority_wsol_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_authority_wsol_account = Some(pool_authority_wsol_account); - self - } - - #[inline(always)] - pub fn amm_global_config( - &mut self, - amm_global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_global_config = Some(amm_global_config); - self - } - - #[inline(always)] - pub fn wsol_mint(&mut self, wsol_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.wsol_mint = Some(wsol_mint); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn user_pool_token_account( - &mut self, - user_pool_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_pool_token_account = Some(user_pool_token_account); - self - } - - #[inline(always)] - pub fn pool_base_token_account( - &mut self, - pool_base_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_base_token_account = Some(pool_base_token_account); - self - } - - #[inline(always)] - pub fn pool_quote_token_account( - &mut self, - pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_quote_token_account = Some(pool_quote_token_account); - self - } - - #[inline(always)] - pub fn token2022_program( - &mut self, - token2022_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token2022_program = Some(token2022_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn pump_amm_event_authority( - &mut self, - pump_amm_event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pump_amm_event_authority = Some(pump_amm_event_authority); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrateCpi { - __program: self.instruction.__program, - - global: self.instruction.global.expect("global is not set"), - - withdraw_authority: self - .instruction - .withdraw_authority - .expect("withdraw_authority is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - associated_bonding_curve: self - .instruction - .associated_bonding_curve - .expect("associated_bonding_curve is not set"), - - user: self.instruction.user.expect("user is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - pump_amm: self.instruction.pump_amm.expect("pump_amm is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - pool_authority: self - .instruction - .pool_authority - .expect("pool_authority is not set"), - - pool_authority_mint_account: self - .instruction - .pool_authority_mint_account - .expect("pool_authority_mint_account is not set"), - - pool_authority_wsol_account: self - .instruction - .pool_authority_wsol_account - .expect("pool_authority_wsol_account is not set"), - - amm_global_config: self - .instruction - .amm_global_config - .expect("amm_global_config is not set"), - - wsol_mint: self.instruction.wsol_mint.expect("wsol_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - user_pool_token_account: self - .instruction - .user_pool_token_account - .expect("user_pool_token_account is not set"), - - pool_base_token_account: self - .instruction - .pool_base_token_account - .expect("pool_base_token_account is not set"), - - pool_quote_token_account: self - .instruction - .pool_quote_token_account - .expect("pool_quote_token_account is not set"), - - token2022_program: self - .instruction - .token2022_program - .expect("token2022_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - pump_amm_event_authority: self - .instruction - .pump_amm_event_authority - .expect("pump_amm_event_authority is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - global: Option<&'b solana_account_info::AccountInfo<'a>>, - withdraw_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - pump_amm: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority_mint_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_authority_wsol_account: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - wsol_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_pool_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - pump_amm_event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/mod.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index a004d02b..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#buy; -pub(crate) mod r#collect_creator_fee; -pub(crate) mod r#create; -pub(crate) mod r#extend_account; -pub(crate) mod r#initialize; -pub(crate) mod r#migrate; -pub(crate) mod r#sell; -pub(crate) mod r#set_creator; -pub(crate) mod r#set_metaplex_creator; -pub(crate) mod r#set_params; -pub(crate) mod r#update_global_authority; - -pub use self::{ - r#buy::*, r#collect_creator_fee::*, r#create::*, r#extend_account::*, r#initialize::*, - r#migrate::*, r#sell::*, r#set_creator::*, r#set_metaplex_creator::*, r#set_params::*, - r#update_global_authority::*, -}; diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/sell.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/sell.rs deleted file mode 100644 index 06f9b4ee..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/sell.rs +++ /dev/null @@ -1,787 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Sell { - pub global: solana_pubkey::Pubkey, - - pub fee_recipient: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub associated_bonding_curve: solana_pubkey::Pubkey, - - pub associated_user: solana_pubkey::Pubkey, - - pub user: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub creator_vault: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Sell { - pub fn instruction(&self, args: SellInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SellInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.fee_recipient, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.associated_bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.associated_user, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.user, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SellInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellInstructionData { - discriminator: [u8; 8], -} - -impl SellInstructionData { - pub fn new() -> Self { - Self { - discriminator: [51, 230, 133, 164, 1, 127, 131, 173], - } - } -} - -impl Default for SellInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellInstructionArgs { - pub amount: u64, - pub min_sol_output: u64, -} - -/// Instruction builder for `Sell`. -/// -/// ### Accounts: -/// -/// 0. `[]` global -/// 1. `[writable]` fee_recipient -/// 2. `[]` mint -/// 3. `[writable]` bonding_curve -/// 4. `[writable]` associated_bonding_curve -/// 5. `[writable]` associated_user -/// 6. `[writable, signer]` user -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 8. `[writable]` creator_vault -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SellBuilder { - global: Option, - fee_recipient: Option, - mint: Option, - bonding_curve: Option, - associated_bonding_curve: Option, - associated_user: Option, - user: Option, - system_program: Option, - creator_vault: Option, - token_program: Option, - event_authority: Option, - program: Option, - amount: Option, - min_sol_output: Option, - __remaining_accounts: Vec, -} - -impl SellBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn global(&mut self, global: solana_pubkey::Pubkey) -> &mut Self { - self.global = Some(global); - self - } - - #[inline(always)] - pub fn fee_recipient(&mut self, fee_recipient: solana_pubkey::Pubkey) -> &mut Self { - self.fee_recipient = Some(fee_recipient); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn associated_bonding_curve( - &mut self, - associated_bonding_curve: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_bonding_curve = Some(associated_bonding_curve); - self - } - - #[inline(always)] - pub fn associated_user(&mut self, associated_user: solana_pubkey::Pubkey) -> &mut Self { - self.associated_user = Some(associated_user); - self - } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn creator_vault(&mut self, creator_vault: solana_pubkey::Pubkey) -> &mut Self { - self.creator_vault = Some(creator_vault); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn min_sol_output(&mut self, min_sol_output: u64) -> &mut Self { - self.min_sol_output = Some(min_sol_output); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Sell { - global: self.global.expect("global is not set"), - fee_recipient: self.fee_recipient.expect("fee_recipient is not set"), - mint: self.mint.expect("mint is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - associated_bonding_curve: self - .associated_bonding_curve - .expect("associated_bonding_curve is not set"), - associated_user: self.associated_user.expect("associated_user is not set"), - user: self.user.expect("user is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - creator_vault: self.creator_vault.expect("creator_vault is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SellInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - min_sol_output: self - .min_sol_output - .clone() - .expect("min_sol_output is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `sell` CPI accounts. -pub struct SellCpiAccounts<'a, 'b> { - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_user: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub creator_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `sell` CPI instruction. -pub struct SellCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub fee_recipient: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub associated_user: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub creator_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SellInstructionArgs, -} - -impl<'a, 'b> SellCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SellCpiAccounts<'a, 'b>, - args: SellInstructionArgs, - ) -> Self { - Self { - __program: program, - global: accounts.global, - fee_recipient: accounts.fee_recipient, - mint: accounts.mint, - bonding_curve: accounts.bonding_curve, - associated_bonding_curve: accounts.associated_bonding_curve, - associated_user: accounts.associated_user, - user: accounts.user, - system_program: accounts.system_program, - creator_vault: accounts.creator_vault, - token_program: accounts.token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.fee_recipient.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.associated_bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.associated_user.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.user.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SellInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.global.clone()); - account_infos.push(self.fee_recipient.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.associated_bonding_curve.clone()); - account_infos.push(self.associated_user.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.creator_vault.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Sell` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` global -/// 1. `[writable]` fee_recipient -/// 2. `[]` mint -/// 3. `[writable]` bonding_curve -/// 4. `[writable]` associated_bonding_curve -/// 5. `[writable]` associated_user -/// 6. `[writable, signer]` user -/// 7. `[]` system_program -/// 8. `[writable]` creator_vault -/// 9. `[]` token_program -/// 10. `[]` event_authority -/// 11. `[]` program -#[derive(Clone, Debug)] -pub struct SellCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SellCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SellCpiBuilderInstruction { - __program: program, - global: None, - fee_recipient: None, - mint: None, - bonding_curve: None, - associated_bonding_curve: None, - associated_user: None, - user: None, - system_program: None, - creator_vault: None, - token_program: None, - event_authority: None, - program: None, - amount: None, - min_sol_output: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn global(&mut self, global: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.global = Some(global); - self - } - - #[inline(always)] - pub fn fee_recipient( - &mut self, - fee_recipient: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_recipient = Some(fee_recipient); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn associated_bonding_curve( - &mut self, - associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_bonding_curve = Some(associated_bonding_curve); - self - } - - #[inline(always)] - pub fn associated_user( - &mut self, - associated_user: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_user = Some(associated_user); - self - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn creator_vault( - &mut self, - creator_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_vault = Some(creator_vault); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn min_sol_output(&mut self, min_sol_output: u64) -> &mut Self { - self.instruction.min_sol_output = Some(min_sol_output); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SellInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - min_sol_output: self - .instruction - .min_sol_output - .clone() - .expect("min_sol_output is not set"), - }; - let instruction = SellCpi { - __program: self.instruction.__program, - - global: self.instruction.global.expect("global is not set"), - - fee_recipient: self - .instruction - .fee_recipient - .expect("fee_recipient is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - associated_bonding_curve: self - .instruction - .associated_bonding_curve - .expect("associated_bonding_curve is not set"), - - associated_user: self - .instruction - .associated_user - .expect("associated_user is not set"), - - user: self.instruction.user.expect("user is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - creator_vault: self - .instruction - .creator_vault - .expect("creator_vault is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SellCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - global: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_recipient: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_user: Option<&'b solana_account_info::AccountInfo<'a>>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - min_sol_output: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/set_creator.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/set_creator.rs deleted file mode 100644 index 176140bf..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/set_creator.rs +++ /dev/null @@ -1,557 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct SetCreator { - pub set_creator_authority: solana_pubkey::Pubkey, - - pub global: solana_pubkey::Pubkey, - - pub mint: solana_pubkey::Pubkey, - - pub metadata: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SetCreator { - pub fn instruction(&self, args: SetCreatorInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetCreatorInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.set_creator_authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetCreatorInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetCreatorInstructionData { - discriminator: [u8; 8], -} - -impl SetCreatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [254, 148, 255, 112, 207, 142, 170, 165], - } - } -} - -impl Default for SetCreatorInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetCreatorInstructionArgs { - pub creator: Pubkey, -} - -/// Instruction builder for `SetCreator`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` set_creator_authority -/// 1. `[]` global -/// 2. `[]` mint -/// 3. `[]` metadata -/// 4. `[writable]` bonding_curve -/// 5. `[]` event_authority -/// 6. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SetCreatorBuilder { - set_creator_authority: Option, - global: Option, - mint: Option, - metadata: Option, - bonding_curve: Option, - event_authority: Option, - program: Option, - creator: Option, - __remaining_accounts: Vec, -} - -impl SetCreatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn set_creator_authority( - &mut self, - set_creator_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.set_creator_authority = Some(set_creator_authority); - self - } - - #[inline(always)] - pub fn global(&mut self, global: solana_pubkey::Pubkey) -> &mut Self { - self.global = Some(global); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: solana_pubkey::Pubkey) -> &mut Self { - self.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetCreator { - set_creator_authority: self - .set_creator_authority - .expect("set_creator_authority is not set"), - global: self.global.expect("global is not set"), - mint: self.mint.expect("mint is not set"), - metadata: self.metadata.expect("metadata is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SetCreatorInstructionArgs { - creator: self.creator.clone().expect("creator is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_creator` CPI accounts. -pub struct SetCreatorCpiAccounts<'a, 'b> { - pub set_creator_authority: &'b solana_account_info::AccountInfo<'a>, - - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_creator` CPI instruction. -pub struct SetCreatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub set_creator_authority: &'b solana_account_info::AccountInfo<'a>, - - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetCreatorInstructionArgs, -} - -impl<'a, 'b> SetCreatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetCreatorCpiAccounts<'a, 'b>, - args: SetCreatorInstructionArgs, - ) -> Self { - Self { - __program: program, - set_creator_authority: accounts.set_creator_authority, - global: accounts.global, - mint: accounts.mint, - metadata: accounts.metadata, - bonding_curve: accounts.bonding_curve, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.set_creator_authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetCreatorInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.set_creator_authority.clone()); - account_infos.push(self.global.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.metadata.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetCreator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` set_creator_authority -/// 1. `[]` global -/// 2. `[]` mint -/// 3. `[]` metadata -/// 4. `[writable]` bonding_curve -/// 5. `[]` event_authority -/// 6. `[]` program -#[derive(Clone, Debug)] -pub struct SetCreatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetCreatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetCreatorCpiBuilderInstruction { - __program: program, - set_creator_authority: None, - global: None, - mint: None, - metadata: None, - bonding_curve: None, - event_authority: None, - program: None, - creator: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn set_creator_authority( - &mut self, - set_creator_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.set_creator_authority = Some(set_creator_authority); - self - } - - #[inline(always)] - pub fn global(&mut self, global: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.global = Some(global); - self - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: Pubkey) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetCreatorInstructionArgs { - creator: self - .instruction - .creator - .clone() - .expect("creator is not set"), - }; - let instruction = SetCreatorCpi { - __program: self.instruction.__program, - - set_creator_authority: self - .instruction - .set_creator_authority - .expect("set_creator_authority is not set"), - - global: self.instruction.global.expect("global is not set"), - - mint: self.instruction.mint.expect("mint is not set"), - - metadata: self.instruction.metadata.expect("metadata is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetCreatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - set_creator_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - global: Option<&'b solana_account_info::AccountInfo<'a>>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/set_metaplex_creator.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/set_metaplex_creator.rs deleted file mode 100644 index 27b1d387..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/set_metaplex_creator.rs +++ /dev/null @@ -1,432 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetMetaplexCreator { - pub mint: solana_pubkey::Pubkey, - - pub metadata: solana_pubkey::Pubkey, - - pub bonding_curve: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SetMetaplexCreator { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.mint, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.bonding_curve, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&SetMetaplexCreatorInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetMetaplexCreatorInstructionData { - discriminator: [u8; 8], -} - -impl SetMetaplexCreatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [138, 96, 174, 217, 48, 85, 197, 246], - } - } -} - -impl Default for SetMetaplexCreatorInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `SetMetaplexCreator`. -/// -/// ### Accounts: -/// -/// 0. `[]` mint -/// 1. `[]` metadata -/// 2. `[writable]` bonding_curve -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SetMetaplexCreatorBuilder { - mint: Option, - metadata: Option, - bonding_curve: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl SetMetaplexCreatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self { - self.mint = Some(mint); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: solana_pubkey::Pubkey) -> &mut Self { - self.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self { - self.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetMetaplexCreator { - mint: self.mint.expect("mint is not set"), - metadata: self.metadata.expect("metadata is not set"), - bonding_curve: self.bonding_curve.expect("bonding_curve is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `set_metaplex_creator` CPI accounts. -pub struct SetMetaplexCreatorCpiAccounts<'a, 'b> { - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_metaplex_creator` CPI instruction. -pub struct SetMetaplexCreatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub mint: &'b solana_account_info::AccountInfo<'a>, - - pub metadata: &'b solana_account_info::AccountInfo<'a>, - - pub bonding_curve: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> SetMetaplexCreatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetMetaplexCreatorCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - mint: accounts.mint, - metadata: accounts.metadata, - bonding_curve: accounts.bonding_curve, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.bonding_curve.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&SetMetaplexCreatorInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.mint.clone()); - account_infos.push(self.metadata.clone()); - account_infos.push(self.bonding_curve.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetMetaplexCreator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` mint -/// 1. `[]` metadata -/// 2. `[writable]` bonding_curve -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct SetMetaplexCreatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetMetaplexCreatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetMetaplexCreatorCpiBuilderInstruction { - __program: program, - mint: None, - metadata: None, - bonding_curve: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.mint = Some(mint); - self - } - - #[inline(always)] - pub fn metadata(&mut self, metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.metadata = Some(metadata); - self - } - - #[inline(always)] - pub fn bonding_curve( - &mut self, - bonding_curve: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.bonding_curve = Some(bonding_curve); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = SetMetaplexCreatorCpi { - __program: self.instruction.__program, - - mint: self.instruction.mint.expect("mint is not set"), - - metadata: self.instruction.metadata.expect("metadata is not set"), - - bonding_curve: self - .instruction - .bonding_curve - .expect("bonding_curve is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetMetaplexCreatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - mint: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/set_params.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/set_params.rs deleted file mode 100644 index c96158cc..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/set_params.rs +++ /dev/null @@ -1,661 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct SetParams { - pub global: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SetParams { - pub fn instruction(&self, args: SetParamsInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetParamsInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.global, false)); - accounts.push(solana_instruction::AccountMeta::new(self.authority, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetParamsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetParamsInstructionData { - discriminator: [u8; 8], -} - -impl SetParamsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [27, 234, 178, 52, 147, 2, 187, 141], - } - } -} - -impl Default for SetParamsInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetParamsInstructionArgs { - pub initial_virtual_token_reserves: u64, - pub initial_virtual_sol_reserves: u64, - pub initial_real_token_reserves: u64, - pub token_total_supply: u64, - pub fee_basis_points: u64, - pub withdraw_authority: Pubkey, - pub enable_migrate: bool, - pub pool_migration_fee: u64, - pub creator_fee_basis_points: u64, - pub set_creator_authority: Pubkey, -} - -/// Instruction builder for `SetParams`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` global -/// 1. `[writable, signer]` authority -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SetParamsBuilder { - global: Option, - authority: Option, - event_authority: Option, - program: Option, - initial_virtual_token_reserves: Option, - initial_virtual_sol_reserves: Option, - initial_real_token_reserves: Option, - token_total_supply: Option, - fee_basis_points: Option, - withdraw_authority: Option, - enable_migrate: Option, - pool_migration_fee: Option, - creator_fee_basis_points: Option, - set_creator_authority: Option, - __remaining_accounts: Vec, -} - -impl SetParamsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn global(&mut self, global: solana_pubkey::Pubkey) -> &mut Self { - self.global = Some(global); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn initial_virtual_token_reserves( - &mut self, - initial_virtual_token_reserves: u64, - ) -> &mut Self { - self.initial_virtual_token_reserves = Some(initial_virtual_token_reserves); - self - } - - #[inline(always)] - pub fn initial_virtual_sol_reserves(&mut self, initial_virtual_sol_reserves: u64) -> &mut Self { - self.initial_virtual_sol_reserves = Some(initial_virtual_sol_reserves); - self - } - - #[inline(always)] - pub fn initial_real_token_reserves(&mut self, initial_real_token_reserves: u64) -> &mut Self { - self.initial_real_token_reserves = Some(initial_real_token_reserves); - self - } - - #[inline(always)] - pub fn token_total_supply(&mut self, token_total_supply: u64) -> &mut Self { - self.token_total_supply = Some(token_total_supply); - self - } - - #[inline(always)] - pub fn fee_basis_points(&mut self, fee_basis_points: u64) -> &mut Self { - self.fee_basis_points = Some(fee_basis_points); - self - } - - #[inline(always)] - pub fn withdraw_authority(&mut self, withdraw_authority: Pubkey) -> &mut Self { - self.withdraw_authority = Some(withdraw_authority); - self - } - - #[inline(always)] - pub fn enable_migrate(&mut self, enable_migrate: bool) -> &mut Self { - self.enable_migrate = Some(enable_migrate); - self - } - - #[inline(always)] - pub fn pool_migration_fee(&mut self, pool_migration_fee: u64) -> &mut Self { - self.pool_migration_fee = Some(pool_migration_fee); - self - } - - #[inline(always)] - pub fn creator_fee_basis_points(&mut self, creator_fee_basis_points: u64) -> &mut Self { - self.creator_fee_basis_points = Some(creator_fee_basis_points); - self - } - - #[inline(always)] - pub fn set_creator_authority(&mut self, set_creator_authority: Pubkey) -> &mut Self { - self.set_creator_authority = Some(set_creator_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetParams { - global: self.global.expect("global is not set"), - authority: self.authority.expect("authority is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SetParamsInstructionArgs { - initial_virtual_token_reserves: self - .initial_virtual_token_reserves - .clone() - .expect("initial_virtual_token_reserves is not set"), - initial_virtual_sol_reserves: self - .initial_virtual_sol_reserves - .clone() - .expect("initial_virtual_sol_reserves is not set"), - initial_real_token_reserves: self - .initial_real_token_reserves - .clone() - .expect("initial_real_token_reserves is not set"), - token_total_supply: self - .token_total_supply - .clone() - .expect("token_total_supply is not set"), - fee_basis_points: self - .fee_basis_points - .clone() - .expect("fee_basis_points is not set"), - withdraw_authority: self - .withdraw_authority - .clone() - .expect("withdraw_authority is not set"), - enable_migrate: self - .enable_migrate - .clone() - .expect("enable_migrate is not set"), - pool_migration_fee: self - .pool_migration_fee - .clone() - .expect("pool_migration_fee is not set"), - creator_fee_basis_points: self - .creator_fee_basis_points - .clone() - .expect("creator_fee_basis_points is not set"), - set_creator_authority: self - .set_creator_authority - .clone() - .expect("set_creator_authority is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_params` CPI accounts. -pub struct SetParamsCpiAccounts<'a, 'b> { - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_params` CPI instruction. -pub struct SetParamsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetParamsInstructionArgs, -} - -impl<'a, 'b> SetParamsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetParamsCpiAccounts<'a, 'b>, - args: SetParamsInstructionArgs, - ) -> Self { - Self { - __program: program, - global: accounts.global, - authority: accounts.authority, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.global.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetParamsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.global.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetParams` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` global -/// 1. `[writable, signer]` authority -/// 2. `[]` event_authority -/// 3. `[]` program -#[derive(Clone, Debug)] -pub struct SetParamsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetParamsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetParamsCpiBuilderInstruction { - __program: program, - global: None, - authority: None, - event_authority: None, - program: None, - initial_virtual_token_reserves: None, - initial_virtual_sol_reserves: None, - initial_real_token_reserves: None, - token_total_supply: None, - fee_basis_points: None, - withdraw_authority: None, - enable_migrate: None, - pool_migration_fee: None, - creator_fee_basis_points: None, - set_creator_authority: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn global(&mut self, global: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.global = Some(global); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn initial_virtual_token_reserves( - &mut self, - initial_virtual_token_reserves: u64, - ) -> &mut Self { - self.instruction.initial_virtual_token_reserves = Some(initial_virtual_token_reserves); - self - } - - #[inline(always)] - pub fn initial_virtual_sol_reserves(&mut self, initial_virtual_sol_reserves: u64) -> &mut Self { - self.instruction.initial_virtual_sol_reserves = Some(initial_virtual_sol_reserves); - self - } - - #[inline(always)] - pub fn initial_real_token_reserves(&mut self, initial_real_token_reserves: u64) -> &mut Self { - self.instruction.initial_real_token_reserves = Some(initial_real_token_reserves); - self - } - - #[inline(always)] - pub fn token_total_supply(&mut self, token_total_supply: u64) -> &mut Self { - self.instruction.token_total_supply = Some(token_total_supply); - self - } - - #[inline(always)] - pub fn fee_basis_points(&mut self, fee_basis_points: u64) -> &mut Self { - self.instruction.fee_basis_points = Some(fee_basis_points); - self - } - - #[inline(always)] - pub fn withdraw_authority(&mut self, withdraw_authority: Pubkey) -> &mut Self { - self.instruction.withdraw_authority = Some(withdraw_authority); - self - } - - #[inline(always)] - pub fn enable_migrate(&mut self, enable_migrate: bool) -> &mut Self { - self.instruction.enable_migrate = Some(enable_migrate); - self - } - - #[inline(always)] - pub fn pool_migration_fee(&mut self, pool_migration_fee: u64) -> &mut Self { - self.instruction.pool_migration_fee = Some(pool_migration_fee); - self - } - - #[inline(always)] - pub fn creator_fee_basis_points(&mut self, creator_fee_basis_points: u64) -> &mut Self { - self.instruction.creator_fee_basis_points = Some(creator_fee_basis_points); - self - } - - #[inline(always)] - pub fn set_creator_authority(&mut self, set_creator_authority: Pubkey) -> &mut Self { - self.instruction.set_creator_authority = Some(set_creator_authority); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetParamsInstructionArgs { - initial_virtual_token_reserves: self - .instruction - .initial_virtual_token_reserves - .clone() - .expect("initial_virtual_token_reserves is not set"), - initial_virtual_sol_reserves: self - .instruction - .initial_virtual_sol_reserves - .clone() - .expect("initial_virtual_sol_reserves is not set"), - initial_real_token_reserves: self - .instruction - .initial_real_token_reserves - .clone() - .expect("initial_real_token_reserves is not set"), - token_total_supply: self - .instruction - .token_total_supply - .clone() - .expect("token_total_supply is not set"), - fee_basis_points: self - .instruction - .fee_basis_points - .clone() - .expect("fee_basis_points is not set"), - withdraw_authority: self - .instruction - .withdraw_authority - .clone() - .expect("withdraw_authority is not set"), - enable_migrate: self - .instruction - .enable_migrate - .clone() - .expect("enable_migrate is not set"), - pool_migration_fee: self - .instruction - .pool_migration_fee - .clone() - .expect("pool_migration_fee is not set"), - creator_fee_basis_points: self - .instruction - .creator_fee_basis_points - .clone() - .expect("creator_fee_basis_points is not set"), - set_creator_authority: self - .instruction - .set_creator_authority - .clone() - .expect("set_creator_authority is not set"), - }; - let instruction = SetParamsCpi { - __program: self.instruction.__program, - - global: self.instruction.global.expect("global is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetParamsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - global: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - initial_virtual_token_reserves: Option, - initial_virtual_sol_reserves: Option, - initial_real_token_reserves: Option, - token_total_supply: Option, - fee_basis_points: Option, - withdraw_authority: Option, - enable_migrate: Option, - pool_migration_fee: Option, - creator_fee_basis_points: Option, - set_creator_authority: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/instructions/update_global_authority.rs b/crates/pumpfun-parser/src/generated_sdk/instructions/update_global_authority.rs deleted file mode 100644 index b588b148..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/instructions/update_global_authority.rs +++ /dev/null @@ -1,430 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateGlobalAuthority { - pub global: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub new_authority: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl UpdateGlobalAuthority { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.global, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&UpdateGlobalAuthorityInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateGlobalAuthorityInstructionData { - discriminator: [u8; 8], -} - -impl UpdateGlobalAuthorityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [227, 181, 74, 196, 208, 21, 97, 213], - } - } -} - -impl Default for UpdateGlobalAuthorityInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `UpdateGlobalAuthority`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` global -/// 1. `[signer]` authority -/// 2. `[]` new_authority -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug, Default)] -pub struct UpdateGlobalAuthorityBuilder { - global: Option, - authority: Option, - new_authority: Option, - event_authority: Option, - program: Option, - __remaining_accounts: Vec, -} - -impl UpdateGlobalAuthorityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn global(&mut self, global: solana_pubkey::Pubkey) -> &mut Self { - self.global = Some(global); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn new_authority(&mut self, new_authority: solana_pubkey::Pubkey) -> &mut Self { - self.new_authority = Some(new_authority); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateGlobalAuthority { - global: self.global.expect("global is not set"), - authority: self.authority.expect("authority is not set"), - new_authority: self.new_authority.expect("new_authority is not set"), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `update_global_authority` CPI accounts. -pub struct UpdateGlobalAuthorityCpiAccounts<'a, 'b> { - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_authority: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_global_authority` CPI instruction. -pub struct UpdateGlobalAuthorityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub global: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub new_authority: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> UpdateGlobalAuthorityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateGlobalAuthorityCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - global: accounts.global, - authority: accounts.authority, - new_authority: accounts.new_authority, - event_authority: accounts.event_authority, - program: accounts.program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.global.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&UpdateGlobalAuthorityInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::PUMP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.global.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.new_authority.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateGlobalAuthority` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` global -/// 1. `[signer]` authority -/// 2. `[]` new_authority -/// 3. `[]` event_authority -/// 4. `[]` program -#[derive(Clone, Debug)] -pub struct UpdateGlobalAuthorityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateGlobalAuthorityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateGlobalAuthorityCpiBuilderInstruction { - __program: program, - global: None, - authority: None, - new_authority: None, - event_authority: None, - program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn global(&mut self, global: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.global = Some(global); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn new_authority( - &mut self, - new_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_authority = Some(new_authority); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = UpdateGlobalAuthorityCpi { - __program: self.instruction.__program, - - global: self.instruction.global.expect("global is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - new_authority: self - .instruction - .new_authority - .expect("new_authority is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateGlobalAuthorityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - global: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - new_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/mod.rs b/crates/pumpfun-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/pumpfun-parser/src/generated_sdk/programs.rs b/crates/pumpfun-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 4c420b74..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `pump` program ID. -pub const PUMP_ID: Pubkey = pubkey!("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"); diff --git a/crates/pumpfun-parser/src/generated_sdk/shared.rs b/crates/pumpfun-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/pumpfun-parser/src/generated_sdk/types/collect_creator_fee_event.rs b/crates/pumpfun-parser/src/generated_sdk/types/collect_creator_fee_event.rs deleted file mode 100644 index 03f11c8f..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/collect_creator_fee_event.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectCreatorFeeEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - pub creator_fee: u64, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/types/complete_event.rs b/crates/pumpfun-parser/src/generated_sdk/types/complete_event.rs deleted file mode 100644 index 1f779f9a..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/complete_event.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CompleteEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub bonding_curve: Pubkey, - pub timestamp: i64, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/types/complete_pump_amm_migration_event.rs b/crates/pumpfun-parser/src/generated_sdk/types/complete_pump_amm_migration_event.rs deleted file mode 100644 index 10e915d5..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/complete_pump_amm_migration_event.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CompletePumpAmmMigrationEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub mint_amount: u64, - pub sol_amount: u64, - pub pool_migration_fee: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub bonding_curve: Pubkey, - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/types/create_event.rs b/crates/pumpfun-parser/src/generated_sdk/types/create_event.rs deleted file mode 100644 index 3ae90a47..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/create_event.rs +++ /dev/null @@ -1,42 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateEvent { - pub name: String, - pub symbol: String, - pub uri: String, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub bonding_curve: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - pub timestamp: i64, - pub virtual_token_reserves: u64, - pub virtual_sol_reserves: u64, - pub real_token_reserves: u64, - pub token_total_supply: u64, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/types/extend_account_event.rs b/crates/pumpfun-parser/src/generated_sdk/types/extend_account_event.rs deleted file mode 100644 index 7c1808b1..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/extend_account_event.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ExtendAccountEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub account: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user: Pubkey, - pub current_size: u64, - pub new_size: u64, - pub timestamp: i64, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/types/mod.rs b/crates/pumpfun-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index d1a91dc6..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#collect_creator_fee_event; -pub(crate) mod r#complete_event; -pub(crate) mod r#complete_pump_amm_migration_event; -pub(crate) mod r#create_event; -pub(crate) mod r#extend_account_event; -pub(crate) mod r#set_creator_event; -pub(crate) mod r#set_metaplex_creator_event; -pub(crate) mod r#set_params_event; -pub(crate) mod r#trade_event; -pub(crate) mod r#update_global_authority_event; - -pub use self::{ - r#collect_creator_fee_event::*, r#complete_event::*, r#complete_pump_amm_migration_event::*, - r#create_event::*, r#extend_account_event::*, r#set_creator_event::*, - r#set_metaplex_creator_event::*, r#set_params_event::*, r#trade_event::*, - r#update_global_authority_event::*, -}; diff --git a/crates/pumpfun-parser/src/generated_sdk/types/set_creator_event.rs b/crates/pumpfun-parser/src/generated_sdk/types/set_creator_event.rs deleted file mode 100644 index 173125b1..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/set_creator_event.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetCreatorEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub bonding_curve: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/types/set_metaplex_creator_event.rs b/crates/pumpfun-parser/src/generated_sdk/types/set_metaplex_creator_event.rs deleted file mode 100644 index d0d2902e..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/set_metaplex_creator_event.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetMetaplexCreatorEvent { - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub bonding_curve: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub metadata: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/types/set_params_event.rs b/crates/pumpfun-parser/src/generated_sdk/types/set_params_event.rs deleted file mode 100644 index 498a7168..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/set_params_event.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetParamsEvent { - pub initial_virtual_token_reserves: u64, - pub initial_virtual_sol_reserves: u64, - pub initial_real_token_reserves: u64, - pub final_real_sol_reserves: u64, - pub token_total_supply: u64, - pub fee_basis_points: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub withdraw_authority: Pubkey, - pub enable_migrate: bool, - pub pool_migration_fee: u64, - pub creator_fee_basis_points: u64, - pub fee_recipients: [Pubkey; 8], - pub timestamp: i64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub set_creator_authority: Pubkey, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/types/trade_event.rs b/crates/pumpfun-parser/src/generated_sdk/types/trade_event.rs deleted file mode 100644 index 40aaab3e..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/trade_event.rs +++ /dev/null @@ -1,46 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TradeEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub sol_amount: u64, - pub token_amount: u64, - pub is_buy: bool, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub user: Pubkey, - pub timestamp: i64, - pub virtual_sol_reserves: u64, - pub virtual_token_reserves: u64, - pub real_sol_reserves: u64, - pub real_token_reserves: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_recipient: Pubkey, - pub fee_basis_points: u64, - pub fee: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - pub creator_fee_basis_points: u64, - pub creator_fee: u64, -} diff --git a/crates/pumpfun-parser/src/generated_sdk/types/update_global_authority_event.rs b/crates/pumpfun-parser/src/generated_sdk/types/update_global_authority_event.rs deleted file mode 100644 index d62488cf..00000000 --- a/crates/pumpfun-parser/src/generated_sdk/types/update_global_authority_event.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateGlobalAuthorityEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub global: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub authority: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub new_authority: Pubkey, - pub timestamp: i64, -} diff --git a/crates/pumpfun-parser/src/lib.rs b/crates/pumpfun-parser/src/lib.rs deleted file mode 100644 index faecf6d8..00000000 --- a/crates/pumpfun-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = PUMP_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.pumpfun"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/raydium-amm-v4-parser/Cargo.toml b/crates/raydium-amm-v4-parser/Cargo.toml deleted file mode 100644 index 5123a6f7..00000000 --- a/crates/raydium-amm-v4-parser/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "yellowstone-vixen-raydium-amm-v4-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Raydium AMM v4 program" -license.workspace = true -repository.workspace = true -authors.workspace = true - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info.workspace = true -solana-cpi.workspace = true -solana-decode-error.workspace = true -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction.workspace = true -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true \ No newline at end of file diff --git a/crates/raydium-amm-v4-parser/build.rs b/crates/raydium-amm-v4-parser/build.rs deleted file mode 100644 index 41cb8288..00000000 --- a/crates/raydium-amm-v4-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/raydium_amm_v4.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/raydium-amm-v4-parser/idl.json b/crates/raydium-amm-v4-parser/idl.json deleted file mode 100644 index ae5708d4..00000000 --- a/crates/raydium-amm-v4-parser/idl.json +++ /dev/null @@ -1,2317 +0,0 @@ -{ - "version": "0.3.0", - "name": "raydium_amm_v4", - "instructions": [ - { - "name": "initialize", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "lpMintAddress", - "isMut": true, - "isSigner": false - }, - { - "name": "coinMintAddress", - "isMut": false, - "isSigner": false - }, - { - "name": "pcMintAddress", - "isMut": false, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "poolWithdrawQueue", - "isMut": true, - "isSigner": false - }, - { - "name": "poolTargetOrdersAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "userLpTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolTempLpTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "serumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": false, - "isSigner": false - }, - { - "name": "userWallet", - "isMut": true, - "isSigner": true - } - ], - "args": [ - { - "name": "nonce", - "type": "u8" - }, - { - "name": "openTime", - "type": "u64" - } - ] - }, - { - "name": "initialize2", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "splAssociatedTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "lpMint", - "isMut": true, - "isSigner": false - }, - { - "name": "coinMint", - "isMut": false, - "isSigner": false - }, - { - "name": "pcMint", - "isMut": false, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolWithdrawQueue", - "isMut": true, - "isSigner": false - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "poolTempLp", - "isMut": true, - "isSigner": false - }, - { - "name": "serumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": false, - "isSigner": false - }, - { - "name": "userWallet", - "isMut": true, - "isSigner": true - }, - { - "name": "userTokenCoin", - "isMut": true, - "isSigner": false - }, - { - "name": "userTokenPc", - "isMut": true, - "isSigner": false - }, - { - "name": "userLpTokenAccount", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "nonce", - "type": "u8" - }, - { - "name": "openTime", - "type": "u64" - }, - { - "name": "initPcAmount", - "type": "u64" - }, - { - "name": "initCoinAmount", - "type": "u64" - } - ] - }, - { - "name": "monitorStep", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "clock", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolWithdrawQueue", - "isMut": true, - "isSigner": false - }, - { - "name": "serumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "serumCoinVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumPcVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumVaultSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "serumReqQ", - "isMut": true, - "isSigner": false - }, - { - "name": "serumEventQ", - "isMut": true, - "isSigner": false - }, - { - "name": "serumBids", - "isMut": true, - "isSigner": false - }, - { - "name": "serumAsks", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "planOrderLimit", - "type": "u16" - }, - { - "name": "placeOrderLimit", - "type": "u16" - }, - { - "name": "cancelOrderLimit", - "type": "u16" - } - ] - }, - { - "name": "deposit", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": false, - "isSigner": false - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "lpMintAddress", - "isMut": true, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": false, - "isSigner": false - }, - { - "name": "userCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "userPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "userLpTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "userOwner", - "isMut": false, - "isSigner": true - }, - { - "name": "serumEventQueue", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "maxCoinAmount", - "type": "u64" - }, - { - "name": "maxPcAmount", - "type": "u64" - }, - { - "name": "baseSide", - "type": "u64" - } - ] - }, - { - "name": "withdraw", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "lpMintAddress", - "isMut": true, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolWithdrawQueue", - "isMut": true, - "isSigner": false - }, - { - "name": "poolTempLpTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "serumCoinVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumPcVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumVaultSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "userLpTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "uerCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "uerPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "userOwner", - "isMut": false, - "isSigner": true - }, - { - "name": "serumEventQ", - "isMut": true, - "isSigner": false - }, - { - "name": "serumBids", - "isMut": true, - "isSigner": false - }, - { - "name": "serumAsks", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "migrateToOpenBook", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "ammTokenCoin", - "isMut": true, - "isSigner": false - }, - { - "name": "ammTokenPc", - "isMut": true, - "isSigner": false - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "serumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "serumBids", - "isMut": true, - "isSigner": false - }, - { - "name": "serumAsks", - "isMut": true, - "isSigner": false - }, - { - "name": "serumEventQueue", - "isMut": true, - "isSigner": false - }, - { - "name": "serumCoinVault", - "isMut": true, - "isSigner": false - }, - { - "name": "serumPcVault", - "isMut": true, - "isSigner": false - }, - { - "name": "serumVaultSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "newAmmOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "newSerumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "newSerumMarket", - "isMut": false, - "isSigner": false - }, - { - "name": "admin", - "isMut": true, - "isSigner": true - } - ], - "args": [] - }, - { - "name": "setParams", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "ammCoinVault", - "isMut": true, - "isSigner": false - }, - { - "name": "ammPcVault", - "isMut": true, - "isSigner": false - }, - { - "name": "serumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "serumCoinVault", - "isMut": true, - "isSigner": false - }, - { - "name": "serumPcVault", - "isMut": true, - "isSigner": false - }, - { - "name": "serumVaultSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "serumEventQueue", - "isMut": true, - "isSigner": false - }, - { - "name": "serumBids", - "isMut": true, - "isSigner": false - }, - { - "name": "serumAsks", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAdminAccount", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "param", - "type": "u8" - }, - { - "name": "value", - "type": { - "option": "u64" - } - }, - { - "name": "newPubkey", - "type": { - "option": "publicKey" - } - }, - { - "name": "fees", - "type": { - "option": { - "defined": "Fees" - } - } - }, - { - "name": "lastOrderDistance", - "type": { - "option": { - "defined": "LastOrderDistance" - } - } - }, - { - "name": "needTakeAmounts", - "type": { - "option": { - "defined": "NeedTake" - } - } - } - ] - }, - { - "name": "withdrawPnl", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": true, - "isSigner": false - }, - { - "name": "ammConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "coinPnlTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "pcPnlTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "pnlOwnerAccount", - "isMut": false, - "isSigner": true - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "serumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "serumEventQueue", - "isMut": false, - "isSigner": false - }, - { - "name": "serumCoinVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumPcVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumVaultSigner", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "withdrawSrm", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOwnerAccount", - "isMut": false, - "isSigner": true - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "srmToken", - "isMut": true, - "isSigner": false - }, - { - "name": "destSrmToken", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "swapBaseIn", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "serumBids", - "isMut": true, - "isSigner": false - }, - { - "name": "serumAsks", - "isMut": true, - "isSigner": false - }, - { - "name": "serumEventQueue", - "isMut": true, - "isSigner": false - }, - { - "name": "serumCoinVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumPcVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumVaultSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "uerSourceTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "uerDestinationTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "userSourceOwner", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "amountIn", - "type": "u64" - }, - { - "name": "minimumAmountOut", - "type": "u64" - } - ] - }, - { - "name": "preInitialize", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "poolWithdrawQueue", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "lpMintAddress", - "isMut": true, - "isSigner": false - }, - { - "name": "coinMintAddress", - "isMut": false, - "isSigner": false - }, - { - "name": "pcMintAddress", - "isMut": false, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolTempLpTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": false, - "isSigner": false - }, - { - "name": "userWallet", - "isMut": true, - "isSigner": true - } - ], - "args": [ - { - "name": "nonce", - "type": "u8" - } - ] - }, - { - "name": "swapBaseOut", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": true, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "serumBids", - "isMut": true, - "isSigner": false - }, - { - "name": "serumAsks", - "isMut": true, - "isSigner": false - }, - { - "name": "serumEventQueue", - "isMut": true, - "isSigner": false - }, - { - "name": "serumCoinVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumPcVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumVaultSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "uerSourceTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "uerDestinationTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "userSourceOwner", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "maxAmountIn", - "type": "u64" - }, - { - "name": "amountOut", - "type": "u64" - } - ] - }, - { - "name": "simulateInfo", - "accounts": [ - { - "name": "amm", - "isMut": false, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": false, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "lpMintAddress", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": false, - "isSigner": false - }, - { - "name": "serumEventQueue", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "param", - "type": "u8" - }, - { - "name": "swapBaseInValue", - "type": { - "option": { - "defined": "SwapInstructionBaseIn" - } - } - }, - { - "name": "swapBaseOutValue", - "type": { - "option": { - "defined": "SwapInstructionBaseOut" - } - } - } - ] - }, - { - "name": "adminCancelOrders", - "accounts": [ - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "amm", - "isMut": false, - "isSigner": false - }, - { - "name": "ammAuthority", - "isMut": false, - "isSigner": false - }, - { - "name": "ammOpenOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "ammTargetOrders", - "isMut": true, - "isSigner": false - }, - { - "name": "poolCoinTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolPcTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "ammOwnerAccount", - "isMut": false, - "isSigner": true - }, - { - "name": "ammConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "serumProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "serumMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "serumCoinVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumPcVaultAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "serumVaultSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "serumEventQ", - "isMut": true, - "isSigner": false - }, - { - "name": "serumBids", - "isMut": true, - "isSigner": false - }, - { - "name": "serumAsks", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "limit", - "type": "u16" - } - ] - }, - { - "name": "createConfigAccount", - "accounts": [ - { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "ammConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "owner", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "updateConfigAccount", - "accounts": [ - { - "name": "admin", - "isMut": false, - "isSigner": true - }, - { - "name": "ammConfig", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "param", - "type": "u8" - }, - { - "name": "owner", - "type": "publicKey" - } - ] - } - ], - "accounts": [ - { - "name": "TargetOrders", - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": { - "array": [ - "u64", - 4 - ] - } - }, - { - "name": "buyOrders", - "type": { - "array": [ - { - "defined": "TargetOrder" - }, - 50 - ] - } - }, - { - "name": "padding1", - "type": { - "array": [ - "u64", - 8 - ] - } - }, - { - "name": "targetX", - "type": "u128" - }, - { - "name": "targetY", - "type": "u128" - }, - { - "name": "planXBuy", - "type": "u128" - }, - { - "name": "planYBuy", - "type": "u128" - }, - { - "name": "planXSell", - "type": "u128" - }, - { - "name": "planYSell", - "type": "u128" - }, - { - "name": "placedX", - "type": "u128" - }, - { - "name": "placedY", - "type": "u128" - }, - { - "name": "calcPnlX", - "type": "u128" - }, - { - "name": "calcPnlY", - "type": "u128" - }, - { - "name": "sellOrders", - "type": { - "array": [ - { - "defined": "TargetOrder" - }, - 50 - ] - } - }, - { - "name": "padding2", - "type": { - "array": [ - "u64", - 6 - ] - } - }, - { - "name": "replaceBuyClientId", - "type": { - "array": [ - "u64", - 10 - ] - } - }, - { - "name": "replaceSellClientId", - "type": { - "array": [ - "u64", - 10 - ] - } - }, - { - "name": "lastOrderNumerator", - "type": "u64" - }, - { - "name": "lastOrderDenominator", - "type": "u64" - }, - { - "name": "planOrdersCur", - "type": "u64" - }, - { - "name": "placeOrdersCur", - "type": "u64" - }, - { - "name": "validBuyOrderNum", - "type": "u64" - }, - { - "name": "validSellOrderNum", - "type": "u64" - }, - { - "name": "padding3", - "type": { - "array": [ - "u64", - 10 - ] - } - }, - { - "name": "freeSlotBits", - "type": "u128" - } - ] - } - }, - { - "name": "Fees", - "type": { - "kind": "struct", - "fields": [ - { - "name": "minSeparateNumerator", - "type": "u64" - }, - { - "name": "minSeparateDenominator", - "type": "u64" - }, - { - "name": "tradeFeeNumerator", - "type": "u64" - }, - { - "name": "tradeFeeDenominator", - "type": "u64" - }, - { - "name": "pnlNumerator", - "type": "u64" - }, - { - "name": "pnlDenominator", - "type": "u64" - }, - { - "name": "swapFeeNumerator", - "type": "u64" - }, - { - "name": "swapFeeDenominator", - "type": "u64" - } - ] - } - }, - { - "name": "AmmInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "status", - "type": "u64" - }, - { - "name": "nonce", - "type": "u64" - }, - { - "name": "orderNum", - "type": "u64" - }, - { - "name": "depth", - "type": "u64" - }, - { - "name": "coinDecimals", - "type": "u64" - }, - { - "name": "pcDecimals", - "type": "u64" - }, - { - "name": "state", - "type": "u64" - }, - { - "name": "resetFlag", - "type": "u64" - }, - { - "name": "minSize", - "type": "u64" - }, - { - "name": "volMaxCutRatio", - "type": "u64" - }, - { - "name": "amountWave", - "type": "u64" - }, - { - "name": "coinLotSize", - "type": "u64" - }, - { - "name": "pcLotSize", - "type": "u64" - }, - { - "name": "minPriceMultiplier", - "type": "u64" - }, - { - "name": "maxPriceMultiplier", - "type": "u64" - }, - { - "name": "sysDecimalValue", - "type": "u64" - }, - { - "name": "fees", - "type": { - "defined": "Fees" - } - }, - { - "name": "outPut", - "type": { - "defined": "OutPutData" - } - }, - { - "name": "tokenCoin", - "type": "publicKey" - }, - { - "name": "tokenPc", - "type": "publicKey" - }, - { - "name": "coinMint", - "type": "publicKey" - }, - { - "name": "pcMint", - "type": "publicKey" - }, - { - "name": "lpMint", - "type": "publicKey" - }, - { - "name": "openOrders", - "type": "publicKey" - }, - { - "name": "market", - "type": "publicKey" - }, - { - "name": "serumDex", - "type": "publicKey" - }, - { - "name": "targetOrders", - "type": "publicKey" - }, - { - "name": "withdrawQueue", - "type": "publicKey" - }, - { - "name": "tokenTempLp", - "type": "publicKey" - }, - { - "name": "ammOwner", - "type": "publicKey" - }, - { - "name": "lpAmount", - "type": "u64" - }, - { - "name": "clientOrderId", - "type": "u64" - }, - { - "name": "padding", - "type": { - "array": [ - "u64", - 2 - ] - } - } - ] - } - } - ], - "types": [ - { - "name": "WithdrawDestToken", - "type": { - "kind": "struct", - "fields": [ - { - "name": "withdrawAmount", - "type": "u64" - }, - { - "name": "coinAmount", - "type": "u64" - }, - { - "name": "pcAmount", - "type": "u64" - }, - { - "name": "destTokenCoin", - "type": "publicKey" - }, - { - "name": "destTokenPc", - "type": "publicKey" - } - ] - } - }, - { - "name": "WithdrawQueue", - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": { - "array": [ - "u64", - 4 - ] - } - }, - { - "name": "head", - "type": "u64" - }, - { - "name": "count", - "type": "u64" - }, - { - "name": "buf", - "type": { - "array": [ - { - "defined": "WithdrawDestToken" - }, - 64 - ] - } - } - ] - } - }, - { - "name": "TargetOrder", - "type": { - "kind": "struct", - "fields": [ - { - "name": "price", - "type": "u64" - }, - { - "name": "vol", - "type": "u64" - } - ] - } - }, - { - "name": "OutPutData", - "type": { - "kind": "struct", - "fields": [ - { - "name": "needTakePnlCoin", - "type": "u64" - }, - { - "name": "needTakePnlPc", - "type": "u64" - }, - { - "name": "totalPnlPc", - "type": "u64" - }, - { - "name": "totalPnlCoin", - "type": "u64" - }, - { - "name": "poolOpenTime", - "type": "u64" - }, - { - "name": "punishPcAmount", - "type": "u64" - }, - { - "name": "punishCoinAmount", - "type": "u64" - }, - { - "name": "orderbookToInitTime", - "type": "u64" - }, - { - "name": "swapCoinInAmount", - "type": "u128" - }, - { - "name": "swapPcOutAmount", - "type": "u128" - }, - { - "name": "swapTakePcFee", - "type": "u64" - }, - { - "name": "swapPcInAmount", - "type": "u128" - }, - { - "name": "swapCoinOutAmount", - "type": "u128" - }, - { - "name": "swapTakeCoinFee", - "type": "u64" - } - ] - } - }, - { - "name": "AmmConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pnlOwner", - "type": "publicKey" - }, - { - "name": "cancelOwner", - "type": "publicKey" - }, - { - "name": "pending1", - "type": { - "array": [ - "u64", - 28 - ] - } - }, - { - "name": "pending2", - "type": { - "array": [ - "u64", - 32 - ] - } - } - ] - } - }, - { - "name": "LastOrderDistance", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lastOrderNumerator", - "type": "u64" - }, - { - "name": "lastOrderDenominator", - "type": "u64" - } - ] - } - }, - { - "name": "NeedTake", - "type": { - "kind": "struct", - "fields": [ - { - "name": "needTakePc", - "type": "u64" - }, - { - "name": "needTakeCoin", - "type": "u64" - } - ] - } - }, - { - "name": "SwapInstructionBaseIn", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amountIn", - "type": "u64" - }, - { - "name": "minimumAmountOut", - "type": "u64" - } - ] - } - }, - { - "name": "SwapInstructionBaseOut", - "type": { - "kind": "struct", - "fields": [ - { - "name": "maxAmountIn", - "type": "u64" - }, - { - "name": "amountOut", - "type": "u64" - } - ] - } - } - ], - "errors": [ - { - "code": 0, - "name": "AlreadyInUse", - "msg": "AlreadyInUse" - }, - { - "code": 1, - "name": "InvalidProgramAddress", - "msg": "InvalidProgramAddress" - }, - { - "code": 2, - "name": "ExpectedMint", - "msg": "ExpectedMint" - }, - { - "code": 3, - "name": "ExpectedAccount", - "msg": "ExpectedAccount" - }, - { - "code": 4, - "name": "InvalidCoinVault", - "msg": "InvalidCoinVault" - }, - { - "code": 5, - "name": "InvalidPCVault", - "msg": "InvalidPCVault" - }, - { - "code": 6, - "name": "InvalidTokenLP", - "msg": "InvalidTokenLP" - }, - { - "code": 7, - "name": "InvalidDestTokenCoin", - "msg": "InvalidDestTokenCoin" - }, - { - "code": 8, - "name": "InvalidDestTokenPC", - "msg": "InvalidDestTokenPC" - }, - { - "code": 9, - "name": "InvalidPoolMint", - "msg": "InvalidPoolMint" - }, - { - "code": 10, - "name": "InvalidOpenOrders", - "msg": "InvalidOpenOrders" - }, - { - "code": 11, - "name": "InvalidSerumMarket", - "msg": "InvalidSerumMarket" - }, - { - "code": 12, - "name": "InvalidSerumProgram", - "msg": "InvalidSerumProgram" - }, - { - "code": 13, - "name": "InvalidTargetOrders", - "msg": "InvalidTargetOrders" - }, - { - "code": 14, - "name": "InvalidWithdrawQueue", - "msg": "InvalidWithdrawQueue" - }, - { - "code": 15, - "name": "InvalidTempLp", - "msg": "InvalidTempLp" - }, - { - "code": 16, - "name": "InvalidCoinMint", - "msg": "InvalidCoinMint" - }, - { - "code": 17, - "name": "InvalidPCMint", - "msg": "InvalidPCMint" - }, - { - "code": 18, - "name": "InvalidOwner", - "msg": "InvalidOwner" - }, - { - "code": 19, - "name": "InvalidSupply", - "msg": "InvalidSupply" - }, - { - "code": 20, - "name": "InvalidDelegate", - "msg": "InvalidDelegate" - }, - { - "code": 21, - "name": "InvalidSignAccount", - "msg": "Invalid Sign Account" - }, - { - "code": 22, - "name": "InvalidStatus", - "msg": "InvalidStatus" - }, - { - "code": 23, - "name": "InvalidInstruction", - "msg": "Invalid instruction" - }, - { - "code": 24, - "name": "WrongAccountsNumber", - "msg": "Wrong accounts number" - }, - { - "code": 25, - "name": "WithdrawTransferBusy", - "msg": "Withdraw_transfer is busy" - }, - { - "code": 26, - "name": "WithdrawQueueFull", - "msg": "WithdrawQueue is full" - }, - { - "code": 27, - "name": "WithdrawQueueEmpty", - "msg": "WithdrawQueue is empty" - }, - { - "code": 28, - "name": "InvalidParamsSet", - "msg": "Params Set is invalid" - }, - { - "code": 29, - "name": "InvalidInput", - "msg": "InvalidInput" - }, - { - "code": 30, - "name": "ExceededSlippage", - "msg": "instruction exceeds desired slippage limit" - }, - { - "code": 31, - "name": "CalculationExRateFailure", - "msg": "CalculationExRateFailure" - }, - { - "code": 32, - "name": "CheckedSubOverflow", - "msg": "Checked_Sub Overflow" - }, - { - "code": 33, - "name": "CheckedAddOverflow", - "msg": "Checked_Add Overflow" - }, - { - "code": 34, - "name": "CheckedMulOverflow", - "msg": "Checked_Mul Overflow" - }, - { - "code": 35, - "name": "CheckedDivOverflow", - "msg": "Checked_Div Overflow" - }, - { - "code": 36, - "name": "CheckedEmptyFunds", - "msg": "Empty Funds" - }, - { - "code": 37, - "name": "CalcPnlError", - "msg": "Calc pnl error" - }, - { - "code": 38, - "name": "InvalidSplTokenProgram", - "msg": "InvalidSplTokenProgram" - }, - { - "code": 39, - "name": "TakePnlError", - "msg": "Take Pnl error" - }, - { - "code": 40, - "name": "InsufficientFunds", - "msg": "Insufficient funds" - }, - { - "code": 41, - "name": "ConversionFailure", - "msg": "Conversion to u64 failed with an overflow or underflow" - }, - { - "code": 42, - "name": "InvalidUserToken", - "msg": "user token input does not match amm" - }, - { - "code": 43, - "name": "InvalidSrmMint", - "msg": "InvalidSrmMint" - }, - { - "code": 44, - "name": "InvalidSrmToken", - "msg": "InvalidSrmToken" - }, - { - "code": 45, - "name": "TooManyOpenOrders", - "msg": "TooManyOpenOrders" - }, - { - "code": 46, - "name": "OrderAtSlotIsPlaced", - "msg": "OrderAtSlotIsPlaced" - }, - { - "code": 47, - "name": "InvalidSysProgramAddress", - "msg": "InvalidSysProgramAddress" - }, - { - "code": 48, - "name": "InvalidFee", - "msg": "The provided fee does not match the program owner's constraints" - }, - { - "code": 49, - "name": "RepeatCreateAmm", - "msg": "Repeat create amm about market" - }, - { - "code": 50, - "name": "NotAllowZeroLP", - "msg": "Not allow Zero LP" - }, - { - "code": 51, - "name": "InvalidCloseAuthority", - "msg": "Token account has a close authority" - }, - { - "code": 52, - "name": "InvalidFreezeAuthority", - "msg": "Pool token mint has a freeze authority" - }, - { - "code": 53, - "name": "InvalidReferPCMint", - "msg": "InvalidReferPCMint" - }, - { - "code": 54, - "name": "InvalidConfigAccount", - "msg": "InvalidConfigAccount" - }, - { - "code": 55, - "name": "RepeatCreateConfigAccount", - "msg": "Repeat create staking config account" - }, - { - "code": 56, - "name": "UnknownAmmError", - "msg": "Unknown Amm Error" - } - ] -} \ No newline at end of file diff --git a/crates/raydium-amm-v4-parser/proto/raydium_amm_v4.proto b/crates/raydium-amm-v4-parser/proto/raydium_amm_v4.proto deleted file mode 100644 index b9a0bed2..00000000 --- a/crates/raydium-amm-v4-parser/proto/raydium_amm_v4.proto +++ /dev/null @@ -1,617 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.raydium_amm_v4; - -message InitializeIx { - InitializeIxAccounts accounts = 1; - InitializeIxData data = 2; -} - -message Initialize2Ix { - Initialize2IxAccounts accounts = 1; - Initialize2IxData data = 2; -} - -message MonitorStepIx { - MonitorStepIxAccounts accounts = 1; - MonitorStepIxData data = 2; -} - -message DepositIx { - DepositIxAccounts accounts = 1; - DepositIxData data = 2; -} - -message WithdrawIx { - WithdrawIxAccounts accounts = 1; - WithdrawIxData data = 2; -} - -message MigrateToOpenBookIx { - MigrateToOpenBookIxAccounts accounts = 1; -} - -message SetParamsIx { - SetParamsIxAccounts accounts = 1; - SetParamsIxData data = 2; -} - -message WithdrawPnlIx { - WithdrawPnlIxAccounts accounts = 1; -} - -message WithdrawSrmIx { - WithdrawSrmIxAccounts accounts = 1; - WithdrawSrmIxData data = 2; -} - -message SwapBaseInIx { - SwapBaseInIxAccounts accounts = 1; - SwapBaseInIxData data = 2; -} - -message PreInitializeIx { - PreInitializeIxAccounts accounts = 1; - PreInitializeIxData data = 2; -} - -message SwapBaseOutIx { - SwapBaseOutIxAccounts accounts = 1; - SwapBaseOutIxData data = 2; -} - -message SimulateInfoIx { - SimulateInfoIxAccounts accounts = 1; - SimulateInfoIxData data = 2; -} - -message AdminCancelOrdersIx { - AdminCancelOrdersIxAccounts accounts = 1; - AdminCancelOrdersIxData data = 2; -} - -message CreateConfigAccountIx { - CreateConfigAccountIxAccounts accounts = 1; -} - -message UpdateConfigAccountIx { - UpdateConfigAccountIxAccounts accounts = 1; - UpdateConfigAccountIxData data = 2; -} - - -message WithdrawDestToken { - uint64 withdraw_amount = 1; - uint64 coin_amount = 2; - uint64 pc_amount = 3; - string dest_token_coin = 4; - string dest_token_pc = 5; -} - -message WithdrawQueue { - repeated uint64 owner = 1; - uint64 head = 2; - uint64 count = 3; - repeated WithdrawDestToken buf = 4; -} - -message TargetOrder { - uint64 price = 1; - uint64 vol = 2; -} - -message OutPutData { - uint64 need_take_pnl_coin = 1; - uint64 need_take_pnl_pc = 2; - uint64 total_pnl_pc = 3; - uint64 total_pnl_coin = 4; - uint64 pool_open_time = 5; - uint64 punish_pc_amount = 6; - uint64 punish_coin_amount = 7; - uint64 orderbook_to_init_time = 8; - string swap_coin_in_amount = 9; - string swap_pc_out_amount = 10; - uint64 swap_take_pc_fee = 11; - string swap_pc_in_amount = 12; - string swap_coin_out_amount = 13; - uint64 swap_take_coin_fee = 14; -} - -message LastOrderDistance { - uint64 last_order_numerator = 1; - uint64 last_order_denominator = 2; -} - -message NeedTake { - uint64 need_take_pc = 1; - uint64 need_take_coin = 2; -} - -message SwapInstructionBaseIn { - uint64 amount_in = 1; - uint64 minimum_amount_out = 2; -} - -message SwapInstructionBaseOut { - uint64 max_amount_in = 1; - uint64 amount_out = 2; -} - -message Fees { - uint64 min_separate_numerator = 1; - uint64 min_separate_denominator = 2; - uint64 trade_fee_numerator = 3; - uint64 trade_fee_denominator = 4; - uint64 pnl_numerator = 5; - uint64 pnl_denominator = 6; - uint64 swap_fee_numerator = 7; - uint64 swap_fee_denominator = 8; -} - - -message TargetOrders { - repeated uint64 owner = 1; - repeated TargetOrder buy_orders = 2; - repeated uint64 padding1 = 3; - string target_x = 4; - string target_y = 5; - string plan_x_buy = 6; - string plan_y_buy = 7; - string plan_x_sell = 8; - string plan_y_sell = 9; - string placed_x = 10; - string placed_y = 11; - string calc_pnl_x = 12; - string calc_pnl_y = 13; - repeated TargetOrder sell_orders = 14; - repeated uint64 padding2 = 15; - repeated uint64 replace_buy_client_id = 16; - repeated uint64 replace_sell_client_id = 17; - uint64 last_order_numerator = 18; - uint64 last_order_denominator = 19; - uint64 plan_orders_cur = 20; - uint64 place_orders_cur = 21; - uint64 valid_buy_order_num = 22; - uint64 valid_sell_order_num = 23; - repeated uint64 padding3 = 24; - string free_slot_bits = 25; -} - -message AmmInfo { - uint64 status = 1; - uint64 nonce = 2; - uint64 order_num = 3; - uint64 depth = 4; - uint64 coin_decimals = 5; - uint64 pc_decimals = 6; - uint64 state = 7; - uint64 reset_flag = 8; - uint64 min_size = 9; - uint64 vol_max_cut_ratio = 10; - uint64 amount_wave = 11; - uint64 coin_lot_size = 12; - uint64 pc_lot_size = 13; - uint64 min_price_multiplier = 14; - uint64 max_price_multiplier = 15; - uint64 sys_decimal_value = 16; - Fees fees = 17; - OutPutData out_put = 18; - string token_coin = 19; - string token_pc = 20; - string coin_mint = 21; - string pc_mint = 22; - string lp_mint = 23; - string open_orders = 24; - string market = 25; - string serum_dex = 26; - string target_orders = 27; - string withdraw_queue = 28; - string token_temp_lp = 29; - string amm_owner = 30; - uint64 lp_amount = 31; - uint64 client_order_id = 32; - repeated uint64 padding = 33; -} - -message AmmConfig { - string pnl_owner = 1; - string cancel_owner = 2; - repeated uint64 pending1 = 3; - repeated uint64 pending2 = 4; - uint64 create_pool_fee = 5; -} - - -message InitializeIxAccounts { - string token_program = 1; - string system_program = 2; - string rent = 3; - string amm = 4; - string amm_authority = 5; - string amm_open_orders = 6; - string lp_mint_address = 7; - string coin_mint_address = 8; - string pc_mint_address = 9; - string pool_coin_token_account = 10; - string pool_pc_token_account = 11; - string pool_withdraw_queue = 12; - string pool_target_orders_account = 13; - string user_lp_token_account = 14; - string pool_temp_lp_token_account = 15; - string serum_program = 16; - string serum_market = 17; - string user_wallet = 18; -} - -message InitializeIxData { - uint32 nonce = 1; - uint64 open_time = 2; -} - -message Initialize2IxAccounts { - string token_program = 1; - string spl_associated_token_account = 2; - string system_program = 3; - string rent = 4; - string amm = 5; - string amm_authority = 6; - string amm_open_orders = 7; - string lp_mint = 8; - string coin_mint = 9; - string pc_mint = 10; - string pool_coin_token_account = 11; - string pool_pc_token_account = 12; - string pool_withdraw_queue = 13; - string amm_target_orders = 14; - string pool_temp_lp = 15; - string serum_program = 16; - string serum_market = 17; - string user_wallet = 18; - string user_token_coin = 19; - string user_token_pc = 20; - string user_lp_token_account = 21; -} - -message Initialize2IxData { - uint32 nonce = 1; - uint64 open_time = 2; - uint64 init_pc_amount = 3; - uint64 init_coin_amount = 4; -} - -message MonitorStepIxAccounts { - string token_program = 1; - string rent = 2; - string clock = 3; - string amm = 4; - string amm_authority = 5; - string amm_open_orders = 6; - string amm_target_orders = 7; - string pool_coin_token_account = 8; - string pool_pc_token_account = 9; - string pool_withdraw_queue = 10; - string serum_program = 11; - string serum_market = 12; - string serum_coin_vault_account = 13; - string serum_pc_vault_account = 14; - string serum_vault_signer = 15; - string serum_req_q = 16; - string serum_event_q = 17; - string serum_bids = 18; - string serum_asks = 19; -} - -message MonitorStepIxData { - uint32 plan_order_limit = 1; - uint32 place_order_limit = 2; - uint32 cancel_order_limit = 3; -} - -message DepositIxAccounts { - string token_program = 1; - string amm = 2; - string amm_authority = 3; - string amm_open_orders = 4; - string amm_target_orders = 5; - string lp_mint_address = 6; - string pool_coin_token_account = 7; - string pool_pc_token_account = 8; - string serum_market = 9; - string user_coin_token_account = 10; - string user_pc_token_account = 11; - string user_lp_token_account = 12; - string user_owner = 13; - string serum_event_queue = 14; -} - -message DepositIxData { - uint64 max_coin_amount = 1; - uint64 max_pc_amount = 2; - uint64 base_side = 3; -} - -message WithdrawIxAccounts { - string token_program = 1; - string amm = 2; - string amm_authority = 3; - string amm_open_orders = 4; - string amm_target_orders = 5; - string lp_mint_address = 6; - string pool_coin_token_account = 7; - string pool_pc_token_account = 8; - string pool_withdraw_queue = 9; - string pool_temp_lp_token_account = 10; - string serum_program = 11; - string serum_market = 12; - string serum_coin_vault_account = 13; - string serum_pc_vault_account = 14; - string serum_vault_signer = 15; - string user_lp_token_account = 16; - string uer_coin_token_account = 17; - string uer_pc_token_account = 18; - string user_owner = 19; - string serum_event_q = 20; - string serum_bids = 21; - string serum_asks = 22; -} - -message WithdrawIxData { - uint64 amount = 1; -} - -message MigrateToOpenBookIxAccounts { - string token_program = 1; - string system_program = 2; - string rent = 3; - string amm = 4; - string amm_authority = 5; - string amm_open_orders = 6; - string amm_token_coin = 7; - string amm_token_pc = 8; - string amm_target_orders = 9; - string serum_program = 10; - string serum_market = 11; - string serum_bids = 12; - string serum_asks = 13; - string serum_event_queue = 14; - string serum_coin_vault = 15; - string serum_pc_vault = 16; - string serum_vault_signer = 17; - string new_amm_open_orders = 18; - string new_serum_program = 19; - string new_serum_market = 20; - string admin = 21; -} - - -message SetParamsIxAccounts { - string token_program = 1; - string amm = 2; - string amm_authority = 3; - string amm_open_orders = 4; - string amm_target_orders = 5; - string amm_coin_vault = 6; - string amm_pc_vault = 7; - string serum_program = 8; - string serum_market = 9; - string serum_coin_vault = 10; - string serum_pc_vault = 11; - string serum_vault_signer = 12; - string serum_event_queue = 13; - string serum_bids = 14; - string serum_asks = 15; - string amm_admin_account = 16; -} - -message SetParamsIxData { - uint32 param = 1; - optional uint64 value = 2; - optional string new_pubkey = 3; - optional Fees fees = 4; - optional LastOrderDistance last_order_distance = 5; - optional NeedTake need_take_amounts = 6; -} - -message WithdrawPnlIxAccounts { - string token_program = 1; - string amm = 2; - string amm_config = 3; - string amm_authority = 4; - string amm_open_orders = 5; - string pool_coin_token_account = 6; - string pool_pc_token_account = 7; - string coin_pnl_token_account = 8; - string pc_pnl_token_account = 9; - string pnl_owner_account = 10; - string amm_target_orders = 11; - string serum_program = 12; - string serum_market = 13; - string serum_event_queue = 14; - string serum_coin_vault_account = 15; - string serum_pc_vault_account = 16; - string serum_vault_signer = 17; -} - - -message WithdrawSrmIxAccounts { - string token_program = 1; - string amm = 2; - string amm_owner_account = 3; - string amm_authority = 4; - string srm_token = 5; - string dest_srm_token = 6; -} - -message WithdrawSrmIxData { - uint64 amount = 1; -} - -message SwapBaseInIxAccounts { - string token_program = 1; - string amm = 2; - string amm_authority = 3; - string amm_open_orders = 4; - optional string amm_target_orders = 5; - string pool_coin_token_account = 6; - string pool_pc_token_account = 7; - string serum_program = 8; - string serum_market = 9; - string serum_bids = 10; - string serum_asks = 11; - string serum_event_queue = 12; - string serum_coin_vault_account = 13; - string serum_pc_vault_account = 14; - string serum_vault_signer = 15; - string uer_source_token_account = 16; - string uer_destination_token_account = 17; - string user_source_owner = 18; -} - -message SwapBaseInIxData { - uint64 amount_in = 1; - uint64 minimum_amount_out = 2; -} - -message PreInitializeIxAccounts { - string token_program = 1; - string system_program = 2; - string rent = 3; - string amm_target_orders = 4; - string pool_withdraw_queue = 5; - string amm_authority = 6; - string lp_mint_address = 7; - string coin_mint_address = 8; - string pc_mint_address = 9; - string pool_coin_token_account = 10; - string pool_pc_token_account = 11; - string pool_temp_lp_token_account = 12; - string serum_market = 13; - string user_wallet = 14; -} - -message PreInitializeIxData { - uint32 nonce = 1; -} - -message SwapBaseOutIxAccounts { - string token_program = 1; - string amm = 2; - string amm_authority = 3; - string amm_open_orders = 4; - optional string amm_target_orders = 5; - string pool_coin_token_account = 6; - string pool_pc_token_account = 7; - string serum_program = 8; - string serum_market = 9; - string serum_bids = 10; - string serum_asks = 11; - string serum_event_queue = 12; - string serum_coin_vault_account = 13; - string serum_pc_vault_account = 14; - string serum_vault_signer = 15; - string uer_source_token_account = 16; - string uer_destination_token_account = 17; - string user_source_owner = 18; -} - -message SwapBaseOutIxData { - uint64 max_amount_in = 1; - uint64 amount_out = 2; -} - -message SimulateInfoIxAccounts { - string amm = 1; - string amm_authority = 2; - string amm_open_orders = 3; - string pool_coin_token_account = 4; - string pool_pc_token_account = 5; - string lp_mint_address = 6; - string serum_market = 7; - string serum_event_queue = 8; -} - -message SimulateInfoIxData { - uint32 param = 1; - optional SwapInstructionBaseIn swap_base_in_value = 2; - optional SwapInstructionBaseOut swap_base_out_value = 3; -} - -message AdminCancelOrdersIxAccounts { - string token_program = 1; - string amm = 2; - string amm_authority = 3; - string amm_open_orders = 4; - string amm_target_orders = 5; - string pool_coin_token_account = 6; - string pool_pc_token_account = 7; - string amm_owner_account = 8; - string amm_config = 9; - string serum_program = 10; - string serum_market = 11; - string serum_coin_vault_account = 12; - string serum_pc_vault_account = 13; - string serum_vault_signer = 14; - string serum_event_q = 15; - string serum_bids = 16; - string serum_asks = 17; -} - -message AdminCancelOrdersIxData { - uint32 limit = 1; -} - -message CreateConfigAccountIxAccounts { - string admin = 1; - string amm_config = 2; - string owner = 3; - string system_program = 4; - string rent = 5; -} - - -message UpdateConfigAccountIxAccounts { - string admin = 1; - string amm_config = 2; -} - -message UpdateConfigAccountIxData { - uint32 param = 1; - string owner = 2; -} - - -message ProgramState { - oneof state_oneof { - TargetOrders target_orders = 1; - AmmInfo amm_info = 2; - AmmConfig amm_config = 3; - } -} - -message ProgramIxs { - oneof ix_oneof { - InitializeIx initialize = 1; - Initialize2Ix initialize2 = 2; - MonitorStepIx monitor_step = 3; - DepositIx deposit = 4; - WithdrawIx withdraw = 5; - MigrateToOpenBookIx migrate_to_open_book = 6; - SetParamsIx set_params = 7; - WithdrawPnlIx withdraw_pnl = 8; - WithdrawSrmIx withdraw_srm = 9; - SwapBaseInIx swap_base_in = 10; - PreInitializeIx pre_initialize = 11; - SwapBaseOutIx swap_base_out = 12; - SimulateInfoIx simulate_info = 13; - AdminCancelOrdersIx admin_cancel_orders = 14; - CreateConfigAccountIx create_config_account = 15; - UpdateConfigAccountIx update_config_account = 16; - } -} - diff --git a/crates/raydium-amm-v4-parser/src/generated_parser/accounts_parser.rs b/crates/raydium-amm-v4-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index a339c5dc..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,245 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{AmmConfig, AmmInfo, TargetOrders}, - deserialize_checked, ID, -}; - -/// RaydiumAmmV4 Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum RaydiumAmmV4ProgramState { - TargetOrders(TargetOrders), - AmmInfo(AmmInfo), - AmmConfig(AmmConfig), -} - -impl RaydiumAmmV4ProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let data_len = data_bytes.len(); - const TARGETORDERS_LEN: usize = std::mem::size_of::(); - const AMMINFO_LEN: usize = std::mem::size_of::(); - const AMMCONFIG_LEN: usize = std::mem::size_of::(); - - let acc = match data_len { - TARGETORDERS_LEN => Ok(RaydiumAmmV4ProgramState::TargetOrders(deserialize_checked( - data_bytes, - &data_len.to_le_bytes(), - )?)), - AMMINFO_LEN => Ok(RaydiumAmmV4ProgramState::AmmInfo(deserialize_checked( - data_bytes, - &data_len.to_le_bytes(), - )?)), - AMMCONFIG_LEN => Ok(RaydiumAmmV4ProgramState::AmmConfig(deserialize_checked( - data_bytes, - &data_len.to_le_bytes(), - )?)), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account data length".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - data_len = ?data_len, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = RaydiumAmmV4ProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "raydium_amm_v4::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = RaydiumAmmV4ProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let data_len = inner.data.len(); - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - data_len = ?data_len, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, RaydiumAmmV4ProgramState, TargetOrders}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for TargetOrders { - fn into_proto(self) -> proto_def::TargetOrders { - proto_def::TargetOrders { - owner: self.owner.to_vec(), - buy_orders: self - .buy_orders - .into_iter() - .map(|x| x.into_proto()) - .collect(), - padding1: self.padding1.to_vec(), - target_x: self.target_x.to_string(), - target_y: self.target_y.to_string(), - plan_x_buy: self.plan_x_buy.to_string(), - plan_y_buy: self.plan_y_buy.to_string(), - plan_x_sell: self.plan_x_sell.to_string(), - plan_y_sell: self.plan_y_sell.to_string(), - placed_x: self.placed_x.to_string(), - placed_y: self.placed_y.to_string(), - calc_pnl_x: self.calc_pnl_x.to_string(), - calc_pnl_y: self.calc_pnl_y.to_string(), - sell_orders: self - .sell_orders - .into_iter() - .map(|x| x.into_proto()) - .collect(), - padding2: self.padding2.to_vec(), - replace_buy_client_id: self.replace_buy_client_id.to_vec(), - replace_sell_client_id: self.replace_sell_client_id.to_vec(), - last_order_numerator: self.last_order_numerator, - last_order_denominator: self.last_order_denominator, - plan_orders_cur: self.plan_orders_cur, - place_orders_cur: self.place_orders_cur, - valid_buy_order_num: self.valid_buy_order_num, - valid_sell_order_num: self.valid_sell_order_num, - padding3: self.padding3.to_vec(), - free_slot_bits: self.free_slot_bits.to_string(), - } - } - } - use super::AmmInfo; - impl IntoProto for AmmInfo { - fn into_proto(self) -> proto_def::AmmInfo { - proto_def::AmmInfo { - status: self.status, - nonce: self.nonce, - order_num: self.order_num, - depth: self.depth, - coin_decimals: self.coin_decimals, - pc_decimals: self.pc_decimals, - state: self.state, - reset_flag: self.reset_flag, - min_size: self.min_size, - vol_max_cut_ratio: self.vol_max_cut_ratio, - amount_wave: self.amount_wave, - coin_lot_size: self.coin_lot_size, - pc_lot_size: self.pc_lot_size, - min_price_multiplier: self.min_price_multiplier, - max_price_multiplier: self.max_price_multiplier, - sys_decimal_value: self.sys_decimal_value, - fees: Some(self.fees.into_proto()), - out_put: Some(self.out_put.into_proto()), - token_coin: self.token_coin.to_string(), - token_pc: self.token_pc.to_string(), - coin_mint: self.coin_mint.to_string(), - pc_mint: self.pc_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - open_orders: self.open_orders.to_string(), - market: self.market.to_string(), - serum_dex: self.serum_dex.to_string(), - target_orders: self.target_orders.to_string(), - withdraw_queue: self.withdraw_queue.to_string(), - token_temp_lp: self.token_temp_lp.to_string(), - amm_owner: self.amm_owner.to_string(), - lp_amount: self.lp_amount, - client_order_id: self.client_order_id, - padding: self.padding.to_vec(), - } - } - } - use super::AmmConfig; - impl IntoProto for AmmConfig { - fn into_proto(self) -> proto_def::AmmConfig { - proto_def::AmmConfig { - pnl_owner: self.pnl_owner.to_string(), - cancel_owner: self.cancel_owner.to_string(), - pending1: self.pending1.to_vec(), - pending2: self.pending2.to_vec(), - create_pool_fee: self.create_pool_fee, - } - } - } - - impl IntoProto for RaydiumAmmV4ProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - RaydiumAmmV4ProgramState::TargetOrders(data) => { - proto_def::program_state::StateOneof::TargetOrders(data.into_proto()) - }, - RaydiumAmmV4ProgramState::AmmInfo(data) => { - proto_def::program_state::StateOneof::AmmInfo(data.into_proto()) - }, - RaydiumAmmV4ProgramState::AmmConfig(data) => { - proto_def::program_state::StateOneof::AmmConfig(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/raydium-amm-v4-parser/src/generated_parser/instructions_parser.rs b/crates/raydium-amm-v4-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index d5244fea..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,1225 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - AdminCancelOrders as AdminCancelOrdersIxAccounts, - AdminCancelOrdersInstructionArgs as AdminCancelOrdersIxData, - CreateConfigAccount as CreateConfigAccountIxAccounts, Deposit as DepositIxAccounts, - DepositInstructionArgs as DepositIxData, Initialize as InitializeIxAccounts, - Initialize2 as Initialize2IxAccounts, Initialize2InstructionArgs as Initialize2IxData, - InitializeInstructionArgs as InitializeIxData, - MigrateToOpenBook as MigrateToOpenBookIxAccounts, MonitorStep as MonitorStepIxAccounts, - MonitorStepInstructionArgs as MonitorStepIxData, PreInitialize as PreInitializeIxAccounts, - PreInitializeInstructionArgs as PreInitializeIxData, SetParams as SetParamsIxAccounts, - SetParamsInstructionArgs as SetParamsIxData, SimulateInfo as SimulateInfoIxAccounts, - SimulateInfoInstructionArgs as SimulateInfoIxData, SwapBaseIn as SwapBaseInIxAccounts, - SwapBaseInInstructionArgs as SwapBaseInIxData, SwapBaseOut as SwapBaseOutIxAccounts, - SwapBaseOutInstructionArgs as SwapBaseOutIxData, - UpdateConfigAccount as UpdateConfigAccountIxAccounts, - UpdateConfigAccountInstructionArgs as UpdateConfigAccountIxData, - Withdraw as WithdrawIxAccounts, WithdrawInstructionArgs as WithdrawIxData, - WithdrawPnl as WithdrawPnlIxAccounts, WithdrawSrm as WithdrawSrmIxAccounts, - WithdrawSrmInstructionArgs as WithdrawSrmIxData, - }, - ID, -}; - -/// RaydiumAmmV4 Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum RaydiumAmmV4ProgramIx { - Initialize(InitializeIxAccounts, InitializeIxData), - Initialize2(Initialize2IxAccounts, Initialize2IxData), - MonitorStep(MonitorStepIxAccounts, MonitorStepIxData), - Deposit(DepositIxAccounts, DepositIxData), - Withdraw(WithdrawIxAccounts, WithdrawIxData), - MigrateToOpenBook(MigrateToOpenBookIxAccounts), - SetParams(SetParamsIxAccounts, SetParamsIxData), - WithdrawPnl(WithdrawPnlIxAccounts), - WithdrawSrm(WithdrawSrmIxAccounts, WithdrawSrmIxData), - SwapBaseIn(SwapBaseInIxAccounts, SwapBaseInIxData), - PreInitialize(PreInitializeIxAccounts, PreInitializeIxData), - SwapBaseOut(SwapBaseOutIxAccounts, SwapBaseOutIxData), - SimulateInfo(SimulateInfoIxAccounts, SimulateInfoIxData), - AdminCancelOrders(AdminCancelOrdersIxAccounts, AdminCancelOrdersIxData), - CreateConfigAccount(CreateConfigAccountIxAccounts), - UpdateConfigAccount(UpdateConfigAccountIxAccounts, UpdateConfigAccountIxData), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = RaydiumAmmV4ProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "RaydiumAmmV4::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 1] = ix_update.data[0..1].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 1] = ix.data[0..1].try_into()?; - let ix_data = &ix.data[1..]; - let ix = match ix_discriminator { - [0] => { - let expected_accounts_len = 18; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeIxAccounts { - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - lp_mint_address: next_account(accounts)?, - coin_mint_address: next_account(accounts)?, - pc_mint_address: next_account(accounts)?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - pool_withdraw_queue: next_account(accounts)?, - pool_target_orders_account: next_account(accounts)?, - user_lp_token_account: next_account(accounts)?, - pool_temp_lp_token_account: next_account(accounts)?, - serum_program: next_account(accounts)?, - serum_market: next_account(accounts)?, - user_wallet: next_account(accounts)?, - }; - let de_ix_data: InitializeIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::Initialize(ix_accounts, de_ix_data)) - }, - [1] => { - let expected_accounts_len = 21; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = Initialize2IxAccounts { - token_program: next_account(accounts)?, - spl_associated_token_account: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - lp_mint: next_account(accounts)?, - coin_mint: next_account(accounts)?, - pc_mint: next_account(accounts)?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - pool_withdraw_queue: next_account(accounts)?, - amm_target_orders: next_account(accounts)?, - pool_temp_lp: next_account(accounts)?, - serum_program: next_account(accounts)?, - serum_market: next_account(accounts)?, - user_wallet: next_account(accounts)?, - user_token_coin: next_account(accounts)?, - user_token_pc: next_account(accounts)?, - user_lp_token_account: next_account(accounts)?, - }; - let de_ix_data: Initialize2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::Initialize2(ix_accounts, de_ix_data)) - }, - [2] => { - let expected_accounts_len = 19; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MonitorStepIxAccounts { - token_program: next_account(accounts)?, - rent: next_account(accounts)?, - clock: next_account(accounts)?, - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - amm_target_orders: next_account(accounts)?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - pool_withdraw_queue: next_account(accounts)?, - serum_program: next_account(accounts)?, - serum_market: next_account(accounts)?, - serum_coin_vault_account: next_account(accounts)?, - serum_pc_vault_account: next_account(accounts)?, - serum_vault_signer: next_account(accounts)?, - serum_req_q: next_account(accounts)?, - serum_event_q: next_account(accounts)?, - serum_bids: next_account(accounts)?, - serum_asks: next_account(accounts)?, - }; - let de_ix_data: MonitorStepIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::MonitorStep(ix_accounts, de_ix_data)) - }, - [3] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DepositIxAccounts { - token_program: next_account(accounts)?, - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - amm_target_orders: next_account(accounts)?, - lp_mint_address: next_account(accounts)?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - serum_market: next_account(accounts)?, - user_coin_token_account: next_account(accounts)?, - user_pc_token_account: next_account(accounts)?, - user_lp_token_account: next_account(accounts)?, - user_owner: next_account(accounts)?, - serum_event_queue: next_account(accounts)?, - }; - let de_ix_data: DepositIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::Deposit(ix_accounts, de_ix_data)) - }, - [4] => { - let expected_accounts_len = 22; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawIxAccounts { - token_program: next_account(accounts)?, - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - amm_target_orders: next_account(accounts)?, - lp_mint_address: next_account(accounts)?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - pool_withdraw_queue: next_account(accounts)?, - pool_temp_lp_token_account: next_account(accounts)?, - serum_program: next_account(accounts)?, - serum_market: next_account(accounts)?, - serum_coin_vault_account: next_account(accounts)?, - serum_pc_vault_account: next_account(accounts)?, - serum_vault_signer: next_account(accounts)?, - user_lp_token_account: next_account(accounts)?, - uer_coin_token_account: next_account(accounts)?, - uer_pc_token_account: next_account(accounts)?, - user_owner: next_account(accounts)?, - serum_event_q: next_account(accounts)?, - serum_bids: next_account(accounts)?, - serum_asks: next_account(accounts)?, - }; - let de_ix_data: WithdrawIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::Withdraw(ix_accounts, de_ix_data)) - }, - [5] => { - let expected_accounts_len = 21; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrateToOpenBookIxAccounts { - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - amm_token_coin: next_account(accounts)?, - amm_token_pc: next_account(accounts)?, - amm_target_orders: next_account(accounts)?, - serum_program: next_account(accounts)?, - serum_market: next_account(accounts)?, - serum_bids: next_account(accounts)?, - serum_asks: next_account(accounts)?, - serum_event_queue: next_account(accounts)?, - serum_coin_vault: next_account(accounts)?, - serum_pc_vault: next_account(accounts)?, - serum_vault_signer: next_account(accounts)?, - new_amm_open_orders: next_account(accounts)?, - new_serum_program: next_account(accounts)?, - new_serum_market: next_account(accounts)?, - admin: next_account(accounts)?, - }; - Ok(RaydiumAmmV4ProgramIx::MigrateToOpenBook(ix_accounts)) - }, - [6] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetParamsIxAccounts { - token_program: next_account(accounts)?, - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - amm_target_orders: next_account(accounts)?, - amm_coin_vault: next_account(accounts)?, - amm_pc_vault: next_account(accounts)?, - serum_program: next_account(accounts)?, - serum_market: next_account(accounts)?, - serum_coin_vault: next_account(accounts)?, - serum_pc_vault: next_account(accounts)?, - serum_vault_signer: next_account(accounts)?, - serum_event_queue: next_account(accounts)?, - serum_bids: next_account(accounts)?, - serum_asks: next_account(accounts)?, - amm_admin_account: next_account(accounts)?, - }; - let de_ix_data: SetParamsIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::SetParams(ix_accounts, de_ix_data)) - }, - [7] => { - let expected_accounts_len = 17; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawPnlIxAccounts { - token_program: next_account(accounts)?, - amm: next_account(accounts)?, - amm_config: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - coin_pnl_token_account: next_account(accounts)?, - pc_pnl_token_account: next_account(accounts)?, - pnl_owner_account: next_account(accounts)?, - amm_target_orders: next_account(accounts)?, - serum_program: next_account(accounts)?, - serum_market: next_account(accounts)?, - serum_event_queue: next_account(accounts)?, - serum_coin_vault_account: next_account(accounts)?, - serum_pc_vault_account: next_account(accounts)?, - serum_vault_signer: next_account(accounts)?, - }; - Ok(RaydiumAmmV4ProgramIx::WithdrawPnl(ix_accounts)) - }, - [8] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawSrmIxAccounts { - token_program: next_account(accounts)?, - amm: next_account(accounts)?, - amm_owner_account: next_account(accounts)?, - amm_authority: next_account(accounts)?, - srm_token: next_account(accounts)?, - dest_srm_token: next_account(accounts)?, - }; - let de_ix_data: WithdrawSrmIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::WithdrawSrm(ix_accounts, de_ix_data)) - }, - [9] => { - let mut expected_accounts_len = 17; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapBaseInIxAccounts { - token_program: next_account(accounts)?, - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - amm_target_orders: next_optional_account( - accounts, - accounts_len, - &mut expected_accounts_len, - )?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - serum_program: next_account(accounts)?, - serum_market: next_account(accounts)?, - serum_bids: next_account(accounts)?, - serum_asks: next_account(accounts)?, - serum_event_queue: next_account(accounts)?, - serum_coin_vault_account: next_account(accounts)?, - serum_pc_vault_account: next_account(accounts)?, - serum_vault_signer: next_account(accounts)?, - uer_source_token_account: next_account(accounts)?, - uer_destination_token_account: next_account(accounts)?, - user_source_owner: next_account(accounts)?, - }; - let de_ix_data: SwapBaseInIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::SwapBaseIn(ix_accounts, de_ix_data)) - }, - [10] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = PreInitializeIxAccounts { - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - amm_target_orders: next_account(accounts)?, - pool_withdraw_queue: next_account(accounts)?, - amm_authority: next_account(accounts)?, - lp_mint_address: next_account(accounts)?, - coin_mint_address: next_account(accounts)?, - pc_mint_address: next_account(accounts)?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - pool_temp_lp_token_account: next_account(accounts)?, - serum_market: next_account(accounts)?, - user_wallet: next_account(accounts)?, - }; - let de_ix_data: PreInitializeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::PreInitialize( - ix_accounts, - de_ix_data, - )) - }, - [11] => { - let mut expected_accounts_len = 17; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapBaseOutIxAccounts { - token_program: next_account(accounts)?, - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - amm_target_orders: next_optional_account( - accounts, - accounts_len, - &mut expected_accounts_len, - )?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - serum_program: next_account(accounts)?, - serum_market: next_account(accounts)?, - serum_bids: next_account(accounts)?, - serum_asks: next_account(accounts)?, - serum_event_queue: next_account(accounts)?, - serum_coin_vault_account: next_account(accounts)?, - serum_pc_vault_account: next_account(accounts)?, - serum_vault_signer: next_account(accounts)?, - uer_source_token_account: next_account(accounts)?, - uer_destination_token_account: next_account(accounts)?, - user_source_owner: next_account(accounts)?, - }; - let de_ix_data: SwapBaseOutIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::SwapBaseOut(ix_accounts, de_ix_data)) - }, - [12] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SimulateInfoIxAccounts { - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - lp_mint_address: next_account(accounts)?, - serum_market: next_account(accounts)?, - serum_event_queue: next_account(accounts)?, - }; - let de_ix_data: SimulateInfoIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::SimulateInfo(ix_accounts, de_ix_data)) - }, - [13] => { - let expected_accounts_len = 17; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = AdminCancelOrdersIxAccounts { - token_program: next_account(accounts)?, - amm: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - amm_target_orders: next_account(accounts)?, - pool_coin_token_account: next_account(accounts)?, - pool_pc_token_account: next_account(accounts)?, - amm_owner_account: next_account(accounts)?, - amm_config: next_account(accounts)?, - serum_program: next_account(accounts)?, - serum_market: next_account(accounts)?, - serum_coin_vault_account: next_account(accounts)?, - serum_pc_vault_account: next_account(accounts)?, - serum_vault_signer: next_account(accounts)?, - serum_event_q: next_account(accounts)?, - serum_bids: next_account(accounts)?, - serum_asks: next_account(accounts)?, - }; - let de_ix_data: AdminCancelOrdersIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::AdminCancelOrders( - ix_accounts, - de_ix_data, - )) - }, - [14] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateConfigAccountIxAccounts { - admin: next_account(accounts)?, - amm_config: next_account(accounts)?, - owner: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - Ok(RaydiumAmmV4ProgramIx::CreateConfigAccount(ix_accounts)) - }, - [15] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateConfigAccountIxAccounts { - admin: next_account(accounts)?, - amm_config: next_account(accounts)?, - }; - let de_ix_data: UpdateConfigAccountIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumAmmV4ProgramIx::UpdateConfigAccount( - ix_accounts, - de_ix_data, - )) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{InitializeIxAccounts, InstructionParser, RaydiumAmmV4ProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for InitializeIxAccounts { - fn into_proto(self) -> proto_def::InitializeIxAccounts { - proto_def::InitializeIxAccounts { - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - lp_mint_address: self.lp_mint_address.to_string(), - coin_mint_address: self.coin_mint_address.to_string(), - pc_mint_address: self.pc_mint_address.to_string(), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - pool_withdraw_queue: self.pool_withdraw_queue.to_string(), - pool_target_orders_account: self.pool_target_orders_account.to_string(), - user_lp_token_account: self.user_lp_token_account.to_string(), - pool_temp_lp_token_account: self.pool_temp_lp_token_account.to_string(), - serum_program: self.serum_program.to_string(), - serum_market: self.serum_market.to_string(), - user_wallet: self.user_wallet.to_string(), - } - } - } - use super::InitializeIxData; - impl IntoProto for InitializeIxData { - fn into_proto(self) -> proto_def::InitializeIxData { - proto_def::InitializeIxData { - nonce: self.nonce.into(), - open_time: self.open_time, - } - } - } - use super::Initialize2IxAccounts; - impl IntoProto for Initialize2IxAccounts { - fn into_proto(self) -> proto_def::Initialize2IxAccounts { - proto_def::Initialize2IxAccounts { - token_program: self.token_program.to_string(), - spl_associated_token_account: self.spl_associated_token_account.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - lp_mint: self.lp_mint.to_string(), - coin_mint: self.coin_mint.to_string(), - pc_mint: self.pc_mint.to_string(), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - pool_withdraw_queue: self.pool_withdraw_queue.to_string(), - amm_target_orders: self.amm_target_orders.to_string(), - pool_temp_lp: self.pool_temp_lp.to_string(), - serum_program: self.serum_program.to_string(), - serum_market: self.serum_market.to_string(), - user_wallet: self.user_wallet.to_string(), - user_token_coin: self.user_token_coin.to_string(), - user_token_pc: self.user_token_pc.to_string(), - user_lp_token_account: self.user_lp_token_account.to_string(), - } - } - } - use super::Initialize2IxData; - impl IntoProto for Initialize2IxData { - fn into_proto(self) -> proto_def::Initialize2IxData { - proto_def::Initialize2IxData { - nonce: self.nonce.into(), - open_time: self.open_time, - init_pc_amount: self.init_pc_amount, - init_coin_amount: self.init_coin_amount, - } - } - } - use super::MonitorStepIxAccounts; - impl IntoProto for MonitorStepIxAccounts { - fn into_proto(self) -> proto_def::MonitorStepIxAccounts { - proto_def::MonitorStepIxAccounts { - token_program: self.token_program.to_string(), - rent: self.rent.to_string(), - clock: self.clock.to_string(), - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - amm_target_orders: self.amm_target_orders.to_string(), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - pool_withdraw_queue: self.pool_withdraw_queue.to_string(), - serum_program: self.serum_program.to_string(), - serum_market: self.serum_market.to_string(), - serum_coin_vault_account: self.serum_coin_vault_account.to_string(), - serum_pc_vault_account: self.serum_pc_vault_account.to_string(), - serum_vault_signer: self.serum_vault_signer.to_string(), - serum_req_q: self.serum_req_q.to_string(), - serum_event_q: self.serum_event_q.to_string(), - serum_bids: self.serum_bids.to_string(), - serum_asks: self.serum_asks.to_string(), - } - } - } - use super::MonitorStepIxData; - impl IntoProto for MonitorStepIxData { - fn into_proto(self) -> proto_def::MonitorStepIxData { - proto_def::MonitorStepIxData { - plan_order_limit: self.plan_order_limit.into(), - place_order_limit: self.place_order_limit.into(), - cancel_order_limit: self.cancel_order_limit.into(), - } - } - } - use super::DepositIxAccounts; - impl IntoProto for DepositIxAccounts { - fn into_proto(self) -> proto_def::DepositIxAccounts { - proto_def::DepositIxAccounts { - token_program: self.token_program.to_string(), - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - amm_target_orders: self.amm_target_orders.to_string(), - lp_mint_address: self.lp_mint_address.to_string(), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - serum_market: self.serum_market.to_string(), - user_coin_token_account: self.user_coin_token_account.to_string(), - user_pc_token_account: self.user_pc_token_account.to_string(), - user_lp_token_account: self.user_lp_token_account.to_string(), - user_owner: self.user_owner.to_string(), - serum_event_queue: self.serum_event_queue.to_string(), - } - } - } - use super::DepositIxData; - impl IntoProto for DepositIxData { - fn into_proto(self) -> proto_def::DepositIxData { - proto_def::DepositIxData { - max_coin_amount: self.max_coin_amount, - max_pc_amount: self.max_pc_amount, - base_side: self.base_side, - } - } - } - use super::WithdrawIxAccounts; - impl IntoProto for WithdrawIxAccounts { - fn into_proto(self) -> proto_def::WithdrawIxAccounts { - proto_def::WithdrawIxAccounts { - token_program: self.token_program.to_string(), - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - amm_target_orders: self.amm_target_orders.to_string(), - lp_mint_address: self.lp_mint_address.to_string(), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - pool_withdraw_queue: self.pool_withdraw_queue.to_string(), - pool_temp_lp_token_account: self.pool_temp_lp_token_account.to_string(), - serum_program: self.serum_program.to_string(), - serum_market: self.serum_market.to_string(), - serum_coin_vault_account: self.serum_coin_vault_account.to_string(), - serum_pc_vault_account: self.serum_pc_vault_account.to_string(), - serum_vault_signer: self.serum_vault_signer.to_string(), - user_lp_token_account: self.user_lp_token_account.to_string(), - uer_coin_token_account: self.uer_coin_token_account.to_string(), - uer_pc_token_account: self.uer_pc_token_account.to_string(), - user_owner: self.user_owner.to_string(), - serum_event_q: self.serum_event_q.to_string(), - serum_bids: self.serum_bids.to_string(), - serum_asks: self.serum_asks.to_string(), - } - } - } - use super::WithdrawIxData; - impl IntoProto for WithdrawIxData { - fn into_proto(self) -> proto_def::WithdrawIxData { - proto_def::WithdrawIxData { - amount: self.amount, - } - } - } - use super::MigrateToOpenBookIxAccounts; - impl IntoProto for MigrateToOpenBookIxAccounts { - fn into_proto(self) -> proto_def::MigrateToOpenBookIxAccounts { - proto_def::MigrateToOpenBookIxAccounts { - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - amm_token_coin: self.amm_token_coin.to_string(), - amm_token_pc: self.amm_token_pc.to_string(), - amm_target_orders: self.amm_target_orders.to_string(), - serum_program: self.serum_program.to_string(), - serum_market: self.serum_market.to_string(), - serum_bids: self.serum_bids.to_string(), - serum_asks: self.serum_asks.to_string(), - serum_event_queue: self.serum_event_queue.to_string(), - serum_coin_vault: self.serum_coin_vault.to_string(), - serum_pc_vault: self.serum_pc_vault.to_string(), - serum_vault_signer: self.serum_vault_signer.to_string(), - new_amm_open_orders: self.new_amm_open_orders.to_string(), - new_serum_program: self.new_serum_program.to_string(), - new_serum_market: self.new_serum_market.to_string(), - admin: self.admin.to_string(), - } - } - } - use super::SetParamsIxAccounts; - impl IntoProto for SetParamsIxAccounts { - fn into_proto(self) -> proto_def::SetParamsIxAccounts { - proto_def::SetParamsIxAccounts { - token_program: self.token_program.to_string(), - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - amm_target_orders: self.amm_target_orders.to_string(), - amm_coin_vault: self.amm_coin_vault.to_string(), - amm_pc_vault: self.amm_pc_vault.to_string(), - serum_program: self.serum_program.to_string(), - serum_market: self.serum_market.to_string(), - serum_coin_vault: self.serum_coin_vault.to_string(), - serum_pc_vault: self.serum_pc_vault.to_string(), - serum_vault_signer: self.serum_vault_signer.to_string(), - serum_event_queue: self.serum_event_queue.to_string(), - serum_bids: self.serum_bids.to_string(), - serum_asks: self.serum_asks.to_string(), - amm_admin_account: self.amm_admin_account.to_string(), - } - } - } - use super::SetParamsIxData; - impl IntoProto for SetParamsIxData { - fn into_proto(self) -> proto_def::SetParamsIxData { - proto_def::SetParamsIxData { - param: self.param.into(), - value: self.value, - new_pubkey: self.new_pubkey.map(|x| x.to_string()), - fees: self.fees.map(|x| x.into_proto()), - last_order_distance: self.last_order_distance.map(|x| x.into_proto()), - need_take_amounts: self.need_take_amounts.map(|x| x.into_proto()), - } - } - } - use super::WithdrawPnlIxAccounts; - impl IntoProto for WithdrawPnlIxAccounts { - fn into_proto(self) -> proto_def::WithdrawPnlIxAccounts { - proto_def::WithdrawPnlIxAccounts { - token_program: self.token_program.to_string(), - amm: self.amm.to_string(), - amm_config: self.amm_config.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - coin_pnl_token_account: self.coin_pnl_token_account.to_string(), - pc_pnl_token_account: self.pc_pnl_token_account.to_string(), - pnl_owner_account: self.pnl_owner_account.to_string(), - amm_target_orders: self.amm_target_orders.to_string(), - serum_program: self.serum_program.to_string(), - serum_market: self.serum_market.to_string(), - serum_event_queue: self.serum_event_queue.to_string(), - serum_coin_vault_account: self.serum_coin_vault_account.to_string(), - serum_pc_vault_account: self.serum_pc_vault_account.to_string(), - serum_vault_signer: self.serum_vault_signer.to_string(), - } - } - } - use super::WithdrawSrmIxAccounts; - impl IntoProto for WithdrawSrmIxAccounts { - fn into_proto(self) -> proto_def::WithdrawSrmIxAccounts { - proto_def::WithdrawSrmIxAccounts { - token_program: self.token_program.to_string(), - amm: self.amm.to_string(), - amm_owner_account: self.amm_owner_account.to_string(), - amm_authority: self.amm_authority.to_string(), - srm_token: self.srm_token.to_string(), - dest_srm_token: self.dest_srm_token.to_string(), - } - } - } - use super::WithdrawSrmIxData; - impl IntoProto for WithdrawSrmIxData { - fn into_proto(self) -> proto_def::WithdrawSrmIxData { - proto_def::WithdrawSrmIxData { - amount: self.amount, - } - } - } - use super::SwapBaseInIxAccounts; - impl IntoProto for SwapBaseInIxAccounts { - fn into_proto(self) -> proto_def::SwapBaseInIxAccounts { - proto_def::SwapBaseInIxAccounts { - token_program: self.token_program.to_string(), - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - amm_target_orders: self.amm_target_orders.map(|p| p.to_string()), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - serum_program: self.serum_program.to_string(), - serum_market: self.serum_market.to_string(), - serum_bids: self.serum_bids.to_string(), - serum_asks: self.serum_asks.to_string(), - serum_event_queue: self.serum_event_queue.to_string(), - serum_coin_vault_account: self.serum_coin_vault_account.to_string(), - serum_pc_vault_account: self.serum_pc_vault_account.to_string(), - serum_vault_signer: self.serum_vault_signer.to_string(), - uer_source_token_account: self.uer_source_token_account.to_string(), - uer_destination_token_account: self.uer_destination_token_account.to_string(), - user_source_owner: self.user_source_owner.to_string(), - } - } - } - use super::SwapBaseInIxData; - impl IntoProto for SwapBaseInIxData { - fn into_proto(self) -> proto_def::SwapBaseInIxData { - proto_def::SwapBaseInIxData { - amount_in: self.amount_in, - minimum_amount_out: self.minimum_amount_out, - } - } - } - use super::PreInitializeIxAccounts; - impl IntoProto for PreInitializeIxAccounts { - fn into_proto(self) -> proto_def::PreInitializeIxAccounts { - proto_def::PreInitializeIxAccounts { - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - amm_target_orders: self.amm_target_orders.to_string(), - pool_withdraw_queue: self.pool_withdraw_queue.to_string(), - amm_authority: self.amm_authority.to_string(), - lp_mint_address: self.lp_mint_address.to_string(), - coin_mint_address: self.coin_mint_address.to_string(), - pc_mint_address: self.pc_mint_address.to_string(), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - pool_temp_lp_token_account: self.pool_temp_lp_token_account.to_string(), - serum_market: self.serum_market.to_string(), - user_wallet: self.user_wallet.to_string(), - } - } - } - use super::PreInitializeIxData; - impl IntoProto for PreInitializeIxData { - fn into_proto(self) -> proto_def::PreInitializeIxData { - proto_def::PreInitializeIxData { - nonce: self.nonce.into(), - } - } - } - use super::SwapBaseOutIxAccounts; - impl IntoProto for SwapBaseOutIxAccounts { - fn into_proto(self) -> proto_def::SwapBaseOutIxAccounts { - proto_def::SwapBaseOutIxAccounts { - token_program: self.token_program.to_string(), - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - amm_target_orders: self.amm_target_orders.map(|p| p.to_string()), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - serum_program: self.serum_program.to_string(), - serum_market: self.serum_market.to_string(), - serum_bids: self.serum_bids.to_string(), - serum_asks: self.serum_asks.to_string(), - serum_event_queue: self.serum_event_queue.to_string(), - serum_coin_vault_account: self.serum_coin_vault_account.to_string(), - serum_pc_vault_account: self.serum_pc_vault_account.to_string(), - serum_vault_signer: self.serum_vault_signer.to_string(), - uer_source_token_account: self.uer_source_token_account.to_string(), - uer_destination_token_account: self.uer_destination_token_account.to_string(), - user_source_owner: self.user_source_owner.to_string(), - } - } - } - use super::SwapBaseOutIxData; - impl IntoProto for SwapBaseOutIxData { - fn into_proto(self) -> proto_def::SwapBaseOutIxData { - proto_def::SwapBaseOutIxData { - max_amount_in: self.max_amount_in, - amount_out: self.amount_out, - } - } - } - use super::SimulateInfoIxAccounts; - impl IntoProto for SimulateInfoIxAccounts { - fn into_proto(self) -> proto_def::SimulateInfoIxAccounts { - proto_def::SimulateInfoIxAccounts { - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - lp_mint_address: self.lp_mint_address.to_string(), - serum_market: self.serum_market.to_string(), - serum_event_queue: self.serum_event_queue.to_string(), - } - } - } - use super::SimulateInfoIxData; - impl IntoProto for SimulateInfoIxData { - fn into_proto(self) -> proto_def::SimulateInfoIxData { - proto_def::SimulateInfoIxData { - param: self.param.into(), - swap_base_in_value: self.swap_base_in_value.map(|x| x.into_proto()), - swap_base_out_value: self.swap_base_out_value.map(|x| x.into_proto()), - } - } - } - use super::AdminCancelOrdersIxAccounts; - impl IntoProto for AdminCancelOrdersIxAccounts { - fn into_proto(self) -> proto_def::AdminCancelOrdersIxAccounts { - proto_def::AdminCancelOrdersIxAccounts { - token_program: self.token_program.to_string(), - amm: self.amm.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - amm_target_orders: self.amm_target_orders.to_string(), - pool_coin_token_account: self.pool_coin_token_account.to_string(), - pool_pc_token_account: self.pool_pc_token_account.to_string(), - amm_owner_account: self.amm_owner_account.to_string(), - amm_config: self.amm_config.to_string(), - serum_program: self.serum_program.to_string(), - serum_market: self.serum_market.to_string(), - serum_coin_vault_account: self.serum_coin_vault_account.to_string(), - serum_pc_vault_account: self.serum_pc_vault_account.to_string(), - serum_vault_signer: self.serum_vault_signer.to_string(), - serum_event_q: self.serum_event_q.to_string(), - serum_bids: self.serum_bids.to_string(), - serum_asks: self.serum_asks.to_string(), - } - } - } - use super::AdminCancelOrdersIxData; - impl IntoProto for AdminCancelOrdersIxData { - fn into_proto(self) -> proto_def::AdminCancelOrdersIxData { - proto_def::AdminCancelOrdersIxData { - limit: self.limit.into(), - } - } - } - use super::CreateConfigAccountIxAccounts; - impl IntoProto for CreateConfigAccountIxAccounts { - fn into_proto(self) -> proto_def::CreateConfigAccountIxAccounts { - proto_def::CreateConfigAccountIxAccounts { - admin: self.admin.to_string(), - amm_config: self.amm_config.to_string(), - owner: self.owner.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::UpdateConfigAccountIxAccounts; - impl IntoProto for UpdateConfigAccountIxAccounts { - fn into_proto(self) -> proto_def::UpdateConfigAccountIxAccounts { - proto_def::UpdateConfigAccountIxAccounts { - admin: self.admin.to_string(), - amm_config: self.amm_config.to_string(), - } - } - } - use super::UpdateConfigAccountIxData; - impl IntoProto for UpdateConfigAccountIxData { - fn into_proto(self) -> proto_def::UpdateConfigAccountIxData { - proto_def::UpdateConfigAccountIxData { - param: self.param.into(), - owner: self.owner.to_string(), - } - } - } - - impl IntoProto for RaydiumAmmV4ProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - RaydiumAmmV4ProgramIx::Initialize(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Initialize( - proto_def::InitializeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::Initialize2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Initialize2( - proto_def::Initialize2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::MonitorStep(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::MonitorStep( - proto_def::MonitorStepIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::Deposit(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Deposit( - proto_def::DepositIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::Withdraw(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Withdraw( - proto_def::WithdrawIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::MigrateToOpenBook(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::MigrateToOpenBook( - proto_def::MigrateToOpenBookIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::SetParams(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetParams( - proto_def::SetParamsIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::WithdrawPnl(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::WithdrawPnl( - proto_def::WithdrawPnlIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::WithdrawSrm(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::WithdrawSrm( - proto_def::WithdrawSrmIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::SwapBaseIn(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapBaseIn( - proto_def::SwapBaseInIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::PreInitialize(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::PreInitialize( - proto_def::PreInitializeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::SwapBaseOut(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapBaseOut( - proto_def::SwapBaseOutIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::SimulateInfo(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SimulateInfo( - proto_def::SimulateInfoIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::AdminCancelOrders(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::AdminCancelOrders( - proto_def::AdminCancelOrdersIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::CreateConfigAccount(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateConfigAccount( - proto_def::CreateConfigAccountIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumAmmV4ProgramIx::UpdateConfigAccount(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateConfigAccount( - proto_def::UpdateConfigAccountIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/raydium-amm-v4-parser/src/generated_parser/mod.rs b/crates/raydium-amm-v4-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/raydium-amm-v4-parser/src/generated_parser/proto_helpers.rs b/crates/raydium-amm-v4-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index f19273d9..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,116 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::WithdrawDestToken}; - impl IntoProto for WithdrawDestToken { - fn into_proto(self) -> proto_def::WithdrawDestToken { - proto_def::WithdrawDestToken { - withdraw_amount: self.withdraw_amount, - coin_amount: self.coin_amount, - pc_amount: self.pc_amount, - dest_token_coin: self.dest_token_coin.to_string(), - dest_token_pc: self.dest_token_pc.to_string(), - } - } - } - use crate::types::WithdrawQueue; - impl IntoProto for WithdrawQueue { - fn into_proto(self) -> proto_def::WithdrawQueue { - proto_def::WithdrawQueue { - owner: self.owner.to_vec(), - head: self.head, - count: self.count, - buf: self.buf.into_iter().map(|x| x.into_proto()).collect(), - } - } - } - use crate::types::TargetOrder; - impl IntoProto for TargetOrder { - fn into_proto(self) -> proto_def::TargetOrder { - proto_def::TargetOrder { - price: self.price, - vol: self.vol, - } - } - } - use crate::types::OutPutData; - impl IntoProto for OutPutData { - fn into_proto(self) -> proto_def::OutPutData { - proto_def::OutPutData { - need_take_pnl_coin: self.need_take_pnl_coin, - need_take_pnl_pc: self.need_take_pnl_pc, - total_pnl_pc: self.total_pnl_pc, - total_pnl_coin: self.total_pnl_coin, - pool_open_time: self.pool_open_time, - punish_pc_amount: self.punish_pc_amount, - punish_coin_amount: self.punish_coin_amount, - orderbook_to_init_time: self.orderbook_to_init_time, - swap_coin_in_amount: self.swap_coin_in_amount.to_string(), - swap_pc_out_amount: self.swap_pc_out_amount.to_string(), - swap_take_pc_fee: self.swap_take_pc_fee, - swap_pc_in_amount: self.swap_pc_in_amount.to_string(), - swap_coin_out_amount: self.swap_coin_out_amount.to_string(), - swap_take_coin_fee: self.swap_take_coin_fee, - } - } - } - use crate::types::LastOrderDistance; - impl IntoProto for LastOrderDistance { - fn into_proto(self) -> proto_def::LastOrderDistance { - proto_def::LastOrderDistance { - last_order_numerator: self.last_order_numerator, - last_order_denominator: self.last_order_denominator, - } - } - } - use crate::types::NeedTake; - impl IntoProto for NeedTake { - fn into_proto(self) -> proto_def::NeedTake { - proto_def::NeedTake { - need_take_pc: self.need_take_pc, - need_take_coin: self.need_take_coin, - } - } - } - use crate::types::SwapInstructionBaseIn; - impl IntoProto for SwapInstructionBaseIn { - fn into_proto(self) -> proto_def::SwapInstructionBaseIn { - proto_def::SwapInstructionBaseIn { - amount_in: self.amount_in, - minimum_amount_out: self.minimum_amount_out, - } - } - } - use crate::types::SwapInstructionBaseOut; - impl IntoProto for SwapInstructionBaseOut { - fn into_proto(self) -> proto_def::SwapInstructionBaseOut { - proto_def::SwapInstructionBaseOut { - max_amount_in: self.max_amount_in, - amount_out: self.amount_out, - } - } - } - use crate::types::Fees; - impl IntoProto for Fees { - fn into_proto(self) -> proto_def::Fees { - proto_def::Fees { - min_separate_numerator: self.min_separate_numerator, - min_separate_denominator: self.min_separate_denominator, - trade_fee_numerator: self.trade_fee_numerator, - trade_fee_denominator: self.trade_fee_denominator, - pnl_numerator: self.pnl_numerator, - pnl_denominator: self.pnl_denominator, - swap_fee_numerator: self.swap_fee_numerator, - swap_fee_denominator: self.swap_fee_denominator, - } - } - } -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/amm_config.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/amm_config.rs deleted file mode 100644 index 99875e56..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/amm_config.rs +++ /dev/null @@ -1,137 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AmmConfig { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pnl_owner: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub cancel_owner: Pubkey, - pub pending1: [u64; 28], - pub pending2: [u64; 31], - pub create_pool_fee: u64, -} - -impl AmmConfig { - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for AmmConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_amm_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = AmmConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_amm_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = AmmConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for AmmConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for AmmConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for AmmConfig { - fn owner() -> Pubkey { crate::RAYDIUM_AMM_V4_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for AmmConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for AmmConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/amm_info.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/amm_info.rs deleted file mode 100644 index d20cff9a..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/amm_info.rs +++ /dev/null @@ -1,207 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{Fees, OutPutData}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AmmInfo { - pub status: u64, - pub nonce: u64, - pub order_num: u64, - pub depth: u64, - pub coin_decimals: u64, - pub pc_decimals: u64, - pub state: u64, - pub reset_flag: u64, - pub min_size: u64, - pub vol_max_cut_ratio: u64, - pub amount_wave: u64, - pub coin_lot_size: u64, - pub pc_lot_size: u64, - pub min_price_multiplier: u64, - pub max_price_multiplier: u64, - pub sys_decimal_value: u64, - pub fees: Fees, - pub out_put: OutPutData, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_coin: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_pc: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub coin_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pc_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lp_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub open_orders: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub market: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub serum_dex: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub target_orders: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub withdraw_queue: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_temp_lp: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub amm_owner: Pubkey, - pub lp_amount: u64, - pub client_order_id: u64, - pub padding: [u64; 2], -} - -impl AmmInfo { - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for AmmInfo { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_amm_info( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_amm_info(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_amm_info( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = AmmInfo::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_amm_info( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_amm_info(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_amm_info( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = AmmInfo::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for AmmInfo { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for AmmInfo {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for AmmInfo { - fn owner() -> Pubkey { crate::RAYDIUM_AMM_V4_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for AmmInfo {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for AmmInfo { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/mod.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index d99f51d6..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#amm_config; -pub(crate) mod r#amm_info; -pub(crate) mod r#target_orders; - -pub use self::{r#amm_config::*, r#amm_info::*, r#target_orders::*}; diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/target_orders.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/target_orders.rs deleted file mode 100644 index 2c4f2d2b..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/accounts/target_orders.rs +++ /dev/null @@ -1,154 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::TargetOrder; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TargetOrders { - pub owner: [u64; 4], - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub buy_orders: [TargetOrder; 50], - pub padding1: [u64; 8], - pub target_x: u128, - pub target_y: u128, - pub plan_x_buy: u128, - pub plan_y_buy: u128, - pub plan_x_sell: u128, - pub plan_y_sell: u128, - pub placed_x: u128, - pub placed_y: u128, - pub calc_pnl_x: u128, - pub calc_pnl_y: u128, - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub sell_orders: [TargetOrder; 50], - pub padding2: [u64; 6], - pub replace_buy_client_id: [u64; 10], - pub replace_sell_client_id: [u64; 10], - pub last_order_numerator: u64, - pub last_order_denominator: u64, - pub plan_orders_cur: u64, - pub place_orders_cur: u64, - pub valid_buy_order_num: u64, - pub valid_sell_order_num: u64, - pub padding3: [u64; 10], - pub free_slot_bits: u128, -} - -impl TargetOrders { - pub const LEN: usize = 2208; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for TargetOrders { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_target_orders( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_target_orders(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_target_orders( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = TargetOrders::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_target_orders( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_target_orders(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_target_orders( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = TargetOrders::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for TargetOrders { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for TargetOrders {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for TargetOrders { - fn owner() -> Pubkey { crate::RAYDIUM_AMM_V4_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for TargetOrders {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for TargetOrders { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/errors/mod.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index b83c64bf..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod raydium_amm_v4; - -pub use self::raydium_amm_v4::RaydiumAmmV4Error; diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/errors/raydium_amm_v4.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/errors/raydium_amm_v4.rs deleted file mode 100644 index 68c0a777..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/errors/raydium_amm_v4.rs +++ /dev/null @@ -1,196 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum RaydiumAmmV4Error { - /// 0 - AlreadyInUse - #[error("AlreadyInUse")] - AlreadyInUse = 0x0, - /// 1 - InvalidProgramAddress - #[error("InvalidProgramAddress")] - InvalidProgramAddress = 0x1, - /// 2 - ExpectedMint - #[error("ExpectedMint")] - ExpectedMint = 0x2, - /// 3 - ExpectedAccount - #[error("ExpectedAccount")] - ExpectedAccount = 0x3, - /// 4 - InvalidCoinVault - #[error("InvalidCoinVault")] - InvalidCoinVault = 0x4, - /// 5 - InvalidPCVault - #[error("InvalidPCVault")] - InvalidPCVault = 0x5, - /// 6 - InvalidTokenLP - #[error("InvalidTokenLP")] - InvalidTokenLP = 0x6, - /// 7 - InvalidDestTokenCoin - #[error("InvalidDestTokenCoin")] - InvalidDestTokenCoin = 0x7, - /// 8 - InvalidDestTokenPC - #[error("InvalidDestTokenPC")] - InvalidDestTokenPC = 0x8, - /// 9 - InvalidPoolMint - #[error("InvalidPoolMint")] - InvalidPoolMint = 0x9, - /// 10 - InvalidOpenOrders - #[error("InvalidOpenOrders")] - InvalidOpenOrders = 0xa, - /// 11 - InvalidSerumMarket - #[error("InvalidSerumMarket")] - InvalidSerumMarket = 0xb, - /// 12 - InvalidSerumProgram - #[error("InvalidSerumProgram")] - InvalidSerumProgram = 0xc, - /// 13 - InvalidTargetOrders - #[error("InvalidTargetOrders")] - InvalidTargetOrders = 0xd, - /// 14 - InvalidWithdrawQueue - #[error("InvalidWithdrawQueue")] - InvalidWithdrawQueue = 0xe, - /// 15 - InvalidTempLp - #[error("InvalidTempLp")] - InvalidTempLp = 0xf, - /// 16 - InvalidCoinMint - #[error("InvalidCoinMint")] - InvalidCoinMint = 0x10, - /// 17 - InvalidPCMint - #[error("InvalidPCMint")] - InvalidPCMint = 0x11, - /// 18 - InvalidOwner - #[error("InvalidOwner")] - InvalidOwner = 0x12, - /// 19 - InvalidSupply - #[error("InvalidSupply")] - InvalidSupply = 0x13, - /// 20 - InvalidDelegate - #[error("InvalidDelegate")] - InvalidDelegate = 0x14, - /// 21 - Invalid Sign Account - #[error("Invalid Sign Account")] - InvalidSignAccount = 0x15, - /// 22 - InvalidStatus - #[error("InvalidStatus")] - InvalidStatus = 0x16, - /// 23 - Invalid instruction - #[error("Invalid instruction")] - InvalidInstruction = 0x17, - /// 24 - Wrong accounts number - #[error("Wrong accounts number")] - WrongAccountsNumber = 0x18, - /// 25 - Withdraw_transfer is busy - #[error("Withdraw_transfer is busy")] - WithdrawTransferBusy = 0x19, - /// 26 - WithdrawQueue is full - #[error("WithdrawQueue is full")] - WithdrawQueueFull = 0x1a, - /// 27 - WithdrawQueue is empty - #[error("WithdrawQueue is empty")] - WithdrawQueueEmpty = 0x1b, - /// 28 - Params Set is invalid - #[error("Params Set is invalid")] - InvalidParamsSet = 0x1c, - /// 29 - InvalidInput - #[error("InvalidInput")] - InvalidInput = 0x1d, - /// 30 - instruction exceeds desired slippage limit - #[error("instruction exceeds desired slippage limit")] - ExceededSlippage = 0x1e, - /// 31 - CalculationExRateFailure - #[error("CalculationExRateFailure")] - CalculationExRateFailure = 0x1f, - /// 32 - Checked_Sub Overflow - #[error("Checked_Sub Overflow")] - CheckedSubOverflow = 0x20, - /// 33 - Checked_Add Overflow - #[error("Checked_Add Overflow")] - CheckedAddOverflow = 0x21, - /// 34 - Checked_Mul Overflow - #[error("Checked_Mul Overflow")] - CheckedMulOverflow = 0x22, - /// 35 - Checked_Div Overflow - #[error("Checked_Div Overflow")] - CheckedDivOverflow = 0x23, - /// 36 - Empty Funds - #[error("Empty Funds")] - CheckedEmptyFunds = 0x24, - /// 37 - Calc pnl error - #[error("Calc pnl error")] - CalcPnlError = 0x25, - /// 38 - InvalidSplTokenProgram - #[error("InvalidSplTokenProgram")] - InvalidSplTokenProgram = 0x26, - /// 39 - Take Pnl error - #[error("Take Pnl error")] - TakePnlError = 0x27, - /// 40 - Insufficient funds - #[error("Insufficient funds")] - InsufficientFunds = 0x28, - /// 41 - Conversion to u64 failed with an overflow or underflow - #[error("Conversion to u64 failed with an overflow or underflow")] - ConversionFailure = 0x29, - /// 42 - user token input does not match amm - #[error("user token input does not match amm")] - InvalidUserToken = 0x2a, - /// 43 - InvalidSrmMint - #[error("InvalidSrmMint")] - InvalidSrmMint = 0x2b, - /// 44 - InvalidSrmToken - #[error("InvalidSrmToken")] - InvalidSrmToken = 0x2c, - /// 45 - TooManyOpenOrders - #[error("TooManyOpenOrders")] - TooManyOpenOrders = 0x2d, - /// 46 - OrderAtSlotIsPlaced - #[error("OrderAtSlotIsPlaced")] - OrderAtSlotIsPlaced = 0x2e, - /// 47 - InvalidSysProgramAddress - #[error("InvalidSysProgramAddress")] - InvalidSysProgramAddress = 0x2f, - /// 48 - The provided fee does not match the program owner's constraints - #[error("The provided fee does not match the program owner's constraints")] - InvalidFee = 0x30, - /// 49 - Repeat create amm about market - #[error("Repeat create amm about market")] - RepeatCreateAmm = 0x31, - /// 50 - Not allow Zero LP - #[error("Not allow Zero LP")] - NotAllowZeroLP = 0x32, - /// 51 - Token account has a close authority - #[error("Token account has a close authority")] - InvalidCloseAuthority = 0x33, - /// 52 - Pool token mint has a freeze authority - #[error("Pool token mint has a freeze authority")] - InvalidFreezeAuthority = 0x34, - /// 53 - InvalidReferPCMint - #[error("InvalidReferPCMint")] - InvalidReferPCMint = 0x35, - /// 54 - InvalidConfigAccount - #[error("InvalidConfigAccount")] - InvalidConfigAccount = 0x36, - /// 55 - Repeat create staking config account - #[error("Repeat create staking config account")] - RepeatCreateConfigAccount = 0x37, - /// 56 - Unknown Amm Error - #[error("Unknown Amm Error")] - UnknownAmmError = 0x38, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for RaydiumAmmV4Error { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for RaydiumAmmV4Error { - fn type_of() -> &'static str { "RaydiumAmmV4Error" } -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/admin_cancel_orders.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/admin_cancel_orders.rs deleted file mode 100644 index 9e4146a7..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/admin_cancel_orders.rs +++ /dev/null @@ -1,999 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct AdminCancelOrders { - pub token_program: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub amm_target_orders: solana_pubkey::Pubkey, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub amm_owner_account: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub serum_program: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub serum_coin_vault_account: solana_pubkey::Pubkey, - - pub serum_pc_vault_account: solana_pubkey::Pubkey, - - pub serum_vault_signer: solana_pubkey::Pubkey, - - pub serum_event_q: solana_pubkey::Pubkey, - - pub serum_bids: solana_pubkey::Pubkey, - - pub serum_asks: solana_pubkey::Pubkey, -} - -impl AdminCancelOrders { - pub fn instruction( - &self, - args: AdminCancelOrdersInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: AdminCancelOrdersInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_target_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_owner_account, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm_config, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_coin_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_pc_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_vault_signer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_event_q, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.serum_bids, false)); - accounts.push(solana_instruction::AccountMeta::new(self.serum_asks, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AdminCancelOrdersInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AdminCancelOrdersInstructionData { - discriminator: [u8; 1], -} - -impl AdminCancelOrdersInstructionData { - pub fn new() -> Self { - Self { - discriminator: [13], - } - } -} - -impl Default for AdminCancelOrdersInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AdminCancelOrdersInstructionArgs { - pub limit: u16, -} - -/// Instruction builder for `AdminCancelOrders`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[]` amm -/// 2. `[]` amm_authority -/// 3. `[writable]` amm_open_orders -/// 4. `[writable]` amm_target_orders -/// 5. `[writable]` pool_coin_token_account -/// 6. `[writable]` pool_pc_token_account -/// 7. `[signer]` amm_owner_account -/// 8. `[writable]` amm_config -/// 9. `[]` serum_program -/// 10. `[writable]` serum_market -/// 11. `[writable]` serum_coin_vault_account -/// 12. `[writable]` serum_pc_vault_account -/// 13. `[]` serum_vault_signer -/// 14. `[writable]` serum_event_q -/// 15. `[writable]` serum_bids -/// 16. `[writable]` serum_asks -#[derive(Clone, Debug, Default)] -pub struct AdminCancelOrdersBuilder { - token_program: Option, - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - amm_target_orders: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - amm_owner_account: Option, - amm_config: Option, - serum_program: Option, - serum_market: Option, - serum_coin_vault_account: Option, - serum_pc_vault_account: Option, - serum_vault_signer: Option, - serum_event_q: Option, - serum_bids: Option, - serum_asks: Option, - limit: Option, - __remaining_accounts: Vec, -} - -impl AdminCancelOrdersBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_target_orders(&mut self, amm_target_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn amm_owner_account(&mut self, amm_owner_account: solana_pubkey::Pubkey) -> &mut Self { - self.amm_owner_account = Some(amm_owner_account); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn serum_program(&mut self, serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer(&mut self, serum_vault_signer: solana_pubkey::Pubkey) -> &mut Self { - self.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn serum_event_q(&mut self, serum_event_q: solana_pubkey::Pubkey) -> &mut Self { - self.serum_event_q = Some(serum_event_q); - self - } - - #[inline(always)] - pub fn serum_bids(&mut self, serum_bids: solana_pubkey::Pubkey) -> &mut Self { - self.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks(&mut self, serum_asks: solana_pubkey::Pubkey) -> &mut Self { - self.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn limit(&mut self, limit: u16) -> &mut Self { - self.limit = Some(limit); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = AdminCancelOrders { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - amm_target_orders: self - .amm_target_orders - .expect("amm_target_orders is not set"), - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - amm_owner_account: self - .amm_owner_account - .expect("amm_owner_account is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - serum_program: self.serum_program.expect("serum_program is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - serum_coin_vault_account: self - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - serum_pc_vault_account: self - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - serum_vault_signer: self - .serum_vault_signer - .expect("serum_vault_signer is not set"), - serum_event_q: self.serum_event_q.expect("serum_event_q is not set"), - serum_bids: self.serum_bids.expect("serum_bids is not set"), - serum_asks: self.serum_asks.expect("serum_asks is not set"), - }; - let args = AdminCancelOrdersInstructionArgs { - limit: self.limit.clone().expect("limit is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `admin_cancel_orders` CPI accounts. -pub struct AdminCancelOrdersCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_owner_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_q: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, -} - -/// `admin_cancel_orders` CPI instruction. -pub struct AdminCancelOrdersCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_owner_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_q: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: AdminCancelOrdersInstructionArgs, -} - -impl<'a, 'b> AdminCancelOrdersCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: AdminCancelOrdersCpiAccounts<'a, 'b>, - args: AdminCancelOrdersInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - amm_target_orders: accounts.amm_target_orders, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - amm_owner_account: accounts.amm_owner_account, - amm_config: accounts.amm_config, - serum_program: accounts.serum_program, - serum_market: accounts.serum_market, - serum_coin_vault_account: accounts.serum_coin_vault_account, - serum_pc_vault_account: accounts.serum_pc_vault_account, - serum_vault_signer: accounts.serum_vault_signer, - serum_event_q: accounts.serum_event_q, - serum_bids: accounts.serum_bids, - serum_asks: accounts.serum_asks, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_target_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_owner_account.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_coin_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_pc_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_vault_signer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_event_q.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_bids.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_asks.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&AdminCancelOrdersInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(18 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.amm_target_orders.clone()); - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.amm_owner_account.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.serum_program.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.serum_coin_vault_account.clone()); - account_infos.push(self.serum_pc_vault_account.clone()); - account_infos.push(self.serum_vault_signer.clone()); - account_infos.push(self.serum_event_q.clone()); - account_infos.push(self.serum_bids.clone()); - account_infos.push(self.serum_asks.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `AdminCancelOrders` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[]` amm -/// 2. `[]` amm_authority -/// 3. `[writable]` amm_open_orders -/// 4. `[writable]` amm_target_orders -/// 5. `[writable]` pool_coin_token_account -/// 6. `[writable]` pool_pc_token_account -/// 7. `[signer]` amm_owner_account -/// 8. `[writable]` amm_config -/// 9. `[]` serum_program -/// 10. `[writable]` serum_market -/// 11. `[writable]` serum_coin_vault_account -/// 12. `[writable]` serum_pc_vault_account -/// 13. `[]` serum_vault_signer -/// 14. `[writable]` serum_event_q -/// 15. `[writable]` serum_bids -/// 16. `[writable]` serum_asks -#[derive(Clone, Debug)] -pub struct AdminCancelOrdersCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> AdminCancelOrdersCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(AdminCancelOrdersCpiBuilderInstruction { - __program: program, - token_program: None, - amm: None, - amm_authority: None, - amm_open_orders: None, - amm_target_orders: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - amm_owner_account: None, - amm_config: None, - serum_program: None, - serum_market: None, - serum_coin_vault_account: None, - serum_pc_vault_account: None, - serum_vault_signer: None, - serum_event_q: None, - serum_bids: None, - serum_asks: None, - limit: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn amm_owner_account( - &mut self, - amm_owner_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_owner_account = Some(amm_owner_account); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn serum_program( - &mut self, - serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer( - &mut self, - serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn serum_event_q( - &mut self, - serum_event_q: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_event_q = Some(serum_event_q); - self - } - - #[inline(always)] - pub fn serum_bids( - &mut self, - serum_bids: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks( - &mut self, - serum_asks: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn limit(&mut self, limit: u16) -> &mut Self { - self.instruction.limit = Some(limit); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = AdminCancelOrdersInstructionArgs { - limit: self.instruction.limit.clone().expect("limit is not set"), - }; - let instruction = AdminCancelOrdersCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - amm_target_orders: self - .instruction - .amm_target_orders - .expect("amm_target_orders is not set"), - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - amm_owner_account: self - .instruction - .amm_owner_account - .expect("amm_owner_account is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - serum_program: self - .instruction - .serum_program - .expect("serum_program is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - serum_coin_vault_account: self - .instruction - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - - serum_pc_vault_account: self - .instruction - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - - serum_vault_signer: self - .instruction - .serum_vault_signer - .expect("serum_vault_signer is not set"), - - serum_event_q: self - .instruction - .serum_event_q - .expect("serum_event_q is not set"), - - serum_bids: self.instruction.serum_bids.expect("serum_bids is not set"), - - serum_asks: self.instruction.serum_asks.expect("serum_asks is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct AdminCancelOrdersCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_owner_account: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_coin_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_pc_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_vault_signer: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_event_q: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_bids: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_asks: Option<&'b solana_account_info::AccountInfo<'a>>, - limit: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/create_config_account.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/create_config_account.rs deleted file mode 100644 index c6b05e1f..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/create_config_account.rs +++ /dev/null @@ -1,425 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateConfigAccount { - pub admin: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub owner: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl CreateConfigAccount { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.push(solana_instruction::AccountMeta::new(self.amm_config, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateConfigAccountInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigAccountInstructionData { - discriminator: [u8; 1], -} - -impl CreateConfigAccountInstructionData { - pub fn new() -> Self { - Self { - discriminator: [14], - } - } -} - -impl Default for CreateConfigAccountInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateConfigAccount`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` admin -/// 1. `[writable]` amm_config -/// 2. `[]` owner -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 4. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateConfigAccountBuilder { - admin: Option, - amm_config: Option, - owner: Option, - system_program: Option, - rent: Option, - __remaining_accounts: Vec, -} - -impl CreateConfigAccountBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateConfigAccount { - admin: self.admin.expect("admin is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - owner: self.owner.expect("owner is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_config_account` CPI accounts. -pub struct CreateConfigAccountCpiAccounts<'a, 'b> { - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_config_account` CPI instruction. -pub struct CreateConfigAccountCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateConfigAccountCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateConfigAccountCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - admin: accounts.admin, - amm_config: accounts.amm_config, - owner: accounts.owner, - system_program: accounts.system_program, - rent: accounts.rent, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateConfigAccountInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateConfigAccount` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` admin -/// 1. `[writable]` amm_config -/// 2. `[]` owner -/// 3. `[]` system_program -/// 4. `[]` rent -#[derive(Clone, Debug)] -pub struct CreateConfigAccountCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateConfigAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateConfigAccountCpiBuilderInstruction { - __program: program, - admin: None, - amm_config: None, - owner: None, - system_program: None, - rent: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateConfigAccountCpi { - __program: self.instruction.__program, - - admin: self.instruction.admin.expect("admin is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - owner: self.instruction.owner.expect("owner is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateConfigAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/deposit.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/deposit.rs deleted file mode 100644 index 2fb11793..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/deposit.rs +++ /dev/null @@ -1,933 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Deposit { - pub token_program: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub amm_target_orders: solana_pubkey::Pubkey, - - pub lp_mint_address: solana_pubkey::Pubkey, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub user_coin_token_account: solana_pubkey::Pubkey, - - pub user_pc_token_account: solana_pubkey::Pubkey, - - pub user_lp_token_account: solana_pubkey::Pubkey, - - pub user_owner: solana_pubkey::Pubkey, - - pub serum_event_queue: solana_pubkey::Pubkey, -} - -impl Deposit { - pub fn instruction(&self, args: DepositInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DepositInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_target_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lp_mint_address, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_lp_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_event_queue, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DepositInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositInstructionData { - discriminator: [u8; 1], -} - -impl DepositInstructionData { - pub fn new() -> Self { Self { discriminator: [3] } } -} - -impl Default for DepositInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositInstructionArgs { - pub max_coin_amount: u64, - pub max_pc_amount: u64, - pub base_side: u64, -} - -/// Instruction builder for `Deposit`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[writable]` amm -/// 2. `[]` amm_authority -/// 3. `[]` amm_open_orders -/// 4. `[writable]` amm_target_orders -/// 5. `[writable]` lp_mint_address -/// 6. `[writable]` pool_coin_token_account -/// 7. `[writable]` pool_pc_token_account -/// 8. `[]` serum_market -/// 9. `[writable]` user_coin_token_account -/// 10. `[writable]` user_pc_token_account -/// 11. `[writable]` user_lp_token_account -/// 12. `[signer]` user_owner -/// 13. `[]` serum_event_queue -#[derive(Clone, Debug, Default)] -pub struct DepositBuilder { - token_program: Option, - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - amm_target_orders: Option, - lp_mint_address: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - serum_market: Option, - user_coin_token_account: Option, - user_pc_token_account: Option, - user_lp_token_account: Option, - user_owner: Option, - serum_event_queue: Option, - max_coin_amount: Option, - max_pc_amount: Option, - base_side: Option, - __remaining_accounts: Vec, -} - -impl DepositBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_target_orders(&mut self, amm_target_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn lp_mint_address(&mut self, lp_mint_address: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint_address = Some(lp_mint_address); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn user_coin_token_account( - &mut self, - user_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_coin_token_account = Some(user_coin_token_account); - self - } - - #[inline(always)] - pub fn user_pc_token_account( - &mut self, - user_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_pc_token_account = Some(user_pc_token_account); - self - } - - #[inline(always)] - pub fn user_lp_token_account( - &mut self, - user_lp_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_lp_token_account = Some(user_lp_token_account); - self - } - - #[inline(always)] - pub fn user_owner(&mut self, user_owner: solana_pubkey::Pubkey) -> &mut Self { - self.user_owner = Some(user_owner); - self - } - - #[inline(always)] - pub fn serum_event_queue(&mut self, serum_event_queue: solana_pubkey::Pubkey) -> &mut Self { - self.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn max_coin_amount(&mut self, max_coin_amount: u64) -> &mut Self { - self.max_coin_amount = Some(max_coin_amount); - self - } - - #[inline(always)] - pub fn max_pc_amount(&mut self, max_pc_amount: u64) -> &mut Self { - self.max_pc_amount = Some(max_pc_amount); - self - } - - #[inline(always)] - pub fn base_side(&mut self, base_side: u64) -> &mut Self { - self.base_side = Some(base_side); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Deposit { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - amm_target_orders: self - .amm_target_orders - .expect("amm_target_orders is not set"), - lp_mint_address: self.lp_mint_address.expect("lp_mint_address is not set"), - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - user_coin_token_account: self - .user_coin_token_account - .expect("user_coin_token_account is not set"), - user_pc_token_account: self - .user_pc_token_account - .expect("user_pc_token_account is not set"), - user_lp_token_account: self - .user_lp_token_account - .expect("user_lp_token_account is not set"), - user_owner: self.user_owner.expect("user_owner is not set"), - serum_event_queue: self - .serum_event_queue - .expect("serum_event_queue is not set"), - }; - let args = DepositInstructionArgs { - max_coin_amount: self - .max_coin_amount - .clone() - .expect("max_coin_amount is not set"), - max_pc_amount: self - .max_pc_amount - .clone() - .expect("max_pc_amount is not set"), - base_side: self.base_side.clone().expect("base_side is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `deposit` CPI accounts. -pub struct DepositCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub user_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_owner: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, -} - -/// `deposit` CPI instruction. -pub struct DepositCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub user_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_owner: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DepositInstructionArgs, -} - -impl<'a, 'b> DepositCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DepositCpiAccounts<'a, 'b>, - args: DepositInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - amm_target_orders: accounts.amm_target_orders, - lp_mint_address: accounts.lp_mint_address, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - serum_market: accounts.serum_market, - user_coin_token_account: accounts.user_coin_token_account, - user_pc_token_account: accounts.user_pc_token_account, - user_lp_token_account: accounts.user_lp_token_account, - user_owner: accounts.user_owner, - serum_event_queue: accounts.serum_event_queue, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.amm.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_target_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint_address.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_lp_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_event_queue.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DepositInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.amm_target_orders.clone()); - account_infos.push(self.lp_mint_address.clone()); - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.user_coin_token_account.clone()); - account_infos.push(self.user_pc_token_account.clone()); - account_infos.push(self.user_lp_token_account.clone()); - account_infos.push(self.user_owner.clone()); - account_infos.push(self.serum_event_queue.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Deposit` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[writable]` amm -/// 2. `[]` amm_authority -/// 3. `[]` amm_open_orders -/// 4. `[writable]` amm_target_orders -/// 5. `[writable]` lp_mint_address -/// 6. `[writable]` pool_coin_token_account -/// 7. `[writable]` pool_pc_token_account -/// 8. `[]` serum_market -/// 9. `[writable]` user_coin_token_account -/// 10. `[writable]` user_pc_token_account -/// 11. `[writable]` user_lp_token_account -/// 12. `[signer]` user_owner -/// 13. `[]` serum_event_queue -#[derive(Clone, Debug)] -pub struct DepositCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DepositCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DepositCpiBuilderInstruction { - __program: program, - token_program: None, - amm: None, - amm_authority: None, - amm_open_orders: None, - amm_target_orders: None, - lp_mint_address: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - serum_market: None, - user_coin_token_account: None, - user_pc_token_account: None, - user_lp_token_account: None, - user_owner: None, - serum_event_queue: None, - max_coin_amount: None, - max_pc_amount: None, - base_side: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn lp_mint_address( - &mut self, - lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lp_mint_address = Some(lp_mint_address); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn user_coin_token_account( - &mut self, - user_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_coin_token_account = Some(user_coin_token_account); - self - } - - #[inline(always)] - pub fn user_pc_token_account( - &mut self, - user_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_pc_token_account = Some(user_pc_token_account); - self - } - - #[inline(always)] - pub fn user_lp_token_account( - &mut self, - user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_lp_token_account = Some(user_lp_token_account); - self - } - - #[inline(always)] - pub fn user_owner( - &mut self, - user_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_owner = Some(user_owner); - self - } - - #[inline(always)] - pub fn serum_event_queue( - &mut self, - serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn max_coin_amount(&mut self, max_coin_amount: u64) -> &mut Self { - self.instruction.max_coin_amount = Some(max_coin_amount); - self - } - - #[inline(always)] - pub fn max_pc_amount(&mut self, max_pc_amount: u64) -> &mut Self { - self.instruction.max_pc_amount = Some(max_pc_amount); - self - } - - #[inline(always)] - pub fn base_side(&mut self, base_side: u64) -> &mut Self { - self.instruction.base_side = Some(base_side); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DepositInstructionArgs { - max_coin_amount: self - .instruction - .max_coin_amount - .clone() - .expect("max_coin_amount is not set"), - max_pc_amount: self - .instruction - .max_pc_amount - .clone() - .expect("max_pc_amount is not set"), - base_side: self - .instruction - .base_side - .clone() - .expect("base_side is not set"), - }; - let instruction = DepositCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - amm_target_orders: self - .instruction - .amm_target_orders - .expect("amm_target_orders is not set"), - - lp_mint_address: self - .instruction - .lp_mint_address - .expect("lp_mint_address is not set"), - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - user_coin_token_account: self - .instruction - .user_coin_token_account - .expect("user_coin_token_account is not set"), - - user_pc_token_account: self - .instruction - .user_pc_token_account - .expect("user_pc_token_account is not set"), - - user_lp_token_account: self - .instruction - .user_lp_token_account - .expect("user_lp_token_account is not set"), - - user_owner: self.instruction.user_owner.expect("user_owner is not set"), - - serum_event_queue: self - .instruction - .serum_event_queue - .expect("serum_event_queue is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DepositCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint_address: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - user_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_lp_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_event_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - max_coin_amount: Option, - max_pc_amount: Option, - base_side: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/initialize.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/initialize.rs deleted file mode 100644 index 0133111b..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/initialize.rs +++ /dev/null @@ -1,1068 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Initialize { - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub lp_mint_address: solana_pubkey::Pubkey, - - pub coin_mint_address: solana_pubkey::Pubkey, - - pub pc_mint_address: solana_pubkey::Pubkey, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub pool_withdraw_queue: solana_pubkey::Pubkey, - - pub pool_target_orders_account: solana_pubkey::Pubkey, - - pub user_lp_token_account: solana_pubkey::Pubkey, - - pub pool_temp_lp_token_account: solana_pubkey::Pubkey, - - pub serum_program: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub user_wallet: solana_pubkey::Pubkey, -} - -impl Initialize { - pub fn instruction(&self, args: InitializeInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lp_mint_address, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.coin_mint_address, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pc_mint_address, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_withdraw_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_target_orders_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_lp_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_temp_lp_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.user_wallet, true)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionData { - discriminator: [u8; 1], -} - -impl InitializeInstructionData { - pub fn new() -> Self { Self { discriminator: [0] } } -} - -impl Default for InitializeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionArgs { - pub nonce: u8, - pub open_time: u64, -} - -/// Instruction builder for `Initialize`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 2. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 3. `[writable]` amm -/// 4. `[]` amm_authority -/// 5. `[writable]` amm_open_orders -/// 6. `[writable]` lp_mint_address -/// 7. `[]` coin_mint_address -/// 8. `[]` pc_mint_address -/// 9. `[]` pool_coin_token_account -/// 10. `[]` pool_pc_token_account -/// 11. `[writable]` pool_withdraw_queue -/// 12. `[writable]` pool_target_orders_account -/// 13. `[writable]` user_lp_token_account -/// 14. `[]` pool_temp_lp_token_account -/// 15. `[]` serum_program -/// 16. `[]` serum_market -/// 17. `[writable, signer]` user_wallet -#[derive(Clone, Debug, Default)] -pub struct InitializeBuilder { - token_program: Option, - system_program: Option, - rent: Option, - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - lp_mint_address: Option, - coin_mint_address: Option, - pc_mint_address: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - pool_withdraw_queue: Option, - pool_target_orders_account: Option, - user_lp_token_account: Option, - pool_temp_lp_token_account: Option, - serum_program: Option, - serum_market: Option, - user_wallet: Option, - nonce: Option, - open_time: Option, - __remaining_accounts: Vec, -} - -impl InitializeBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn lp_mint_address(&mut self, lp_mint_address: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint_address = Some(lp_mint_address); - self - } - - #[inline(always)] - pub fn coin_mint_address(&mut self, coin_mint_address: solana_pubkey::Pubkey) -> &mut Self { - self.coin_mint_address = Some(coin_mint_address); - self - } - - #[inline(always)] - pub fn pc_mint_address(&mut self, pc_mint_address: solana_pubkey::Pubkey) -> &mut Self { - self.pc_mint_address = Some(pc_mint_address); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn pool_withdraw_queue(&mut self, pool_withdraw_queue: solana_pubkey::Pubkey) -> &mut Self { - self.pool_withdraw_queue = Some(pool_withdraw_queue); - self - } - - #[inline(always)] - pub fn pool_target_orders_account( - &mut self, - pool_target_orders_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_target_orders_account = Some(pool_target_orders_account); - self - } - - #[inline(always)] - pub fn user_lp_token_account( - &mut self, - user_lp_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_lp_token_account = Some(user_lp_token_account); - self - } - - #[inline(always)] - pub fn pool_temp_lp_token_account( - &mut self, - pool_temp_lp_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_temp_lp_token_account = Some(pool_temp_lp_token_account); - self - } - - #[inline(always)] - pub fn serum_program(&mut self, serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn user_wallet(&mut self, user_wallet: solana_pubkey::Pubkey) -> &mut Self { - self.user_wallet = Some(user_wallet); - self - } - - #[inline(always)] - pub fn nonce(&mut self, nonce: u8) -> &mut Self { - self.nonce = Some(nonce); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.open_time = Some(open_time); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Initialize { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - lp_mint_address: self.lp_mint_address.expect("lp_mint_address is not set"), - coin_mint_address: self - .coin_mint_address - .expect("coin_mint_address is not set"), - pc_mint_address: self.pc_mint_address.expect("pc_mint_address is not set"), - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - pool_withdraw_queue: self - .pool_withdraw_queue - .expect("pool_withdraw_queue is not set"), - pool_target_orders_account: self - .pool_target_orders_account - .expect("pool_target_orders_account is not set"), - user_lp_token_account: self - .user_lp_token_account - .expect("user_lp_token_account is not set"), - pool_temp_lp_token_account: self - .pool_temp_lp_token_account - .expect("pool_temp_lp_token_account is not set"), - serum_program: self.serum_program.expect("serum_program is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - user_wallet: self.user_wallet.expect("user_wallet is not set"), - }; - let args = InitializeInstructionArgs { - nonce: self.nonce.clone().expect("nonce is not set"), - open_time: self.open_time.clone().expect("open_time is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize` CPI accounts. -pub struct InitializeCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub coin_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pc_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - - pub pool_target_orders_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_temp_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub user_wallet: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize` CPI instruction. -pub struct InitializeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub coin_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pc_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - - pub pool_target_orders_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_temp_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub user_wallet: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeInstructionArgs, -} - -impl<'a, 'b> InitializeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCpiAccounts<'a, 'b>, - args: InitializeInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - lp_mint_address: accounts.lp_mint_address, - coin_mint_address: accounts.coin_mint_address, - pc_mint_address: accounts.pc_mint_address, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - pool_withdraw_queue: accounts.pool_withdraw_queue, - pool_target_orders_account: accounts.pool_target_orders_account, - user_lp_token_account: accounts.user_lp_token_account, - pool_temp_lp_token_account: accounts.pool_temp_lp_token_account, - serum_program: accounts.serum_program, - serum_market: accounts.serum_market, - user_wallet: accounts.user_wallet, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.amm.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint_address.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.coin_mint_address.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pc_mint_address.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_withdraw_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_target_orders_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_lp_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_temp_lp_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_wallet.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(19 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.lp_mint_address.clone()); - account_infos.push(self.coin_mint_address.clone()); - account_infos.push(self.pc_mint_address.clone()); - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.pool_withdraw_queue.clone()); - account_infos.push(self.pool_target_orders_account.clone()); - account_infos.push(self.user_lp_token_account.clone()); - account_infos.push(self.pool_temp_lp_token_account.clone()); - account_infos.push(self.serum_program.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.user_wallet.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Initialize` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[]` system_program -/// 2. `[]` rent -/// 3. `[writable]` amm -/// 4. `[]` amm_authority -/// 5. `[writable]` amm_open_orders -/// 6. `[writable]` lp_mint_address -/// 7. `[]` coin_mint_address -/// 8. `[]` pc_mint_address -/// 9. `[]` pool_coin_token_account -/// 10. `[]` pool_pc_token_account -/// 11. `[writable]` pool_withdraw_queue -/// 12. `[writable]` pool_target_orders_account -/// 13. `[writable]` user_lp_token_account -/// 14. `[]` pool_temp_lp_token_account -/// 15. `[]` serum_program -/// 16. `[]` serum_market -/// 17. `[writable, signer]` user_wallet -#[derive(Clone, Debug)] -pub struct InitializeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCpiBuilderInstruction { - __program: program, - token_program: None, - system_program: None, - rent: None, - amm: None, - amm_authority: None, - amm_open_orders: None, - lp_mint_address: None, - coin_mint_address: None, - pc_mint_address: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - pool_withdraw_queue: None, - pool_target_orders_account: None, - user_lp_token_account: None, - pool_temp_lp_token_account: None, - serum_program: None, - serum_market: None, - user_wallet: None, - nonce: None, - open_time: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn lp_mint_address( - &mut self, - lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lp_mint_address = Some(lp_mint_address); - self - } - - #[inline(always)] - pub fn coin_mint_address( - &mut self, - coin_mint_address: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_mint_address = Some(coin_mint_address); - self - } - - #[inline(always)] - pub fn pc_mint_address( - &mut self, - pc_mint_address: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pc_mint_address = Some(pc_mint_address); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn pool_withdraw_queue( - &mut self, - pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_withdraw_queue = Some(pool_withdraw_queue); - self - } - - #[inline(always)] - pub fn pool_target_orders_account( - &mut self, - pool_target_orders_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_target_orders_account = Some(pool_target_orders_account); - self - } - - #[inline(always)] - pub fn user_lp_token_account( - &mut self, - user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_lp_token_account = Some(user_lp_token_account); - self - } - - #[inline(always)] - pub fn pool_temp_lp_token_account( - &mut self, - pool_temp_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_temp_lp_token_account = Some(pool_temp_lp_token_account); - self - } - - #[inline(always)] - pub fn serum_program( - &mut self, - serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn user_wallet( - &mut self, - user_wallet: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_wallet = Some(user_wallet); - self - } - - #[inline(always)] - pub fn nonce(&mut self, nonce: u8) -> &mut Self { - self.instruction.nonce = Some(nonce); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.instruction.open_time = Some(open_time); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeInstructionArgs { - nonce: self.instruction.nonce.clone().expect("nonce is not set"), - open_time: self - .instruction - .open_time - .clone() - .expect("open_time is not set"), - }; - let instruction = InitializeCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - lp_mint_address: self - .instruction - .lp_mint_address - .expect("lp_mint_address is not set"), - - coin_mint_address: self - .instruction - .coin_mint_address - .expect("coin_mint_address is not set"), - - pc_mint_address: self - .instruction - .pc_mint_address - .expect("pc_mint_address is not set"), - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - pool_withdraw_queue: self - .instruction - .pool_withdraw_queue - .expect("pool_withdraw_queue is not set"), - - pool_target_orders_account: self - .instruction - .pool_target_orders_account - .expect("pool_target_orders_account is not set"), - - user_lp_token_account: self - .instruction - .user_lp_token_account - .expect("user_lp_token_account is not set"), - - pool_temp_lp_token_account: self - .instruction - .pool_temp_lp_token_account - .expect("pool_temp_lp_token_account is not set"), - - serum_program: self - .instruction - .serum_program - .expect("serum_program is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - user_wallet: self - .instruction - .user_wallet - .expect("user_wallet is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint_address: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_mint_address: Option<&'b solana_account_info::AccountInfo<'a>>, - pc_mint_address: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_withdraw_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_target_orders_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_lp_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_temp_lp_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - user_wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - nonce: Option, - open_time: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/initialize2.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/initialize2.rs deleted file mode 100644 index 8daf2323..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/initialize2.rs +++ /dev/null @@ -1,1218 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Initialize2 { - pub token_program: solana_pubkey::Pubkey, - - pub spl_associated_token_account: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub coin_mint: solana_pubkey::Pubkey, - - pub pc_mint: solana_pubkey::Pubkey, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub pool_withdraw_queue: solana_pubkey::Pubkey, - - pub amm_target_orders: solana_pubkey::Pubkey, - - pub pool_temp_lp: solana_pubkey::Pubkey, - - pub serum_program: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub user_wallet: solana_pubkey::Pubkey, - - pub user_token_coin: solana_pubkey::Pubkey, - - pub user_token_pc: solana_pubkey::Pubkey, - - pub user_lp_token_account: solana_pubkey::Pubkey, -} - -impl Initialize2 { - pub fn instruction(&self, args: Initialize2InstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: Initialize2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(21 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.spl_associated_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.coin_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pc_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_withdraw_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_target_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_temp_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.user_wallet, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_coin, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_pc, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_lp_token_account, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&Initialize2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Initialize2InstructionData { - discriminator: [u8; 1], -} - -impl Initialize2InstructionData { - pub fn new() -> Self { Self { discriminator: [1] } } -} - -impl Default for Initialize2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Initialize2InstructionArgs { - pub nonce: u8, - pub open_time: u64, - pub init_pc_amount: u64, - pub init_coin_amount: u64, -} - -/// Instruction builder for `Initialize2`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[]` spl_associated_token_account -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 3. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 4. `[writable]` amm -/// 5. `[]` amm_authority -/// 6. `[writable]` amm_open_orders -/// 7. `[writable]` lp_mint -/// 8. `[]` coin_mint -/// 9. `[]` pc_mint -/// 10. `[writable]` pool_coin_token_account -/// 11. `[writable]` pool_pc_token_account -/// 12. `[writable]` pool_withdraw_queue -/// 13. `[writable]` amm_target_orders -/// 14. `[writable]` pool_temp_lp -/// 15. `[]` serum_program -/// 16. `[]` serum_market -/// 17. `[writable, signer]` user_wallet -/// 18. `[writable]` user_token_coin -/// 19. `[writable]` user_token_pc -/// 20. `[writable]` user_lp_token_account -#[derive(Clone, Debug, Default)] -pub struct Initialize2Builder { - token_program: Option, - spl_associated_token_account: Option, - system_program: Option, - rent: Option, - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - lp_mint: Option, - coin_mint: Option, - pc_mint: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - pool_withdraw_queue: Option, - amm_target_orders: Option, - pool_temp_lp: Option, - serum_program: Option, - serum_market: Option, - user_wallet: Option, - user_token_coin: Option, - user_token_pc: Option, - user_lp_token_account: Option, - nonce: Option, - open_time: Option, - init_pc_amount: Option, - init_coin_amount: Option, - __remaining_accounts: Vec, -} - -impl Initialize2Builder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn spl_associated_token_account( - &mut self, - spl_associated_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.spl_associated_token_account = Some(spl_associated_token_account); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn coin_mint(&mut self, coin_mint: solana_pubkey::Pubkey) -> &mut Self { - self.coin_mint = Some(coin_mint); - self - } - - #[inline(always)] - pub fn pc_mint(&mut self, pc_mint: solana_pubkey::Pubkey) -> &mut Self { - self.pc_mint = Some(pc_mint); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn pool_withdraw_queue(&mut self, pool_withdraw_queue: solana_pubkey::Pubkey) -> &mut Self { - self.pool_withdraw_queue = Some(pool_withdraw_queue); - self - } - - #[inline(always)] - pub fn amm_target_orders(&mut self, amm_target_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn pool_temp_lp(&mut self, pool_temp_lp: solana_pubkey::Pubkey) -> &mut Self { - self.pool_temp_lp = Some(pool_temp_lp); - self - } - - #[inline(always)] - pub fn serum_program(&mut self, serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn user_wallet(&mut self, user_wallet: solana_pubkey::Pubkey) -> &mut Self { - self.user_wallet = Some(user_wallet); - self - } - - #[inline(always)] - pub fn user_token_coin(&mut self, user_token_coin: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_coin = Some(user_token_coin); - self - } - - #[inline(always)] - pub fn user_token_pc(&mut self, user_token_pc: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_pc = Some(user_token_pc); - self - } - - #[inline(always)] - pub fn user_lp_token_account( - &mut self, - user_lp_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_lp_token_account = Some(user_lp_token_account); - self - } - - #[inline(always)] - pub fn nonce(&mut self, nonce: u8) -> &mut Self { - self.nonce = Some(nonce); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.open_time = Some(open_time); - self - } - - #[inline(always)] - pub fn init_pc_amount(&mut self, init_pc_amount: u64) -> &mut Self { - self.init_pc_amount = Some(init_pc_amount); - self - } - - #[inline(always)] - pub fn init_coin_amount(&mut self, init_coin_amount: u64) -> &mut Self { - self.init_coin_amount = Some(init_coin_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Initialize2 { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - spl_associated_token_account: self - .spl_associated_token_account - .expect("spl_associated_token_account is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - coin_mint: self.coin_mint.expect("coin_mint is not set"), - pc_mint: self.pc_mint.expect("pc_mint is not set"), - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - pool_withdraw_queue: self - .pool_withdraw_queue - .expect("pool_withdraw_queue is not set"), - amm_target_orders: self - .amm_target_orders - .expect("amm_target_orders is not set"), - pool_temp_lp: self.pool_temp_lp.expect("pool_temp_lp is not set"), - serum_program: self.serum_program.expect("serum_program is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - user_wallet: self.user_wallet.expect("user_wallet is not set"), - user_token_coin: self.user_token_coin.expect("user_token_coin is not set"), - user_token_pc: self.user_token_pc.expect("user_token_pc is not set"), - user_lp_token_account: self - .user_lp_token_account - .expect("user_lp_token_account is not set"), - }; - let args = Initialize2InstructionArgs { - nonce: self.nonce.clone().expect("nonce is not set"), - open_time: self.open_time.clone().expect("open_time is not set"), - init_pc_amount: self - .init_pc_amount - .clone() - .expect("init_pc_amount is not set"), - init_coin_amount: self - .init_coin_amount - .clone() - .expect("init_coin_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize2` CPI accounts. -pub struct Initialize2CpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub spl_associated_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub coin_mint: &'b solana_account_info::AccountInfo<'a>, - - pub pc_mint: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_temp_lp: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub user_wallet: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_coin: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_pc: &'b solana_account_info::AccountInfo<'a>, - - pub user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize2` CPI instruction. -pub struct Initialize2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub spl_associated_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub coin_mint: &'b solana_account_info::AccountInfo<'a>, - - pub pc_mint: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_temp_lp: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub user_wallet: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_coin: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_pc: &'b solana_account_info::AccountInfo<'a>, - - pub user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: Initialize2InstructionArgs, -} - -impl<'a, 'b> Initialize2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: Initialize2CpiAccounts<'a, 'b>, - args: Initialize2InstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - spl_associated_token_account: accounts.spl_associated_token_account, - system_program: accounts.system_program, - rent: accounts.rent, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - lp_mint: accounts.lp_mint, - coin_mint: accounts.coin_mint, - pc_mint: accounts.pc_mint, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - pool_withdraw_queue: accounts.pool_withdraw_queue, - amm_target_orders: accounts.amm_target_orders, - pool_temp_lp: accounts.pool_temp_lp, - serum_program: accounts.serum_program, - serum_market: accounts.serum_market, - user_wallet: accounts.user_wallet, - user_token_coin: accounts.user_token_coin, - user_token_pc: accounts.user_token_pc, - user_lp_token_account: accounts.user_lp_token_account, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(21 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.spl_associated_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.amm.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.coin_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pc_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_withdraw_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_target_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_temp_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_wallet.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_coin.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_pc.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_lp_token_account.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&Initialize2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(22 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.spl_associated_token_account.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.coin_mint.clone()); - account_infos.push(self.pc_mint.clone()); - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.pool_withdraw_queue.clone()); - account_infos.push(self.amm_target_orders.clone()); - account_infos.push(self.pool_temp_lp.clone()); - account_infos.push(self.serum_program.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.user_wallet.clone()); - account_infos.push(self.user_token_coin.clone()); - account_infos.push(self.user_token_pc.clone()); - account_infos.push(self.user_lp_token_account.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Initialize2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[]` spl_associated_token_account -/// 2. `[]` system_program -/// 3. `[]` rent -/// 4. `[writable]` amm -/// 5. `[]` amm_authority -/// 6. `[writable]` amm_open_orders -/// 7. `[writable]` lp_mint -/// 8. `[]` coin_mint -/// 9. `[]` pc_mint -/// 10. `[writable]` pool_coin_token_account -/// 11. `[writable]` pool_pc_token_account -/// 12. `[writable]` pool_withdraw_queue -/// 13. `[writable]` amm_target_orders -/// 14. `[writable]` pool_temp_lp -/// 15. `[]` serum_program -/// 16. `[]` serum_market -/// 17. `[writable, signer]` user_wallet -/// 18. `[writable]` user_token_coin -/// 19. `[writable]` user_token_pc -/// 20. `[writable]` user_lp_token_account -#[derive(Clone, Debug)] -pub struct Initialize2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> Initialize2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(Initialize2CpiBuilderInstruction { - __program: program, - token_program: None, - spl_associated_token_account: None, - system_program: None, - rent: None, - amm: None, - amm_authority: None, - amm_open_orders: None, - lp_mint: None, - coin_mint: None, - pc_mint: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - pool_withdraw_queue: None, - amm_target_orders: None, - pool_temp_lp: None, - serum_program: None, - serum_market: None, - user_wallet: None, - user_token_coin: None, - user_token_pc: None, - user_lp_token_account: None, - nonce: None, - open_time: None, - init_pc_amount: None, - init_coin_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn spl_associated_token_account( - &mut self, - spl_associated_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.spl_associated_token_account = Some(spl_associated_token_account); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn coin_mint(&mut self, coin_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.coin_mint = Some(coin_mint); - self - } - - #[inline(always)] - pub fn pc_mint(&mut self, pc_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pc_mint = Some(pc_mint); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn pool_withdraw_queue( - &mut self, - pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_withdraw_queue = Some(pool_withdraw_queue); - self - } - - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn pool_temp_lp( - &mut self, - pool_temp_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_temp_lp = Some(pool_temp_lp); - self - } - - #[inline(always)] - pub fn serum_program( - &mut self, - serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn user_wallet( - &mut self, - user_wallet: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_wallet = Some(user_wallet); - self - } - - #[inline(always)] - pub fn user_token_coin( - &mut self, - user_token_coin: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_coin = Some(user_token_coin); - self - } - - #[inline(always)] - pub fn user_token_pc( - &mut self, - user_token_pc: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_pc = Some(user_token_pc); - self - } - - #[inline(always)] - pub fn user_lp_token_account( - &mut self, - user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_lp_token_account = Some(user_lp_token_account); - self - } - - #[inline(always)] - pub fn nonce(&mut self, nonce: u8) -> &mut Self { - self.instruction.nonce = Some(nonce); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.instruction.open_time = Some(open_time); - self - } - - #[inline(always)] - pub fn init_pc_amount(&mut self, init_pc_amount: u64) -> &mut Self { - self.instruction.init_pc_amount = Some(init_pc_amount); - self - } - - #[inline(always)] - pub fn init_coin_amount(&mut self, init_coin_amount: u64) -> &mut Self { - self.instruction.init_coin_amount = Some(init_coin_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = Initialize2InstructionArgs { - nonce: self.instruction.nonce.clone().expect("nonce is not set"), - open_time: self - .instruction - .open_time - .clone() - .expect("open_time is not set"), - init_pc_amount: self - .instruction - .init_pc_amount - .clone() - .expect("init_pc_amount is not set"), - init_coin_amount: self - .instruction - .init_coin_amount - .clone() - .expect("init_coin_amount is not set"), - }; - let instruction = Initialize2Cpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - spl_associated_token_account: self - .instruction - .spl_associated_token_account - .expect("spl_associated_token_account is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - coin_mint: self.instruction.coin_mint.expect("coin_mint is not set"), - - pc_mint: self.instruction.pc_mint.expect("pc_mint is not set"), - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - pool_withdraw_queue: self - .instruction - .pool_withdraw_queue - .expect("pool_withdraw_queue is not set"), - - amm_target_orders: self - .instruction - .amm_target_orders - .expect("amm_target_orders is not set"), - - pool_temp_lp: self - .instruction - .pool_temp_lp - .expect("pool_temp_lp is not set"), - - serum_program: self - .instruction - .serum_program - .expect("serum_program is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - user_wallet: self - .instruction - .user_wallet - .expect("user_wallet is not set"), - - user_token_coin: self - .instruction - .user_token_coin - .expect("user_token_coin is not set"), - - user_token_pc: self - .instruction - .user_token_pc - .expect("user_token_pc is not set"), - - user_lp_token_account: self - .instruction - .user_lp_token_account - .expect("user_lp_token_account is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct Initialize2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - spl_associated_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - pc_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_withdraw_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_temp_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - user_wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_coin: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_pc: Option<&'b solana_account_info::AccountInfo<'a>>, - user_lp_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - nonce: Option, - open_time: Option, - init_pc_amount: Option, - init_coin_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/migrate_to_open_book.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/migrate_to_open_book.rs deleted file mode 100644 index ef697cee..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/migrate_to_open_book.rs +++ /dev/null @@ -1,1095 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MigrateToOpenBook { - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub amm_token_coin: solana_pubkey::Pubkey, - - pub amm_token_pc: solana_pubkey::Pubkey, - - pub amm_target_orders: solana_pubkey::Pubkey, - - pub serum_program: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub serum_bids: solana_pubkey::Pubkey, - - pub serum_asks: solana_pubkey::Pubkey, - - pub serum_event_queue: solana_pubkey::Pubkey, - - pub serum_coin_vault: solana_pubkey::Pubkey, - - pub serum_pc_vault: solana_pubkey::Pubkey, - - pub serum_vault_signer: solana_pubkey::Pubkey, - - pub new_amm_open_orders: solana_pubkey::Pubkey, - - pub new_serum_program: solana_pubkey::Pubkey, - - pub new_serum_market: solana_pubkey::Pubkey, - - pub admin: solana_pubkey::Pubkey, -} - -impl MigrateToOpenBook { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(21 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_token_coin, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_token_pc, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_target_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.serum_bids, false)); - accounts.push(solana_instruction::AccountMeta::new(self.serum_asks, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_event_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_coin_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_pc_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_vault_signer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.new_amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.admin, true)); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigrateToOpenBookInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateToOpenBookInstructionData { - discriminator: [u8; 1], -} - -impl MigrateToOpenBookInstructionData { - pub fn new() -> Self { Self { discriminator: [5] } } -} - -impl Default for MigrateToOpenBookInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigrateToOpenBook`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 2. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 3. `[writable]` amm -/// 4. `[]` amm_authority -/// 5. `[writable]` amm_open_orders -/// 6. `[writable]` amm_token_coin -/// 7. `[writable]` amm_token_pc -/// 8. `[writable]` amm_target_orders -/// 9. `[]` serum_program -/// 10. `[writable]` serum_market -/// 11. `[writable]` serum_bids -/// 12. `[writable]` serum_asks -/// 13. `[writable]` serum_event_queue -/// 14. `[writable]` serum_coin_vault -/// 15. `[writable]` serum_pc_vault -/// 16. `[]` serum_vault_signer -/// 17. `[writable]` new_amm_open_orders -/// 18. `[]` new_serum_program -/// 19. `[]` new_serum_market -/// 20. `[writable, signer]` admin -#[derive(Clone, Debug, Default)] -pub struct MigrateToOpenBookBuilder { - token_program: Option, - system_program: Option, - rent: Option, - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - amm_token_coin: Option, - amm_token_pc: Option, - amm_target_orders: Option, - serum_program: Option, - serum_market: Option, - serum_bids: Option, - serum_asks: Option, - serum_event_queue: Option, - serum_coin_vault: Option, - serum_pc_vault: Option, - serum_vault_signer: Option, - new_amm_open_orders: Option, - new_serum_program: Option, - new_serum_market: Option, - admin: Option, - __remaining_accounts: Vec, -} - -impl MigrateToOpenBookBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_token_coin(&mut self, amm_token_coin: solana_pubkey::Pubkey) -> &mut Self { - self.amm_token_coin = Some(amm_token_coin); - self - } - - #[inline(always)] - pub fn amm_token_pc(&mut self, amm_token_pc: solana_pubkey::Pubkey) -> &mut Self { - self.amm_token_pc = Some(amm_token_pc); - self - } - - #[inline(always)] - pub fn amm_target_orders(&mut self, amm_target_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn serum_program(&mut self, serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_bids(&mut self, serum_bids: solana_pubkey::Pubkey) -> &mut Self { - self.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks(&mut self, serum_asks: solana_pubkey::Pubkey) -> &mut Self { - self.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn serum_event_queue(&mut self, serum_event_queue: solana_pubkey::Pubkey) -> &mut Self { - self.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn serum_coin_vault(&mut self, serum_coin_vault: solana_pubkey::Pubkey) -> &mut Self { - self.serum_coin_vault = Some(serum_coin_vault); - self - } - - #[inline(always)] - pub fn serum_pc_vault(&mut self, serum_pc_vault: solana_pubkey::Pubkey) -> &mut Self { - self.serum_pc_vault = Some(serum_pc_vault); - self - } - - #[inline(always)] - pub fn serum_vault_signer(&mut self, serum_vault_signer: solana_pubkey::Pubkey) -> &mut Self { - self.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn new_amm_open_orders(&mut self, new_amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.new_amm_open_orders = Some(new_amm_open_orders); - self - } - - #[inline(always)] - pub fn new_serum_program(&mut self, new_serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.new_serum_program = Some(new_serum_program); - self - } - - #[inline(always)] - pub fn new_serum_market(&mut self, new_serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.new_serum_market = Some(new_serum_market); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrateToOpenBook { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - amm_token_coin: self.amm_token_coin.expect("amm_token_coin is not set"), - amm_token_pc: self.amm_token_pc.expect("amm_token_pc is not set"), - amm_target_orders: self - .amm_target_orders - .expect("amm_target_orders is not set"), - serum_program: self.serum_program.expect("serum_program is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - serum_bids: self.serum_bids.expect("serum_bids is not set"), - serum_asks: self.serum_asks.expect("serum_asks is not set"), - serum_event_queue: self - .serum_event_queue - .expect("serum_event_queue is not set"), - serum_coin_vault: self.serum_coin_vault.expect("serum_coin_vault is not set"), - serum_pc_vault: self.serum_pc_vault.expect("serum_pc_vault is not set"), - serum_vault_signer: self - .serum_vault_signer - .expect("serum_vault_signer is not set"), - new_amm_open_orders: self - .new_amm_open_orders - .expect("new_amm_open_orders is not set"), - new_serum_program: self - .new_serum_program - .expect("new_serum_program is not set"), - new_serum_market: self.new_serum_market.expect("new_serum_market is not set"), - admin: self.admin.expect("admin is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migrate_to_open_book` CPI accounts. -pub struct MigrateToOpenBookCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_token_coin: &'b solana_account_info::AccountInfo<'a>, - - pub amm_token_pc: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub new_amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub new_serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub new_serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migrate_to_open_book` CPI instruction. -pub struct MigrateToOpenBookCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_token_coin: &'b solana_account_info::AccountInfo<'a>, - - pub amm_token_pc: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub new_amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub new_serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub new_serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrateToOpenBookCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrateToOpenBookCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - amm_token_coin: accounts.amm_token_coin, - amm_token_pc: accounts.amm_token_pc, - amm_target_orders: accounts.amm_target_orders, - serum_program: accounts.serum_program, - serum_market: accounts.serum_market, - serum_bids: accounts.serum_bids, - serum_asks: accounts.serum_asks, - serum_event_queue: accounts.serum_event_queue, - serum_coin_vault: accounts.serum_coin_vault, - serum_pc_vault: accounts.serum_pc_vault, - serum_vault_signer: accounts.serum_vault_signer, - new_amm_open_orders: accounts.new_amm_open_orders, - new_serum_program: accounts.new_serum_program, - new_serum_market: accounts.new_serum_market, - admin: accounts.admin, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(21 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.amm.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_token_coin.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_token_pc.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_target_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_bids.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_asks.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_event_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_coin_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_pc_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_vault_signer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.new_amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.admin.key, true)); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigrateToOpenBookInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(22 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.amm_token_coin.clone()); - account_infos.push(self.amm_token_pc.clone()); - account_infos.push(self.amm_target_orders.clone()); - account_infos.push(self.serum_program.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.serum_bids.clone()); - account_infos.push(self.serum_asks.clone()); - account_infos.push(self.serum_event_queue.clone()); - account_infos.push(self.serum_coin_vault.clone()); - account_infos.push(self.serum_pc_vault.clone()); - account_infos.push(self.serum_vault_signer.clone()); - account_infos.push(self.new_amm_open_orders.clone()); - account_infos.push(self.new_serum_program.clone()); - account_infos.push(self.new_serum_market.clone()); - account_infos.push(self.admin.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrateToOpenBook` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[]` system_program -/// 2. `[]` rent -/// 3. `[writable]` amm -/// 4. `[]` amm_authority -/// 5. `[writable]` amm_open_orders -/// 6. `[writable]` amm_token_coin -/// 7. `[writable]` amm_token_pc -/// 8. `[writable]` amm_target_orders -/// 9. `[]` serum_program -/// 10. `[writable]` serum_market -/// 11. `[writable]` serum_bids -/// 12. `[writable]` serum_asks -/// 13. `[writable]` serum_event_queue -/// 14. `[writable]` serum_coin_vault -/// 15. `[writable]` serum_pc_vault -/// 16. `[]` serum_vault_signer -/// 17. `[writable]` new_amm_open_orders -/// 18. `[]` new_serum_program -/// 19. `[]` new_serum_market -/// 20. `[writable, signer]` admin -#[derive(Clone, Debug)] -pub struct MigrateToOpenBookCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrateToOpenBookCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrateToOpenBookCpiBuilderInstruction { - __program: program, - token_program: None, - system_program: None, - rent: None, - amm: None, - amm_authority: None, - amm_open_orders: None, - amm_token_coin: None, - amm_token_pc: None, - amm_target_orders: None, - serum_program: None, - serum_market: None, - serum_bids: None, - serum_asks: None, - serum_event_queue: None, - serum_coin_vault: None, - serum_pc_vault: None, - serum_vault_signer: None, - new_amm_open_orders: None, - new_serum_program: None, - new_serum_market: None, - admin: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_token_coin( - &mut self, - amm_token_coin: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_token_coin = Some(amm_token_coin); - self - } - - #[inline(always)] - pub fn amm_token_pc( - &mut self, - amm_token_pc: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_token_pc = Some(amm_token_pc); - self - } - - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn serum_program( - &mut self, - serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_bids( - &mut self, - serum_bids: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks( - &mut self, - serum_asks: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn serum_event_queue( - &mut self, - serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn serum_coin_vault( - &mut self, - serum_coin_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_coin_vault = Some(serum_coin_vault); - self - } - - #[inline(always)] - pub fn serum_pc_vault( - &mut self, - serum_pc_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_pc_vault = Some(serum_pc_vault); - self - } - - #[inline(always)] - pub fn serum_vault_signer( - &mut self, - serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn new_amm_open_orders( - &mut self, - new_amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_amm_open_orders = Some(new_amm_open_orders); - self - } - - #[inline(always)] - pub fn new_serum_program( - &mut self, - new_serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_serum_program = Some(new_serum_program); - self - } - - #[inline(always)] - pub fn new_serum_market( - &mut self, - new_serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_serum_market = Some(new_serum_market); - self - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrateToOpenBookCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - amm_token_coin: self - .instruction - .amm_token_coin - .expect("amm_token_coin is not set"), - - amm_token_pc: self - .instruction - .amm_token_pc - .expect("amm_token_pc is not set"), - - amm_target_orders: self - .instruction - .amm_target_orders - .expect("amm_target_orders is not set"), - - serum_program: self - .instruction - .serum_program - .expect("serum_program is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - serum_bids: self.instruction.serum_bids.expect("serum_bids is not set"), - - serum_asks: self.instruction.serum_asks.expect("serum_asks is not set"), - - serum_event_queue: self - .instruction - .serum_event_queue - .expect("serum_event_queue is not set"), - - serum_coin_vault: self - .instruction - .serum_coin_vault - .expect("serum_coin_vault is not set"), - - serum_pc_vault: self - .instruction - .serum_pc_vault - .expect("serum_pc_vault is not set"), - - serum_vault_signer: self - .instruction - .serum_vault_signer - .expect("serum_vault_signer is not set"), - - new_amm_open_orders: self - .instruction - .new_amm_open_orders - .expect("new_amm_open_orders is not set"), - - new_serum_program: self - .instruction - .new_serum_program - .expect("new_serum_program is not set"), - - new_serum_market: self - .instruction - .new_serum_market - .expect("new_serum_market is not set"), - - admin: self.instruction.admin.expect("admin is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrateToOpenBookCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_token_coin: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_token_pc: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_bids: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_asks: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_event_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_coin_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_pc_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_vault_signer: Option<&'b solana_account_info::AccountInfo<'a>>, - new_amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - new_serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - new_serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/mod.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index b998fb12..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#admin_cancel_orders; -pub(crate) mod r#create_config_account; -pub(crate) mod r#deposit; -pub(crate) mod r#initialize; -pub(crate) mod r#initialize2; -pub(crate) mod r#migrate_to_open_book; -pub(crate) mod r#monitor_step; -pub(crate) mod r#pre_initialize; -pub(crate) mod r#set_params; -pub(crate) mod r#simulate_info; -pub(crate) mod r#swap_base_in; -pub(crate) mod r#swap_base_out; -pub(crate) mod r#update_config_account; -pub(crate) mod r#withdraw; -pub(crate) mod r#withdraw_pnl; -pub(crate) mod r#withdraw_srm; - -pub use self::{ - r#admin_cancel_orders::*, r#create_config_account::*, r#deposit::*, r#initialize::*, - r#initialize2::*, r#migrate_to_open_book::*, r#monitor_step::*, r#pre_initialize::*, - r#set_params::*, r#simulate_info::*, r#swap_base_in::*, r#swap_base_out::*, - r#update_config_account::*, r#withdraw::*, r#withdraw_pnl::*, r#withdraw_srm::*, -}; diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/monitor_step.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/monitor_step.rs deleted file mode 100644 index 0839cd9f..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/monitor_step.rs +++ /dev/null @@ -1,1123 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct MonitorStep { - pub token_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub clock: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub amm_target_orders: solana_pubkey::Pubkey, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub pool_withdraw_queue: solana_pubkey::Pubkey, - - pub serum_program: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub serum_coin_vault_account: solana_pubkey::Pubkey, - - pub serum_pc_vault_account: solana_pubkey::Pubkey, - - pub serum_vault_signer: solana_pubkey::Pubkey, - - pub serum_req_q: solana_pubkey::Pubkey, - - pub serum_event_q: solana_pubkey::Pubkey, - - pub serum_bids: solana_pubkey::Pubkey, - - pub serum_asks: solana_pubkey::Pubkey, -} - -impl MonitorStep { - pub fn instruction(&self, args: MonitorStepInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: MonitorStepInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(19 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.clock, false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_target_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_withdraw_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_coin_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_pc_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_vault_signer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_req_q, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_event_q, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.serum_bids, false)); - accounts.push(solana_instruction::AccountMeta::new(self.serum_asks, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&MonitorStepInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MonitorStepInstructionData { - discriminator: [u8; 1], -} - -impl MonitorStepInstructionData { - pub fn new() -> Self { Self { discriminator: [2] } } -} - -impl Default for MonitorStepInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MonitorStepInstructionArgs { - pub plan_order_limit: u16, - pub place_order_limit: u16, - pub cancel_order_limit: u16, -} - -/// Instruction builder for `MonitorStep`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 2. `[]` clock -/// 3. `[writable]` amm -/// 4. `[]` amm_authority -/// 5. `[writable]` amm_open_orders -/// 6. `[writable]` amm_target_orders -/// 7. `[writable]` pool_coin_token_account -/// 8. `[writable]` pool_pc_token_account -/// 9. `[writable]` pool_withdraw_queue -/// 10. `[]` serum_program -/// 11. `[writable]` serum_market -/// 12. `[writable]` serum_coin_vault_account -/// 13. `[writable]` serum_pc_vault_account -/// 14. `[]` serum_vault_signer -/// 15. `[writable]` serum_req_q -/// 16. `[writable]` serum_event_q -/// 17. `[writable]` serum_bids -/// 18. `[writable]` serum_asks -#[derive(Clone, Debug, Default)] -pub struct MonitorStepBuilder { - token_program: Option, - rent: Option, - clock: Option, - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - amm_target_orders: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - pool_withdraw_queue: Option, - serum_program: Option, - serum_market: Option, - serum_coin_vault_account: Option, - serum_pc_vault_account: Option, - serum_vault_signer: Option, - serum_req_q: Option, - serum_event_q: Option, - serum_bids: Option, - serum_asks: Option, - plan_order_limit: Option, - place_order_limit: Option, - cancel_order_limit: Option, - __remaining_accounts: Vec, -} - -impl MonitorStepBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn clock(&mut self, clock: solana_pubkey::Pubkey) -> &mut Self { - self.clock = Some(clock); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_target_orders(&mut self, amm_target_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn pool_withdraw_queue(&mut self, pool_withdraw_queue: solana_pubkey::Pubkey) -> &mut Self { - self.pool_withdraw_queue = Some(pool_withdraw_queue); - self - } - - #[inline(always)] - pub fn serum_program(&mut self, serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer(&mut self, serum_vault_signer: solana_pubkey::Pubkey) -> &mut Self { - self.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn serum_req_q(&mut self, serum_req_q: solana_pubkey::Pubkey) -> &mut Self { - self.serum_req_q = Some(serum_req_q); - self - } - - #[inline(always)] - pub fn serum_event_q(&mut self, serum_event_q: solana_pubkey::Pubkey) -> &mut Self { - self.serum_event_q = Some(serum_event_q); - self - } - - #[inline(always)] - pub fn serum_bids(&mut self, serum_bids: solana_pubkey::Pubkey) -> &mut Self { - self.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks(&mut self, serum_asks: solana_pubkey::Pubkey) -> &mut Self { - self.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn plan_order_limit(&mut self, plan_order_limit: u16) -> &mut Self { - self.plan_order_limit = Some(plan_order_limit); - self - } - - #[inline(always)] - pub fn place_order_limit(&mut self, place_order_limit: u16) -> &mut Self { - self.place_order_limit = Some(place_order_limit); - self - } - - #[inline(always)] - pub fn cancel_order_limit(&mut self, cancel_order_limit: u16) -> &mut Self { - self.cancel_order_limit = Some(cancel_order_limit); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MonitorStep { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - clock: self.clock.expect("clock is not set"), - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - amm_target_orders: self - .amm_target_orders - .expect("amm_target_orders is not set"), - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - pool_withdraw_queue: self - .pool_withdraw_queue - .expect("pool_withdraw_queue is not set"), - serum_program: self.serum_program.expect("serum_program is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - serum_coin_vault_account: self - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - serum_pc_vault_account: self - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - serum_vault_signer: self - .serum_vault_signer - .expect("serum_vault_signer is not set"), - serum_req_q: self.serum_req_q.expect("serum_req_q is not set"), - serum_event_q: self.serum_event_q.expect("serum_event_q is not set"), - serum_bids: self.serum_bids.expect("serum_bids is not set"), - serum_asks: self.serum_asks.expect("serum_asks is not set"), - }; - let args = MonitorStepInstructionArgs { - plan_order_limit: self - .plan_order_limit - .clone() - .expect("plan_order_limit is not set"), - place_order_limit: self - .place_order_limit - .clone() - .expect("place_order_limit is not set"), - cancel_order_limit: self - .cancel_order_limit - .clone() - .expect("cancel_order_limit is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `monitor_step` CPI accounts. -pub struct MonitorStepCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub clock: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub serum_req_q: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_q: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, -} - -/// `monitor_step` CPI instruction. -pub struct MonitorStepCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub clock: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub serum_req_q: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_q: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: MonitorStepInstructionArgs, -} - -impl<'a, 'b> MonitorStepCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MonitorStepCpiAccounts<'a, 'b>, - args: MonitorStepInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - rent: accounts.rent, - clock: accounts.clock, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - amm_target_orders: accounts.amm_target_orders, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - pool_withdraw_queue: accounts.pool_withdraw_queue, - serum_program: accounts.serum_program, - serum_market: accounts.serum_market, - serum_coin_vault_account: accounts.serum_coin_vault_account, - serum_pc_vault_account: accounts.serum_pc_vault_account, - serum_vault_signer: accounts.serum_vault_signer, - serum_req_q: accounts.serum_req_q, - serum_event_q: accounts.serum_event_q, - serum_bids: accounts.serum_bids, - serum_asks: accounts.serum_asks, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(19 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.clock.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.amm.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_target_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_withdraw_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_coin_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_pc_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_vault_signer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_req_q.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_event_q.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_bids.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_asks.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&MonitorStepInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(20 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.clock.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.amm_target_orders.clone()); - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.pool_withdraw_queue.clone()); - account_infos.push(self.serum_program.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.serum_coin_vault_account.clone()); - account_infos.push(self.serum_pc_vault_account.clone()); - account_infos.push(self.serum_vault_signer.clone()); - account_infos.push(self.serum_req_q.clone()); - account_infos.push(self.serum_event_q.clone()); - account_infos.push(self.serum_bids.clone()); - account_infos.push(self.serum_asks.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MonitorStep` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[]` rent -/// 2. `[]` clock -/// 3. `[writable]` amm -/// 4. `[]` amm_authority -/// 5. `[writable]` amm_open_orders -/// 6. `[writable]` amm_target_orders -/// 7. `[writable]` pool_coin_token_account -/// 8. `[writable]` pool_pc_token_account -/// 9. `[writable]` pool_withdraw_queue -/// 10. `[]` serum_program -/// 11. `[writable]` serum_market -/// 12. `[writable]` serum_coin_vault_account -/// 13. `[writable]` serum_pc_vault_account -/// 14. `[]` serum_vault_signer -/// 15. `[writable]` serum_req_q -/// 16. `[writable]` serum_event_q -/// 17. `[writable]` serum_bids -/// 18. `[writable]` serum_asks -#[derive(Clone, Debug)] -pub struct MonitorStepCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MonitorStepCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MonitorStepCpiBuilderInstruction { - __program: program, - token_program: None, - rent: None, - clock: None, - amm: None, - amm_authority: None, - amm_open_orders: None, - amm_target_orders: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - pool_withdraw_queue: None, - serum_program: None, - serum_market: None, - serum_coin_vault_account: None, - serum_pc_vault_account: None, - serum_vault_signer: None, - serum_req_q: None, - serum_event_q: None, - serum_bids: None, - serum_asks: None, - plan_order_limit: None, - place_order_limit: None, - cancel_order_limit: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn clock(&mut self, clock: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock = Some(clock); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn pool_withdraw_queue( - &mut self, - pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_withdraw_queue = Some(pool_withdraw_queue); - self - } - - #[inline(always)] - pub fn serum_program( - &mut self, - serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer( - &mut self, - serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn serum_req_q( - &mut self, - serum_req_q: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_req_q = Some(serum_req_q); - self - } - - #[inline(always)] - pub fn serum_event_q( - &mut self, - serum_event_q: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_event_q = Some(serum_event_q); - self - } - - #[inline(always)] - pub fn serum_bids( - &mut self, - serum_bids: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks( - &mut self, - serum_asks: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn plan_order_limit(&mut self, plan_order_limit: u16) -> &mut Self { - self.instruction.plan_order_limit = Some(plan_order_limit); - self - } - - #[inline(always)] - pub fn place_order_limit(&mut self, place_order_limit: u16) -> &mut Self { - self.instruction.place_order_limit = Some(place_order_limit); - self - } - - #[inline(always)] - pub fn cancel_order_limit(&mut self, cancel_order_limit: u16) -> &mut Self { - self.instruction.cancel_order_limit = Some(cancel_order_limit); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = MonitorStepInstructionArgs { - plan_order_limit: self - .instruction - .plan_order_limit - .clone() - .expect("plan_order_limit is not set"), - place_order_limit: self - .instruction - .place_order_limit - .clone() - .expect("place_order_limit is not set"), - cancel_order_limit: self - .instruction - .cancel_order_limit - .clone() - .expect("cancel_order_limit is not set"), - }; - let instruction = MonitorStepCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - clock: self.instruction.clock.expect("clock is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - amm_target_orders: self - .instruction - .amm_target_orders - .expect("amm_target_orders is not set"), - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - pool_withdraw_queue: self - .instruction - .pool_withdraw_queue - .expect("pool_withdraw_queue is not set"), - - serum_program: self - .instruction - .serum_program - .expect("serum_program is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - serum_coin_vault_account: self - .instruction - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - - serum_pc_vault_account: self - .instruction - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - - serum_vault_signer: self - .instruction - .serum_vault_signer - .expect("serum_vault_signer is not set"), - - serum_req_q: self - .instruction - .serum_req_q - .expect("serum_req_q is not set"), - - serum_event_q: self - .instruction - .serum_event_q - .expect("serum_event_q is not set"), - - serum_bids: self.instruction.serum_bids.expect("serum_bids is not set"), - - serum_asks: self.instruction.serum_asks.expect("serum_asks is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MonitorStepCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - clock: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_withdraw_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_coin_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_pc_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_vault_signer: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_req_q: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_event_q: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_bids: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_asks: Option<&'b solana_account_info::AccountInfo<'a>>, - plan_order_limit: Option, - place_order_limit: Option, - cancel_order_limit: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/pre_initialize.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/pre_initialize.rs deleted file mode 100644 index 71f1e2a3..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/pre_initialize.rs +++ /dev/null @@ -1,889 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct PreInitialize { - pub token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub amm_target_orders: solana_pubkey::Pubkey, - - pub pool_withdraw_queue: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub lp_mint_address: solana_pubkey::Pubkey, - - pub coin_mint_address: solana_pubkey::Pubkey, - - pub pc_mint_address: solana_pubkey::Pubkey, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub pool_temp_lp_token_account: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub user_wallet: solana_pubkey::Pubkey, -} - -impl PreInitialize { - pub fn instruction( - &self, - args: PreInitializeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: PreInitializeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_target_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_withdraw_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lp_mint_address, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.coin_mint_address, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pc_mint_address, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_temp_lp_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.user_wallet, true)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&PreInitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PreInitializeInstructionData { - discriminator: [u8; 1], -} - -impl PreInitializeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [10], - } - } -} - -impl Default for PreInitializeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PreInitializeInstructionArgs { - pub nonce: u8, -} - -/// Instruction builder for `PreInitialize`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 2. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 3. `[writable]` amm_target_orders -/// 4. `[writable]` pool_withdraw_queue -/// 5. `[]` amm_authority -/// 6. `[writable]` lp_mint_address -/// 7. `[]` coin_mint_address -/// 8. `[]` pc_mint_address -/// 9. `[writable]` pool_coin_token_account -/// 10. `[writable]` pool_pc_token_account -/// 11. `[writable]` pool_temp_lp_token_account -/// 12. `[]` serum_market -/// 13. `[writable, signer]` user_wallet -#[derive(Clone, Debug, Default)] -pub struct PreInitializeBuilder { - token_program: Option, - system_program: Option, - rent: Option, - amm_target_orders: Option, - pool_withdraw_queue: Option, - amm_authority: Option, - lp_mint_address: Option, - coin_mint_address: Option, - pc_mint_address: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - pool_temp_lp_token_account: Option, - serum_market: Option, - user_wallet: Option, - nonce: Option, - __remaining_accounts: Vec, -} - -impl PreInitializeBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn amm_target_orders(&mut self, amm_target_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn pool_withdraw_queue(&mut self, pool_withdraw_queue: solana_pubkey::Pubkey) -> &mut Self { - self.pool_withdraw_queue = Some(pool_withdraw_queue); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn lp_mint_address(&mut self, lp_mint_address: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint_address = Some(lp_mint_address); - self - } - - #[inline(always)] - pub fn coin_mint_address(&mut self, coin_mint_address: solana_pubkey::Pubkey) -> &mut Self { - self.coin_mint_address = Some(coin_mint_address); - self - } - - #[inline(always)] - pub fn pc_mint_address(&mut self, pc_mint_address: solana_pubkey::Pubkey) -> &mut Self { - self.pc_mint_address = Some(pc_mint_address); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn pool_temp_lp_token_account( - &mut self, - pool_temp_lp_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_temp_lp_token_account = Some(pool_temp_lp_token_account); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn user_wallet(&mut self, user_wallet: solana_pubkey::Pubkey) -> &mut Self { - self.user_wallet = Some(user_wallet); - self - } - - #[inline(always)] - pub fn nonce(&mut self, nonce: u8) -> &mut Self { - self.nonce = Some(nonce); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = PreInitialize { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - amm_target_orders: self - .amm_target_orders - .expect("amm_target_orders is not set"), - pool_withdraw_queue: self - .pool_withdraw_queue - .expect("pool_withdraw_queue is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - lp_mint_address: self.lp_mint_address.expect("lp_mint_address is not set"), - coin_mint_address: self - .coin_mint_address - .expect("coin_mint_address is not set"), - pc_mint_address: self.pc_mint_address.expect("pc_mint_address is not set"), - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - pool_temp_lp_token_account: self - .pool_temp_lp_token_account - .expect("pool_temp_lp_token_account is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - user_wallet: self.user_wallet.expect("user_wallet is not set"), - }; - let args = PreInitializeInstructionArgs { - nonce: self.nonce.clone().expect("nonce is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `pre_initialize` CPI accounts. -pub struct PreInitializeCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub coin_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pc_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_temp_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub user_wallet: &'b solana_account_info::AccountInfo<'a>, -} - -/// `pre_initialize` CPI instruction. -pub struct PreInitializeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub coin_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pc_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_temp_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub user_wallet: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: PreInitializeInstructionArgs, -} - -impl<'a, 'b> PreInitializeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: PreInitializeCpiAccounts<'a, 'b>, - args: PreInitializeInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - system_program: accounts.system_program, - rent: accounts.rent, - amm_target_orders: accounts.amm_target_orders, - pool_withdraw_queue: accounts.pool_withdraw_queue, - amm_authority: accounts.amm_authority, - lp_mint_address: accounts.lp_mint_address, - coin_mint_address: accounts.coin_mint_address, - pc_mint_address: accounts.pc_mint_address, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - pool_temp_lp_token_account: accounts.pool_temp_lp_token_account, - serum_market: accounts.serum_market, - user_wallet: accounts.user_wallet, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_target_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_withdraw_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint_address.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.coin_mint_address.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pc_mint_address.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_temp_lp_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_wallet.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&PreInitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.amm_target_orders.clone()); - account_infos.push(self.pool_withdraw_queue.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.lp_mint_address.clone()); - account_infos.push(self.coin_mint_address.clone()); - account_infos.push(self.pc_mint_address.clone()); - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.pool_temp_lp_token_account.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.user_wallet.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `PreInitialize` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[]` system_program -/// 2. `[]` rent -/// 3. `[writable]` amm_target_orders -/// 4. `[writable]` pool_withdraw_queue -/// 5. `[]` amm_authority -/// 6. `[writable]` lp_mint_address -/// 7. `[]` coin_mint_address -/// 8. `[]` pc_mint_address -/// 9. `[writable]` pool_coin_token_account -/// 10. `[writable]` pool_pc_token_account -/// 11. `[writable]` pool_temp_lp_token_account -/// 12. `[]` serum_market -/// 13. `[writable, signer]` user_wallet -#[derive(Clone, Debug)] -pub struct PreInitializeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> PreInitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(PreInitializeCpiBuilderInstruction { - __program: program, - token_program: None, - system_program: None, - rent: None, - amm_target_orders: None, - pool_withdraw_queue: None, - amm_authority: None, - lp_mint_address: None, - coin_mint_address: None, - pc_mint_address: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - pool_temp_lp_token_account: None, - serum_market: None, - user_wallet: None, - nonce: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn pool_withdraw_queue( - &mut self, - pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_withdraw_queue = Some(pool_withdraw_queue); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn lp_mint_address( - &mut self, - lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lp_mint_address = Some(lp_mint_address); - self - } - - #[inline(always)] - pub fn coin_mint_address( - &mut self, - coin_mint_address: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_mint_address = Some(coin_mint_address); - self - } - - #[inline(always)] - pub fn pc_mint_address( - &mut self, - pc_mint_address: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pc_mint_address = Some(pc_mint_address); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn pool_temp_lp_token_account( - &mut self, - pool_temp_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_temp_lp_token_account = Some(pool_temp_lp_token_account); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn user_wallet( - &mut self, - user_wallet: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_wallet = Some(user_wallet); - self - } - - #[inline(always)] - pub fn nonce(&mut self, nonce: u8) -> &mut Self { - self.instruction.nonce = Some(nonce); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = PreInitializeInstructionArgs { - nonce: self.instruction.nonce.clone().expect("nonce is not set"), - }; - let instruction = PreInitializeCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - amm_target_orders: self - .instruction - .amm_target_orders - .expect("amm_target_orders is not set"), - - pool_withdraw_queue: self - .instruction - .pool_withdraw_queue - .expect("pool_withdraw_queue is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - lp_mint_address: self - .instruction - .lp_mint_address - .expect("lp_mint_address is not set"), - - coin_mint_address: self - .instruction - .coin_mint_address - .expect("coin_mint_address is not set"), - - pc_mint_address: self - .instruction - .pc_mint_address - .expect("pc_mint_address is not set"), - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - pool_temp_lp_token_account: self - .instruction - .pool_temp_lp_token_account - .expect("pool_temp_lp_token_account is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - user_wallet: self - .instruction - .user_wallet - .expect("user_wallet is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct PreInitializeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_withdraw_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint_address: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_mint_address: Option<&'b solana_account_info::AccountInfo<'a>>, - pc_mint_address: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_temp_lp_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - user_wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - nonce: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/set_params.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/set_params.rs deleted file mode 100644 index 1a1b99c3..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/set_params.rs +++ /dev/null @@ -1,1036 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{Fees, LastOrderDistance, NeedTake}; - -/// Accounts. -#[derive(Debug)] -pub struct SetParams { - pub token_program: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub amm_target_orders: solana_pubkey::Pubkey, - - pub amm_coin_vault: solana_pubkey::Pubkey, - - pub amm_pc_vault: solana_pubkey::Pubkey, - - pub serum_program: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub serum_coin_vault: solana_pubkey::Pubkey, - - pub serum_pc_vault: solana_pubkey::Pubkey, - - pub serum_vault_signer: solana_pubkey::Pubkey, - - pub serum_event_queue: solana_pubkey::Pubkey, - - pub serum_bids: solana_pubkey::Pubkey, - - pub serum_asks: solana_pubkey::Pubkey, - - pub amm_admin_account: solana_pubkey::Pubkey, -} - -impl SetParams { - pub fn instruction(&self, args: SetParamsInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetParamsInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_target_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_coin_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_pc_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_coin_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_pc_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_vault_signer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_event_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.serum_bids, false)); - accounts.push(solana_instruction::AccountMeta::new(self.serum_asks, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_admin_account, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetParamsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetParamsInstructionData { - discriminator: [u8; 1], -} - -impl SetParamsInstructionData { - pub fn new() -> Self { Self { discriminator: [6] } } -} - -impl Default for SetParamsInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetParamsInstructionArgs { - pub param: u8, - pub value: Option, - pub new_pubkey: Option, - pub fees: Option, - pub last_order_distance: Option, - pub need_take_amounts: Option, -} - -/// Instruction builder for `SetParams`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[writable]` amm -/// 2. `[]` amm_authority -/// 3. `[writable]` amm_open_orders -/// 4. `[writable]` amm_target_orders -/// 5. `[writable]` amm_coin_vault -/// 6. `[writable]` amm_pc_vault -/// 7. `[]` serum_program -/// 8. `[writable]` serum_market -/// 9. `[writable]` serum_coin_vault -/// 10. `[writable]` serum_pc_vault -/// 11. `[]` serum_vault_signer -/// 12. `[writable]` serum_event_queue -/// 13. `[writable]` serum_bids -/// 14. `[writable]` serum_asks -/// 15. `[signer]` amm_admin_account -#[derive(Clone, Debug, Default)] -pub struct SetParamsBuilder { - token_program: Option, - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - amm_target_orders: Option, - amm_coin_vault: Option, - amm_pc_vault: Option, - serum_program: Option, - serum_market: Option, - serum_coin_vault: Option, - serum_pc_vault: Option, - serum_vault_signer: Option, - serum_event_queue: Option, - serum_bids: Option, - serum_asks: Option, - amm_admin_account: Option, - param: Option, - value: Option, - new_pubkey: Option, - fees: Option, - last_order_distance: Option, - need_take_amounts: Option, - __remaining_accounts: Vec, -} - -impl SetParamsBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_target_orders(&mut self, amm_target_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn amm_coin_vault(&mut self, amm_coin_vault: solana_pubkey::Pubkey) -> &mut Self { - self.amm_coin_vault = Some(amm_coin_vault); - self - } - - #[inline(always)] - pub fn amm_pc_vault(&mut self, amm_pc_vault: solana_pubkey::Pubkey) -> &mut Self { - self.amm_pc_vault = Some(amm_pc_vault); - self - } - - #[inline(always)] - pub fn serum_program(&mut self, serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_coin_vault(&mut self, serum_coin_vault: solana_pubkey::Pubkey) -> &mut Self { - self.serum_coin_vault = Some(serum_coin_vault); - self - } - - #[inline(always)] - pub fn serum_pc_vault(&mut self, serum_pc_vault: solana_pubkey::Pubkey) -> &mut Self { - self.serum_pc_vault = Some(serum_pc_vault); - self - } - - #[inline(always)] - pub fn serum_vault_signer(&mut self, serum_vault_signer: solana_pubkey::Pubkey) -> &mut Self { - self.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn serum_event_queue(&mut self, serum_event_queue: solana_pubkey::Pubkey) -> &mut Self { - self.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn serum_bids(&mut self, serum_bids: solana_pubkey::Pubkey) -> &mut Self { - self.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks(&mut self, serum_asks: solana_pubkey::Pubkey) -> &mut Self { - self.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn amm_admin_account(&mut self, amm_admin_account: solana_pubkey::Pubkey) -> &mut Self { - self.amm_admin_account = Some(amm_admin_account); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.param = Some(param); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn value(&mut self, value: u64) -> &mut Self { - self.value = Some(value); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn new_pubkey(&mut self, new_pubkey: Pubkey) -> &mut Self { - self.new_pubkey = Some(new_pubkey); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn fees(&mut self, fees: Fees) -> &mut Self { - self.fees = Some(fees); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn last_order_distance(&mut self, last_order_distance: LastOrderDistance) -> &mut Self { - self.last_order_distance = Some(last_order_distance); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn need_take_amounts(&mut self, need_take_amounts: NeedTake) -> &mut Self { - self.need_take_amounts = Some(need_take_amounts); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetParams { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - amm_target_orders: self - .amm_target_orders - .expect("amm_target_orders is not set"), - amm_coin_vault: self.amm_coin_vault.expect("amm_coin_vault is not set"), - amm_pc_vault: self.amm_pc_vault.expect("amm_pc_vault is not set"), - serum_program: self.serum_program.expect("serum_program is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - serum_coin_vault: self.serum_coin_vault.expect("serum_coin_vault is not set"), - serum_pc_vault: self.serum_pc_vault.expect("serum_pc_vault is not set"), - serum_vault_signer: self - .serum_vault_signer - .expect("serum_vault_signer is not set"), - serum_event_queue: self - .serum_event_queue - .expect("serum_event_queue is not set"), - serum_bids: self.serum_bids.expect("serum_bids is not set"), - serum_asks: self.serum_asks.expect("serum_asks is not set"), - amm_admin_account: self - .amm_admin_account - .expect("amm_admin_account is not set"), - }; - let args = SetParamsInstructionArgs { - param: self.param.clone().expect("param is not set"), - value: self.value.clone(), - new_pubkey: self.new_pubkey.clone(), - fees: self.fees.clone(), - last_order_distance: self.last_order_distance.clone(), - need_take_amounts: self.need_take_amounts.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_params` CPI accounts. -pub struct SetParamsCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_coin_vault: &'b solana_account_info::AccountInfo<'a>, - - pub amm_pc_vault: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - - pub amm_admin_account: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_params` CPI instruction. -pub struct SetParamsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_coin_vault: &'b solana_account_info::AccountInfo<'a>, - - pub amm_pc_vault: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - - pub amm_admin_account: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetParamsInstructionArgs, -} - -impl<'a, 'b> SetParamsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetParamsCpiAccounts<'a, 'b>, - args: SetParamsInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - amm_target_orders: accounts.amm_target_orders, - amm_coin_vault: accounts.amm_coin_vault, - amm_pc_vault: accounts.amm_pc_vault, - serum_program: accounts.serum_program, - serum_market: accounts.serum_market, - serum_coin_vault: accounts.serum_coin_vault, - serum_pc_vault: accounts.serum_pc_vault, - serum_vault_signer: accounts.serum_vault_signer, - serum_event_queue: accounts.serum_event_queue, - serum_bids: accounts.serum_bids, - serum_asks: accounts.serum_asks, - amm_admin_account: accounts.amm_admin_account, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.amm.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_target_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_coin_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_pc_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_coin_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_pc_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_vault_signer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_event_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_bids.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_asks.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_admin_account.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetParamsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.amm_target_orders.clone()); - account_infos.push(self.amm_coin_vault.clone()); - account_infos.push(self.amm_pc_vault.clone()); - account_infos.push(self.serum_program.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.serum_coin_vault.clone()); - account_infos.push(self.serum_pc_vault.clone()); - account_infos.push(self.serum_vault_signer.clone()); - account_infos.push(self.serum_event_queue.clone()); - account_infos.push(self.serum_bids.clone()); - account_infos.push(self.serum_asks.clone()); - account_infos.push(self.amm_admin_account.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetParams` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[writable]` amm -/// 2. `[]` amm_authority -/// 3. `[writable]` amm_open_orders -/// 4. `[writable]` amm_target_orders -/// 5. `[writable]` amm_coin_vault -/// 6. `[writable]` amm_pc_vault -/// 7. `[]` serum_program -/// 8. `[writable]` serum_market -/// 9. `[writable]` serum_coin_vault -/// 10. `[writable]` serum_pc_vault -/// 11. `[]` serum_vault_signer -/// 12. `[writable]` serum_event_queue -/// 13. `[writable]` serum_bids -/// 14. `[writable]` serum_asks -/// 15. `[signer]` amm_admin_account -#[derive(Clone, Debug)] -pub struct SetParamsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetParamsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetParamsCpiBuilderInstruction { - __program: program, - token_program: None, - amm: None, - amm_authority: None, - amm_open_orders: None, - amm_target_orders: None, - amm_coin_vault: None, - amm_pc_vault: None, - serum_program: None, - serum_market: None, - serum_coin_vault: None, - serum_pc_vault: None, - serum_vault_signer: None, - serum_event_queue: None, - serum_bids: None, - serum_asks: None, - amm_admin_account: None, - param: None, - value: None, - new_pubkey: None, - fees: None, - last_order_distance: None, - need_take_amounts: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn amm_coin_vault( - &mut self, - amm_coin_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_coin_vault = Some(amm_coin_vault); - self - } - - #[inline(always)] - pub fn amm_pc_vault( - &mut self, - amm_pc_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_pc_vault = Some(amm_pc_vault); - self - } - - #[inline(always)] - pub fn serum_program( - &mut self, - serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_coin_vault( - &mut self, - serum_coin_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_coin_vault = Some(serum_coin_vault); - self - } - - #[inline(always)] - pub fn serum_pc_vault( - &mut self, - serum_pc_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_pc_vault = Some(serum_pc_vault); - self - } - - #[inline(always)] - pub fn serum_vault_signer( - &mut self, - serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn serum_event_queue( - &mut self, - serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn serum_bids( - &mut self, - serum_bids: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks( - &mut self, - serum_asks: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn amm_admin_account( - &mut self, - amm_admin_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_admin_account = Some(amm_admin_account); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.instruction.param = Some(param); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn value(&mut self, value: u64) -> &mut Self { - self.instruction.value = Some(value); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn new_pubkey(&mut self, new_pubkey: Pubkey) -> &mut Self { - self.instruction.new_pubkey = Some(new_pubkey); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn fees(&mut self, fees: Fees) -> &mut Self { - self.instruction.fees = Some(fees); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn last_order_distance(&mut self, last_order_distance: LastOrderDistance) -> &mut Self { - self.instruction.last_order_distance = Some(last_order_distance); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn need_take_amounts(&mut self, need_take_amounts: NeedTake) -> &mut Self { - self.instruction.need_take_amounts = Some(need_take_amounts); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetParamsInstructionArgs { - param: self.instruction.param.clone().expect("param is not set"), - value: self.instruction.value.clone(), - new_pubkey: self.instruction.new_pubkey.clone(), - fees: self.instruction.fees.clone(), - last_order_distance: self.instruction.last_order_distance.clone(), - need_take_amounts: self.instruction.need_take_amounts.clone(), - }; - let instruction = SetParamsCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - amm_target_orders: self - .instruction - .amm_target_orders - .expect("amm_target_orders is not set"), - - amm_coin_vault: self - .instruction - .amm_coin_vault - .expect("amm_coin_vault is not set"), - - amm_pc_vault: self - .instruction - .amm_pc_vault - .expect("amm_pc_vault is not set"), - - serum_program: self - .instruction - .serum_program - .expect("serum_program is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - serum_coin_vault: self - .instruction - .serum_coin_vault - .expect("serum_coin_vault is not set"), - - serum_pc_vault: self - .instruction - .serum_pc_vault - .expect("serum_pc_vault is not set"), - - serum_vault_signer: self - .instruction - .serum_vault_signer - .expect("serum_vault_signer is not set"), - - serum_event_queue: self - .instruction - .serum_event_queue - .expect("serum_event_queue is not set"), - - serum_bids: self.instruction.serum_bids.expect("serum_bids is not set"), - - serum_asks: self.instruction.serum_asks.expect("serum_asks is not set"), - - amm_admin_account: self - .instruction - .amm_admin_account - .expect("amm_admin_account is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetParamsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_coin_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_pc_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_coin_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_pc_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_vault_signer: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_event_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_bids: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_asks: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_admin_account: Option<&'b solana_account_info::AccountInfo<'a>>, - param: Option, - value: Option, - new_pubkey: Option, - fees: Option, - last_order_distance: Option, - need_take_amounts: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/simulate_info.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/simulate_info.rs deleted file mode 100644 index ecae3343..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/simulate_info.rs +++ /dev/null @@ -1,670 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{SwapInstructionBaseIn, SwapInstructionBaseOut}; - -/// Accounts. -#[derive(Debug)] -pub struct SimulateInfo { - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub lp_mint_address: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub serum_event_queue: solana_pubkey::Pubkey, -} - -impl SimulateInfo { - pub fn instruction( - &self, - args: SimulateInfoInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SimulateInfoInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lp_mint_address, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_event_queue, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SimulateInfoInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SimulateInfoInstructionData { - discriminator: [u8; 1], -} - -impl SimulateInfoInstructionData { - pub fn new() -> Self { - Self { - discriminator: [12], - } - } -} - -impl Default for SimulateInfoInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SimulateInfoInstructionArgs { - pub param: u8, - pub swap_base_in_value: Option, - pub swap_base_out_value: Option, -} - -/// Instruction builder for `SimulateInfo`. -/// -/// ### Accounts: -/// -/// 0. `[]` amm -/// 1. `[]` amm_authority -/// 2. `[]` amm_open_orders -/// 3. `[]` pool_coin_token_account -/// 4. `[]` pool_pc_token_account -/// 5. `[]` lp_mint_address -/// 6. `[]` serum_market -/// 7. `[]` serum_event_queue -#[derive(Clone, Debug, Default)] -pub struct SimulateInfoBuilder { - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - lp_mint_address: Option, - serum_market: Option, - serum_event_queue: Option, - param: Option, - swap_base_in_value: Option, - swap_base_out_value: Option, - __remaining_accounts: Vec, -} - -impl SimulateInfoBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn lp_mint_address(&mut self, lp_mint_address: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint_address = Some(lp_mint_address); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_event_queue(&mut self, serum_event_queue: solana_pubkey::Pubkey) -> &mut Self { - self.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.param = Some(param); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn swap_base_in_value(&mut self, swap_base_in_value: SwapInstructionBaseIn) -> &mut Self { - self.swap_base_in_value = Some(swap_base_in_value); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn swap_base_out_value( - &mut self, - swap_base_out_value: SwapInstructionBaseOut, - ) -> &mut Self { - self.swap_base_out_value = Some(swap_base_out_value); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SimulateInfo { - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - lp_mint_address: self.lp_mint_address.expect("lp_mint_address is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - serum_event_queue: self - .serum_event_queue - .expect("serum_event_queue is not set"), - }; - let args = SimulateInfoInstructionArgs { - param: self.param.clone().expect("param is not set"), - swap_base_in_value: self.swap_base_in_value.clone(), - swap_base_out_value: self.swap_base_out_value.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `simulate_info` CPI accounts. -pub struct SimulateInfoCpiAccounts<'a, 'b> { - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, -} - -/// `simulate_info` CPI instruction. -pub struct SimulateInfoCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SimulateInfoInstructionArgs, -} - -impl<'a, 'b> SimulateInfoCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SimulateInfoCpiAccounts<'a, 'b>, - args: SimulateInfoInstructionArgs, - ) -> Self { - Self { - __program: program, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - lp_mint_address: accounts.lp_mint_address, - serum_market: accounts.serum_market, - serum_event_queue: accounts.serum_event_queue, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lp_mint_address.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_event_queue.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SimulateInfoInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.lp_mint_address.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.serum_event_queue.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SimulateInfo` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` amm -/// 1. `[]` amm_authority -/// 2. `[]` amm_open_orders -/// 3. `[]` pool_coin_token_account -/// 4. `[]` pool_pc_token_account -/// 5. `[]` lp_mint_address -/// 6. `[]` serum_market -/// 7. `[]` serum_event_queue -#[derive(Clone, Debug)] -pub struct SimulateInfoCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SimulateInfoCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SimulateInfoCpiBuilderInstruction { - __program: program, - amm: None, - amm_authority: None, - amm_open_orders: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - lp_mint_address: None, - serum_market: None, - serum_event_queue: None, - param: None, - swap_base_in_value: None, - swap_base_out_value: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn lp_mint_address( - &mut self, - lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lp_mint_address = Some(lp_mint_address); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_event_queue( - &mut self, - serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.instruction.param = Some(param); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn swap_base_in_value(&mut self, swap_base_in_value: SwapInstructionBaseIn) -> &mut Self { - self.instruction.swap_base_in_value = Some(swap_base_in_value); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn swap_base_out_value( - &mut self, - swap_base_out_value: SwapInstructionBaseOut, - ) -> &mut Self { - self.instruction.swap_base_out_value = Some(swap_base_out_value); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SimulateInfoInstructionArgs { - param: self.instruction.param.clone().expect("param is not set"), - swap_base_in_value: self.instruction.swap_base_in_value.clone(), - swap_base_out_value: self.instruction.swap_base_out_value.clone(), - }; - let instruction = SimulateInfoCpi { - __program: self.instruction.__program, - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - lp_mint_address: self - .instruction - .lp_mint_address - .expect("lp_mint_address is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - serum_event_queue: self - .instruction - .serum_event_queue - .expect("serum_event_queue is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SimulateInfoCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint_address: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_event_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - param: Option, - swap_base_in_value: Option, - swap_base_out_value: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/swap_base_in.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/swap_base_in.rs deleted file mode 100644 index 18312ae1..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/swap_base_in.rs +++ /dev/null @@ -1,1082 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SwapBaseIn { - pub token_program: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub amm_target_orders: Option, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub serum_program: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub serum_bids: solana_pubkey::Pubkey, - - pub serum_asks: solana_pubkey::Pubkey, - - pub serum_event_queue: solana_pubkey::Pubkey, - - pub serum_coin_vault_account: solana_pubkey::Pubkey, - - pub serum_pc_vault_account: solana_pubkey::Pubkey, - - pub serum_vault_signer: solana_pubkey::Pubkey, - - pub uer_source_token_account: solana_pubkey::Pubkey, - - pub uer_destination_token_account: solana_pubkey::Pubkey, - - pub user_source_owner: solana_pubkey::Pubkey, -} - -impl SwapBaseIn { - pub fn instruction(&self, args: SwapBaseInInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapBaseInInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - if let Some(amm_target_orders) = self.amm_target_orders { - accounts.push(solana_instruction::AccountMeta::new( - amm_target_orders, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.serum_bids, false)); - accounts.push(solana_instruction::AccountMeta::new(self.serum_asks, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_event_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_coin_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_pc_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_vault_signer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.uer_source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.uer_destination_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_source_owner, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapBaseInInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapBaseInInstructionData { - discriminator: [u8; 1], -} - -impl SwapBaseInInstructionData { - pub fn new() -> Self { Self { discriminator: [9] } } -} - -impl Default for SwapBaseInInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapBaseInInstructionArgs { - pub amount_in: u64, - pub minimum_amount_out: u64, -} - -/// Instruction builder for `SwapBaseIn`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[writable]` amm -/// 2. `[]` amm_authority -/// 3. `[writable]` amm_open_orders -/// 4. `[writable, optional]` amm_target_orders -/// 5. `[writable]` pool_coin_token_account -/// 6. `[writable]` pool_pc_token_account -/// 7. `[]` serum_program -/// 8. `[writable]` serum_market -/// 9. `[writable]` serum_bids -/// 10. `[writable]` serum_asks -/// 11. `[writable]` serum_event_queue -/// 12. `[writable]` serum_coin_vault_account -/// 13. `[writable]` serum_pc_vault_account -/// 14. `[]` serum_vault_signer -/// 15. `[writable]` uer_source_token_account -/// 16. `[writable]` uer_destination_token_account -/// 17. `[signer]` user_source_owner -#[derive(Clone, Debug, Default)] -pub struct SwapBaseInBuilder { - token_program: Option, - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - amm_target_orders: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - serum_program: Option, - serum_market: Option, - serum_bids: Option, - serum_asks: Option, - serum_event_queue: Option, - serum_coin_vault_account: Option, - serum_pc_vault_account: Option, - serum_vault_signer: Option, - uer_source_token_account: Option, - uer_destination_token_account: Option, - user_source_owner: Option, - amount_in: Option, - minimum_amount_out: Option, - __remaining_accounts: Vec, -} - -impl SwapBaseInBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: Option, - ) -> &mut Self { - self.amm_target_orders = amm_target_orders; - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn serum_program(&mut self, serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_bids(&mut self, serum_bids: solana_pubkey::Pubkey) -> &mut Self { - self.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks(&mut self, serum_asks: solana_pubkey::Pubkey) -> &mut Self { - self.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn serum_event_queue(&mut self, serum_event_queue: solana_pubkey::Pubkey) -> &mut Self { - self.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer(&mut self, serum_vault_signer: solana_pubkey::Pubkey) -> &mut Self { - self.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn uer_source_token_account( - &mut self, - uer_source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.uer_source_token_account = Some(uer_source_token_account); - self - } - - #[inline(always)] - pub fn uer_destination_token_account( - &mut self, - uer_destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.uer_destination_token_account = Some(uer_destination_token_account); - self - } - - #[inline(always)] - pub fn user_source_owner(&mut self, user_source_owner: solana_pubkey::Pubkey) -> &mut Self { - self.user_source_owner = Some(user_source_owner); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.minimum_amount_out = Some(minimum_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapBaseIn { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - amm_target_orders: self.amm_target_orders, - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - serum_program: self.serum_program.expect("serum_program is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - serum_bids: self.serum_bids.expect("serum_bids is not set"), - serum_asks: self.serum_asks.expect("serum_asks is not set"), - serum_event_queue: self - .serum_event_queue - .expect("serum_event_queue is not set"), - serum_coin_vault_account: self - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - serum_pc_vault_account: self - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - serum_vault_signer: self - .serum_vault_signer - .expect("serum_vault_signer is not set"), - uer_source_token_account: self - .uer_source_token_account - .expect("uer_source_token_account is not set"), - uer_destination_token_account: self - .uer_destination_token_account - .expect("uer_destination_token_account is not set"), - user_source_owner: self - .user_source_owner - .expect("user_source_owner is not set"), - }; - let args = SwapBaseInInstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - minimum_amount_out: self - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_base_in` CPI accounts. -pub struct SwapBaseInCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub uer_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub uer_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_source_owner: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_base_in` CPI instruction. -pub struct SwapBaseInCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub uer_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub uer_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_source_owner: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapBaseInInstructionArgs, -} - -impl<'a, 'b> SwapBaseInCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapBaseInCpiAccounts<'a, 'b>, - args: SwapBaseInInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - amm_target_orders: accounts.amm_target_orders, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - serum_program: accounts.serum_program, - serum_market: accounts.serum_market, - serum_bids: accounts.serum_bids, - serum_asks: accounts.serum_asks, - serum_event_queue: accounts.serum_event_queue, - serum_coin_vault_account: accounts.serum_coin_vault_account, - serum_pc_vault_account: accounts.serum_pc_vault_account, - serum_vault_signer: accounts.serum_vault_signer, - uer_source_token_account: accounts.uer_source_token_account, - uer_destination_token_account: accounts.uer_destination_token_account, - user_source_owner: accounts.user_source_owner, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.amm.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - if let Some(amm_target_orders) = self.amm_target_orders { - accounts.push(solana_instruction::AccountMeta::new( - *amm_target_orders.key, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_bids.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_asks.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_event_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_coin_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_pc_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_vault_signer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.uer_source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.uer_destination_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_source_owner.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapBaseInInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(19 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - if let Some(amm_target_orders) = self.amm_target_orders { - account_infos.push(amm_target_orders.clone()); - } - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.serum_program.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.serum_bids.clone()); - account_infos.push(self.serum_asks.clone()); - account_infos.push(self.serum_event_queue.clone()); - account_infos.push(self.serum_coin_vault_account.clone()); - account_infos.push(self.serum_pc_vault_account.clone()); - account_infos.push(self.serum_vault_signer.clone()); - account_infos.push(self.uer_source_token_account.clone()); - account_infos.push(self.uer_destination_token_account.clone()); - account_infos.push(self.user_source_owner.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapBaseIn` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[writable]` amm -/// 2. `[]` amm_authority -/// 3. `[writable]` amm_open_orders -/// 4. `[writable, optional]` amm_target_orders -/// 5. `[writable]` pool_coin_token_account -/// 6. `[writable]` pool_pc_token_account -/// 7. `[]` serum_program -/// 8. `[writable]` serum_market -/// 9. `[writable]` serum_bids -/// 10. `[writable]` serum_asks -/// 11. `[writable]` serum_event_queue -/// 12. `[writable]` serum_coin_vault_account -/// 13. `[writable]` serum_pc_vault_account -/// 14. `[]` serum_vault_signer -/// 15. `[writable]` uer_source_token_account -/// 16. `[writable]` uer_destination_token_account -/// 17. `[signer]` user_source_owner -#[derive(Clone, Debug)] -pub struct SwapBaseInCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapBaseInCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapBaseInCpiBuilderInstruction { - __program: program, - token_program: None, - amm: None, - amm_authority: None, - amm_open_orders: None, - amm_target_orders: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - serum_program: None, - serum_market: None, - serum_bids: None, - serum_asks: None, - serum_event_queue: None, - serum_coin_vault_account: None, - serum_pc_vault_account: None, - serum_vault_signer: None, - uer_source_token_account: None, - uer_destination_token_account: None, - user_source_owner: None, - amount_in: None, - minimum_amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.amm_target_orders = amm_target_orders; - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn serum_program( - &mut self, - serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_bids( - &mut self, - serum_bids: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks( - &mut self, - serum_asks: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn serum_event_queue( - &mut self, - serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer( - &mut self, - serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn uer_source_token_account( - &mut self, - uer_source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.uer_source_token_account = Some(uer_source_token_account); - self - } - - #[inline(always)] - pub fn uer_destination_token_account( - &mut self, - uer_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.uer_destination_token_account = Some(uer_destination_token_account); - self - } - - #[inline(always)] - pub fn user_source_owner( - &mut self, - user_source_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_source_owner = Some(user_source_owner); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.instruction.minimum_amount_out = Some(minimum_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapBaseInInstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - minimum_amount_out: self - .instruction - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - }; - let instruction = SwapBaseInCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - amm_target_orders: self.instruction.amm_target_orders, - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - serum_program: self - .instruction - .serum_program - .expect("serum_program is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - serum_bids: self.instruction.serum_bids.expect("serum_bids is not set"), - - serum_asks: self.instruction.serum_asks.expect("serum_asks is not set"), - - serum_event_queue: self - .instruction - .serum_event_queue - .expect("serum_event_queue is not set"), - - serum_coin_vault_account: self - .instruction - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - - serum_pc_vault_account: self - .instruction - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - - serum_vault_signer: self - .instruction - .serum_vault_signer - .expect("serum_vault_signer is not set"), - - uer_source_token_account: self - .instruction - .uer_source_token_account - .expect("uer_source_token_account is not set"), - - uer_destination_token_account: self - .instruction - .uer_destination_token_account - .expect("uer_destination_token_account is not set"), - - user_source_owner: self - .instruction - .user_source_owner - .expect("user_source_owner is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapBaseInCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_bids: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_asks: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_event_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_coin_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_pc_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_vault_signer: Option<&'b solana_account_info::AccountInfo<'a>>, - uer_source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - uer_destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_source_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - minimum_amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/swap_base_out.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/swap_base_out.rs deleted file mode 100644 index 12ebc849..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/swap_base_out.rs +++ /dev/null @@ -1,1086 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SwapBaseOut { - pub token_program: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub amm_target_orders: Option, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub serum_program: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub serum_bids: solana_pubkey::Pubkey, - - pub serum_asks: solana_pubkey::Pubkey, - - pub serum_event_queue: solana_pubkey::Pubkey, - - pub serum_coin_vault_account: solana_pubkey::Pubkey, - - pub serum_pc_vault_account: solana_pubkey::Pubkey, - - pub serum_vault_signer: solana_pubkey::Pubkey, - - pub uer_source_token_account: solana_pubkey::Pubkey, - - pub uer_destination_token_account: solana_pubkey::Pubkey, - - pub user_source_owner: solana_pubkey::Pubkey, -} - -impl SwapBaseOut { - pub fn instruction(&self, args: SwapBaseOutInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapBaseOutInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - if let Some(amm_target_orders) = self.amm_target_orders { - accounts.push(solana_instruction::AccountMeta::new( - amm_target_orders, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.serum_bids, false)); - accounts.push(solana_instruction::AccountMeta::new(self.serum_asks, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_event_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_coin_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_pc_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_vault_signer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.uer_source_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.uer_destination_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_source_owner, - true, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapBaseOutInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapBaseOutInstructionData { - discriminator: [u8; 1], -} - -impl SwapBaseOutInstructionData { - pub fn new() -> Self { - Self { - discriminator: [11], - } - } -} - -impl Default for SwapBaseOutInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapBaseOutInstructionArgs { - pub max_amount_in: u64, - pub amount_out: u64, -} - -/// Instruction builder for `SwapBaseOut`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[writable]` amm -/// 2. `[]` amm_authority -/// 3. `[writable]` amm_open_orders -/// 4. `[writable, optional]` amm_target_orders -/// 5. `[writable]` pool_coin_token_account -/// 6. `[writable]` pool_pc_token_account -/// 7. `[]` serum_program -/// 8. `[writable]` serum_market -/// 9. `[writable]` serum_bids -/// 10. `[writable]` serum_asks -/// 11. `[writable]` serum_event_queue -/// 12. `[writable]` serum_coin_vault_account -/// 13. `[writable]` serum_pc_vault_account -/// 14. `[]` serum_vault_signer -/// 15. `[writable]` uer_source_token_account -/// 16. `[writable]` uer_destination_token_account -/// 17. `[signer]` user_source_owner -#[derive(Clone, Debug, Default)] -pub struct SwapBaseOutBuilder { - token_program: Option, - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - amm_target_orders: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - serum_program: Option, - serum_market: Option, - serum_bids: Option, - serum_asks: Option, - serum_event_queue: Option, - serum_coin_vault_account: Option, - serum_pc_vault_account: Option, - serum_vault_signer: Option, - uer_source_token_account: Option, - uer_destination_token_account: Option, - user_source_owner: Option, - max_amount_in: Option, - amount_out: Option, - __remaining_accounts: Vec, -} - -impl SwapBaseOutBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: Option, - ) -> &mut Self { - self.amm_target_orders = amm_target_orders; - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn serum_program(&mut self, serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_bids(&mut self, serum_bids: solana_pubkey::Pubkey) -> &mut Self { - self.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks(&mut self, serum_asks: solana_pubkey::Pubkey) -> &mut Self { - self.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn serum_event_queue(&mut self, serum_event_queue: solana_pubkey::Pubkey) -> &mut Self { - self.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer(&mut self, serum_vault_signer: solana_pubkey::Pubkey) -> &mut Self { - self.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn uer_source_token_account( - &mut self, - uer_source_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.uer_source_token_account = Some(uer_source_token_account); - self - } - - #[inline(always)] - pub fn uer_destination_token_account( - &mut self, - uer_destination_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.uer_destination_token_account = Some(uer_destination_token_account); - self - } - - #[inline(always)] - pub fn user_source_owner(&mut self, user_source_owner: solana_pubkey::Pubkey) -> &mut Self { - self.user_source_owner = Some(user_source_owner); - self - } - - #[inline(always)] - pub fn max_amount_in(&mut self, max_amount_in: u64) -> &mut Self { - self.max_amount_in = Some(max_amount_in); - self - } - - #[inline(always)] - pub fn amount_out(&mut self, amount_out: u64) -> &mut Self { - self.amount_out = Some(amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapBaseOut { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - amm_target_orders: self.amm_target_orders, - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - serum_program: self.serum_program.expect("serum_program is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - serum_bids: self.serum_bids.expect("serum_bids is not set"), - serum_asks: self.serum_asks.expect("serum_asks is not set"), - serum_event_queue: self - .serum_event_queue - .expect("serum_event_queue is not set"), - serum_coin_vault_account: self - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - serum_pc_vault_account: self - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - serum_vault_signer: self - .serum_vault_signer - .expect("serum_vault_signer is not set"), - uer_source_token_account: self - .uer_source_token_account - .expect("uer_source_token_account is not set"), - uer_destination_token_account: self - .uer_destination_token_account - .expect("uer_destination_token_account is not set"), - user_source_owner: self - .user_source_owner - .expect("user_source_owner is not set"), - }; - let args = SwapBaseOutInstructionArgs { - max_amount_in: self - .max_amount_in - .clone() - .expect("max_amount_in is not set"), - amount_out: self.amount_out.clone().expect("amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_base_out` CPI accounts. -pub struct SwapBaseOutCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub uer_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub uer_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_source_owner: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_base_out` CPI instruction. -pub struct SwapBaseOutCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub uer_source_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub uer_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_source_owner: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapBaseOutInstructionArgs, -} - -impl<'a, 'b> SwapBaseOutCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapBaseOutCpiAccounts<'a, 'b>, - args: SwapBaseOutInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - amm_target_orders: accounts.amm_target_orders, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - serum_program: accounts.serum_program, - serum_market: accounts.serum_market, - serum_bids: accounts.serum_bids, - serum_asks: accounts.serum_asks, - serum_event_queue: accounts.serum_event_queue, - serum_coin_vault_account: accounts.serum_coin_vault_account, - serum_pc_vault_account: accounts.serum_pc_vault_account, - serum_vault_signer: accounts.serum_vault_signer, - uer_source_token_account: accounts.uer_source_token_account, - uer_destination_token_account: accounts.uer_destination_token_account, - user_source_owner: accounts.user_source_owner, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.amm.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - if let Some(amm_target_orders) = self.amm_target_orders { - accounts.push(solana_instruction::AccountMeta::new( - *amm_target_orders.key, - false, - )); - } - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_bids.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_asks.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_event_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_coin_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_pc_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_vault_signer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.uer_source_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.uer_destination_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_source_owner.key, - true, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapBaseOutInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(19 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - if let Some(amm_target_orders) = self.amm_target_orders { - account_infos.push(amm_target_orders.clone()); - } - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.serum_program.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.serum_bids.clone()); - account_infos.push(self.serum_asks.clone()); - account_infos.push(self.serum_event_queue.clone()); - account_infos.push(self.serum_coin_vault_account.clone()); - account_infos.push(self.serum_pc_vault_account.clone()); - account_infos.push(self.serum_vault_signer.clone()); - account_infos.push(self.uer_source_token_account.clone()); - account_infos.push(self.uer_destination_token_account.clone()); - account_infos.push(self.user_source_owner.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapBaseOut` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[writable]` amm -/// 2. `[]` amm_authority -/// 3. `[writable]` amm_open_orders -/// 4. `[writable, optional]` amm_target_orders -/// 5. `[writable]` pool_coin_token_account -/// 6. `[writable]` pool_pc_token_account -/// 7. `[]` serum_program -/// 8. `[writable]` serum_market -/// 9. `[writable]` serum_bids -/// 10. `[writable]` serum_asks -/// 11. `[writable]` serum_event_queue -/// 12. `[writable]` serum_coin_vault_account -/// 13. `[writable]` serum_pc_vault_account -/// 14. `[]` serum_vault_signer -/// 15. `[writable]` uer_source_token_account -/// 16. `[writable]` uer_destination_token_account -/// 17. `[signer]` user_source_owner -#[derive(Clone, Debug)] -pub struct SwapBaseOutCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapBaseOutCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapBaseOutCpiBuilderInstruction { - __program: program, - token_program: None, - amm: None, - amm_authority: None, - amm_open_orders: None, - amm_target_orders: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - serum_program: None, - serum_market: None, - serum_bids: None, - serum_asks: None, - serum_event_queue: None, - serum_coin_vault_account: None, - serum_pc_vault_account: None, - serum_vault_signer: None, - uer_source_token_account: None, - uer_destination_token_account: None, - user_source_owner: None, - max_amount_in: None, - amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - /// `[optional account]` - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - ) -> &mut Self { - self.instruction.amm_target_orders = amm_target_orders; - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn serum_program( - &mut self, - serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_bids( - &mut self, - serum_bids: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks( - &mut self, - serum_asks: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn serum_event_queue( - &mut self, - serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer( - &mut self, - serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn uer_source_token_account( - &mut self, - uer_source_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.uer_source_token_account = Some(uer_source_token_account); - self - } - - #[inline(always)] - pub fn uer_destination_token_account( - &mut self, - uer_destination_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.uer_destination_token_account = Some(uer_destination_token_account); - self - } - - #[inline(always)] - pub fn user_source_owner( - &mut self, - user_source_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_source_owner = Some(user_source_owner); - self - } - - #[inline(always)] - pub fn max_amount_in(&mut self, max_amount_in: u64) -> &mut Self { - self.instruction.max_amount_in = Some(max_amount_in); - self - } - - #[inline(always)] - pub fn amount_out(&mut self, amount_out: u64) -> &mut Self { - self.instruction.amount_out = Some(amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapBaseOutInstructionArgs { - max_amount_in: self - .instruction - .max_amount_in - .clone() - .expect("max_amount_in is not set"), - amount_out: self - .instruction - .amount_out - .clone() - .expect("amount_out is not set"), - }; - let instruction = SwapBaseOutCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - amm_target_orders: self.instruction.amm_target_orders, - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - serum_program: self - .instruction - .serum_program - .expect("serum_program is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - serum_bids: self.instruction.serum_bids.expect("serum_bids is not set"), - - serum_asks: self.instruction.serum_asks.expect("serum_asks is not set"), - - serum_event_queue: self - .instruction - .serum_event_queue - .expect("serum_event_queue is not set"), - - serum_coin_vault_account: self - .instruction - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - - serum_pc_vault_account: self - .instruction - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - - serum_vault_signer: self - .instruction - .serum_vault_signer - .expect("serum_vault_signer is not set"), - - uer_source_token_account: self - .instruction - .uer_source_token_account - .expect("uer_source_token_account is not set"), - - uer_destination_token_account: self - .instruction - .uer_destination_token_account - .expect("uer_destination_token_account is not set"), - - user_source_owner: self - .instruction - .user_source_owner - .expect("user_source_owner is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapBaseOutCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_bids: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_asks: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_event_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_coin_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_pc_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_vault_signer: Option<&'b solana_account_info::AccountInfo<'a>>, - uer_source_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - uer_destination_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_source_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - max_amount_in: Option, - amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/update_config_account.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/update_config_account.rs deleted file mode 100644 index 17174cc7..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/update_config_account.rs +++ /dev/null @@ -1,371 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateConfigAccount { - pub admin: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, -} - -impl UpdateConfigAccount { - pub fn instruction( - &self, - args: UpdateConfigAccountInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateConfigAccountInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.admin, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm_config, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateConfigAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateConfigAccountInstructionData { - discriminator: [u8; 1], -} - -impl UpdateConfigAccountInstructionData { - pub fn new() -> Self { - Self { - discriminator: [15], - } - } -} - -impl Default for UpdateConfigAccountInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateConfigAccountInstructionArgs { - pub param: u8, - pub owner: Pubkey, -} - -/// Instruction builder for `UpdateConfigAccount`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` admin -/// 1. `[writable]` amm_config -#[derive(Clone, Debug, Default)] -pub struct UpdateConfigAccountBuilder { - admin: Option, - amm_config: Option, - param: Option, - owner: Option, - __remaining_accounts: Vec, -} - -impl UpdateConfigAccountBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self { - self.admin = Some(admin); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.param = Some(param); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateConfigAccount { - admin: self.admin.expect("admin is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - }; - let args = UpdateConfigAccountInstructionArgs { - param: self.param.clone().expect("param is not set"), - owner: self.owner.clone().expect("owner is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_config_account` CPI accounts. -pub struct UpdateConfigAccountCpiAccounts<'a, 'b> { - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_config_account` CPI instruction. -pub struct UpdateConfigAccountCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub admin: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateConfigAccountInstructionArgs, -} - -impl<'a, 'b> UpdateConfigAccountCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateConfigAccountCpiAccounts<'a, 'b>, - args: UpdateConfigAccountInstructionArgs, - ) -> Self { - Self { - __program: program, - admin: accounts.admin, - amm_config: accounts.amm_config, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_config.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateConfigAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.admin.clone()); - account_infos.push(self.amm_config.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateConfigAccount` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` admin -/// 1. `[writable]` amm_config -#[derive(Clone, Debug)] -pub struct UpdateConfigAccountCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateConfigAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateConfigAccountCpiBuilderInstruction { - __program: program, - admin: None, - amm_config: None, - param: None, - owner: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.admin = Some(admin); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.instruction.param = Some(param); - self - } - - #[inline(always)] - pub fn owner(&mut self, owner: Pubkey) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateConfigAccountInstructionArgs { - param: self.instruction.param.clone().expect("param is not set"), - owner: self.instruction.owner.clone().expect("owner is not set"), - }; - let instruction = UpdateConfigAccountCpi { - __program: self.instruction.__program, - - admin: self.instruction.admin.expect("admin is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateConfigAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - admin: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - param: Option, - owner: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/withdraw.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/withdraw.rs deleted file mode 100644 index 427ce7ac..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/withdraw.rs +++ /dev/null @@ -1,1220 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Withdraw { - pub token_program: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub amm_target_orders: solana_pubkey::Pubkey, - - pub lp_mint_address: solana_pubkey::Pubkey, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub pool_withdraw_queue: solana_pubkey::Pubkey, - - pub pool_temp_lp_token_account: solana_pubkey::Pubkey, - - pub serum_program: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub serum_coin_vault_account: solana_pubkey::Pubkey, - - pub serum_pc_vault_account: solana_pubkey::Pubkey, - - pub serum_vault_signer: solana_pubkey::Pubkey, - - pub user_lp_token_account: solana_pubkey::Pubkey, - - pub uer_coin_token_account: solana_pubkey::Pubkey, - - pub uer_pc_token_account: solana_pubkey::Pubkey, - - pub user_owner: solana_pubkey::Pubkey, - - pub serum_event_q: solana_pubkey::Pubkey, - - pub serum_bids: solana_pubkey::Pubkey, - - pub serum_asks: solana_pubkey::Pubkey, -} - -impl Withdraw { - pub fn instruction(&self, args: WithdrawInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: WithdrawInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(22 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_target_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lp_mint_address, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_withdraw_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_temp_lp_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_coin_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_pc_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_vault_signer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_lp_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.uer_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.uer_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_event_q, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.serum_bids, false)); - accounts.push(solana_instruction::AccountMeta::new(self.serum_asks, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawInstructionData { - discriminator: [u8; 1], -} - -impl WithdrawInstructionData { - pub fn new() -> Self { Self { discriminator: [4] } } -} - -impl Default for WithdrawInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawInstructionArgs { - pub amount: u64, -} - -/// Instruction builder for `Withdraw`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[writable]` amm -/// 2. `[]` amm_authority -/// 3. `[writable]` amm_open_orders -/// 4. `[writable]` amm_target_orders -/// 5. `[writable]` lp_mint_address -/// 6. `[writable]` pool_coin_token_account -/// 7. `[writable]` pool_pc_token_account -/// 8. `[writable]` pool_withdraw_queue -/// 9. `[writable]` pool_temp_lp_token_account -/// 10. `[]` serum_program -/// 11. `[writable]` serum_market -/// 12. `[writable]` serum_coin_vault_account -/// 13. `[writable]` serum_pc_vault_account -/// 14. `[]` serum_vault_signer -/// 15. `[writable]` user_lp_token_account -/// 16. `[writable]` uer_coin_token_account -/// 17. `[writable]` uer_pc_token_account -/// 18. `[signer]` user_owner -/// 19. `[writable]` serum_event_q -/// 20. `[writable]` serum_bids -/// 21. `[writable]` serum_asks -#[derive(Clone, Debug, Default)] -pub struct WithdrawBuilder { - token_program: Option, - amm: Option, - amm_authority: Option, - amm_open_orders: Option, - amm_target_orders: Option, - lp_mint_address: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - pool_withdraw_queue: Option, - pool_temp_lp_token_account: Option, - serum_program: Option, - serum_market: Option, - serum_coin_vault_account: Option, - serum_pc_vault_account: Option, - serum_vault_signer: Option, - user_lp_token_account: Option, - uer_coin_token_account: Option, - uer_pc_token_account: Option, - user_owner: Option, - serum_event_q: Option, - serum_bids: Option, - serum_asks: Option, - amount: Option, - __remaining_accounts: Vec, -} - -impl WithdrawBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_target_orders(&mut self, amm_target_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn lp_mint_address(&mut self, lp_mint_address: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint_address = Some(lp_mint_address); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn pool_withdraw_queue(&mut self, pool_withdraw_queue: solana_pubkey::Pubkey) -> &mut Self { - self.pool_withdraw_queue = Some(pool_withdraw_queue); - self - } - - #[inline(always)] - pub fn pool_temp_lp_token_account( - &mut self, - pool_temp_lp_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_temp_lp_token_account = Some(pool_temp_lp_token_account); - self - } - - #[inline(always)] - pub fn serum_program(&mut self, serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer(&mut self, serum_vault_signer: solana_pubkey::Pubkey) -> &mut Self { - self.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn user_lp_token_account( - &mut self, - user_lp_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.user_lp_token_account = Some(user_lp_token_account); - self - } - - #[inline(always)] - pub fn uer_coin_token_account( - &mut self, - uer_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.uer_coin_token_account = Some(uer_coin_token_account); - self - } - - #[inline(always)] - pub fn uer_pc_token_account( - &mut self, - uer_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.uer_pc_token_account = Some(uer_pc_token_account); - self - } - - #[inline(always)] - pub fn user_owner(&mut self, user_owner: solana_pubkey::Pubkey) -> &mut Self { - self.user_owner = Some(user_owner); - self - } - - #[inline(always)] - pub fn serum_event_q(&mut self, serum_event_q: solana_pubkey::Pubkey) -> &mut Self { - self.serum_event_q = Some(serum_event_q); - self - } - - #[inline(always)] - pub fn serum_bids(&mut self, serum_bids: solana_pubkey::Pubkey) -> &mut Self { - self.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks(&mut self, serum_asks: solana_pubkey::Pubkey) -> &mut Self { - self.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Withdraw { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - amm: self.amm.expect("amm is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - amm_target_orders: self - .amm_target_orders - .expect("amm_target_orders is not set"), - lp_mint_address: self.lp_mint_address.expect("lp_mint_address is not set"), - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - pool_withdraw_queue: self - .pool_withdraw_queue - .expect("pool_withdraw_queue is not set"), - pool_temp_lp_token_account: self - .pool_temp_lp_token_account - .expect("pool_temp_lp_token_account is not set"), - serum_program: self.serum_program.expect("serum_program is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - serum_coin_vault_account: self - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - serum_pc_vault_account: self - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - serum_vault_signer: self - .serum_vault_signer - .expect("serum_vault_signer is not set"), - user_lp_token_account: self - .user_lp_token_account - .expect("user_lp_token_account is not set"), - uer_coin_token_account: self - .uer_coin_token_account - .expect("uer_coin_token_account is not set"), - uer_pc_token_account: self - .uer_pc_token_account - .expect("uer_pc_token_account is not set"), - user_owner: self.user_owner.expect("user_owner is not set"), - serum_event_q: self.serum_event_q.expect("serum_event_q is not set"), - serum_bids: self.serum_bids.expect("serum_bids is not set"), - serum_asks: self.serum_asks.expect("serum_asks is not set"), - }; - let args = WithdrawInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw` CPI accounts. -pub struct WithdrawCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - - pub pool_temp_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub uer_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub uer_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_owner: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_q: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw` CPI instruction. -pub struct WithdrawCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - - pub pool_temp_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - - pub user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub uer_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub uer_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub user_owner: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_q: &'b solana_account_info::AccountInfo<'a>, - - pub serum_bids: &'b solana_account_info::AccountInfo<'a>, - - pub serum_asks: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: WithdrawInstructionArgs, -} - -impl<'a, 'b> WithdrawCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawCpiAccounts<'a, 'b>, - args: WithdrawInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - amm: accounts.amm, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - amm_target_orders: accounts.amm_target_orders, - lp_mint_address: accounts.lp_mint_address, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - pool_withdraw_queue: accounts.pool_withdraw_queue, - pool_temp_lp_token_account: accounts.pool_temp_lp_token_account, - serum_program: accounts.serum_program, - serum_market: accounts.serum_market, - serum_coin_vault_account: accounts.serum_coin_vault_account, - serum_pc_vault_account: accounts.serum_pc_vault_account, - serum_vault_signer: accounts.serum_vault_signer, - user_lp_token_account: accounts.user_lp_token_account, - uer_coin_token_account: accounts.uer_coin_token_account, - uer_pc_token_account: accounts.uer_pc_token_account, - user_owner: accounts.user_owner, - serum_event_q: accounts.serum_event_q, - serum_bids: accounts.serum_bids, - serum_asks: accounts.serum_asks, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(22 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.amm.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_target_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint_address.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_withdraw_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_temp_lp_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_coin_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_pc_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_vault_signer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_lp_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.uer_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.uer_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_event_q.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_bids.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_asks.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(23 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.amm_target_orders.clone()); - account_infos.push(self.lp_mint_address.clone()); - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.pool_withdraw_queue.clone()); - account_infos.push(self.pool_temp_lp_token_account.clone()); - account_infos.push(self.serum_program.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.serum_coin_vault_account.clone()); - account_infos.push(self.serum_pc_vault_account.clone()); - account_infos.push(self.serum_vault_signer.clone()); - account_infos.push(self.user_lp_token_account.clone()); - account_infos.push(self.uer_coin_token_account.clone()); - account_infos.push(self.uer_pc_token_account.clone()); - account_infos.push(self.user_owner.clone()); - account_infos.push(self.serum_event_q.clone()); - account_infos.push(self.serum_bids.clone()); - account_infos.push(self.serum_asks.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Withdraw` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[writable]` amm -/// 2. `[]` amm_authority -/// 3. `[writable]` amm_open_orders -/// 4. `[writable]` amm_target_orders -/// 5. `[writable]` lp_mint_address -/// 6. `[writable]` pool_coin_token_account -/// 7. `[writable]` pool_pc_token_account -/// 8. `[writable]` pool_withdraw_queue -/// 9. `[writable]` pool_temp_lp_token_account -/// 10. `[]` serum_program -/// 11. `[writable]` serum_market -/// 12. `[writable]` serum_coin_vault_account -/// 13. `[writable]` serum_pc_vault_account -/// 14. `[]` serum_vault_signer -/// 15. `[writable]` user_lp_token_account -/// 16. `[writable]` uer_coin_token_account -/// 17. `[writable]` uer_pc_token_account -/// 18. `[signer]` user_owner -/// 19. `[writable]` serum_event_q -/// 20. `[writable]` serum_bids -/// 21. `[writable]` serum_asks -#[derive(Clone, Debug)] -pub struct WithdrawCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawCpiBuilderInstruction { - __program: program, - token_program: None, - amm: None, - amm_authority: None, - amm_open_orders: None, - amm_target_orders: None, - lp_mint_address: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - pool_withdraw_queue: None, - pool_temp_lp_token_account: None, - serum_program: None, - serum_market: None, - serum_coin_vault_account: None, - serum_pc_vault_account: None, - serum_vault_signer: None, - user_lp_token_account: None, - uer_coin_token_account: None, - uer_pc_token_account: None, - user_owner: None, - serum_event_q: None, - serum_bids: None, - serum_asks: None, - amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn lp_mint_address( - &mut self, - lp_mint_address: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lp_mint_address = Some(lp_mint_address); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn pool_withdraw_queue( - &mut self, - pool_withdraw_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_withdraw_queue = Some(pool_withdraw_queue); - self - } - - #[inline(always)] - pub fn pool_temp_lp_token_account( - &mut self, - pool_temp_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_temp_lp_token_account = Some(pool_temp_lp_token_account); - self - } - - #[inline(always)] - pub fn serum_program( - &mut self, - serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer( - &mut self, - serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_vault_signer = Some(serum_vault_signer); - self - } - - #[inline(always)] - pub fn user_lp_token_account( - &mut self, - user_lp_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_lp_token_account = Some(user_lp_token_account); - self - } - - #[inline(always)] - pub fn uer_coin_token_account( - &mut self, - uer_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.uer_coin_token_account = Some(uer_coin_token_account); - self - } - - #[inline(always)] - pub fn uer_pc_token_account( - &mut self, - uer_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.uer_pc_token_account = Some(uer_pc_token_account); - self - } - - #[inline(always)] - pub fn user_owner( - &mut self, - user_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_owner = Some(user_owner); - self - } - - #[inline(always)] - pub fn serum_event_q( - &mut self, - serum_event_q: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_event_q = Some(serum_event_q); - self - } - - #[inline(always)] - pub fn serum_bids( - &mut self, - serum_bids: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_bids = Some(serum_bids); - self - } - - #[inline(always)] - pub fn serum_asks( - &mut self, - serum_asks: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_asks = Some(serum_asks); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = WithdrawInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - }; - let instruction = WithdrawCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - amm_target_orders: self - .instruction - .amm_target_orders - .expect("amm_target_orders is not set"), - - lp_mint_address: self - .instruction - .lp_mint_address - .expect("lp_mint_address is not set"), - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - pool_withdraw_queue: self - .instruction - .pool_withdraw_queue - .expect("pool_withdraw_queue is not set"), - - pool_temp_lp_token_account: self - .instruction - .pool_temp_lp_token_account - .expect("pool_temp_lp_token_account is not set"), - - serum_program: self - .instruction - .serum_program - .expect("serum_program is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - serum_coin_vault_account: self - .instruction - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - - serum_pc_vault_account: self - .instruction - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - - serum_vault_signer: self - .instruction - .serum_vault_signer - .expect("serum_vault_signer is not set"), - - user_lp_token_account: self - .instruction - .user_lp_token_account - .expect("user_lp_token_account is not set"), - - uer_coin_token_account: self - .instruction - .uer_coin_token_account - .expect("uer_coin_token_account is not set"), - - uer_pc_token_account: self - .instruction - .uer_pc_token_account - .expect("uer_pc_token_account is not set"), - - user_owner: self.instruction.user_owner.expect("user_owner is not set"), - - serum_event_q: self - .instruction - .serum_event_q - .expect("serum_event_q is not set"), - - serum_bids: self.instruction.serum_bids.expect("serum_bids is not set"), - - serum_asks: self.instruction.serum_asks.expect("serum_asks is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint_address: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_withdraw_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_temp_lp_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_coin_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_pc_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_vault_signer: Option<&'b solana_account_info::AccountInfo<'a>>, - user_lp_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - uer_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - uer_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - user_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_event_q: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_bids: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_asks: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/withdraw_pnl.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/withdraw_pnl.rs deleted file mode 100644 index 303ef740..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/withdraw_pnl.rs +++ /dev/null @@ -1,977 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct WithdrawPnl { - pub token_program: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub pool_coin_token_account: solana_pubkey::Pubkey, - - pub pool_pc_token_account: solana_pubkey::Pubkey, - - pub coin_pnl_token_account: solana_pubkey::Pubkey, - - pub pc_pnl_token_account: solana_pubkey::Pubkey, - - pub pnl_owner_account: solana_pubkey::Pubkey, - - pub amm_target_orders: solana_pubkey::Pubkey, - - pub serum_program: solana_pubkey::Pubkey, - - pub serum_market: solana_pubkey::Pubkey, - - pub serum_event_queue: solana_pubkey::Pubkey, - - pub serum_coin_vault_account: solana_pubkey::Pubkey, - - pub serum_pc_vault_account: solana_pubkey::Pubkey, - - pub serum_vault_signer: solana_pubkey::Pubkey, -} - -impl WithdrawPnl { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_coin_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_pc_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.coin_pnl_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pc_pnl_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.pnl_owner_account, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_target_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_market, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_event_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_coin_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.serum_pc_vault_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.serum_vault_signer, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&WithdrawPnlInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawPnlInstructionData { - discriminator: [u8; 1], -} - -impl WithdrawPnlInstructionData { - pub fn new() -> Self { Self { discriminator: [7] } } -} - -impl Default for WithdrawPnlInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `WithdrawPnl`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[writable]` amm -/// 2. `[]` amm_config -/// 3. `[]` amm_authority -/// 4. `[writable]` amm_open_orders -/// 5. `[writable]` pool_coin_token_account -/// 6. `[writable]` pool_pc_token_account -/// 7. `[writable]` coin_pnl_token_account -/// 8. `[writable]` pc_pnl_token_account -/// 9. `[signer]` pnl_owner_account -/// 10. `[writable]` amm_target_orders -/// 11. `[]` serum_program -/// 12. `[writable]` serum_market -/// 13. `[]` serum_event_queue -/// 14. `[writable]` serum_coin_vault_account -/// 15. `[writable]` serum_pc_vault_account -/// 16. `[]` serum_vault_signer -#[derive(Clone, Debug, Default)] -pub struct WithdrawPnlBuilder { - token_program: Option, - amm: Option, - amm_config: Option, - amm_authority: Option, - amm_open_orders: Option, - pool_coin_token_account: Option, - pool_pc_token_account: Option, - coin_pnl_token_account: Option, - pc_pnl_token_account: Option, - pnl_owner_account: Option, - amm_target_orders: Option, - serum_program: Option, - serum_market: Option, - serum_event_queue: Option, - serum_coin_vault_account: Option, - serum_pc_vault_account: Option, - serum_vault_signer: Option, - __remaining_accounts: Vec, -} - -impl WithdrawPnlBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn coin_pnl_token_account( - &mut self, - coin_pnl_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.coin_pnl_token_account = Some(coin_pnl_token_account); - self - } - - #[inline(always)] - pub fn pc_pnl_token_account( - &mut self, - pc_pnl_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.pc_pnl_token_account = Some(pc_pnl_token_account); - self - } - - #[inline(always)] - pub fn pnl_owner_account(&mut self, pnl_owner_account: solana_pubkey::Pubkey) -> &mut Self { - self.pnl_owner_account = Some(pnl_owner_account); - self - } - - #[inline(always)] - pub fn amm_target_orders(&mut self, amm_target_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn serum_program(&mut self, serum_program: solana_pubkey::Pubkey) -> &mut Self { - self.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market(&mut self, serum_market: solana_pubkey::Pubkey) -> &mut Self { - self.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_event_queue(&mut self, serum_event_queue: solana_pubkey::Pubkey) -> &mut Self { - self.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer(&mut self, serum_vault_signer: solana_pubkey::Pubkey) -> &mut Self { - self.serum_vault_signer = Some(serum_vault_signer); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = WithdrawPnl { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - amm: self.amm.expect("amm is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - pool_coin_token_account: self - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - pool_pc_token_account: self - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - coin_pnl_token_account: self - .coin_pnl_token_account - .expect("coin_pnl_token_account is not set"), - pc_pnl_token_account: self - .pc_pnl_token_account - .expect("pc_pnl_token_account is not set"), - pnl_owner_account: self - .pnl_owner_account - .expect("pnl_owner_account is not set"), - amm_target_orders: self - .amm_target_orders - .expect("amm_target_orders is not set"), - serum_program: self.serum_program.expect("serum_program is not set"), - serum_market: self.serum_market.expect("serum_market is not set"), - serum_event_queue: self - .serum_event_queue - .expect("serum_event_queue is not set"), - serum_coin_vault_account: self - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - serum_pc_vault_account: self - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - serum_vault_signer: self - .serum_vault_signer - .expect("serum_vault_signer is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `withdraw_pnl` CPI accounts. -pub struct WithdrawPnlCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub coin_pnl_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pc_pnl_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pnl_owner_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw_pnl` CPI instruction. -pub struct WithdrawPnlCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub coin_pnl_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pc_pnl_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pnl_owner_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub serum_program: &'b solana_account_info::AccountInfo<'a>, - - pub serum_market: &'b solana_account_info::AccountInfo<'a>, - - pub serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - - pub serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - - pub serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> WithdrawPnlCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawPnlCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - amm: accounts.amm, - amm_config: accounts.amm_config, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - pool_coin_token_account: accounts.pool_coin_token_account, - pool_pc_token_account: accounts.pool_pc_token_account, - coin_pnl_token_account: accounts.coin_pnl_token_account, - pc_pnl_token_account: accounts.pc_pnl_token_account, - pnl_owner_account: accounts.pnl_owner_account, - amm_target_orders: accounts.amm_target_orders, - serum_program: accounts.serum_program, - serum_market: accounts.serum_market, - serum_event_queue: accounts.serum_event_queue, - serum_coin_vault_account: accounts.serum_coin_vault_account, - serum_pc_vault_account: accounts.serum_pc_vault_account, - serum_vault_signer: accounts.serum_vault_signer, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.amm.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_coin_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_pc_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.coin_pnl_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pc_pnl_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.pnl_owner_account.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_target_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_event_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_coin_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.serum_pc_vault_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.serum_vault_signer.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&WithdrawPnlInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(18 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.pool_coin_token_account.clone()); - account_infos.push(self.pool_pc_token_account.clone()); - account_infos.push(self.coin_pnl_token_account.clone()); - account_infos.push(self.pc_pnl_token_account.clone()); - account_infos.push(self.pnl_owner_account.clone()); - account_infos.push(self.amm_target_orders.clone()); - account_infos.push(self.serum_program.clone()); - account_infos.push(self.serum_market.clone()); - account_infos.push(self.serum_event_queue.clone()); - account_infos.push(self.serum_coin_vault_account.clone()); - account_infos.push(self.serum_pc_vault_account.clone()); - account_infos.push(self.serum_vault_signer.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `WithdrawPnl` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[writable]` amm -/// 2. `[]` amm_config -/// 3. `[]` amm_authority -/// 4. `[writable]` amm_open_orders -/// 5. `[writable]` pool_coin_token_account -/// 6. `[writable]` pool_pc_token_account -/// 7. `[writable]` coin_pnl_token_account -/// 8. `[writable]` pc_pnl_token_account -/// 9. `[signer]` pnl_owner_account -/// 10. `[writable]` amm_target_orders -/// 11. `[]` serum_program -/// 12. `[writable]` serum_market -/// 13. `[]` serum_event_queue -/// 14. `[writable]` serum_coin_vault_account -/// 15. `[writable]` serum_pc_vault_account -/// 16. `[]` serum_vault_signer -#[derive(Clone, Debug)] -pub struct WithdrawPnlCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawPnlCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawPnlCpiBuilderInstruction { - __program: program, - token_program: None, - amm: None, - amm_config: None, - amm_authority: None, - amm_open_orders: None, - pool_coin_token_account: None, - pool_pc_token_account: None, - coin_pnl_token_account: None, - pc_pnl_token_account: None, - pnl_owner_account: None, - amm_target_orders: None, - serum_program: None, - serum_market: None, - serum_event_queue: None, - serum_coin_vault_account: None, - serum_pc_vault_account: None, - serum_vault_signer: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn pool_coin_token_account( - &mut self, - pool_coin_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_coin_token_account = Some(pool_coin_token_account); - self - } - - #[inline(always)] - pub fn pool_pc_token_account( - &mut self, - pool_pc_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_pc_token_account = Some(pool_pc_token_account); - self - } - - #[inline(always)] - pub fn coin_pnl_token_account( - &mut self, - coin_pnl_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.coin_pnl_token_account = Some(coin_pnl_token_account); - self - } - - #[inline(always)] - pub fn pc_pnl_token_account( - &mut self, - pc_pnl_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pc_pnl_token_account = Some(pc_pnl_token_account); - self - } - - #[inline(always)] - pub fn pnl_owner_account( - &mut self, - pnl_owner_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pnl_owner_account = Some(pnl_owner_account); - self - } - - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn serum_program( - &mut self, - serum_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_program = Some(serum_program); - self - } - - #[inline(always)] - pub fn serum_market( - &mut self, - serum_market: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_market = Some(serum_market); - self - } - - #[inline(always)] - pub fn serum_event_queue( - &mut self, - serum_event_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_event_queue = Some(serum_event_queue); - self - } - - #[inline(always)] - pub fn serum_coin_vault_account( - &mut self, - serum_coin_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_coin_vault_account = Some(serum_coin_vault_account); - self - } - - #[inline(always)] - pub fn serum_pc_vault_account( - &mut self, - serum_pc_vault_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_pc_vault_account = Some(serum_pc_vault_account); - self - } - - #[inline(always)] - pub fn serum_vault_signer( - &mut self, - serum_vault_signer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.serum_vault_signer = Some(serum_vault_signer); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = WithdrawPnlCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - pool_coin_token_account: self - .instruction - .pool_coin_token_account - .expect("pool_coin_token_account is not set"), - - pool_pc_token_account: self - .instruction - .pool_pc_token_account - .expect("pool_pc_token_account is not set"), - - coin_pnl_token_account: self - .instruction - .coin_pnl_token_account - .expect("coin_pnl_token_account is not set"), - - pc_pnl_token_account: self - .instruction - .pc_pnl_token_account - .expect("pc_pnl_token_account is not set"), - - pnl_owner_account: self - .instruction - .pnl_owner_account - .expect("pnl_owner_account is not set"), - - amm_target_orders: self - .instruction - .amm_target_orders - .expect("amm_target_orders is not set"), - - serum_program: self - .instruction - .serum_program - .expect("serum_program is not set"), - - serum_market: self - .instruction - .serum_market - .expect("serum_market is not set"), - - serum_event_queue: self - .instruction - .serum_event_queue - .expect("serum_event_queue is not set"), - - serum_coin_vault_account: self - .instruction - .serum_coin_vault_account - .expect("serum_coin_vault_account is not set"), - - serum_pc_vault_account: self - .instruction - .serum_pc_vault_account - .expect("serum_pc_vault_account is not set"), - - serum_vault_signer: self - .instruction - .serum_vault_signer - .expect("serum_vault_signer is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawPnlCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_coin_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_pc_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - coin_pnl_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pc_pnl_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pnl_owner_account: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_program: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_market: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_event_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_coin_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_pc_vault_account: Option<&'b solana_account_info::AccountInfo<'a>>, - serum_vault_signer: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/withdraw_srm.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/withdraw_srm.rs deleted file mode 100644 index c92b5ad4..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/instructions/withdraw_srm.rs +++ /dev/null @@ -1,515 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct WithdrawSrm { - pub token_program: solana_pubkey::Pubkey, - - pub amm: solana_pubkey::Pubkey, - - pub amm_owner_account: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub srm_token: solana_pubkey::Pubkey, - - pub dest_srm_token: solana_pubkey::Pubkey, -} - -impl WithdrawSrm { - pub fn instruction(&self, args: WithdrawSrmInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: WithdrawSrmInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_owner_account, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.srm_token, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.dest_srm_token, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawSrmInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawSrmInstructionData { - discriminator: [u8; 1], -} - -impl WithdrawSrmInstructionData { - pub fn new() -> Self { Self { discriminator: [8] } } -} - -impl Default for WithdrawSrmInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawSrmInstructionArgs { - pub amount: u64, -} - -/// Instruction builder for `WithdrawSrm`. -/// -/// ### Accounts: -/// -/// 0. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 1. `[]` amm -/// 2. `[signer]` amm_owner_account -/// 3. `[]` amm_authority -/// 4. `[writable]` srm_token -/// 5. `[writable]` dest_srm_token -#[derive(Clone, Debug, Default)] -pub struct WithdrawSrmBuilder { - token_program: Option, - amm: Option, - amm_owner_account: Option, - amm_authority: Option, - srm_token: Option, - dest_srm_token: Option, - amount: Option, - __remaining_accounts: Vec, -} - -impl WithdrawSrmBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: solana_pubkey::Pubkey) -> &mut Self { - self.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_owner_account(&mut self, amm_owner_account: solana_pubkey::Pubkey) -> &mut Self { - self.amm_owner_account = Some(amm_owner_account); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn srm_token(&mut self, srm_token: solana_pubkey::Pubkey) -> &mut Self { - self.srm_token = Some(srm_token); - self - } - - #[inline(always)] - pub fn dest_srm_token(&mut self, dest_srm_token: solana_pubkey::Pubkey) -> &mut Self { - self.dest_srm_token = Some(dest_srm_token); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = WithdrawSrm { - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - amm: self.amm.expect("amm is not set"), - amm_owner_account: self - .amm_owner_account - .expect("amm_owner_account is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - srm_token: self.srm_token.expect("srm_token is not set"), - dest_srm_token: self.dest_srm_token.expect("dest_srm_token is not set"), - }; - let args = WithdrawSrmInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw_srm` CPI accounts. -pub struct WithdrawSrmCpiAccounts<'a, 'b> { - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_owner_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub srm_token: &'b solana_account_info::AccountInfo<'a>, - - pub dest_srm_token: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw_srm` CPI instruction. -pub struct WithdrawSrmCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm: &'b solana_account_info::AccountInfo<'a>, - - pub amm_owner_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub srm_token: &'b solana_account_info::AccountInfo<'a>, - - pub dest_srm_token: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: WithdrawSrmInstructionArgs, -} - -impl<'a, 'b> WithdrawSrmCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawSrmCpiAccounts<'a, 'b>, - args: WithdrawSrmInstructionArgs, - ) -> Self { - Self { - __program: program, - token_program: accounts.token_program, - amm: accounts.amm, - amm_owner_account: accounts.amm_owner_account, - amm_authority: accounts.amm_authority, - srm_token: accounts.srm_token, - dest_srm_token: accounts.dest_srm_token, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_owner_account.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.srm_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.dest_srm_token.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&WithdrawSrmInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_AMM_V4_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.amm.clone()); - account_infos.push(self.amm_owner_account.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.srm_token.clone()); - account_infos.push(self.dest_srm_token.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `WithdrawSrm` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[]` token_program -/// 1. `[]` amm -/// 2. `[signer]` amm_owner_account -/// 3. `[]` amm_authority -/// 4. `[writable]` srm_token -/// 5. `[writable]` dest_srm_token -#[derive(Clone, Debug)] -pub struct WithdrawSrmCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawSrmCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawSrmCpiBuilderInstruction { - __program: program, - token_program: None, - amm: None, - amm_owner_account: None, - amm_authority: None, - srm_token: None, - dest_srm_token: None, - amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amm(&mut self, amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm = Some(amm); - self - } - - #[inline(always)] - pub fn amm_owner_account( - &mut self, - amm_owner_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_owner_account = Some(amm_owner_account); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn srm_token(&mut self, srm_token: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.srm_token = Some(srm_token); - self - } - - #[inline(always)] - pub fn dest_srm_token( - &mut self, - dest_srm_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.dest_srm_token = Some(dest_srm_token); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = WithdrawSrmInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - }; - let instruction = WithdrawSrmCpi { - __program: self.instruction.__program, - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - amm: self.instruction.amm.expect("amm is not set"), - - amm_owner_account: self - .instruction - .amm_owner_account - .expect("amm_owner_account is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - srm_token: self.instruction.srm_token.expect("srm_token is not set"), - - dest_srm_token: self - .instruction - .dest_srm_token - .expect("dest_srm_token is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawSrmCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_owner_account: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - srm_token: Option<&'b solana_account_info::AccountInfo<'a>>, - dest_srm_token: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/mod.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/programs.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 64351081..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `raydium_amm_v4` program ID. -pub const RAYDIUM_AMM_V4_ID: Pubkey = pubkey!("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"); diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/shared.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/types/fees.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/types/fees.rs deleted file mode 100644 index 81625dab..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/types/fees.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Fees { - pub min_separate_numerator: u64, - pub min_separate_denominator: u64, - pub trade_fee_numerator: u64, - pub trade_fee_denominator: u64, - pub pnl_numerator: u64, - pub pnl_denominator: u64, - pub swap_fee_numerator: u64, - pub swap_fee_denominator: u64, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/types/last_order_distance.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/types/last_order_distance.rs deleted file mode 100644 index 2e0c063a..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/types/last_order_distance.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LastOrderDistance { - pub last_order_numerator: u64, - pub last_order_denominator: u64, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/types/mod.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index 45667e33..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#fees; -pub(crate) mod r#last_order_distance; -pub(crate) mod r#need_take; -pub(crate) mod r#out_put_data; -pub(crate) mod r#swap_instruction_base_in; -pub(crate) mod r#swap_instruction_base_out; -pub(crate) mod r#target_order; -pub(crate) mod r#withdraw_dest_token; -pub(crate) mod r#withdraw_queue; - -pub use self::{ - r#fees::*, r#last_order_distance::*, r#need_take::*, r#out_put_data::*, - r#swap_instruction_base_in::*, r#swap_instruction_base_out::*, r#target_order::*, - r#withdraw_dest_token::*, r#withdraw_queue::*, -}; diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/types/need_take.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/types/need_take.rs deleted file mode 100644 index e07b729c..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/types/need_take.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct NeedTake { - pub need_take_pc: u64, - pub need_take_coin: u64, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/types/out_put_data.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/types/out_put_data.rs deleted file mode 100644 index 0e27b927..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/types/out_put_data.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OutPutData { - pub need_take_pnl_coin: u64, - pub need_take_pnl_pc: u64, - pub total_pnl_pc: u64, - pub total_pnl_coin: u64, - pub pool_open_time: u64, - pub punish_pc_amount: u64, - pub punish_coin_amount: u64, - pub orderbook_to_init_time: u64, - pub swap_coin_in_amount: u128, - pub swap_pc_out_amount: u128, - pub swap_take_pc_fee: u64, - pub swap_pc_in_amount: u128, - pub swap_coin_out_amount: u128, - pub swap_take_coin_fee: u64, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/types/swap_instruction_base_in.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/types/swap_instruction_base_in.rs deleted file mode 100644 index 9cdf112d..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/types/swap_instruction_base_in.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionBaseIn { - pub amount_in: u64, - pub minimum_amount_out: u64, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/types/swap_instruction_base_out.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/types/swap_instruction_base_out.rs deleted file mode 100644 index 965bd987..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/types/swap_instruction_base_out.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionBaseOut { - pub max_amount_in: u64, - pub amount_out: u64, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/types/target_order.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/types/target_order.rs deleted file mode 100644 index c52000a1..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/types/target_order.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TargetOrder { - pub price: u64, - pub vol: u64, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/types/withdraw_dest_token.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/types/withdraw_dest_token.rs deleted file mode 100644 index b37d6963..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/types/withdraw_dest_token.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawDestToken { - pub withdraw_amount: u64, - pub coin_amount: u64, - pub pc_amount: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub dest_token_coin: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub dest_token_pc: Pubkey, -} diff --git a/crates/raydium-amm-v4-parser/src/generated_sdk/types/withdraw_queue.rs b/crates/raydium-amm-v4-parser/src/generated_sdk/types/withdraw_queue.rs deleted file mode 100644 index c70280e4..00000000 --- a/crates/raydium-amm-v4-parser/src/generated_sdk/types/withdraw_queue.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::WithdrawDestToken; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawQueue { - pub owner: [u64; 4], - pub head: u64, - pub count: u64, - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub buf: [WithdrawDestToken; 64], -} diff --git a/crates/raydium-amm-v4-parser/src/lib.rs b/crates/raydium-amm-v4-parser/src/lib.rs deleted file mode 100644 index 6e2021c7..00000000 --- a/crates/raydium-amm-v4-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = RAYDIUM_AMM_V4_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.raydium_amm_v4"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/raydium-clmm-parser/Cargo.toml b/crates/raydium-clmm-parser/Cargo.toml deleted file mode 100644 index 5ca5bebe..00000000 --- a/crates/raydium-clmm-parser/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "yellowstone-vixen-raydium-clmm-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Raydium CLMM program" -license.workspace = true -repository.workspace = true -authors.workspace = true - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info.workspace = true -solana-cpi.workspace = true -solana-decode-error.workspace = true -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction.workspace = true -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true \ No newline at end of file diff --git a/crates/raydium-clmm-parser/build.rs b/crates/raydium-clmm-parser/build.rs deleted file mode 100644 index 1619c2f4..00000000 --- a/crates/raydium-clmm-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/raydium_clmm.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/raydium-clmm-parser/idl.json b/crates/raydium-clmm-parser/idl.json deleted file mode 100644 index 0d97399d..00000000 --- a/crates/raydium-clmm-parser/idl.json +++ /dev/null @@ -1,3052 +0,0 @@ -{ - "version": "0.1.0", - "name": "amm_v3", - "instructions": [ - { - "name": "createAmmConfig", - "accounts": [ - { - "name": "owner", - "isMut": true, - "isSigner": true - }, - { - "name": "ammConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "index", - "type": "u16" - }, - { - "name": "tickSpacing", - "type": "u16" - }, - { - "name": "tradeFeeRate", - "type": "u32" - }, - { - "name": "protocolFeeRate", - "type": "u32" - }, - { - "name": "fundFeeRate", - "type": "u32" - } - ] - }, - { - "name": "updateAmmConfig", - "accounts": [ - { - "name": "owner", - "isMut": false, - "isSigner": true - }, - { - "name": "ammConfig", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "param", - "type": "u8" - }, - { - "name": "value", - "type": "u32" - } - ] - }, - { - "name": "createPool", - "accounts": [ - { - "name": "poolCreator", - "isMut": true, - "isSigner": true - }, - { - "name": "ammConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenMint0", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenMint1", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenVault0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault1", - "isMut": true, - "isSigner": false - }, - { - "name": "observationState", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayBitmap", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram0", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram1", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "sqrtPriceX64", - "type": "u128" - }, - { - "name": "openTime", - "type": "u64" - } - ] - }, - { - "name": "updatePoolStatus", - "accounts": [ - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "status", - "type": "u8" - } - ] - }, - { - "name": "createOperationAccount", - "accounts": [ - { - "name": "owner", - "isMut": true, - "isSigner": true - }, - { - "name": "operationState", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "updateOperationAccount", - "accounts": [ - { - "name": "owner", - "isMut": false, - "isSigner": true - }, - { - "name": "operationState", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "param", - "type": "u8" - }, - { - "name": "keys", - "type": { - "vec": "publicKey" - } - } - ] - }, - { - "name": "transferRewardOwner", - "accounts": [ - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "newOwner", - "type": "publicKey" - } - ] - }, - { - "name": "initializeReward", - "accounts": [ - { - "name": "rewardFunder", - "isMut": true, - "isSigner": true - }, - { - "name": "funderTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "ammConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "operationState", - "isMut": false, - "isSigner": false - }, - { - "name": "rewardTokenMint", - "isMut": false, - "isSigner": false - }, - { - "name": "rewardTokenVault", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "param", - "type": { - "defined": "InitializeRewardParam" - } - } - ] - }, - { - "name": "collectRemainingRewards", - "accounts": [ - { - "name": "rewardFunder", - "isMut": false, - "isSigner": true - }, - { - "name": "funderTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "rewardTokenVault", - "isMut": false, - "isSigner": false - }, - { - "name": "rewardVaultMint", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram2022", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u8" - } - ] - }, - { - "name": "updateRewardInfos", - "accounts": [ - { - "name": "poolState", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "setRewardParams", - "accounts": [ - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "ammConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "operationState", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram2022", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u8" - }, - { - "name": "emissionsPerSecondX64", - "type": "u128" - }, - { - "name": "openTime", - "type": "u64" - }, - { - "name": "endTime", - "type": "u64" - } - ] - }, - { - "name": "collectProtocolFee", - "accounts": [ - { - "name": "owner", - "isMut": false, - "isSigner": true - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "ammConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenVault0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault1", - "isMut": true, - "isSigner": false - }, - { - "name": "vault0Mint", - "isMut": false, - "isSigner": false - }, - { - "name": "vault1Mint", - "isMut": false, - "isSigner": false - }, - { - "name": "recipientTokenAccount0", - "isMut": true, - "isSigner": false - }, - { - "name": "recipientTokenAccount1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram2022", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amount0Requested", - "type": "u64" - }, - { - "name": "amount1Requested", - "type": "u64" - } - ] - }, - { - "name": "collectFundFee", - "accounts": [ - { - "name": "owner", - "isMut": false, - "isSigner": true - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "ammConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenVault0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault1", - "isMut": true, - "isSigner": false - }, - { - "name": "vault0Mint", - "isMut": false, - "isSigner": false - }, - { - "name": "vault1Mint", - "isMut": false, - "isSigner": false - }, - { - "name": "recipientTokenAccount0", - "isMut": true, - "isSigner": false - }, - { - "name": "recipientTokenAccount1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram2022", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amount0Requested", - "type": "u64" - }, - { - "name": "amount1Requested", - "type": "u64" - } - ] - }, - { - "name": "openPosition", - "accounts": [ - { - "name": "payer", - "isMut": true, - "isSigner": true - }, - { - "name": "positionNftOwner", - "isMut": false, - "isSigner": false - }, - { - "name": "positionNftMint", - "isMut": true, - "isSigner": true - }, - { - "name": "positionNftAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "metadataAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "protocolPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "personalPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault1", - "isMut": true, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tickLowerIndex", - "type": "i32" - }, - { - "name": "tickUpperIndex", - "type": "i32" - }, - { - "name": "tickArrayLowerStartIndex", - "type": "i32" - }, - { - "name": "tickArrayUpperStartIndex", - "type": "i32" - }, - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "amount0Max", - "type": "u64" - }, - { - "name": "amount1Max", - "type": "u64" - } - ] - }, - { - "name": "openPositionV2", - "accounts": [ - { - "name": "payer", - "isMut": true, - "isSigner": true - }, - { - "name": "positionNftOwner", - "isMut": false, - "isSigner": false - }, - { - "name": "positionNftMint", - "isMut": true, - "isSigner": true - }, - { - "name": "positionNftAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "metadataAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "protocolPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "personalPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault1", - "isMut": true, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "metadataProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram2022", - "isMut": false, - "isSigner": false - }, - { - "name": "vault0Mint", - "isMut": false, - "isSigner": false - }, - { - "name": "vault1Mint", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tickLowerIndex", - "type": "i32" - }, - { - "name": "tickUpperIndex", - "type": "i32" - }, - { - "name": "tickArrayLowerStartIndex", - "type": "i32" - }, - { - "name": "tickArrayUpperStartIndex", - "type": "i32" - }, - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "amount0Max", - "type": "u64" - }, - { - "name": "amount1Max", - "type": "u64" - }, - { - "name": "withMetadata", - "type": "bool" - }, - { - "name": "baseFlag", - "type": { - "option": "bool" - } - } - ] - }, - { - "name": "openPositionWithToken22Nft", - "accounts": [ - { - "name": "payer", - "isMut": true, - "isSigner": true - }, - { - "name": "positionNftOwner", - "isMut": false, - "isSigner": false - }, - { - "name": "positionNftMint", - "isMut": true, - "isSigner": true - }, - { - "name": "positionNftAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "protocolPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "personalPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault1", - "isMut": true, - "isSigner": false - }, - { - "name": "rent", - "isMut": false, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "associatedTokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram2022", - "isMut": false, - "isSigner": false - }, - { - "name": "vault0Mint", - "isMut": false, - "isSigner": false - }, - { - "name": "vault1Mint", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "tickLowerIndex", - "type": "i32" - }, - { - "name": "tickUpperIndex", - "type": "i32" - }, - { - "name": "tickArrayLowerStartIndex", - "type": "i32" - }, - { - "name": "tickArrayUpperStartIndex", - "type": "i32" - }, - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "amount0Max", - "type": "u64" - }, - { - "name": "amount1Max", - "type": "u64" - }, - { - "name": "withMetadata", - "type": "bool" - }, - { - "name": "baseFlag", - "type": { - "option": "bool" - } - } - ] - }, - { - "name": "closePosition", - "accounts": [ - { - "name": "nftOwner", - "isMut": true, - "isSigner": true - }, - { - "name": "positionNftMint", - "isMut": true, - "isSigner": false - }, - { - "name": "positionNftAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "personalPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "systemProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "increaseLiquidity", - "accounts": [ - { - "name": "nftOwner", - "isMut": false, - "isSigner": true - }, - { - "name": "nftAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "protocolPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "personalPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "amount0Max", - "type": "u64" - }, - { - "name": "amount1Max", - "type": "u64" - } - ] - }, - { - "name": "increaseLiquidityV2", - "accounts": [ - { - "name": "nftOwner", - "isMut": false, - "isSigner": true - }, - { - "name": "nftAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "protocolPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "personalPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenAccount1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram2022", - "isMut": false, - "isSigner": false - }, - { - "name": "vault0Mint", - "isMut": false, - "isSigner": false - }, - { - "name": "vault1Mint", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "amount0Max", - "type": "u64" - }, - { - "name": "amount1Max", - "type": "u64" - }, - { - "name": "baseFlag", - "type": { - "option": "bool" - } - } - ] - }, - { - "name": "decreaseLiquidity", - "accounts": [ - { - "name": "nftOwner", - "isMut": false, - "isSigner": true - }, - { - "name": "nftAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "personalPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "protocolPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault1", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "recipientTokenAccount0", - "isMut": true, - "isSigner": false - }, - { - "name": "recipientTokenAccount1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "amount0Min", - "type": "u64" - }, - { - "name": "amount1Min", - "type": "u64" - } - ] - }, - { - "name": "decreaseLiquidityV2", - "accounts": [ - { - "name": "nftOwner", - "isMut": false, - "isSigner": true - }, - { - "name": "nftAccount", - "isMut": false, - "isSigner": false - }, - { - "name": "personalPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "protocolPosition", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault0", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenVault1", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayLower", - "isMut": true, - "isSigner": false - }, - { - "name": "tickArrayUpper", - "isMut": true, - "isSigner": false - }, - { - "name": "recipientTokenAccount0", - "isMut": true, - "isSigner": false - }, - { - "name": "recipientTokenAccount1", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram2022", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "vault0Mint", - "isMut": false, - "isSigner": false - }, - { - "name": "vault1Mint", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "amount0Min", - "type": "u64" - }, - { - "name": "amount1Min", - "type": "u64" - } - ] - }, - { - "name": "swap", - "accounts": [ - { - "name": "payer", - "isMut": false, - "isSigner": true - }, - { - "name": "ammConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "inputTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "outputTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "inputVault", - "isMut": true, - "isSigner": false - }, - { - "name": "outputVault", - "isMut": true, - "isSigner": false - }, - { - "name": "observationState", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tickArray", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "otherAmountThreshold", - "type": "u64" - }, - { - "name": "sqrtPriceLimitX64", - "type": "u128" - }, - { - "name": "isBaseInput", - "type": "bool" - } - ] - }, - { - "name": "swapV2", - "accounts": [ - { - "name": "payer", - "isMut": false, - "isSigner": true - }, - { - "name": "ammConfig", - "isMut": false, - "isSigner": false - }, - { - "name": "poolState", - "isMut": true, - "isSigner": false - }, - { - "name": "inputTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "outputTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "inputVault", - "isMut": true, - "isSigner": false - }, - { - "name": "outputVault", - "isMut": true, - "isSigner": false - }, - { - "name": "observationState", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram2022", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "inputVaultMint", - "isMut": false, - "isSigner": false - }, - { - "name": "outputVaultMint", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "otherAmountThreshold", - "type": "u64" - }, - { - "name": "sqrtPriceLimitX64", - "type": "u128" - }, - { - "name": "isBaseInput", - "type": "bool" - } - ] - }, - { - "name": "swapRouterBaseIn", - "accounts": [ - { - "name": "payer", - "isMut": false, - "isSigner": true - }, - { - "name": "inputTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "inputTokenMint", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "tokenProgram2022", - "isMut": false, - "isSigner": false - }, - { - "name": "memoProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "amountIn", - "type": "u64" - }, - { - "name": "amountOutMinimum", - "type": "u64" - } - ] - } - ], - "accounts": [ - { - "name": "AmmConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "index", - "type": "u16" - }, - { - "name": "owner", - "type": "publicKey" - }, - { - "name": "protocolFeeRate", - "type": "u32" - }, - { - "name": "tradeFeeRate", - "type": "u32" - }, - { - "name": "tickSpacing", - "type": "u16" - }, - { - "name": "fundFeeRate", - "type": "u32" - }, - { - "name": "paddingU32", - "type": "u32" - }, - { - "name": "fundOwner", - "type": "publicKey" - }, - { - "name": "padding", - "type": { - "array": [ - "u64", - 3 - ] - } - } - ] - } - }, - { - "name": "OperationState", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "operationOwners", - "type": { - "array": [ - "publicKey", - 10 - ] - } - }, - { - "name": "whitelistMints", - "type": { - "array": [ - "publicKey", - 100 - ] - } - } - ] - } - }, - { - "name": "ObservationState", - "type": { - "kind": "struct", - "fields": [ - { - "name": "initialized", - "type": "bool" - }, - { - "name": "recentEpoch", - "type": "u64" - }, - { - "name": "observationIndex", - "type": "u16" - }, - { - "name": "poolId", - "type": "publicKey" - }, - { - "name": "observations", - "type": { - "array": [ - { - "defined": "Observation" - }, - 100 - ] - } - }, - { - "name": "padding", - "type": { - "array": [ - "u64", - 4 - ] - } - } - ] - } - }, - { - "name": "PersonalPositionState", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": { - "array": [ - "u8", - 1 - ] - } - }, - { - "name": "nftMint", - "type": "publicKey" - }, - { - "name": "poolId", - "type": "publicKey" - }, - { - "name": "tickLowerIndex", - "type": "i32" - }, - { - "name": "tickUpperIndex", - "type": "i32" - }, - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "feeGrowthInside0LastX64", - "type": "u128" - }, - { - "name": "feeGrowthInside1LastX64", - "type": "u128" - }, - { - "name": "tokenFeesOwed0", - "type": "u64" - }, - { - "name": "tokenFeesOwed1", - "type": "u64" - }, - { - "name": "rewardInfos", - "type": { - "array": [ - { - "defined": "PositionRewardInfo" - }, - 3 - ] - } - }, - { - "name": "recentEpoch", - "type": "u64" - }, - { - "name": "padding", - "type": { - "array": [ - "u64", - 7 - ] - } - } - ] - } - }, - { - "name": "PoolState", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": { - "array": [ - "u8", - 1 - ] - } - }, - { - "name": "ammConfig", - "type": "publicKey" - }, - { - "name": "owner", - "type": "publicKey" - }, - { - "name": "tokenMint0", - "type": "publicKey" - }, - { - "name": "tokenMint1", - "type": "publicKey" - }, - { - "name": "tokenVault0", - "type": "publicKey" - }, - { - "name": "tokenVault1", - "type": "publicKey" - }, - { - "name": "observationKey", - "type": "publicKey" - }, - { - "name": "mintDecimals0", - "type": "u8" - }, - { - "name": "mintDecimals1", - "type": "u8" - }, - { - "name": "tickSpacing", - "type": "u16" - }, - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "sqrtPriceX64", - "type": "u128" - }, - { - "name": "tickCurrent", - "type": "i32" - }, - { - "name": "padding3", - "type": "u16" - }, - { - "name": "padding4", - "type": "u16" - }, - { - "name": "feeGrowthGlobal0X64", - "type": "u128" - }, - { - "name": "feeGrowthGlobal1X64", - "type": "u128" - }, - { - "name": "protocolFeesToken0", - "type": "u64" - }, - { - "name": "protocolFeesToken1", - "type": "u64" - }, - { - "name": "swapInAmountToken0", - "type": "u128" - }, - { - "name": "swapOutAmountToken1", - "type": "u128" - }, - { - "name": "swapInAmountToken1", - "type": "u128" - }, - { - "name": "swapOutAmountToken0", - "type": "u128" - }, - { - "name": "status", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 7 - ] - } - }, - { - "name": "rewardInfos", - "type": { - "array": [ - { - "defined": "RewardInfo" - }, - 3 - ] - } - }, - { - "name": "tickArrayBitmap", - "type": { - "array": [ - "u64", - 16 - ] - } - }, - { - "name": "totalFeesToken0", - "type": "u64" - }, - { - "name": "totalFeesClaimedToken0", - "type": "u64" - }, - { - "name": "totalFeesToken1", - "type": "u64" - }, - { - "name": "totalFeesClaimedToken1", - "type": "u64" - }, - { - "name": "fundFeesToken0", - "type": "u64" - }, - { - "name": "fundFeesToken1", - "type": "u64" - }, - { - "name": "openTime", - "type": "u64" - }, - { - "name": "recentEpoch", - "type": "u64" - }, - { - "name": "padding1", - "type": { - "array": [ - "u64", - 24 - ] - } - }, - { - "name": "padding2", - "type": { - "array": [ - "u64", - 32 - ] - } - } - ] - } - }, - { - "name": "ProtocolPositionState", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "poolId", - "type": "publicKey" - }, - { - "name": "tickLowerIndex", - "type": "i32" - }, - { - "name": "tickUpperIndex", - "type": "i32" - }, - { - "name": "liquidity", - "type": "u128" - }, - { - "name": "feeGrowthInside0LastX64", - "type": "u128" - }, - { - "name": "feeGrowthInside1LastX64", - "type": "u128" - }, - { - "name": "tokenFeesOwed0", - "type": "u64" - }, - { - "name": "tokenFeesOwed1", - "type": "u64" - }, - { - "name": "rewardGrowthInside", - "type": { - "array": [ - "u128", - 3 - ] - } - }, - { - "name": "recentEpoch", - "type": "u64" - }, - { - "name": "padding", - "type": { - "array": [ - "u64", - 7 - ] - } - } - ] - } - }, - { - "name": "TickArrayState", - "type": { - "kind": "struct", - "fields": [ - { - "name": "poolId", - "type": "publicKey" - }, - { - "name": "startTickIndex", - "type": "i32" - }, - { - "name": "ticks", - "type": { - "array": [ - { - "defined": "TickState" - }, - 60 - ] - } - }, - { - "name": "initializedTickCount", - "type": "u8" - }, - { - "name": "recentEpoch", - "type": "u64" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 107 - ] - } - } - ] - } - }, - { - "name": "TickArrayBitmapExtension", - "type": { - "kind": "struct", - "fields": [ - { - "name": "poolId", - "type": "publicKey" - }, - { - "name": "positiveTickArrayBitmap", - "type": { - "array": [ - { - "array": [ - "u64", - 8 - ] - }, - 14 - ] - } - }, - { - "name": "negativeTickArrayBitmap", - "type": { - "array": [ - { - "array": [ - "u64", - 8 - ] - }, - 14 - ] - } - } - ] - } - } - ], - "types": [ - { - "name": "InitializeRewardParam", - "type": { - "kind": "struct", - "fields": [ - { - "name": "openTime", - "type": "u64" - }, - { - "name": "endTime", - "type": "u64" - }, - { - "name": "emissionsPerSecondX64", - "type": "u128" - } - ] - } - }, - { - "name": "Observation", - "type": { - "kind": "struct", - "fields": [ - { - "name": "blockTimestamp", - "type": "u32" - }, - { - "name": "tickCumulative", - "type": "i64" - }, - { - "name": "padding", - "type": { - "array": [ - "u64", - 4 - ] - } - } - ] - } - }, - { - "name": "PositionRewardInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "growthInsideLastX64", - "type": "u128" - }, - { - "name": "rewardAmountOwed", - "type": "u64" - } - ] - } - }, - { - "name": "RewardInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rewardState", - "type": "u8" - }, - { - "name": "openTime", - "type": "u64" - }, - { - "name": "endTime", - "type": "u64" - }, - { - "name": "lastUpdateTime", - "type": "u64" - }, - { - "name": "emissionsPerSecondX64", - "type": "u128" - }, - { - "name": "rewardTotalEmissioned", - "type": "u64" - }, - { - "name": "rewardClaimed", - "type": "u64" - }, - { - "name": "tokenMint", - "type": "publicKey" - }, - { - "name": "tokenVault", - "type": "publicKey" - }, - { - "name": "authority", - "type": "publicKey" - }, - { - "name": "rewardGrowthGlobalX64", - "type": "u128" - } - ] - } - }, - { - "name": "TickState", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tick", - "type": "i32" - }, - { - "name": "liquidityNet", - "type": "i128" - }, - { - "name": "liquidityGross", - "type": "u128" - }, - { - "name": "feeGrowthOutside0X64", - "type": "u128" - }, - { - "name": "feeGrowthOutside1X64", - "type": "u128" - }, - { - "name": "rewardGrowthsOutsideX64", - "type": { - "array": [ - "u128", - 3 - ] - } - }, - { - "name": "padding", - "type": { - "array": [ - "u32", - 13 - ] - } - } - ] - } - }, - { - "name": "PoolStatusBitIndex", - "type": { - "kind": "enum", - "variants": [ - { - "name": "OpenPositionOrIncreaseLiquidity" - }, - { - "name": "DecreaseLiquidity" - }, - { - "name": "CollectFee" - }, - { - "name": "CollectReward" - }, - { - "name": "Swap" - } - ] - } - }, - { - "name": "PoolStatusBitFlag", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Enable" - }, - { - "name": "Disable" - } - ] - } - }, - { - "name": "RewardState", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Uninitialized" - }, - { - "name": "Initialized" - }, - { - "name": "Opening" - }, - { - "name": "Ended" - } - ] - } - }, - { - "name": "TickArryBitmap", - "type": { - "kind": "alias", - "value": { - "array": [ - "u64", - 8 - ] - } - } - } - ], - "events": [ - { - "name": "ConfigChangeEvent", - "fields": [ - { - "name": "index", - "type": "u16", - "index": false - }, - { - "name": "owner", - "type": "publicKey", - "index": true - }, - { - "name": "protocolFeeRate", - "type": "u32", - "index": false - }, - { - "name": "tradeFeeRate", - "type": "u32", - "index": false - }, - { - "name": "tickSpacing", - "type": "u16", - "index": false - }, - { - "name": "fundFeeRate", - "type": "u32", - "index": false - }, - { - "name": "fundOwner", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "CreatePersonalPositionEvent", - "fields": [ - { - "name": "poolState", - "type": "publicKey", - "index": false - }, - { - "name": "minter", - "type": "publicKey", - "index": false - }, - { - "name": "nftOwner", - "type": "publicKey", - "index": false - }, - { - "name": "tickLowerIndex", - "type": "i32", - "index": false - }, - { - "name": "tickUpperIndex", - "type": "i32", - "index": false - }, - { - "name": "liquidity", - "type": "u128", - "index": false - }, - { - "name": "depositAmount0", - "type": "u64", - "index": false - }, - { - "name": "depositAmount1", - "type": "u64", - "index": false - }, - { - "name": "depositAmount0TransferFee", - "type": "u64", - "index": false - }, - { - "name": "depositAmount1TransferFee", - "type": "u64", - "index": false - } - ] - }, - { - "name": "IncreaseLiquidityEvent", - "fields": [ - { - "name": "positionNftMint", - "type": "publicKey", - "index": false - }, - { - "name": "liquidity", - "type": "u128", - "index": false - }, - { - "name": "amount0", - "type": "u64", - "index": false - }, - { - "name": "amount1", - "type": "u64", - "index": false - }, - { - "name": "amount0TransferFee", - "type": "u64", - "index": false - }, - { - "name": "amount1TransferFee", - "type": "u64", - "index": false - } - ] - }, - { - "name": "DecreaseLiquidityEvent", - "fields": [ - { - "name": "positionNftMint", - "type": "publicKey", - "index": false - }, - { - "name": "liquidity", - "type": "u128", - "index": false - }, - { - "name": "decreaseAmount0", - "type": "u64", - "index": false - }, - { - "name": "decreaseAmount1", - "type": "u64", - "index": false - }, - { - "name": "feeAmount0", - "type": "u64", - "index": false - }, - { - "name": "feeAmount1", - "type": "u64", - "index": false - }, - { - "name": "rewardAmounts", - "type": { - "array": [ - "u64", - 3 - ] - }, - "index": false - }, - { - "name": "transferFee0", - "type": "u64", - "index": false - }, - { - "name": "transferFee1", - "type": "u64", - "index": false - } - ] - }, - { - "name": "LiquidityCalculateEvent", - "fields": [ - { - "name": "poolLiquidity", - "type": "u128", - "index": false - }, - { - "name": "poolSqrtPriceX64", - "type": "u128", - "index": false - }, - { - "name": "poolTick", - "type": "i32", - "index": false - }, - { - "name": "calcAmount0", - "type": "u64", - "index": false - }, - { - "name": "calcAmount1", - "type": "u64", - "index": false - }, - { - "name": "tradeFeeOwed0", - "type": "u64", - "index": false - }, - { - "name": "tradeFeeOwed1", - "type": "u64", - "index": false - }, - { - "name": "transferFee0", - "type": "u64", - "index": false - }, - { - "name": "transferFee1", - "type": "u64", - "index": false - } - ] - }, - { - "name": "CollectPersonalFeeEvent", - "fields": [ - { - "name": "positionNftMint", - "type": "publicKey", - "index": false - }, - { - "name": "recipientTokenAccount0", - "type": "publicKey", - "index": false - }, - { - "name": "recipientTokenAccount1", - "type": "publicKey", - "index": false - }, - { - "name": "amount0", - "type": "u64", - "index": false - }, - { - "name": "amount1", - "type": "u64", - "index": false - } - ] - }, - { - "name": "UpdateRewardInfosEvent", - "fields": [ - { - "name": "rewardGrowthGlobalX64", - "type": { - "array": [ - "u128", - 3 - ] - }, - "index": false - } - ] - }, - { - "name": "PoolCreatedEvent", - "fields": [ - { - "name": "tokenMint0", - "type": "publicKey", - "index": false - }, - { - "name": "tokenMint1", - "type": "publicKey", - "index": false - }, - { - "name": "tickSpacing", - "type": "u16", - "index": false - }, - { - "name": "poolState", - "type": "publicKey", - "index": false - }, - { - "name": "sqrtPriceX64", - "type": "u128", - "index": false - }, - { - "name": "tick", - "type": "i32", - "index": false - }, - { - "name": "tokenVault0", - "type": "publicKey", - "index": false - }, - { - "name": "tokenVault1", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "CollectProtocolFeeEvent", - "fields": [ - { - "name": "poolState", - "type": "publicKey", - "index": false - }, - { - "name": "recipientTokenAccount0", - "type": "publicKey", - "index": false - }, - { - "name": "recipientTokenAccount1", - "type": "publicKey", - "index": false - }, - { - "name": "amount0", - "type": "u64", - "index": false - }, - { - "name": "amount1", - "type": "u64", - "index": false - } - ] - }, - { - "name": "SwapEvent", - "fields": [ - { - "name": "poolState", - "type": "publicKey", - "index": false - }, - { - "name": "sender", - "type": "publicKey", - "index": false - }, - { - "name": "tokenAccount0", - "type": "publicKey", - "index": false - }, - { - "name": "tokenAccount1", - "type": "publicKey", - "index": false - }, - { - "name": "amount0", - "type": "u64", - "index": false - }, - { - "name": "transferFee0", - "type": "u64", - "index": false - }, - { - "name": "amount1", - "type": "u64", - "index": false - }, - { - "name": "transferFee1", - "type": "u64", - "index": false - }, - { - "name": "zeroForOne", - "type": "bool", - "index": false - }, - { - "name": "sqrtPriceX64", - "type": "u128", - "index": false - }, - { - "name": "liquidity", - "type": "u128", - "index": false - }, - { - "name": "tick", - "type": "i32", - "index": false - } - ] - }, - { - "name": "LiquidityChangeEvent", - "fields": [ - { - "name": "poolState", - "type": "publicKey", - "index": false - }, - { - "name": "tick", - "type": "i32", - "index": false - }, - { - "name": "tickLower", - "type": "i32", - "index": false - }, - { - "name": "tickUpper", - "type": "i32", - "index": false - }, - { - "name": "liquidityBefore", - "type": "u128", - "index": false - }, - { - "name": "liquidityAfter", - "type": "u128", - "index": false - } - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "LOK", - "msg": "LOK" - }, - { - "code": 6001, - "name": "NotApproved", - "msg": "Not approved" - }, - { - "code": 6002, - "name": "InvalidUpdateConfigFlag", - "msg": "invalid update amm config flag" - }, - { - "code": 6003, - "name": "AccountLack", - "msg": "Account lack" - }, - { - "code": 6004, - "name": "ClosePositionErr", - "msg": "Remove liquitity, collect fees owed and reward then you can close position account" - }, - { - "code": 6005, - "name": "ZeroMintAmount", - "msg": "Minting amount should be greater than 0" - }, - { - "code": 6006, - "name": "InvaildTickIndex", - "msg": "Tick out of range" - }, - { - "code": 6007, - "name": "TickInvaildOrder", - "msg": "The lower tick must be below the upper tick" - }, - { - "code": 6008, - "name": "TickLowerOverflow", - "msg": "The tick must be greater, or equal to the minimum tick(-443636)" - }, - { - "code": 6009, - "name": "TickUpperOverflow", - "msg": "The tick must be lesser than, or equal to the maximum tick(443636)" - }, - { - "code": 6010, - "name": "TickAndSpacingNotMatch", - "msg": "tick % tick_spacing must be zero" - }, - { - "code": 6011, - "name": "InvalidTickArray", - "msg": "Invaild tick array account" - }, - { - "code": 6012, - "name": "InvalidTickArrayBoundary", - "msg": "Invaild tick array boundary" - }, - { - "code": 6013, - "name": "SqrtPriceLimitOverflow", - "msg": "Square root price limit overflow" - }, - { - "code": 6014, - "name": "SqrtPriceX64", - "msg": "sqrt_price_x64 out of range" - }, - { - "code": 6015, - "name": "LiquiditySubValueErr", - "msg": "Liquidity sub delta L must be smaller than before" - }, - { - "code": 6016, - "name": "LiquidityAddValueErr", - "msg": "Liquidity add delta L must be greater, or equal to before" - }, - { - "code": 6017, - "name": "InvaildLiquidity", - "msg": "Invaild liquidity when update position" - }, - { - "code": 6018, - "name": "ForbidBothZeroForSupplyLiquidity", - "msg": "Both token amount must not be zero while supply liquidity" - }, - { - "code": 6019, - "name": "LiquidityInsufficient", - "msg": "Liquidity insufficient" - }, - { - "code": 6020, - "name": "TransactionTooOld", - "msg": "Transaction too old" - }, - { - "code": 6021, - "name": "PriceSlippageCheck", - "msg": "Price slippage check" - }, - { - "code": 6022, - "name": "TooLittleOutputReceived", - "msg": "Too little output received" - }, - { - "code": 6023, - "name": "TooMuchInputPaid", - "msg": "Too much input paid" - }, - { - "code": 6024, - "name": "ZeroAmountSpecified", - "msg": "Swap special amount can not be zero" - }, - { - "code": 6025, - "name": "InvalidInputPoolVault", - "msg": "Input pool vault is invalid" - }, - { - "code": 6026, - "name": "TooSmallInputOrOutputAmount", - "msg": "Swap input or output amount is too small" - }, - { - "code": 6027, - "name": "NotEnoughTickArrayAccount", - "msg": "Not enought tick array account" - }, - { - "code": 6028, - "name": "InvalidFirstTickArrayAccount", - "msg": "Invaild first tick array account" - }, - { - "code": 6029, - "name": "InvalidRewardIndex", - "msg": "Invalid reward index" - }, - { - "code": 6030, - "name": "FullRewardInfo", - "msg": "The init reward token reach to the max" - }, - { - "code": 6031, - "name": "RewardTokenAlreadyInUse", - "msg": "The init reward token already in use" - }, - { - "code": 6032, - "name": "ExceptPoolVaultMint", - "msg": "The reward tokens must contain one of pool vault mint except the last reward" - }, - { - "code": 6033, - "name": "InvalidRewardInitParam", - "msg": "Invalid reward init param" - }, - { - "code": 6034, - "name": "InvalidRewardDesiredAmount", - "msg": "Invalid collect reward desired amount" - }, - { - "code": 6035, - "name": "InvalidRewardInputAccountNumber", - "msg": "Invalid collect reward input account number" - }, - { - "code": 6036, - "name": "InvalidRewardPeriod", - "msg": "Invalid reward period" - }, - { - "code": 6037, - "name": "NotApproveUpdateRewardEmissiones", - "msg": "Modification of emissiones is allowed within 72 hours from the end of the previous cycle" - }, - { - "code": 6038, - "name": "UnInitializedRewardInfo", - "msg": "uninitialized reward info" - }, - { - "code": 6039, - "name": "NotSupportMint", - "msg": "Not support token_2022 mint extension" - }, - { - "code": 6040, - "name": "MissingTickArrayBitmapExtensionAccount", - "msg": "Missing tickarray bitmap extension account" - }, - { - "code": 6041, - "name": "InsufficientLiquidityForDirection", - "msg": "Insufficient liquidity for this direction" - }, - { - "code": 6042, - "name": "MaxTokenOverflow", - "msg": "Max token overflow" - }, - { - "code": 6043, - "name": "CalculateOverflow", - "msg": "calculate overflow" - } - ] -} \ No newline at end of file diff --git a/crates/raydium-clmm-parser/proto/raydium_clmm.proto b/crates/raydium-clmm-parser/proto/raydium_clmm.proto deleted file mode 100644 index 7a8fd3f6..00000000 --- a/crates/raydium-clmm-parser/proto/raydium_clmm.proto +++ /dev/null @@ -1,784 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.raydium_clmm; - -message CreateAmmConfigIx { - CreateAmmConfigIxAccounts accounts = 1; - CreateAmmConfigIxData data = 2; -} - -message UpdateAmmConfigIx { - UpdateAmmConfigIxAccounts accounts = 1; - UpdateAmmConfigIxData data = 2; -} - -message CreatePoolIx { - CreatePoolIxAccounts accounts = 1; - CreatePoolIxData data = 2; -} - -message UpdatePoolStatusIx { - UpdatePoolStatusIxAccounts accounts = 1; - UpdatePoolStatusIxData data = 2; -} - -message CreateOperationAccountIx { - CreateOperationAccountIxAccounts accounts = 1; -} - -message UpdateOperationAccountIx { - UpdateOperationAccountIxAccounts accounts = 1; - UpdateOperationAccountIxData data = 2; -} - -message TransferRewardOwnerIx { - TransferRewardOwnerIxAccounts accounts = 1; - TransferRewardOwnerIxData data = 2; -} - -message InitializeRewardIx { - InitializeRewardIxAccounts accounts = 1; - InitializeRewardIxData data = 2; -} - -message CollectRemainingRewardsIx { - CollectRemainingRewardsIxAccounts accounts = 1; - CollectRemainingRewardsIxData data = 2; -} - -message UpdateRewardInfosIx { - UpdateRewardInfosIxAccounts accounts = 1; -} - -message SetRewardParamsIx { - SetRewardParamsIxAccounts accounts = 1; - SetRewardParamsIxData data = 2; -} - -message CollectProtocolFeeIx { - CollectProtocolFeeIxAccounts accounts = 1; - CollectProtocolFeeIxData data = 2; -} - -message CollectFundFeeIx { - CollectFundFeeIxAccounts accounts = 1; - CollectFundFeeIxData data = 2; -} - -message OpenPositionIx { - OpenPositionIxAccounts accounts = 1; - OpenPositionIxData data = 2; -} - -message OpenPositionV2Ix { - OpenPositionV2IxAccounts accounts = 1; - OpenPositionV2IxData data = 2; -} - -message OpenPositionWithToken22NftIx { - OpenPositionWithToken22NftIxAccounts accounts = 1; - OpenPositionWithToken22NftIxData data = 2; -} - -message ClosePositionIx { - ClosePositionIxAccounts accounts = 1; -} - -message IncreaseLiquidityIx { - IncreaseLiquidityIxAccounts accounts = 1; - IncreaseLiquidityIxData data = 2; -} - -message IncreaseLiquidityV2Ix { - IncreaseLiquidityV2IxAccounts accounts = 1; - IncreaseLiquidityV2IxData data = 2; -} - -message DecreaseLiquidityIx { - DecreaseLiquidityIxAccounts accounts = 1; - DecreaseLiquidityIxData data = 2; -} - -message DecreaseLiquidityV2Ix { - DecreaseLiquidityV2IxAccounts accounts = 1; - DecreaseLiquidityV2IxData data = 2; -} - -message SwapIx { - SwapIxAccounts accounts = 1; - SwapIxData data = 2; -} - -message SwapV2Ix { - SwapV2IxAccounts accounts = 1; - SwapV2IxData data = 2; -} - -message SwapRouterBaseInIx { - SwapRouterBaseInIxAccounts accounts = 1; - SwapRouterBaseInIxData data = 2; -} - -message RepeatedUint64Row { - repeated uint64 rows = 1; -} - - -message Observation { - uint32 block_timestamp = 1; - int64 tick_cumulative = 2; - repeated uint64 padding = 3; -} - -message PositionRewardInfo { - string growth_inside_last_x64 = 1; - uint64 reward_amount_owed = 2; -} - -message RewardInfo { - uint32 reward_state = 1; - uint64 open_time = 2; - uint64 end_time = 3; - uint64 last_update_time = 4; - string emissions_per_second_x64 = 5; - uint64 reward_total_emissioned = 6; - uint64 reward_claimed = 7; - string token_mint = 8; - string token_vault = 9; - string authority = 10; - string reward_growth_global_x64 = 11; -} - -message TickState { - int32 tick = 1; - string liquidity_net = 2; - string liquidity_gross = 3; - string fee_growth_outside0_x64 = 4; - string fee_growth_outside1_x64 = 5; - repeated string reward_growths_outside_x64 = 6; - repeated uint32 padding = 7; -} - -enum PoolStatusBitIndex { - PoolStatusBitIndexOpenPositionOrIncreaseLiquidity = 0; - PoolStatusBitIndexDecreaseLiquidity = 1; - PoolStatusBitIndexCollectFee = 2; - PoolStatusBitIndexCollectReward = 3; - PoolStatusBitIndexSwap = 4; -} - -enum PoolStatusBitFlag { - PoolStatusBitFlagEnable = 0; - PoolStatusBitFlagDisable = 1; -} - -enum RewardState { - RewardStateUninitialized = 0; - RewardStateInitialized = 1; - RewardStateOpening = 2; - RewardStateEnded = 3; -} - - -message AmmConfig { - uint32 bump = 1; - uint32 index = 2; - string owner = 3; - uint32 protocol_fee_rate = 4; - uint32 trade_fee_rate = 5; - uint32 tick_spacing = 6; - uint32 fund_fee_rate = 7; - uint32 padding_u32 = 8; - string fund_owner = 9; - repeated uint64 padding = 10; -} - -message OperationState { - uint32 bump = 1; - repeated string operation_owners = 2; - repeated string whitelist_mints = 3; -} - -message ObservationState { - bool initialized = 1; - uint64 recent_epoch = 2; - uint32 observation_index = 3; - string pool_id = 4; - repeated Observation observations = 5; - repeated uint64 padding = 6; -} - -message PersonalPositionState { - repeated uint32 bump = 1; - string nft_mint = 2; - string pool_id = 3; - int32 tick_lower_index = 4; - int32 tick_upper_index = 5; - string liquidity = 6; - string fee_growth_inside0_last_x64 = 7; - string fee_growth_inside1_last_x64 = 8; - uint64 token_fees_owed0 = 9; - uint64 token_fees_owed1 = 10; - repeated PositionRewardInfo reward_infos = 11; - uint64 recent_epoch = 12; - repeated uint64 padding = 13; -} - -message PoolState { - repeated uint32 bump = 1; - string amm_config = 2; - string owner = 3; - string token_mint0 = 4; - string token_mint1 = 5; - string token_vault0 = 6; - string token_vault1 = 7; - string observation_key = 8; - uint32 mint_decimals0 = 9; - uint32 mint_decimals1 = 10; - uint32 tick_spacing = 11; - string liquidity = 12; - string sqrt_price_x64 = 13; - int32 tick_current = 14; - uint32 padding3 = 15; - uint32 padding4 = 16; - string fee_growth_global0_x64 = 17; - string fee_growth_global1_x64 = 18; - uint64 protocol_fees_token0 = 19; - uint64 protocol_fees_token1 = 20; - string swap_in_amount_token0 = 21; - string swap_out_amount_token1 = 22; - string swap_in_amount_token1 = 23; - string swap_out_amount_token0 = 24; - uint32 status = 25; - repeated uint32 padding = 26; - repeated RewardInfo reward_infos = 27; - repeated uint64 tick_array_bitmap = 28; - uint64 total_fees_token0 = 29; - uint64 total_fees_claimed_token0 = 30; - uint64 total_fees_token1 = 31; - uint64 total_fees_claimed_token1 = 32; - uint64 fund_fees_token0 = 33; - uint64 fund_fees_token1 = 34; - uint64 open_time = 35; - uint64 recent_epoch = 36; - repeated uint64 padding1 = 37; - repeated uint64 padding2 = 38; -} - -message ProtocolPositionState { - uint32 bump = 1; - string pool_id = 2; - int32 tick_lower_index = 3; - int32 tick_upper_index = 4; - string liquidity = 5; - string fee_growth_inside0_last_x64 = 6; - string fee_growth_inside1_last_x64 = 7; - uint64 token_fees_owed0 = 8; - uint64 token_fees_owed1 = 9; - repeated string reward_growth_inside = 10; - uint64 recent_epoch = 11; - repeated uint64 padding = 12; -} - -message TickArrayState { - string pool_id = 1; - int32 start_tick_index = 2; - repeated TickState ticks = 3; - uint32 initialized_tick_count = 4; - uint64 recent_epoch = 5; - repeated uint32 padding = 6; -} - -message TickArrayBitmapExtension { - string pool_id = 1; - repeated RepeatedUint64Row positive_tick_array_bitmap = 2; - repeated RepeatedUint64Row negative_tick_array_bitmap = 3; -} - - -message CreateAmmConfigIxAccounts { - string owner = 1; - string amm_config = 2; - string system_program = 3; -} - -message CreateAmmConfigIxData { - uint32 index = 1; - uint32 tick_spacing = 2; - uint32 trade_fee_rate = 3; - uint32 protocol_fee_rate = 4; - uint32 fund_fee_rate = 5; -} - -message UpdateAmmConfigIxAccounts { - string owner = 1; - string amm_config = 2; -} - -message UpdateAmmConfigIxData { - uint32 param = 1; - uint32 value = 2; -} - -message CreatePoolIxAccounts { - string pool_creator = 1; - string amm_config = 2; - string pool_state = 3; - string token_mint0 = 4; - string token_mint1 = 5; - string token_vault0 = 6; - string token_vault1 = 7; - string observation_state = 8; - string tick_array_bitmap = 9; - string token_program0 = 10; - string token_program1 = 11; - string system_program = 12; - string rent = 13; -} - -message CreatePoolIxData { - string sqrt_price_x64 = 1; - uint64 open_time = 2; -} - -message UpdatePoolStatusIxAccounts { - string authority = 1; - string pool_state = 2; -} - -message UpdatePoolStatusIxData { - uint32 status = 1; -} - -message CreateOperationAccountIxAccounts { - string owner = 1; - string operation_state = 2; - string system_program = 3; -} - - -message UpdateOperationAccountIxAccounts { - string owner = 1; - string operation_state = 2; - string system_program = 3; -} - -message UpdateOperationAccountIxData { - uint32 param = 1; - repeated string keys = 2; -} - -message TransferRewardOwnerIxAccounts { - string authority = 1; - string pool_state = 2; -} - -message TransferRewardOwnerIxData { - string new_owner = 1; -} - -message InitializeRewardIxAccounts { - string reward_funder = 1; - string funder_token_account = 2; - string amm_config = 3; - string pool_state = 4; - string operation_state = 5; - string reward_token_mint = 6; - string reward_token_vault = 7; - string reward_token_program = 8; - string system_program = 9; - string rent = 10; -} - -message InitializeRewardIxData { - uint64 open_time = 1; - uint64 end_time = 2; - string emissions_per_second_x64 = 3; -} - -message CollectRemainingRewardsIxAccounts { - string reward_funder = 1; - string funder_token_account = 2; - string pool_state = 3; - string reward_token_vault = 4; - string reward_vault_mint = 5; - string token_program = 6; - string token_program2022 = 7; - string memo_program = 8; -} - -message CollectRemainingRewardsIxData { - uint32 reward_index = 1; -} - -message UpdateRewardInfosIxAccounts { - string pool_state = 1; -} - - -message SetRewardParamsIxAccounts { - string authority = 1; - string amm_config = 2; - string pool_state = 3; - string operation_state = 4; - string token_program = 5; - string token_program2022 = 6; -} - -message SetRewardParamsIxData { - uint32 reward_index = 1; - string emissions_per_second_x64 = 2; - uint64 open_time = 3; - uint64 end_time = 4; -} - -message CollectProtocolFeeIxAccounts { - string owner = 1; - string pool_state = 2; - string amm_config = 3; - string token_vault0 = 4; - string token_vault1 = 5; - string vault0_mint = 6; - string vault1_mint = 7; - string recipient_token_account0 = 8; - string recipient_token_account1 = 9; - string token_program = 10; - string token_program2022 = 11; -} - -message CollectProtocolFeeIxData { - uint64 amount0_requested = 1; - uint64 amount1_requested = 2; -} - -message CollectFundFeeIxAccounts { - string owner = 1; - string pool_state = 2; - string amm_config = 3; - string token_vault0 = 4; - string token_vault1 = 5; - string vault0_mint = 6; - string vault1_mint = 7; - string recipient_token_account0 = 8; - string recipient_token_account1 = 9; - string token_program = 10; - string token_program2022 = 11; -} - -message CollectFundFeeIxData { - uint64 amount0_requested = 1; - uint64 amount1_requested = 2; -} - -message OpenPositionIxAccounts { - string payer = 1; - string position_nft_owner = 2; - string position_nft_mint = 3; - string position_nft_account = 4; - string metadata_account = 5; - string pool_state = 6; - string protocol_position = 7; - string tick_array_lower = 8; - string tick_array_upper = 9; - string personal_position = 10; - string token_account0 = 11; - string token_account1 = 12; - string token_vault0 = 13; - string token_vault1 = 14; - string rent = 15; - string system_program = 16; - string token_program = 17; - string associated_token_program = 18; - string metadata_program = 19; -} - -message OpenPositionIxData { - int32 tick_lower_index = 1; - int32 tick_upper_index = 2; - int32 tick_array_lower_start_index = 3; - int32 tick_array_upper_start_index = 4; - string liquidity = 5; - uint64 amount0_max = 6; - uint64 amount1_max = 7; -} - -message OpenPositionV2IxAccounts { - string payer = 1; - string position_nft_owner = 2; - string position_nft_mint = 3; - string position_nft_account = 4; - string metadata_account = 5; - string pool_state = 6; - string protocol_position = 7; - string tick_array_lower = 8; - string tick_array_upper = 9; - string personal_position = 10; - string token_account0 = 11; - string token_account1 = 12; - string token_vault0 = 13; - string token_vault1 = 14; - string rent = 15; - string system_program = 16; - string token_program = 17; - string associated_token_program = 18; - string metadata_program = 19; - string token_program2022 = 20; - string vault0_mint = 21; - string vault1_mint = 22; -} - -message OpenPositionV2IxData { - int32 tick_lower_index = 1; - int32 tick_upper_index = 2; - int32 tick_array_lower_start_index = 3; - int32 tick_array_upper_start_index = 4; - string liquidity = 5; - uint64 amount0_max = 6; - uint64 amount1_max = 7; - bool with_metadata = 8; - optional bool base_flag = 9; -} - -message OpenPositionWithToken22NftIxAccounts { - string payer = 1; - string position_nft_owner = 2; - string position_nft_mint = 3; - string position_nft_account = 4; - string pool_state = 5; - string protocol_position = 6; - string tick_array_lower = 7; - string tick_array_upper = 8; - string personal_position = 9; - string token_account0 = 10; - string token_account1 = 11; - string token_vault0 = 12; - string token_vault1 = 13; - string rent = 14; - string system_program = 15; - string token_program = 16; - string associated_token_program = 17; - string token_program2022 = 18; - string vault0_mint = 19; - string vault1_mint = 20; -} - -message OpenPositionWithToken22NftIxData { - int32 tick_lower_index = 1; - int32 tick_upper_index = 2; - int32 tick_array_lower_start_index = 3; - int32 tick_array_upper_start_index = 4; - string liquidity = 5; - uint64 amount0_max = 6; - uint64 amount1_max = 7; - bool with_metadata = 8; - optional bool base_flag = 9; -} - -message ClosePositionIxAccounts { - string nft_owner = 1; - string position_nft_mint = 2; - string position_nft_account = 3; - string personal_position = 4; - string system_program = 5; - string token_program = 6; -} - - -message IncreaseLiquidityIxAccounts { - string nft_owner = 1; - string nft_account = 2; - string pool_state = 3; - string protocol_position = 4; - string personal_position = 5; - string tick_array_lower = 6; - string tick_array_upper = 7; - string token_account0 = 8; - string token_account1 = 9; - string token_vault0 = 10; - string token_vault1 = 11; - string token_program = 12; -} - -message IncreaseLiquidityIxData { - string liquidity = 1; - uint64 amount0_max = 2; - uint64 amount1_max = 3; -} - -message IncreaseLiquidityV2IxAccounts { - string nft_owner = 1; - string nft_account = 2; - string pool_state = 3; - string protocol_position = 4; - string personal_position = 5; - string tick_array_lower = 6; - string tick_array_upper = 7; - string token_account0 = 8; - string token_account1 = 9; - string token_vault0 = 10; - string token_vault1 = 11; - string token_program = 12; - string token_program2022 = 13; - string vault0_mint = 14; - string vault1_mint = 15; -} - -message IncreaseLiquidityV2IxData { - string liquidity = 1; - uint64 amount0_max = 2; - uint64 amount1_max = 3; - optional bool base_flag = 4; -} - -message DecreaseLiquidityIxAccounts { - string nft_owner = 1; - string nft_account = 2; - string personal_position = 3; - string pool_state = 4; - string protocol_position = 5; - string token_vault0 = 6; - string token_vault1 = 7; - string tick_array_lower = 8; - string tick_array_upper = 9; - string recipient_token_account0 = 10; - string recipient_token_account1 = 11; - string token_program = 12; -} - -message DecreaseLiquidityIxData { - string liquidity = 1; - uint64 amount0_min = 2; - uint64 amount1_min = 3; -} - -message DecreaseLiquidityV2IxAccounts { - string nft_owner = 1; - string nft_account = 2; - string personal_position = 3; - string pool_state = 4; - string protocol_position = 5; - string token_vault0 = 6; - string token_vault1 = 7; - string tick_array_lower = 8; - string tick_array_upper = 9; - string recipient_token_account0 = 10; - string recipient_token_account1 = 11; - string token_program = 12; - string token_program2022 = 13; - string memo_program = 14; - string vault0_mint = 15; - string vault1_mint = 16; -} - -message DecreaseLiquidityV2IxData { - string liquidity = 1; - uint64 amount0_min = 2; - uint64 amount1_min = 3; -} - -message SwapIxAccounts { - string payer = 1; - string amm_config = 2; - string pool_state = 3; - string input_token_account = 4; - string output_token_account = 5; - string input_vault = 6; - string output_vault = 7; - string observation_state = 8; - string token_program = 9; - string tick_array = 10; -} - -message SwapIxData { - uint64 amount = 1; - uint64 other_amount_threshold = 2; - string sqrt_price_limit_x64 = 3; - bool is_base_input = 4; -} - -message SwapV2IxAccounts { - string payer = 1; - string amm_config = 2; - string pool_state = 3; - string input_token_account = 4; - string output_token_account = 5; - string input_vault = 6; - string output_vault = 7; - string observation_state = 8; - string token_program = 9; - string token_program2022 = 10; - string memo_program = 11; - string input_vault_mint = 12; - string output_vault_mint = 13; -} - -message SwapV2IxData { - uint64 amount = 1; - uint64 other_amount_threshold = 2; - string sqrt_price_limit_x64 = 3; - bool is_base_input = 4; -} - -message SwapRouterBaseInIxAccounts { - string payer = 1; - string input_token_account = 2; - string input_token_mint = 3; - string token_program = 4; - string token_program2022 = 5; - string memo_program = 6; -} - -message SwapRouterBaseInIxData { - uint64 amount_in = 1; - uint64 amount_out_minimum = 2; -} - - -message ProgramState { - oneof state_oneof { - AmmConfig amm_config = 1; - OperationState operation_state = 2; - ObservationState observation_state = 3; - PersonalPositionState personal_position_state = 4; - PoolState pool_state = 5; - ProtocolPositionState protocol_position_state = 6; - TickArrayState tick_array_state = 7; - TickArrayBitmapExtension tick_array_bitmap_extension = 8; - } -} - -message ProgramIxs { - oneof ix_oneof { - CreateAmmConfigIx create_amm_config = 1; - UpdateAmmConfigIx update_amm_config = 2; - CreatePoolIx create_pool = 3; - UpdatePoolStatusIx update_pool_status = 4; - CreateOperationAccountIx create_operation_account = 5; - UpdateOperationAccountIx update_operation_account = 6; - TransferRewardOwnerIx transfer_reward_owner = 7; - InitializeRewardIx initialize_reward = 8; - CollectRemainingRewardsIx collect_remaining_rewards = 9; - UpdateRewardInfosIx update_reward_infos = 10; - SetRewardParamsIx set_reward_params = 11; - CollectProtocolFeeIx collect_protocol_fee = 12; - CollectFundFeeIx collect_fund_fee = 13; - OpenPositionIx open_position = 14; - OpenPositionV2Ix open_position_v2 = 15; - OpenPositionWithToken22NftIx open_position_with_token22_nft = 16; - ClosePositionIx close_position = 17; - IncreaseLiquidityIx increase_liquidity = 18; - IncreaseLiquidityV2Ix increase_liquidity_v2 = 19; - DecreaseLiquidityIx decrease_liquidity = 20; - DecreaseLiquidityV2Ix decrease_liquidity_v2 = 21; - SwapIx swap = 22; - SwapV2Ix swap_v2 = 23; - SwapRouterBaseInIx swap_router_base_in = 24; - } -} - diff --git a/crates/raydium-clmm-parser/src/generated_parser/accounts_parser.rs b/crates/raydium-clmm-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index 45f975bb..00000000 --- a/crates/raydium-clmm-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,369 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{ - AmmConfig, ObservationState, OperationState, PersonalPositionState, PoolState, - ProtocolPositionState, TickArrayBitmapExtension, TickArrayState, - }, - deserialize_checked, ID, -}; - -/// AmmV3 Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum AmmV3ProgramState { - AmmConfig(AmmConfig), - OperationState(OperationState), - ObservationState(ObservationState), - PersonalPositionState(PersonalPositionState), - PoolState(PoolState), - ProtocolPositionState(ProtocolPositionState), - TickArrayState(TickArrayState), - TickArrayBitmapExtension(TickArrayBitmapExtension), -} - -impl AmmV3ProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [218, 244, 33, 104, 203, 203, 43, 111] => Ok(AmmV3ProgramState::AmmConfig( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [19, 236, 58, 237, 81, 222, 183, 252] => Ok(AmmV3ProgramState::OperationState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [122, 174, 197, 53, 129, 9, 165, 132] => Ok(AmmV3ProgramState::ObservationState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [70, 111, 150, 126, 230, 15, 25, 117] => Ok(AmmV3ProgramState::PersonalPositionState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [247, 237, 227, 245, 215, 195, 222, 70] => Ok(AmmV3ProgramState::PoolState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [100, 226, 145, 99, 146, 218, 160, 106] => { - Ok(AmmV3ProgramState::ProtocolPositionState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [192, 155, 85, 205, 49, 249, 129, 42] => Ok(AmmV3ProgramState::TickArrayState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [60, 150, 36, 219, 97, 128, 139, 153] => { - Ok(AmmV3ProgramState::TickArrayBitmapExtension( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = AmmV3ProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "amm_v3::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = AmmV3ProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, AmmConfig, AmmV3ProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for AmmConfig { - fn into_proto(self) -> proto_def::AmmConfig { - proto_def::AmmConfig { - bump: self.bump.into(), - index: self.index.into(), - owner: self.owner.to_string(), - protocol_fee_rate: self.protocol_fee_rate, - trade_fee_rate: self.trade_fee_rate, - tick_spacing: self.tick_spacing.into(), - fund_fee_rate: self.fund_fee_rate, - padding_u32: self.padding_u32, - fund_owner: self.fund_owner.to_string(), - padding: self.padding.to_vec(), - } - } - } - use super::OperationState; - impl IntoProto for OperationState { - fn into_proto(self) -> proto_def::OperationState { - proto_def::OperationState { - bump: self.bump.into(), - operation_owners: self - .operation_owners - .into_iter() - .map(|x| x.to_string()) - .collect(), - whitelist_mints: self - .whitelist_mints - .into_iter() - .map(|x| x.to_string()) - .collect(), - } - } - } - use super::ObservationState; - impl IntoProto for ObservationState { - fn into_proto(self) -> proto_def::ObservationState { - proto_def::ObservationState { - initialized: self.initialized, - recent_epoch: self.recent_epoch, - observation_index: self.observation_index.into(), - pool_id: self.pool_id.to_string(), - observations: self - .observations - .into_iter() - .map(|x| x.into_proto()) - .collect(), - padding: self.padding.to_vec(), - } - } - } - use super::PersonalPositionState; - impl IntoProto for PersonalPositionState { - fn into_proto(self) -> proto_def::PersonalPositionState { - proto_def::PersonalPositionState { - bump: self.bump.into_iter().map(|x| x.into()).collect(), - nft_mint: self.nft_mint.to_string(), - pool_id: self.pool_id.to_string(), - tick_lower_index: self.tick_lower_index, - tick_upper_index: self.tick_upper_index, - liquidity: self.liquidity.to_string(), - fee_growth_inside0_last_x64: self.fee_growth_inside0_last_x64.to_string(), - fee_growth_inside1_last_x64: self.fee_growth_inside1_last_x64.to_string(), - token_fees_owed0: self.token_fees_owed0, - token_fees_owed1: self.token_fees_owed1, - reward_infos: self - .reward_infos - .into_iter() - .map(|x| x.into_proto()) - .collect(), - recent_epoch: self.recent_epoch, - padding: self.padding.to_vec(), - } - } - } - use super::PoolState; - impl IntoProto for PoolState { - fn into_proto(self) -> proto_def::PoolState { - proto_def::PoolState { - bump: self.bump.into_iter().map(|x| x.into()).collect(), - amm_config: self.amm_config.to_string(), - owner: self.owner.to_string(), - token_mint0: self.token_mint0.to_string(), - token_mint1: self.token_mint1.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - observation_key: self.observation_key.to_string(), - mint_decimals0: self.mint_decimals0.into(), - mint_decimals1: self.mint_decimals1.into(), - tick_spacing: self.tick_spacing.into(), - liquidity: self.liquidity.to_string(), - sqrt_price_x64: self.sqrt_price_x64.to_string(), - tick_current: self.tick_current, - padding3: self.padding3.into(), - padding4: self.padding4.into(), - fee_growth_global0_x64: self.fee_growth_global0_x64.to_string(), - fee_growth_global1_x64: self.fee_growth_global1_x64.to_string(), - protocol_fees_token0: self.protocol_fees_token0, - protocol_fees_token1: self.protocol_fees_token1, - swap_in_amount_token0: self.swap_in_amount_token0.to_string(), - swap_out_amount_token1: self.swap_out_amount_token1.to_string(), - swap_in_amount_token1: self.swap_in_amount_token1.to_string(), - swap_out_amount_token0: self.swap_out_amount_token0.to_string(), - status: self.status.into(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - reward_infos: self - .reward_infos - .into_iter() - .map(|x| x.into_proto()) - .collect(), - tick_array_bitmap: self.tick_array_bitmap.to_vec(), - total_fees_token0: self.total_fees_token0, - total_fees_claimed_token0: self.total_fees_claimed_token0, - total_fees_token1: self.total_fees_token1, - total_fees_claimed_token1: self.total_fees_claimed_token1, - fund_fees_token0: self.fund_fees_token0, - fund_fees_token1: self.fund_fees_token1, - open_time: self.open_time, - recent_epoch: self.recent_epoch, - padding1: self.padding1.to_vec(), - padding2: self.padding2.to_vec(), - } - } - } - use super::ProtocolPositionState; - impl IntoProto for ProtocolPositionState { - fn into_proto(self) -> proto_def::ProtocolPositionState { - proto_def::ProtocolPositionState { - bump: self.bump.into(), - pool_id: self.pool_id.to_string(), - tick_lower_index: self.tick_lower_index, - tick_upper_index: self.tick_upper_index, - liquidity: self.liquidity.to_string(), - fee_growth_inside0_last_x64: self.fee_growth_inside0_last_x64.to_string(), - fee_growth_inside1_last_x64: self.fee_growth_inside1_last_x64.to_string(), - token_fees_owed0: self.token_fees_owed0, - token_fees_owed1: self.token_fees_owed1, - reward_growth_inside: self - .reward_growth_inside - .into_iter() - .map(|x| x.to_string()) - .collect(), - recent_epoch: self.recent_epoch, - padding: self.padding.to_vec(), - } - } - } - use super::TickArrayState; - impl IntoProto for TickArrayState { - fn into_proto(self) -> proto_def::TickArrayState { - proto_def::TickArrayState { - pool_id: self.pool_id.to_string(), - start_tick_index: self.start_tick_index, - ticks: self.ticks.into_iter().map(|x| x.into_proto()).collect(), - initialized_tick_count: self.initialized_tick_count.into(), - recent_epoch: self.recent_epoch, - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::TickArrayBitmapExtension; - impl IntoProto for TickArrayBitmapExtension { - fn into_proto(self) -> proto_def::TickArrayBitmapExtension { - proto_def::TickArrayBitmapExtension { - pool_id: self.pool_id.to_string(), - positive_tick_array_bitmap: self - .positive_tick_array_bitmap - .into_iter() - .map(|x| proto_def::RepeatedUint64Row { rows: x.to_vec() }) - .collect(), - negative_tick_array_bitmap: self - .negative_tick_array_bitmap - .into_iter() - .map(|x| proto_def::RepeatedUint64Row { rows: x.to_vec() }) - .collect(), - } - } - } - - impl IntoProto for AmmV3ProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - AmmV3ProgramState::AmmConfig(data) => { - proto_def::program_state::StateOneof::AmmConfig(data.into_proto()) - }, - AmmV3ProgramState::OperationState(data) => { - proto_def::program_state::StateOneof::OperationState(data.into_proto()) - }, - AmmV3ProgramState::ObservationState(data) => { - proto_def::program_state::StateOneof::ObservationState(data.into_proto()) - }, - AmmV3ProgramState::PersonalPositionState(data) => { - proto_def::program_state::StateOneof::PersonalPositionState(data.into_proto()) - }, - AmmV3ProgramState::PoolState(data) => { - proto_def::program_state::StateOneof::PoolState(data.into_proto()) - }, - AmmV3ProgramState::ProtocolPositionState(data) => { - proto_def::program_state::StateOneof::ProtocolPositionState(data.into_proto()) - }, - AmmV3ProgramState::TickArrayState(data) => { - proto_def::program_state::StateOneof::TickArrayState(data.into_proto()) - }, - AmmV3ProgramState::TickArrayBitmapExtension(data) => { - proto_def::program_state::StateOneof::TickArrayBitmapExtension( - data.into_proto(), - ) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/raydium-clmm-parser/src/generated_parser/instructions_parser.rs b/crates/raydium-clmm-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index eacfcda6..00000000 --- a/crates/raydium-clmm-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,1527 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - ClosePosition as ClosePositionIxAccounts, CollectFundFee as CollectFundFeeIxAccounts, - CollectFundFeeInstructionArgs as CollectFundFeeIxData, - CollectProtocolFee as CollectProtocolFeeIxAccounts, - CollectProtocolFeeInstructionArgs as CollectProtocolFeeIxData, - CollectRemainingRewards as CollectRemainingRewardsIxAccounts, - CollectRemainingRewardsInstructionArgs as CollectRemainingRewardsIxData, - CreateAmmConfig as CreateAmmConfigIxAccounts, - CreateAmmConfigInstructionArgs as CreateAmmConfigIxData, - CreateOperationAccount as CreateOperationAccountIxAccounts, - CreatePool as CreatePoolIxAccounts, CreatePoolInstructionArgs as CreatePoolIxData, - DecreaseLiquidity as DecreaseLiquidityIxAccounts, - DecreaseLiquidityInstructionArgs as DecreaseLiquidityIxData, - DecreaseLiquidityV2 as DecreaseLiquidityV2IxAccounts, - DecreaseLiquidityV2InstructionArgs as DecreaseLiquidityV2IxData, - IncreaseLiquidity as IncreaseLiquidityIxAccounts, - IncreaseLiquidityInstructionArgs as IncreaseLiquidityIxData, - IncreaseLiquidityV2 as IncreaseLiquidityV2IxAccounts, - IncreaseLiquidityV2InstructionArgs as IncreaseLiquidityV2IxData, - InitializeReward as InitializeRewardIxAccounts, - InitializeRewardInstructionArgs as InitializeRewardIxData, - OpenPosition as OpenPositionIxAccounts, OpenPositionInstructionArgs as OpenPositionIxData, - OpenPositionV2 as OpenPositionV2IxAccounts, - OpenPositionV2InstructionArgs as OpenPositionV2IxData, - OpenPositionWithToken22Nft as OpenPositionWithToken22NftIxAccounts, - OpenPositionWithToken22NftInstructionArgs as OpenPositionWithToken22NftIxData, - SetRewardParams as SetRewardParamsIxAccounts, - SetRewardParamsInstructionArgs as SetRewardParamsIxData, Swap as SwapIxAccounts, - SwapInstructionArgs as SwapIxData, SwapRouterBaseIn as SwapRouterBaseInIxAccounts, - SwapRouterBaseInInstructionArgs as SwapRouterBaseInIxData, SwapV2 as SwapV2IxAccounts, - SwapV2InstructionArgs as SwapV2IxData, - TransferRewardOwner as TransferRewardOwnerIxAccounts, - TransferRewardOwnerInstructionArgs as TransferRewardOwnerIxData, - UpdateAmmConfig as UpdateAmmConfigIxAccounts, - UpdateAmmConfigInstructionArgs as UpdateAmmConfigIxData, - UpdateOperationAccount as UpdateOperationAccountIxAccounts, - UpdateOperationAccountInstructionArgs as UpdateOperationAccountIxData, - UpdatePoolStatus as UpdatePoolStatusIxAccounts, - UpdatePoolStatusInstructionArgs as UpdatePoolStatusIxData, - UpdateRewardInfos as UpdateRewardInfosIxAccounts, - }, - ID, -}; - -/// AmmV3 Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum AmmV3ProgramIx { - CreateAmmConfig(CreateAmmConfigIxAccounts, CreateAmmConfigIxData), - UpdateAmmConfig(UpdateAmmConfigIxAccounts, UpdateAmmConfigIxData), - CreatePool(CreatePoolIxAccounts, CreatePoolIxData), - UpdatePoolStatus(UpdatePoolStatusIxAccounts, UpdatePoolStatusIxData), - CreateOperationAccount(CreateOperationAccountIxAccounts), - UpdateOperationAccount( - UpdateOperationAccountIxAccounts, - UpdateOperationAccountIxData, - ), - TransferRewardOwner(TransferRewardOwnerIxAccounts, TransferRewardOwnerIxData), - InitializeReward(InitializeRewardIxAccounts, InitializeRewardIxData), - CollectRemainingRewards( - CollectRemainingRewardsIxAccounts, - CollectRemainingRewardsIxData, - ), - UpdateRewardInfos(UpdateRewardInfosIxAccounts), - SetRewardParams(SetRewardParamsIxAccounts, SetRewardParamsIxData), - CollectProtocolFee(CollectProtocolFeeIxAccounts, CollectProtocolFeeIxData), - CollectFundFee(CollectFundFeeIxAccounts, CollectFundFeeIxData), - OpenPosition(OpenPositionIxAccounts, OpenPositionIxData), - OpenPositionV2(OpenPositionV2IxAccounts, OpenPositionV2IxData), - OpenPositionWithToken22Nft( - OpenPositionWithToken22NftIxAccounts, - OpenPositionWithToken22NftIxData, - ), - ClosePosition(ClosePositionIxAccounts), - IncreaseLiquidity(IncreaseLiquidityIxAccounts, IncreaseLiquidityIxData), - IncreaseLiquidityV2(IncreaseLiquidityV2IxAccounts, IncreaseLiquidityV2IxData), - DecreaseLiquidity(DecreaseLiquidityIxAccounts, DecreaseLiquidityIxData), - DecreaseLiquidityV2(DecreaseLiquidityV2IxAccounts, DecreaseLiquidityV2IxData), - Swap(SwapIxAccounts, SwapIxData), - SwapV2(SwapV2IxAccounts, SwapV2IxData), - SwapRouterBaseIn(SwapRouterBaseInIxAccounts, SwapRouterBaseInIxData), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = AmmV3ProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "AmmV3::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [137, 52, 237, 212, 215, 117, 108, 104] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateAmmConfigIxAccounts { - owner: next_account(accounts)?, - amm_config: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: CreateAmmConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::CreateAmmConfig(ix_accounts, de_ix_data)) - }, - [49, 60, 174, 136, 154, 28, 116, 200] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateAmmConfigIxAccounts { - owner: next_account(accounts)?, - amm_config: next_account(accounts)?, - }; - let de_ix_data: UpdateAmmConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::UpdateAmmConfig(ix_accounts, de_ix_data)) - }, - [233, 146, 209, 142, 207, 104, 64, 188] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreatePoolIxAccounts { - pool_creator: next_account(accounts)?, - amm_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - token_mint0: next_account(accounts)?, - token_mint1: next_account(accounts)?, - token_vault0: next_account(accounts)?, - token_vault1: next_account(accounts)?, - observation_state: next_account(accounts)?, - tick_array_bitmap: next_account(accounts)?, - token_program0: next_account(accounts)?, - token_program1: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: CreatePoolIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::CreatePool(ix_accounts, de_ix_data)) - }, - [130, 87, 108, 6, 46, 224, 117, 123] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdatePoolStatusIxAccounts { - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - }; - let de_ix_data: UpdatePoolStatusIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::UpdatePoolStatus(ix_accounts, de_ix_data)) - }, - [63, 87, 148, 33, 109, 35, 8, 104] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateOperationAccountIxAccounts { - owner: next_account(accounts)?, - operation_state: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(AmmV3ProgramIx::CreateOperationAccount(ix_accounts)) - }, - [127, 70, 119, 40, 188, 227, 61, 7] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateOperationAccountIxAccounts { - owner: next_account(accounts)?, - operation_state: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: UpdateOperationAccountIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::UpdateOperationAccount( - ix_accounts, - de_ix_data, - )) - }, - [7, 22, 12, 83, 242, 43, 48, 121] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = TransferRewardOwnerIxAccounts { - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - }; - let de_ix_data: TransferRewardOwnerIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::TransferRewardOwner(ix_accounts, de_ix_data)) - }, - [95, 135, 192, 196, 242, 129, 230, 68] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeRewardIxAccounts { - reward_funder: next_account(accounts)?, - funder_token_account: next_account(accounts)?, - amm_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - operation_state: next_account(accounts)?, - reward_token_mint: next_account(accounts)?, - reward_token_vault: next_account(accounts)?, - reward_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: InitializeRewardIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::InitializeReward(ix_accounts, de_ix_data)) - }, - [18, 237, 166, 197, 34, 16, 213, 144] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectRemainingRewardsIxAccounts { - reward_funder: next_account(accounts)?, - funder_token_account: next_account(accounts)?, - pool_state: next_account(accounts)?, - reward_token_vault: next_account(accounts)?, - reward_vault_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - memo_program: next_account(accounts)?, - }; - let de_ix_data: CollectRemainingRewardsIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::CollectRemainingRewards( - ix_accounts, - de_ix_data, - )) - }, - [163, 172, 224, 52, 11, 154, 106, 223] => { - let expected_accounts_len = 1; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateRewardInfosIxAccounts { - pool_state: next_account(accounts)?, - }; - Ok(AmmV3ProgramIx::UpdateRewardInfos(ix_accounts)) - }, - [112, 52, 167, 75, 32, 201, 211, 137] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SetRewardParamsIxAccounts { - authority: next_account(accounts)?, - amm_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - operation_state: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - }; - let de_ix_data: SetRewardParamsIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::SetRewardParams(ix_accounts, de_ix_data)) - }, - [136, 136, 252, 221, 194, 66, 126, 89] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectProtocolFeeIxAccounts { - owner: next_account(accounts)?, - pool_state: next_account(accounts)?, - amm_config: next_account(accounts)?, - token_vault0: next_account(accounts)?, - token_vault1: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - recipient_token_account0: next_account(accounts)?, - recipient_token_account1: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - }; - let de_ix_data: CollectProtocolFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::CollectProtocolFee(ix_accounts, de_ix_data)) - }, - [167, 138, 78, 149, 223, 194, 6, 126] => { - let expected_accounts_len = 11; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectFundFeeIxAccounts { - owner: next_account(accounts)?, - pool_state: next_account(accounts)?, - amm_config: next_account(accounts)?, - token_vault0: next_account(accounts)?, - token_vault1: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - recipient_token_account0: next_account(accounts)?, - recipient_token_account1: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - }; - let de_ix_data: CollectFundFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::CollectFundFee(ix_accounts, de_ix_data)) - }, - [135, 128, 47, 77, 15, 152, 240, 49] => { - let expected_accounts_len = 19; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = OpenPositionIxAccounts { - payer: next_account(accounts)?, - position_nft_owner: next_account(accounts)?, - position_nft_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - metadata_account: next_account(accounts)?, - pool_state: next_account(accounts)?, - protocol_position: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - personal_position: next_account(accounts)?, - token_account0: next_account(accounts)?, - token_account1: next_account(accounts)?, - token_vault0: next_account(accounts)?, - token_vault1: next_account(accounts)?, - rent: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - metadata_program: next_account(accounts)?, - }; - let de_ix_data: OpenPositionIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::OpenPosition(ix_accounts, de_ix_data)) - }, - [77, 184, 74, 214, 112, 86, 241, 199] => { - let expected_accounts_len = 22; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = OpenPositionV2IxAccounts { - payer: next_account(accounts)?, - position_nft_owner: next_account(accounts)?, - position_nft_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - metadata_account: next_account(accounts)?, - pool_state: next_account(accounts)?, - protocol_position: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - personal_position: next_account(accounts)?, - token_account0: next_account(accounts)?, - token_account1: next_account(accounts)?, - token_vault0: next_account(accounts)?, - token_vault1: next_account(accounts)?, - rent: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - metadata_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - }; - let de_ix_data: OpenPositionV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::OpenPositionV2(ix_accounts, de_ix_data)) - }, - [77, 255, 174, 82, 125, 29, 201, 46] => { - let expected_accounts_len = 20; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = OpenPositionWithToken22NftIxAccounts { - payer: next_account(accounts)?, - position_nft_owner: next_account(accounts)?, - position_nft_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - pool_state: next_account(accounts)?, - protocol_position: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - personal_position: next_account(accounts)?, - token_account0: next_account(accounts)?, - token_account1: next_account(accounts)?, - token_vault0: next_account(accounts)?, - token_vault1: next_account(accounts)?, - rent: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - }; - let de_ix_data: OpenPositionWithToken22NftIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::OpenPositionWithToken22Nft( - ix_accounts, - de_ix_data, - )) - }, - [123, 134, 81, 0, 49, 68, 98, 98] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClosePositionIxAccounts { - nft_owner: next_account(accounts)?, - position_nft_mint: next_account(accounts)?, - position_nft_account: next_account(accounts)?, - personal_position: next_account(accounts)?, - system_program: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(AmmV3ProgramIx::ClosePosition(ix_accounts)) - }, - [46, 156, 243, 118, 13, 205, 251, 178] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = IncreaseLiquidityIxAccounts { - nft_owner: next_account(accounts)?, - nft_account: next_account(accounts)?, - pool_state: next_account(accounts)?, - protocol_position: next_account(accounts)?, - personal_position: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - token_account0: next_account(accounts)?, - token_account1: next_account(accounts)?, - token_vault0: next_account(accounts)?, - token_vault1: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: IncreaseLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::IncreaseLiquidity(ix_accounts, de_ix_data)) - }, - [133, 29, 89, 223, 69, 238, 176, 10] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = IncreaseLiquidityV2IxAccounts { - nft_owner: next_account(accounts)?, - nft_account: next_account(accounts)?, - pool_state: next_account(accounts)?, - protocol_position: next_account(accounts)?, - personal_position: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - token_account0: next_account(accounts)?, - token_account1: next_account(accounts)?, - token_vault0: next_account(accounts)?, - token_vault1: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - }; - let de_ix_data: IncreaseLiquidityV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::IncreaseLiquidityV2(ix_accounts, de_ix_data)) - }, - [160, 38, 208, 111, 104, 91, 44, 1] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DecreaseLiquidityIxAccounts { - nft_owner: next_account(accounts)?, - nft_account: next_account(accounts)?, - personal_position: next_account(accounts)?, - pool_state: next_account(accounts)?, - protocol_position: next_account(accounts)?, - token_vault0: next_account(accounts)?, - token_vault1: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - recipient_token_account0: next_account(accounts)?, - recipient_token_account1: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: DecreaseLiquidityIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::DecreaseLiquidity(ix_accounts, de_ix_data)) - }, - [58, 127, 188, 62, 79, 82, 196, 96] => { - let expected_accounts_len = 16; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DecreaseLiquidityV2IxAccounts { - nft_owner: next_account(accounts)?, - nft_account: next_account(accounts)?, - personal_position: next_account(accounts)?, - pool_state: next_account(accounts)?, - protocol_position: next_account(accounts)?, - token_vault0: next_account(accounts)?, - token_vault1: next_account(accounts)?, - tick_array_lower: next_account(accounts)?, - tick_array_upper: next_account(accounts)?, - recipient_token_account0: next_account(accounts)?, - recipient_token_account1: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - memo_program: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - }; - let de_ix_data: DecreaseLiquidityV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::DecreaseLiquidityV2(ix_accounts, de_ix_data)) - }, - [248, 198, 158, 145, 225, 117, 135, 200] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapIxAccounts { - payer: next_account(accounts)?, - amm_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - input_token_account: next_account(accounts)?, - output_token_account: next_account(accounts)?, - input_vault: next_account(accounts)?, - output_vault: next_account(accounts)?, - observation_state: next_account(accounts)?, - token_program: next_account(accounts)?, - tick_array: next_account(accounts)?, - }; - let de_ix_data: SwapIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::Swap(ix_accounts, de_ix_data)) - }, - [43, 4, 237, 11, 26, 201, 30, 98] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapV2IxAccounts { - payer: next_account(accounts)?, - amm_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - input_token_account: next_account(accounts)?, - output_token_account: next_account(accounts)?, - input_vault: next_account(accounts)?, - output_vault: next_account(accounts)?, - observation_state: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - memo_program: next_account(accounts)?, - input_vault_mint: next_account(accounts)?, - output_vault_mint: next_account(accounts)?, - }; - let de_ix_data: SwapV2IxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::SwapV2(ix_accounts, de_ix_data)) - }, - [69, 125, 115, 218, 245, 186, 242, 196] => { - let expected_accounts_len = 6; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapRouterBaseInIxAccounts { - payer: next_account(accounts)?, - input_token_account: next_account(accounts)?, - input_token_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - memo_program: next_account(accounts)?, - }; - let de_ix_data: SwapRouterBaseInIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(AmmV3ProgramIx::SwapRouterBaseIn(ix_accounts, de_ix_data)) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AmmV3ProgramIx, CreateAmmConfigIxAccounts, InstructionParser}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for CreateAmmConfigIxAccounts { - fn into_proto(self) -> proto_def::CreateAmmConfigIxAccounts { - proto_def::CreateAmmConfigIxAccounts { - owner: self.owner.to_string(), - amm_config: self.amm_config.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreateAmmConfigIxData; - impl IntoProto for CreateAmmConfigIxData { - fn into_proto(self) -> proto_def::CreateAmmConfigIxData { - proto_def::CreateAmmConfigIxData { - index: self.index.into(), - tick_spacing: self.tick_spacing.into(), - trade_fee_rate: self.trade_fee_rate, - protocol_fee_rate: self.protocol_fee_rate, - fund_fee_rate: self.fund_fee_rate, - } - } - } - use super::UpdateAmmConfigIxAccounts; - impl IntoProto for UpdateAmmConfigIxAccounts { - fn into_proto(self) -> proto_def::UpdateAmmConfigIxAccounts { - proto_def::UpdateAmmConfigIxAccounts { - owner: self.owner.to_string(), - amm_config: self.amm_config.to_string(), - } - } - } - use super::UpdateAmmConfigIxData; - impl IntoProto for UpdateAmmConfigIxData { - fn into_proto(self) -> proto_def::UpdateAmmConfigIxData { - proto_def::UpdateAmmConfigIxData { - param: self.param.into(), - value: self.value, - } - } - } - use super::CreatePoolIxAccounts; - impl IntoProto for CreatePoolIxAccounts { - fn into_proto(self) -> proto_def::CreatePoolIxAccounts { - proto_def::CreatePoolIxAccounts { - pool_creator: self.pool_creator.to_string(), - amm_config: self.amm_config.to_string(), - pool_state: self.pool_state.to_string(), - token_mint0: self.token_mint0.to_string(), - token_mint1: self.token_mint1.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - observation_state: self.observation_state.to_string(), - tick_array_bitmap: self.tick_array_bitmap.to_string(), - token_program0: self.token_program0.to_string(), - token_program1: self.token_program1.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::CreatePoolIxData; - impl IntoProto for CreatePoolIxData { - fn into_proto(self) -> proto_def::CreatePoolIxData { - proto_def::CreatePoolIxData { - sqrt_price_x64: self.sqrt_price_x64.to_string(), - open_time: self.open_time, - } - } - } - use super::UpdatePoolStatusIxAccounts; - impl IntoProto for UpdatePoolStatusIxAccounts { - fn into_proto(self) -> proto_def::UpdatePoolStatusIxAccounts { - proto_def::UpdatePoolStatusIxAccounts { - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - } - } - } - use super::UpdatePoolStatusIxData; - impl IntoProto for UpdatePoolStatusIxData { - fn into_proto(self) -> proto_def::UpdatePoolStatusIxData { - proto_def::UpdatePoolStatusIxData { - status: self.status.into(), - } - } - } - use super::CreateOperationAccountIxAccounts; - impl IntoProto for CreateOperationAccountIxAccounts { - fn into_proto(self) -> proto_def::CreateOperationAccountIxAccounts { - proto_def::CreateOperationAccountIxAccounts { - owner: self.owner.to_string(), - operation_state: self.operation_state.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::UpdateOperationAccountIxAccounts; - impl IntoProto for UpdateOperationAccountIxAccounts { - fn into_proto(self) -> proto_def::UpdateOperationAccountIxAccounts { - proto_def::UpdateOperationAccountIxAccounts { - owner: self.owner.to_string(), - operation_state: self.operation_state.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::UpdateOperationAccountIxData; - impl IntoProto for UpdateOperationAccountIxData { - fn into_proto(self) -> proto_def::UpdateOperationAccountIxData { - proto_def::UpdateOperationAccountIxData { - param: self.param.into(), - keys: self.keys.into_iter().map(|x| x.to_string()).collect(), - } - } - } - use super::TransferRewardOwnerIxAccounts; - impl IntoProto for TransferRewardOwnerIxAccounts { - fn into_proto(self) -> proto_def::TransferRewardOwnerIxAccounts { - proto_def::TransferRewardOwnerIxAccounts { - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - } - } - } - use super::TransferRewardOwnerIxData; - impl IntoProto for TransferRewardOwnerIxData { - fn into_proto(self) -> proto_def::TransferRewardOwnerIxData { - proto_def::TransferRewardOwnerIxData { - new_owner: self.new_owner.to_string(), - } - } - } - use super::InitializeRewardIxAccounts; - impl IntoProto for InitializeRewardIxAccounts { - fn into_proto(self) -> proto_def::InitializeRewardIxAccounts { - proto_def::InitializeRewardIxAccounts { - reward_funder: self.reward_funder.to_string(), - funder_token_account: self.funder_token_account.to_string(), - amm_config: self.amm_config.to_string(), - pool_state: self.pool_state.to_string(), - operation_state: self.operation_state.to_string(), - reward_token_mint: self.reward_token_mint.to_string(), - reward_token_vault: self.reward_token_vault.to_string(), - reward_token_program: self.reward_token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::InitializeRewardIxData; - impl IntoProto for InitializeRewardIxData { - fn into_proto(self) -> proto_def::InitializeRewardIxData { - proto_def::InitializeRewardIxData { - open_time: self.open_time, - end_time: self.end_time, - emissions_per_second_x64: self.emissions_per_second_x64.to_string(), - } - } - } - use super::CollectRemainingRewardsIxAccounts; - impl IntoProto for CollectRemainingRewardsIxAccounts { - fn into_proto(self) -> proto_def::CollectRemainingRewardsIxAccounts { - proto_def::CollectRemainingRewardsIxAccounts { - reward_funder: self.reward_funder.to_string(), - funder_token_account: self.funder_token_account.to_string(), - pool_state: self.pool_state.to_string(), - reward_token_vault: self.reward_token_vault.to_string(), - reward_vault_mint: self.reward_vault_mint.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - memo_program: self.memo_program.to_string(), - } - } - } - use super::CollectRemainingRewardsIxData; - impl IntoProto for CollectRemainingRewardsIxData { - fn into_proto(self) -> proto_def::CollectRemainingRewardsIxData { - proto_def::CollectRemainingRewardsIxData { - reward_index: self.reward_index.into(), - } - } - } - use super::UpdateRewardInfosIxAccounts; - impl IntoProto for UpdateRewardInfosIxAccounts { - fn into_proto(self) -> proto_def::UpdateRewardInfosIxAccounts { - proto_def::UpdateRewardInfosIxAccounts { - pool_state: self.pool_state.to_string(), - } - } - } - use super::SetRewardParamsIxAccounts; - impl IntoProto for SetRewardParamsIxAccounts { - fn into_proto(self) -> proto_def::SetRewardParamsIxAccounts { - proto_def::SetRewardParamsIxAccounts { - authority: self.authority.to_string(), - amm_config: self.amm_config.to_string(), - pool_state: self.pool_state.to_string(), - operation_state: self.operation_state.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - } - } - } - use super::SetRewardParamsIxData; - impl IntoProto for SetRewardParamsIxData { - fn into_proto(self) -> proto_def::SetRewardParamsIxData { - proto_def::SetRewardParamsIxData { - reward_index: self.reward_index.into(), - emissions_per_second_x64: self.emissions_per_second_x64.to_string(), - open_time: self.open_time, - end_time: self.end_time, - } - } - } - use super::CollectProtocolFeeIxAccounts; - impl IntoProto for CollectProtocolFeeIxAccounts { - fn into_proto(self) -> proto_def::CollectProtocolFeeIxAccounts { - proto_def::CollectProtocolFeeIxAccounts { - owner: self.owner.to_string(), - pool_state: self.pool_state.to_string(), - amm_config: self.amm_config.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - recipient_token_account0: self.recipient_token_account0.to_string(), - recipient_token_account1: self.recipient_token_account1.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - } - } - } - use super::CollectProtocolFeeIxData; - impl IntoProto for CollectProtocolFeeIxData { - fn into_proto(self) -> proto_def::CollectProtocolFeeIxData { - proto_def::CollectProtocolFeeIxData { - amount0_requested: self.amount0_requested, - amount1_requested: self.amount1_requested, - } - } - } - use super::CollectFundFeeIxAccounts; - impl IntoProto for CollectFundFeeIxAccounts { - fn into_proto(self) -> proto_def::CollectFundFeeIxAccounts { - proto_def::CollectFundFeeIxAccounts { - owner: self.owner.to_string(), - pool_state: self.pool_state.to_string(), - amm_config: self.amm_config.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - recipient_token_account0: self.recipient_token_account0.to_string(), - recipient_token_account1: self.recipient_token_account1.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - } - } - } - use super::CollectFundFeeIxData; - impl IntoProto for CollectFundFeeIxData { - fn into_proto(self) -> proto_def::CollectFundFeeIxData { - proto_def::CollectFundFeeIxData { - amount0_requested: self.amount0_requested, - amount1_requested: self.amount1_requested, - } - } - } - use super::OpenPositionIxAccounts; - impl IntoProto for OpenPositionIxAccounts { - fn into_proto(self) -> proto_def::OpenPositionIxAccounts { - proto_def::OpenPositionIxAccounts { - payer: self.payer.to_string(), - position_nft_owner: self.position_nft_owner.to_string(), - position_nft_mint: self.position_nft_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - metadata_account: self.metadata_account.to_string(), - pool_state: self.pool_state.to_string(), - protocol_position: self.protocol_position.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - personal_position: self.personal_position.to_string(), - token_account0: self.token_account0.to_string(), - token_account1: self.token_account1.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - rent: self.rent.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - metadata_program: self.metadata_program.to_string(), - } - } - } - use super::OpenPositionIxData; - impl IntoProto for OpenPositionIxData { - fn into_proto(self) -> proto_def::OpenPositionIxData { - proto_def::OpenPositionIxData { - tick_lower_index: self.tick_lower_index, - tick_upper_index: self.tick_upper_index, - tick_array_lower_start_index: self.tick_array_lower_start_index, - tick_array_upper_start_index: self.tick_array_upper_start_index, - liquidity: self.liquidity.to_string(), - amount0_max: self.amount0_max, - amount1_max: self.amount1_max, - } - } - } - use super::OpenPositionV2IxAccounts; - impl IntoProto for OpenPositionV2IxAccounts { - fn into_proto(self) -> proto_def::OpenPositionV2IxAccounts { - proto_def::OpenPositionV2IxAccounts { - payer: self.payer.to_string(), - position_nft_owner: self.position_nft_owner.to_string(), - position_nft_mint: self.position_nft_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - metadata_account: self.metadata_account.to_string(), - pool_state: self.pool_state.to_string(), - protocol_position: self.protocol_position.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - personal_position: self.personal_position.to_string(), - token_account0: self.token_account0.to_string(), - token_account1: self.token_account1.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - rent: self.rent.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - metadata_program: self.metadata_program.to_string(), - token_program2022: self.token_program2022.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - } - } - } - use super::OpenPositionV2IxData; - impl IntoProto for OpenPositionV2IxData { - fn into_proto(self) -> proto_def::OpenPositionV2IxData { - proto_def::OpenPositionV2IxData { - tick_lower_index: self.tick_lower_index, - tick_upper_index: self.tick_upper_index, - tick_array_lower_start_index: self.tick_array_lower_start_index, - tick_array_upper_start_index: self.tick_array_upper_start_index, - liquidity: self.liquidity.to_string(), - amount0_max: self.amount0_max, - amount1_max: self.amount1_max, - with_metadata: self.with_metadata, - base_flag: self.base_flag, - } - } - } - use super::OpenPositionWithToken22NftIxAccounts; - impl IntoProto - for OpenPositionWithToken22NftIxAccounts - { - fn into_proto(self) -> proto_def::OpenPositionWithToken22NftIxAccounts { - proto_def::OpenPositionWithToken22NftIxAccounts { - payer: self.payer.to_string(), - position_nft_owner: self.position_nft_owner.to_string(), - position_nft_mint: self.position_nft_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - pool_state: self.pool_state.to_string(), - protocol_position: self.protocol_position.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - personal_position: self.personal_position.to_string(), - token_account0: self.token_account0.to_string(), - token_account1: self.token_account1.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - rent: self.rent.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - } - } - } - use super::OpenPositionWithToken22NftIxData; - impl IntoProto for OpenPositionWithToken22NftIxData { - fn into_proto(self) -> proto_def::OpenPositionWithToken22NftIxData { - proto_def::OpenPositionWithToken22NftIxData { - tick_lower_index: self.tick_lower_index, - tick_upper_index: self.tick_upper_index, - tick_array_lower_start_index: self.tick_array_lower_start_index, - tick_array_upper_start_index: self.tick_array_upper_start_index, - liquidity: self.liquidity.to_string(), - amount0_max: self.amount0_max, - amount1_max: self.amount1_max, - with_metadata: self.with_metadata, - base_flag: self.base_flag, - } - } - } - use super::ClosePositionIxAccounts; - impl IntoProto for ClosePositionIxAccounts { - fn into_proto(self) -> proto_def::ClosePositionIxAccounts { - proto_def::ClosePositionIxAccounts { - nft_owner: self.nft_owner.to_string(), - position_nft_mint: self.position_nft_mint.to_string(), - position_nft_account: self.position_nft_account.to_string(), - personal_position: self.personal_position.to_string(), - system_program: self.system_program.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::IncreaseLiquidityIxAccounts; - impl IntoProto for IncreaseLiquidityIxAccounts { - fn into_proto(self) -> proto_def::IncreaseLiquidityIxAccounts { - proto_def::IncreaseLiquidityIxAccounts { - nft_owner: self.nft_owner.to_string(), - nft_account: self.nft_account.to_string(), - pool_state: self.pool_state.to_string(), - protocol_position: self.protocol_position.to_string(), - personal_position: self.personal_position.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - token_account0: self.token_account0.to_string(), - token_account1: self.token_account1.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::IncreaseLiquidityIxData; - impl IntoProto for IncreaseLiquidityIxData { - fn into_proto(self) -> proto_def::IncreaseLiquidityIxData { - proto_def::IncreaseLiquidityIxData { - liquidity: self.liquidity.to_string(), - amount0_max: self.amount0_max, - amount1_max: self.amount1_max, - } - } - } - use super::IncreaseLiquidityV2IxAccounts; - impl IntoProto for IncreaseLiquidityV2IxAccounts { - fn into_proto(self) -> proto_def::IncreaseLiquidityV2IxAccounts { - proto_def::IncreaseLiquidityV2IxAccounts { - nft_owner: self.nft_owner.to_string(), - nft_account: self.nft_account.to_string(), - pool_state: self.pool_state.to_string(), - protocol_position: self.protocol_position.to_string(), - personal_position: self.personal_position.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - token_account0: self.token_account0.to_string(), - token_account1: self.token_account1.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - } - } - } - use super::IncreaseLiquidityV2IxData; - impl IntoProto for IncreaseLiquidityV2IxData { - fn into_proto(self) -> proto_def::IncreaseLiquidityV2IxData { - proto_def::IncreaseLiquidityV2IxData { - liquidity: self.liquidity.to_string(), - amount0_max: self.amount0_max, - amount1_max: self.amount1_max, - base_flag: self.base_flag, - } - } - } - use super::DecreaseLiquidityIxAccounts; - impl IntoProto for DecreaseLiquidityIxAccounts { - fn into_proto(self) -> proto_def::DecreaseLiquidityIxAccounts { - proto_def::DecreaseLiquidityIxAccounts { - nft_owner: self.nft_owner.to_string(), - nft_account: self.nft_account.to_string(), - personal_position: self.personal_position.to_string(), - pool_state: self.pool_state.to_string(), - protocol_position: self.protocol_position.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - recipient_token_account0: self.recipient_token_account0.to_string(), - recipient_token_account1: self.recipient_token_account1.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::DecreaseLiquidityIxData; - impl IntoProto for DecreaseLiquidityIxData { - fn into_proto(self) -> proto_def::DecreaseLiquidityIxData { - proto_def::DecreaseLiquidityIxData { - liquidity: self.liquidity.to_string(), - amount0_min: self.amount0_min, - amount1_min: self.amount1_min, - } - } - } - use super::DecreaseLiquidityV2IxAccounts; - impl IntoProto for DecreaseLiquidityV2IxAccounts { - fn into_proto(self) -> proto_def::DecreaseLiquidityV2IxAccounts { - proto_def::DecreaseLiquidityV2IxAccounts { - nft_owner: self.nft_owner.to_string(), - nft_account: self.nft_account.to_string(), - personal_position: self.personal_position.to_string(), - pool_state: self.pool_state.to_string(), - protocol_position: self.protocol_position.to_string(), - token_vault0: self.token_vault0.to_string(), - token_vault1: self.token_vault1.to_string(), - tick_array_lower: self.tick_array_lower.to_string(), - tick_array_upper: self.tick_array_upper.to_string(), - recipient_token_account0: self.recipient_token_account0.to_string(), - recipient_token_account1: self.recipient_token_account1.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - memo_program: self.memo_program.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - } - } - } - use super::DecreaseLiquidityV2IxData; - impl IntoProto for DecreaseLiquidityV2IxData { - fn into_proto(self) -> proto_def::DecreaseLiquidityV2IxData { - proto_def::DecreaseLiquidityV2IxData { - liquidity: self.liquidity.to_string(), - amount0_min: self.amount0_min, - amount1_min: self.amount1_min, - } - } - } - use super::SwapIxAccounts; - impl IntoProto for SwapIxAccounts { - fn into_proto(self) -> proto_def::SwapIxAccounts { - proto_def::SwapIxAccounts { - payer: self.payer.to_string(), - amm_config: self.amm_config.to_string(), - pool_state: self.pool_state.to_string(), - input_token_account: self.input_token_account.to_string(), - output_token_account: self.output_token_account.to_string(), - input_vault: self.input_vault.to_string(), - output_vault: self.output_vault.to_string(), - observation_state: self.observation_state.to_string(), - token_program: self.token_program.to_string(), - tick_array: self.tick_array.to_string(), - } - } - } - use super::SwapIxData; - impl IntoProto for SwapIxData { - fn into_proto(self) -> proto_def::SwapIxData { - proto_def::SwapIxData { - amount: self.amount, - other_amount_threshold: self.other_amount_threshold, - sqrt_price_limit_x64: self.sqrt_price_limit_x64.to_string(), - is_base_input: self.is_base_input, - } - } - } - use super::SwapV2IxAccounts; - impl IntoProto for SwapV2IxAccounts { - fn into_proto(self) -> proto_def::SwapV2IxAccounts { - proto_def::SwapV2IxAccounts { - payer: self.payer.to_string(), - amm_config: self.amm_config.to_string(), - pool_state: self.pool_state.to_string(), - input_token_account: self.input_token_account.to_string(), - output_token_account: self.output_token_account.to_string(), - input_vault: self.input_vault.to_string(), - output_vault: self.output_vault.to_string(), - observation_state: self.observation_state.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - memo_program: self.memo_program.to_string(), - input_vault_mint: self.input_vault_mint.to_string(), - output_vault_mint: self.output_vault_mint.to_string(), - } - } - } - use super::SwapV2IxData; - impl IntoProto for SwapV2IxData { - fn into_proto(self) -> proto_def::SwapV2IxData { - proto_def::SwapV2IxData { - amount: self.amount, - other_amount_threshold: self.other_amount_threshold, - sqrt_price_limit_x64: self.sqrt_price_limit_x64.to_string(), - is_base_input: self.is_base_input, - } - } - } - use super::SwapRouterBaseInIxAccounts; - impl IntoProto for SwapRouterBaseInIxAccounts { - fn into_proto(self) -> proto_def::SwapRouterBaseInIxAccounts { - proto_def::SwapRouterBaseInIxAccounts { - payer: self.payer.to_string(), - input_token_account: self.input_token_account.to_string(), - input_token_mint: self.input_token_mint.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - memo_program: self.memo_program.to_string(), - } - } - } - use super::SwapRouterBaseInIxData; - impl IntoProto for SwapRouterBaseInIxData { - fn into_proto(self) -> proto_def::SwapRouterBaseInIxData { - proto_def::SwapRouterBaseInIxData { - amount_in: self.amount_in, - amount_out_minimum: self.amount_out_minimum, - } - } - } - - impl IntoProto for AmmV3ProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - AmmV3ProgramIx::CreateAmmConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateAmmConfig( - proto_def::CreateAmmConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::UpdateAmmConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateAmmConfig( - proto_def::UpdateAmmConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::CreatePool(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreatePool( - proto_def::CreatePoolIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::UpdatePoolStatus(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdatePoolStatus( - proto_def::UpdatePoolStatusIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::CreateOperationAccount(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateOperationAccount( - proto_def::CreateOperationAccountIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - AmmV3ProgramIx::UpdateOperationAccount(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateOperationAccount( - proto_def::UpdateOperationAccountIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::TransferRewardOwner(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::TransferRewardOwner( - proto_def::TransferRewardOwnerIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::InitializeReward(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeReward( - proto_def::InitializeRewardIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::CollectRemainingRewards(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectRemainingRewards( - proto_def::CollectRemainingRewardsIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::UpdateRewardInfos(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateRewardInfos( - proto_def::UpdateRewardInfosIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - AmmV3ProgramIx::SetRewardParams(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SetRewardParams( - proto_def::SetRewardParamsIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::CollectProtocolFee(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectProtocolFee( - proto_def::CollectProtocolFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::CollectFundFee(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectFundFee( - proto_def::CollectFundFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::OpenPosition(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::OpenPosition( - proto_def::OpenPositionIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::OpenPositionV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::OpenPositionV2( - proto_def::OpenPositionV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::OpenPositionWithToken22Nft(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::OpenPositionWithToken22Nft( - proto_def::OpenPositionWithToken22NftIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::ClosePosition(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClosePosition( - proto_def::ClosePositionIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - AmmV3ProgramIx::IncreaseLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::IncreaseLiquidity( - proto_def::IncreaseLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::IncreaseLiquidityV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::IncreaseLiquidityV2( - proto_def::IncreaseLiquidityV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::DecreaseLiquidity(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::DecreaseLiquidity( - proto_def::DecreaseLiquidityIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::DecreaseLiquidityV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::DecreaseLiquidityV2( - proto_def::DecreaseLiquidityV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::Swap(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Swap(proto_def::SwapIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - AmmV3ProgramIx::SwapV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapV2( - proto_def::SwapV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - AmmV3ProgramIx::SwapRouterBaseIn(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapRouterBaseIn( - proto_def::SwapRouterBaseInIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/raydium-clmm-parser/src/generated_parser/mod.rs b/crates/raydium-clmm-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/raydium-clmm-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/raydium-clmm-parser/src/generated_parser/proto_helpers.rs b/crates/raydium-clmm-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index 8fd66a5e..00000000 --- a/crates/raydium-clmm-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,67 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::Observation}; - impl IntoProto for Observation { - fn into_proto(self) -> proto_def::Observation { - proto_def::Observation { - block_timestamp: self.block_timestamp, - tick_cumulative: self.tick_cumulative, - padding: self.padding.to_vec(), - } - } - } - use crate::types::PositionRewardInfo; - impl IntoProto for PositionRewardInfo { - fn into_proto(self) -> proto_def::PositionRewardInfo { - proto_def::PositionRewardInfo { - growth_inside_last_x64: self.growth_inside_last_x64.to_string(), - reward_amount_owed: self.reward_amount_owed, - } - } - } - use crate::types::RewardInfo; - impl IntoProto for RewardInfo { - fn into_proto(self) -> proto_def::RewardInfo { - proto_def::RewardInfo { - reward_state: self.reward_state.into(), - open_time: self.open_time, - end_time: self.end_time, - last_update_time: self.last_update_time, - emissions_per_second_x64: self.emissions_per_second_x64.to_string(), - reward_total_emissioned: self.reward_total_emissioned, - reward_claimed: self.reward_claimed, - token_mint: self.token_mint.to_string(), - token_vault: self.token_vault.to_string(), - authority: self.authority.to_string(), - reward_growth_global_x64: self.reward_growth_global_x64.to_string(), - } - } - } - use crate::types::TickState; - impl IntoProto for TickState { - fn into_proto(self) -> proto_def::TickState { - proto_def::TickState { - tick: self.tick, - liquidity_net: self.liquidity_net.to_string(), - liquidity_gross: self.liquidity_gross.to_string(), - fee_growth_outside0_x64: self.fee_growth_outside0_x64.to_string(), - fee_growth_outside1_x64: self.fee_growth_outside1_x64.to_string(), - reward_growths_outside_x64: self - .reward_growths_outside_x64 - .into_iter() - .map(|x| x.to_string()) - .collect(), - padding: self.padding.to_vec(), - } - } - } -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/accounts/amm_config.rs b/crates/raydium-clmm-parser/src/generated_sdk/accounts/amm_config.rs deleted file mode 100644 index 59a07f5f..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/accounts/amm_config.rs +++ /dev/null @@ -1,145 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AmmConfig { - pub discriminator: [u8; 8], - pub bump: u8, - pub index: u16, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - pub protocol_fee_rate: u32, - pub trade_fee_rate: u32, - pub tick_spacing: u16, - pub fund_fee_rate: u32, - pub padding_u32: u32, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fund_owner: Pubkey, - pub padding: [u64; 3], -} - -impl AmmConfig { - pub const LEN: usize = 117; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for AmmConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_amm_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = AmmConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_amm_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = AmmConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for AmmConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for AmmConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for AmmConfig { - fn owner() -> Pubkey { crate::AMM_V3_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for AmmConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for AmmConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/accounts/mod.rs b/crates/raydium-clmm-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index 7ab02b12..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#amm_config; -pub(crate) mod r#observation_state; -pub(crate) mod r#operation_state; -pub(crate) mod r#personal_position_state; -pub(crate) mod r#pool_state; -pub(crate) mod r#protocol_position_state; -pub(crate) mod r#tick_array_bitmap_extension; -pub(crate) mod r#tick_array_state; - -pub use self::{ - r#amm_config::*, r#observation_state::*, r#operation_state::*, r#personal_position_state::*, - r#pool_state::*, r#protocol_position_state::*, r#tick_array_bitmap_extension::*, - r#tick_array_state::*, -}; diff --git a/crates/raydium-clmm-parser/src/generated_sdk/accounts/observation_state.rs b/crates/raydium-clmm-parser/src/generated_sdk/accounts/observation_state.rs deleted file mode 100644 index abde4b07..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/accounts/observation_state.rs +++ /dev/null @@ -1,140 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::Observation; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ObservationState { - pub discriminator: [u8; 8], - pub initialized: bool, - pub recent_epoch: u64, - pub observation_index: u16, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_id: Pubkey, - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub observations: [Observation; 100], - pub padding: [u64; 4], -} - -impl ObservationState { - pub const LEN: usize = 4483; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for ObservationState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_observation_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_observation_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_observation_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = ObservationState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_observation_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_observation_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_observation_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = ObservationState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for ObservationState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for ObservationState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for ObservationState { - fn owner() -> Pubkey { crate::AMM_V3_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for ObservationState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for ObservationState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/accounts/operation_state.rs b/crates/raydium-clmm-parser/src/generated_sdk/accounts/operation_state.rs deleted file mode 100644 index a57fc45c..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/accounts/operation_state.rs +++ /dev/null @@ -1,131 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OperationState { - pub discriminator: [u8; 8], - pub bump: u8, - pub operation_owners: [Pubkey; 10], - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub whitelist_mints: [Pubkey; 100], -} - -impl OperationState { - pub const LEN: usize = 3529; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for OperationState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_operation_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_operation_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_operation_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = OperationState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_operation_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_operation_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_operation_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = OperationState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for OperationState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for OperationState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for OperationState { - fn owner() -> Pubkey { crate::AMM_V3_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for OperationState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for OperationState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/accounts/personal_position_state.rs b/crates/raydium-clmm-parser/src/generated_sdk/accounts/personal_position_state.rs deleted file mode 100644 index 73719e72..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/accounts/personal_position_state.rs +++ /dev/null @@ -1,151 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::PositionRewardInfo; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PersonalPositionState { - pub discriminator: [u8; 8], - pub bump: [u8; 1], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub nft_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_id: Pubkey, - pub tick_lower_index: i32, - pub tick_upper_index: i32, - pub liquidity: u128, - pub fee_growth_inside0_last_x64: u128, - pub fee_growth_inside1_last_x64: u128, - pub token_fees_owed0: u64, - pub token_fees_owed1: u64, - pub reward_infos: [PositionRewardInfo; 3], - pub recent_epoch: u64, - pub padding: [u64; 7], -} - -impl PersonalPositionState { - pub const LEN: usize = 281; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PersonalPositionState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_personal_position_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_personal_position_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_personal_position_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PersonalPositionState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_personal_position_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_personal_position_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_personal_position_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PersonalPositionState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PersonalPositionState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PersonalPositionState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PersonalPositionState { - fn owner() -> Pubkey { crate::AMM_V3_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PersonalPositionState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PersonalPositionState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/accounts/pool_state.rs b/crates/raydium-clmm-parser/src/generated_sdk/accounts/pool_state.rs deleted file mode 100644 index 122e7235..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/accounts/pool_state.rs +++ /dev/null @@ -1,195 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::RewardInfo; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolState { - pub discriminator: [u8; 8], - pub bump: [u8; 1], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub amm_config: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub owner: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_mint0: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_mint1: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_vault0: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_vault1: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub observation_key: Pubkey, - pub mint_decimals0: u8, - pub mint_decimals1: u8, - pub tick_spacing: u16, - pub liquidity: u128, - pub sqrt_price_x64: u128, - pub tick_current: i32, - pub padding3: u16, - pub padding4: u16, - pub fee_growth_global0_x64: u128, - pub fee_growth_global1_x64: u128, - pub protocol_fees_token0: u64, - pub protocol_fees_token1: u64, - pub swap_in_amount_token0: u128, - pub swap_out_amount_token1: u128, - pub swap_in_amount_token1: u128, - pub swap_out_amount_token0: u128, - pub status: u8, - pub padding: [u8; 7], - pub reward_infos: [RewardInfo; 3], - pub tick_array_bitmap: [u64; 16], - pub total_fees_token0: u64, - pub total_fees_claimed_token0: u64, - pub total_fees_token1: u64, - pub total_fees_claimed_token1: u64, - pub fund_fees_token0: u64, - pub fund_fees_token1: u64, - pub open_time: u64, - pub recent_epoch: u64, - pub padding1: [u64; 24], - pub padding2: [u64; 32], -} - -impl PoolState { - pub const LEN: usize = 1544; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PoolState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_pool_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PoolState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_pool_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PoolState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PoolState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PoolState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PoolState { - fn owner() -> Pubkey { crate::AMM_V3_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PoolState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PoolState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/accounts/protocol_position_state.rs b/crates/raydium-clmm-parser/src/generated_sdk/accounts/protocol_position_state.rs deleted file mode 100644 index 8ed8f06c..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/accounts/protocol_position_state.rs +++ /dev/null @@ -1,144 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ProtocolPositionState { - pub discriminator: [u8; 8], - pub bump: u8, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_id: Pubkey, - pub tick_lower_index: i32, - pub tick_upper_index: i32, - pub liquidity: u128, - pub fee_growth_inside0_last_x64: u128, - pub fee_growth_inside1_last_x64: u128, - pub token_fees_owed0: u64, - pub token_fees_owed1: u64, - pub reward_growth_inside: [u128; 3], - pub recent_epoch: u64, - pub padding: [u64; 7], -} - -impl ProtocolPositionState { - pub const LEN: usize = 225; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for ProtocolPositionState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_protocol_position_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_protocol_position_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_protocol_position_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = ProtocolPositionState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_protocol_position_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_protocol_position_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_protocol_position_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = ProtocolPositionState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for ProtocolPositionState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for ProtocolPositionState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for ProtocolPositionState { - fn owner() -> Pubkey { crate::AMM_V3_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for ProtocolPositionState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for ProtocolPositionState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/accounts/tick_array_bitmap_extension.rs b/crates/raydium-clmm-parser/src/generated_sdk/accounts/tick_array_bitmap_extension.rs deleted file mode 100644 index 2d7d1f07..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/accounts/tick_array_bitmap_extension.rs +++ /dev/null @@ -1,136 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TickArrayBitmapExtension { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_id: Pubkey, - pub positive_tick_array_bitmap: [[u64; 8]; 14], - pub negative_tick_array_bitmap: [[u64; 8]; 14], -} - -impl TickArrayBitmapExtension { - pub const LEN: usize = 1832; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for TickArrayBitmapExtension { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_tick_array_bitmap_extension( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_tick_array_bitmap_extension(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_tick_array_bitmap_extension( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = TickArrayBitmapExtension::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_tick_array_bitmap_extension( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_tick_array_bitmap_extension(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_tick_array_bitmap_extension( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = - Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = TickArrayBitmapExtension::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for TickArrayBitmapExtension { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for TickArrayBitmapExtension {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for TickArrayBitmapExtension { - fn owner() -> Pubkey { crate::AMM_V3_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for TickArrayBitmapExtension {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for TickArrayBitmapExtension { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/accounts/tick_array_state.rs b/crates/raydium-clmm-parser/src/generated_sdk/accounts/tick_array_state.rs deleted file mode 100644 index 920eb852..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/accounts/tick_array_state.rs +++ /dev/null @@ -1,141 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::TickState; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TickArrayState { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_id: Pubkey, - pub start_tick_index: i32, - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub ticks: [TickState; 60], - pub initialized_tick_count: u8, - pub recent_epoch: u64, - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 107], -} - -impl TickArrayState { - pub const LEN: usize = 10240; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for TickArrayState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_tick_array_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_tick_array_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_tick_array_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = TickArrayState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_tick_array_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_tick_array_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_tick_array_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = TickArrayState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for TickArrayState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for TickArrayState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for TickArrayState { - fn owner() -> Pubkey { crate::AMM_V3_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for TickArrayState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for TickArrayState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/errors/amm_v3.rs b/crates/raydium-clmm-parser/src/generated_sdk/errors/amm_v3.rs deleted file mode 100644 index 730e7676..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/errors/amm_v3.rs +++ /dev/null @@ -1,159 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum AmmV3Error { - /// 6000 - LOK - #[error("LOK")] - LOK = 0x1770, - /// 6001 - Not approved - #[error("Not approved")] - NotApproved = 0x1771, - /// 6002 - invalid update amm config flag - #[error("invalid update amm config flag")] - InvalidUpdateConfigFlag = 0x1772, - /// 6003 - Account lack - #[error("Account lack")] - AccountLack = 0x1773, - /// 6004 - Remove liquitity, collect fees owed and reward then you can close position account - #[error("Remove liquitity, collect fees owed and reward then you can close position account")] - ClosePositionErr = 0x1774, - /// 6005 - Minting amount should be greater than 0 - #[error("Minting amount should be greater than 0")] - ZeroMintAmount = 0x1775, - /// 6006 - Tick out of range - #[error("Tick out of range")] - InvaildTickIndex = 0x1776, - /// 6007 - The lower tick must be below the upper tick - #[error("The lower tick must be below the upper tick")] - TickInvaildOrder = 0x1777, - /// 6008 - The tick must be greater, or equal to the minimum tick(-443636) - #[error("The tick must be greater, or equal to the minimum tick(-443636)")] - TickLowerOverflow = 0x1778, - /// 6009 - The tick must be lesser than, or equal to the maximum tick(443636) - #[error("The tick must be lesser than, or equal to the maximum tick(443636)")] - TickUpperOverflow = 0x1779, - /// 6010 - tick % tick_spacing must be zero - #[error("tick % tick_spacing must be zero")] - TickAndSpacingNotMatch = 0x177a, - /// 6011 - Invaild tick array account - #[error("Invaild tick array account")] - InvalidTickArray = 0x177b, - /// 6012 - Invaild tick array boundary - #[error("Invaild tick array boundary")] - InvalidTickArrayBoundary = 0x177c, - /// 6013 - Square root price limit overflow - #[error("Square root price limit overflow")] - SqrtPriceLimitOverflow = 0x177d, - /// 6014 - sqrt_price_x64 out of range - #[error("sqrt_price_x64 out of range")] - SqrtPriceX64 = 0x177e, - /// 6015 - Liquidity sub delta L must be smaller than before - #[error("Liquidity sub delta L must be smaller than before")] - LiquiditySubValueErr = 0x177f, - /// 6016 - Liquidity add delta L must be greater, or equal to before - #[error("Liquidity add delta L must be greater, or equal to before")] - LiquidityAddValueErr = 0x1780, - /// 6017 - Invaild liquidity when update position - #[error("Invaild liquidity when update position")] - InvaildLiquidity = 0x1781, - /// 6018 - Both token amount must not be zero while supply liquidity - #[error("Both token amount must not be zero while supply liquidity")] - ForbidBothZeroForSupplyLiquidity = 0x1782, - /// 6019 - Liquidity insufficient - #[error("Liquidity insufficient")] - LiquidityInsufficient = 0x1783, - /// 6020 - Transaction too old - #[error("Transaction too old")] - TransactionTooOld = 0x1784, - /// 6021 - Price slippage check - #[error("Price slippage check")] - PriceSlippageCheck = 0x1785, - /// 6022 - Too little output received - #[error("Too little output received")] - TooLittleOutputReceived = 0x1786, - /// 6023 - Too much input paid - #[error("Too much input paid")] - TooMuchInputPaid = 0x1787, - /// 6024 - Swap special amount can not be zero - #[error("Swap special amount can not be zero")] - ZeroAmountSpecified = 0x1788, - /// 6025 - Input pool vault is invalid - #[error("Input pool vault is invalid")] - InvalidInputPoolVault = 0x1789, - /// 6026 - Swap input or output amount is too small - #[error("Swap input or output amount is too small")] - TooSmallInputOrOutputAmount = 0x178a, - /// 6027 - Not enought tick array account - #[error("Not enought tick array account")] - NotEnoughTickArrayAccount = 0x178b, - /// 6028 - Invaild first tick array account - #[error("Invaild first tick array account")] - InvalidFirstTickArrayAccount = 0x178c, - /// 6029 - Invalid reward index - #[error("Invalid reward index")] - InvalidRewardIndex = 0x178d, - /// 6030 - The init reward token reach to the max - #[error("The init reward token reach to the max")] - FullRewardInfo = 0x178e, - /// 6031 - The init reward token already in use - #[error("The init reward token already in use")] - RewardTokenAlreadyInUse = 0x178f, - /// 6032 - The reward tokens must contain one of pool vault mint except the last reward - #[error("The reward tokens must contain one of pool vault mint except the last reward")] - ExceptPoolVaultMint = 0x1790, - /// 6033 - Invalid reward init param - #[error("Invalid reward init param")] - InvalidRewardInitParam = 0x1791, - /// 6034 - Invalid collect reward desired amount - #[error("Invalid collect reward desired amount")] - InvalidRewardDesiredAmount = 0x1792, - /// 6035 - Invalid collect reward input account number - #[error("Invalid collect reward input account number")] - InvalidRewardInputAccountNumber = 0x1793, - /// 6036 - Invalid reward period - #[error("Invalid reward period")] - InvalidRewardPeriod = 0x1794, - /// 6037 - Modification of emissiones is allowed within 72 hours from the end of the previous cycle - #[error( - "Modification of emissiones is allowed within 72 hours from the end of the previous cycle" - )] - NotApproveUpdateRewardEmissiones = 0x1795, - /// 6038 - uninitialized reward info - #[error("uninitialized reward info")] - UnInitializedRewardInfo = 0x1796, - /// 6039 - Not support token_2022 mint extension - #[error("Not support token_2022 mint extension")] - NotSupportMint = 0x1797, - /// 6040 - Missing tickarray bitmap extension account - #[error("Missing tickarray bitmap extension account")] - MissingTickArrayBitmapExtensionAccount = 0x1798, - /// 6041 - Insufficient liquidity for this direction - #[error("Insufficient liquidity for this direction")] - InsufficientLiquidityForDirection = 0x1799, - /// 6042 - Max token overflow - #[error("Max token overflow")] - MaxTokenOverflow = 0x179a, - /// 6043 - calculate overflow - #[error("calculate overflow")] - CalculateOverflow = 0x179b, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for AmmV3Error { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for AmmV3Error { - fn type_of() -> &'static str { "AmmV3Error" } -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/errors/mod.rs b/crates/raydium-clmm-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 1d951599..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod amm_v3; - -pub use self::amm_v3::AmmV3Error; diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/close_position.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/close_position.rs deleted file mode 100644 index e736d6dc..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/close_position.rs +++ /dev/null @@ -1,499 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClosePosition { - pub nft_owner: solana_pubkey::Pubkey, - - pub position_nft_mint: solana_pubkey::Pubkey, - - pub position_nft_account: solana_pubkey::Pubkey, - - pub personal_position: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl ClosePosition { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.nft_owner, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.personal_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClosePositionInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClosePositionInstructionData { - discriminator: [u8; 8], -} - -impl ClosePositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [123, 134, 81, 0, 49, 68, 98, 98], - } - } -} - -impl Default for ClosePositionInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClosePosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` nft_owner -/// 1. `[writable]` position_nft_mint -/// 2. `[writable]` position_nft_account -/// 3. `[writable]` personal_position -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct ClosePositionBuilder { - nft_owner: Option, - position_nft_mint: Option, - position_nft_account: Option, - personal_position: Option, - system_program: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl ClosePositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn nft_owner(&mut self, nft_owner: solana_pubkey::Pubkey) -> &mut Self { - self.nft_owner = Some(nft_owner); - self - } - - #[inline(always)] - pub fn position_nft_mint(&mut self, position_nft_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_mint = Some(position_nft_mint); - self - } - - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn personal_position(&mut self, personal_position: solana_pubkey::Pubkey) -> &mut Self { - self.personal_position = Some(personal_position); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClosePosition { - nft_owner: self.nft_owner.expect("nft_owner is not set"), - position_nft_mint: self - .position_nft_mint - .expect("position_nft_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - personal_position: self - .personal_position - .expect("personal_position is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_position` CPI accounts. -pub struct ClosePositionCpiAccounts<'a, 'b> { - pub nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_position` CPI instruction. -pub struct ClosePositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClosePositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClosePositionCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - nft_owner: accounts.nft_owner, - position_nft_mint: accounts.position_nft_mint, - position_nft_account: accounts.position_nft_account, - personal_position: accounts.personal_position, - system_program: accounts.system_program, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.nft_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.personal_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClosePositionInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.nft_owner.clone()); - account_infos.push(self.position_nft_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.personal_position.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClosePosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` nft_owner -/// 1. `[writable]` position_nft_mint -/// 2. `[writable]` position_nft_account -/// 3. `[writable]` personal_position -/// 4. `[]` system_program -/// 5. `[]` token_program -#[derive(Clone, Debug)] -pub struct ClosePositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClosePositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClosePositionCpiBuilderInstruction { - __program: program, - nft_owner: None, - position_nft_mint: None, - position_nft_account: None, - personal_position: None, - system_program: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn nft_owner(&mut self, nft_owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.nft_owner = Some(nft_owner); - self - } - - #[inline(always)] - pub fn position_nft_mint( - &mut self, - position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_mint = Some(position_nft_mint); - self - } - - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn personal_position( - &mut self, - personal_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClosePositionCpi { - __program: self.instruction.__program, - - nft_owner: self.instruction.nft_owner.expect("nft_owner is not set"), - - position_nft_mint: self - .instruction - .position_nft_mint - .expect("position_nft_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - personal_position: self - .instruction - .personal_position - .expect("personal_position is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClosePositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - nft_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - personal_position: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/collect_fund_fee.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/collect_fund_fee.rs deleted file mode 100644 index a40279dc..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/collect_fund_fee.rs +++ /dev/null @@ -1,774 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CollectFundFee { - pub owner: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub token_vault0: solana_pubkey::Pubkey, - - pub token_vault1: solana_pubkey::Pubkey, - - pub vault0_mint: solana_pubkey::Pubkey, - - pub vault1_mint: solana_pubkey::Pubkey, - - pub recipient_token_account0: solana_pubkey::Pubkey, - - pub recipient_token_account1: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token_program2022: solana_pubkey::Pubkey, -} - -impl CollectFundFee { - pub fn instruction( - &self, - args: CollectFundFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CollectFundFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CollectFundFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectFundFeeInstructionData { - discriminator: [u8; 8], -} - -impl CollectFundFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [167, 138, 78, 149, 223, 194, 6, 126], - } - } -} - -impl Default for CollectFundFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectFundFeeInstructionArgs { - pub amount0_requested: u64, - pub amount1_requested: u64, -} - -/// Instruction builder for `CollectFundFee`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[writable]` pool_state -/// 2. `[]` amm_config -/// 3. `[writable]` token_vault0 -/// 4. `[writable]` token_vault1 -/// 5. `[]` vault0_mint -/// 6. `[]` vault1_mint -/// 7. `[writable]` recipient_token_account0 -/// 8. `[writable]` recipient_token_account1 -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 10. `[]` token_program2022 -#[derive(Clone, Debug, Default)] -pub struct CollectFundFeeBuilder { - owner: Option, - pool_state: Option, - amm_config: Option, - token_vault0: Option, - token_vault1: Option, - vault0_mint: Option, - vault1_mint: Option, - recipient_token_account0: Option, - recipient_token_account1: Option, - token_program: Option, - token_program2022: Option, - amount0_requested: Option, - amount1_requested: Option, - __remaining_accounts: Vec, -} - -impl CollectFundFeeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn token_vault0(&mut self, token_vault0: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1(&mut self, token_vault1: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn recipient_token_account0( - &mut self, - recipient_token_account0: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account0 = Some(recipient_token_account0); - self - } - - #[inline(always)] - pub fn recipient_token_account1( - &mut self, - recipient_token_account1: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account1 = Some(recipient_token_account1); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn amount0_requested(&mut self, amount0_requested: u64) -> &mut Self { - self.amount0_requested = Some(amount0_requested); - self - } - - #[inline(always)] - pub fn amount1_requested(&mut self, amount1_requested: u64) -> &mut Self { - self.amount1_requested = Some(amount1_requested); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectFundFee { - owner: self.owner.expect("owner is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - token_vault0: self.token_vault0.expect("token_vault0 is not set"), - token_vault1: self.token_vault1.expect("token_vault1 is not set"), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - recipient_token_account0: self - .recipient_token_account0 - .expect("recipient_token_account0 is not set"), - recipient_token_account1: self - .recipient_token_account1 - .expect("recipient_token_account1 is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self - .token_program2022 - .expect("token_program2022 is not set"), - }; - let args = CollectFundFeeInstructionArgs { - amount0_requested: self - .amount0_requested - .clone() - .expect("amount0_requested is not set"), - amount1_requested: self - .amount1_requested - .clone() - .expect("amount1_requested is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `collect_fund_fee` CPI accounts. -pub struct CollectFundFeeCpiAccounts<'a, 'b> { - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_fund_fee` CPI instruction. -pub struct CollectFundFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CollectFundFeeInstructionArgs, -} - -impl<'a, 'b> CollectFundFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectFundFeeCpiAccounts<'a, 'b>, - args: CollectFundFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - pool_state: accounts.pool_state, - amm_config: accounts.amm_config, - token_vault0: accounts.token_vault0, - token_vault1: accounts.token_vault1, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - recipient_token_account0: accounts.recipient_token_account0, - recipient_token_account1: accounts.recipient_token_account1, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CollectFundFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.token_vault0.clone()); - account_infos.push(self.token_vault1.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - account_infos.push(self.recipient_token_account0.clone()); - account_infos.push(self.recipient_token_account1.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectFundFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[writable]` pool_state -/// 2. `[]` amm_config -/// 3. `[writable]` token_vault0 -/// 4. `[writable]` token_vault1 -/// 5. `[]` vault0_mint -/// 6. `[]` vault1_mint -/// 7. `[writable]` recipient_token_account0 -/// 8. `[writable]` recipient_token_account1 -/// 9. `[]` token_program -/// 10. `[]` token_program2022 -#[derive(Clone, Debug)] -pub struct CollectFundFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectFundFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectFundFeeCpiBuilderInstruction { - __program: program, - owner: None, - pool_state: None, - amm_config: None, - token_vault0: None, - token_vault1: None, - vault0_mint: None, - vault1_mint: None, - recipient_token_account0: None, - recipient_token_account1: None, - token_program: None, - token_program2022: None, - amount0_requested: None, - amount1_requested: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn token_vault0( - &mut self, - token_vault0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1( - &mut self, - token_vault1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn recipient_token_account0( - &mut self, - recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account0 = Some(recipient_token_account0); - self - } - - #[inline(always)] - pub fn recipient_token_account1( - &mut self, - recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account1 = Some(recipient_token_account1); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn amount0_requested(&mut self, amount0_requested: u64) -> &mut Self { - self.instruction.amount0_requested = Some(amount0_requested); - self - } - - #[inline(always)] - pub fn amount1_requested(&mut self, amount1_requested: u64) -> &mut Self { - self.instruction.amount1_requested = Some(amount1_requested); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CollectFundFeeInstructionArgs { - amount0_requested: self - .instruction - .amount0_requested - .clone() - .expect("amount0_requested is not set"), - amount1_requested: self - .instruction - .amount1_requested - .clone() - .expect("amount1_requested is not set"), - }; - let instruction = CollectFundFeeCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - token_vault0: self - .instruction - .token_vault0 - .expect("token_vault0 is not set"), - - token_vault1: self - .instruction - .token_vault1 - .expect("token_vault1 is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - - recipient_token_account0: self - .instruction - .recipient_token_account0 - .expect("recipient_token_account0 is not set"), - - recipient_token_account1: self - .instruction - .recipient_token_account1 - .expect("recipient_token_account1 is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectFundFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault1: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account0: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - amount0_requested: Option, - amount1_requested: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/collect_protocol_fee.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/collect_protocol_fee.rs deleted file mode 100644 index 8e6e5371..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/collect_protocol_fee.rs +++ /dev/null @@ -1,774 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CollectProtocolFee { - pub owner: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub token_vault0: solana_pubkey::Pubkey, - - pub token_vault1: solana_pubkey::Pubkey, - - pub vault0_mint: solana_pubkey::Pubkey, - - pub vault1_mint: solana_pubkey::Pubkey, - - pub recipient_token_account0: solana_pubkey::Pubkey, - - pub recipient_token_account1: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token_program2022: solana_pubkey::Pubkey, -} - -impl CollectProtocolFee { - pub fn instruction( - &self, - args: CollectProtocolFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CollectProtocolFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CollectProtocolFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectProtocolFeeInstructionData { - discriminator: [u8; 8], -} - -impl CollectProtocolFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [136, 136, 252, 221, 194, 66, 126, 89], - } - } -} - -impl Default for CollectProtocolFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectProtocolFeeInstructionArgs { - pub amount0_requested: u64, - pub amount1_requested: u64, -} - -/// Instruction builder for `CollectProtocolFee`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[writable]` pool_state -/// 2. `[]` amm_config -/// 3. `[writable]` token_vault0 -/// 4. `[writable]` token_vault1 -/// 5. `[]` vault0_mint -/// 6. `[]` vault1_mint -/// 7. `[writable]` recipient_token_account0 -/// 8. `[writable]` recipient_token_account1 -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 10. `[]` token_program2022 -#[derive(Clone, Debug, Default)] -pub struct CollectProtocolFeeBuilder { - owner: Option, - pool_state: Option, - amm_config: Option, - token_vault0: Option, - token_vault1: Option, - vault0_mint: Option, - vault1_mint: Option, - recipient_token_account0: Option, - recipient_token_account1: Option, - token_program: Option, - token_program2022: Option, - amount0_requested: Option, - amount1_requested: Option, - __remaining_accounts: Vec, -} - -impl CollectProtocolFeeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn token_vault0(&mut self, token_vault0: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1(&mut self, token_vault1: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn recipient_token_account0( - &mut self, - recipient_token_account0: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account0 = Some(recipient_token_account0); - self - } - - #[inline(always)] - pub fn recipient_token_account1( - &mut self, - recipient_token_account1: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account1 = Some(recipient_token_account1); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn amount0_requested(&mut self, amount0_requested: u64) -> &mut Self { - self.amount0_requested = Some(amount0_requested); - self - } - - #[inline(always)] - pub fn amount1_requested(&mut self, amount1_requested: u64) -> &mut Self { - self.amount1_requested = Some(amount1_requested); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectProtocolFee { - owner: self.owner.expect("owner is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - token_vault0: self.token_vault0.expect("token_vault0 is not set"), - token_vault1: self.token_vault1.expect("token_vault1 is not set"), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - recipient_token_account0: self - .recipient_token_account0 - .expect("recipient_token_account0 is not set"), - recipient_token_account1: self - .recipient_token_account1 - .expect("recipient_token_account1 is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self - .token_program2022 - .expect("token_program2022 is not set"), - }; - let args = CollectProtocolFeeInstructionArgs { - amount0_requested: self - .amount0_requested - .clone() - .expect("amount0_requested is not set"), - amount1_requested: self - .amount1_requested - .clone() - .expect("amount1_requested is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `collect_protocol_fee` CPI accounts. -pub struct CollectProtocolFeeCpiAccounts<'a, 'b> { - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_protocol_fee` CPI instruction. -pub struct CollectProtocolFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CollectProtocolFeeInstructionArgs, -} - -impl<'a, 'b> CollectProtocolFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectProtocolFeeCpiAccounts<'a, 'b>, - args: CollectProtocolFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - pool_state: accounts.pool_state, - amm_config: accounts.amm_config, - token_vault0: accounts.token_vault0, - token_vault1: accounts.token_vault1, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - recipient_token_account0: accounts.recipient_token_account0, - recipient_token_account1: accounts.recipient_token_account1, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CollectProtocolFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.token_vault0.clone()); - account_infos.push(self.token_vault1.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - account_infos.push(self.recipient_token_account0.clone()); - account_infos.push(self.recipient_token_account1.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectProtocolFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[writable]` pool_state -/// 2. `[]` amm_config -/// 3. `[writable]` token_vault0 -/// 4. `[writable]` token_vault1 -/// 5. `[]` vault0_mint -/// 6. `[]` vault1_mint -/// 7. `[writable]` recipient_token_account0 -/// 8. `[writable]` recipient_token_account1 -/// 9. `[]` token_program -/// 10. `[]` token_program2022 -#[derive(Clone, Debug)] -pub struct CollectProtocolFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectProtocolFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectProtocolFeeCpiBuilderInstruction { - __program: program, - owner: None, - pool_state: None, - amm_config: None, - token_vault0: None, - token_vault1: None, - vault0_mint: None, - vault1_mint: None, - recipient_token_account0: None, - recipient_token_account1: None, - token_program: None, - token_program2022: None, - amount0_requested: None, - amount1_requested: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn token_vault0( - &mut self, - token_vault0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1( - &mut self, - token_vault1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn recipient_token_account0( - &mut self, - recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account0 = Some(recipient_token_account0); - self - } - - #[inline(always)] - pub fn recipient_token_account1( - &mut self, - recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account1 = Some(recipient_token_account1); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn amount0_requested(&mut self, amount0_requested: u64) -> &mut Self { - self.instruction.amount0_requested = Some(amount0_requested); - self - } - - #[inline(always)] - pub fn amount1_requested(&mut self, amount1_requested: u64) -> &mut Self { - self.instruction.amount1_requested = Some(amount1_requested); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CollectProtocolFeeInstructionArgs { - amount0_requested: self - .instruction - .amount0_requested - .clone() - .expect("amount0_requested is not set"), - amount1_requested: self - .instruction - .amount1_requested - .clone() - .expect("amount1_requested is not set"), - }; - let instruction = CollectProtocolFeeCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - token_vault0: self - .instruction - .token_vault0 - .expect("token_vault0 is not set"), - - token_vault1: self - .instruction - .token_vault1 - .expect("token_vault1 is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - - recipient_token_account0: self - .instruction - .recipient_token_account0 - .expect("recipient_token_account0 is not set"), - - recipient_token_account1: self - .instruction - .recipient_token_account1 - .expect("recipient_token_account1 is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectProtocolFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault1: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account0: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - amount0_requested: Option, - amount1_requested: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/collect_remaining_rewards.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/collect_remaining_rewards.rs deleted file mode 100644 index 25d36d7d..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/collect_remaining_rewards.rs +++ /dev/null @@ -1,629 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CollectRemainingRewards { - pub reward_funder: solana_pubkey::Pubkey, - - pub funder_token_account: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub reward_token_vault: solana_pubkey::Pubkey, - - pub reward_vault_mint: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token_program2022: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, -} - -impl CollectRemainingRewards { - pub fn instruction( - &self, - args: CollectRemainingRewardsInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CollectRemainingRewardsInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_funder, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.funder_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_vault_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CollectRemainingRewardsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectRemainingRewardsInstructionData { - discriminator: [u8; 8], -} - -impl CollectRemainingRewardsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [18, 237, 166, 197, 34, 16, 213, 144], - } - } -} - -impl Default for CollectRemainingRewardsInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectRemainingRewardsInstructionArgs { - pub reward_index: u8, -} - -/// Instruction builder for `CollectRemainingRewards`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` reward_funder -/// 1. `[writable]` funder_token_account -/// 2. `[writable]` pool_state -/// 3. `[]` reward_token_vault -/// 4. `[]` reward_vault_mint -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 6. `[]` token_program2022 -/// 7. `[]` memo_program -#[derive(Clone, Debug, Default)] -pub struct CollectRemainingRewardsBuilder { - reward_funder: Option, - funder_token_account: Option, - pool_state: Option, - reward_token_vault: Option, - reward_vault_mint: Option, - token_program: Option, - token_program2022: Option, - memo_program: Option, - reward_index: Option, - __remaining_accounts: Vec, -} - -impl CollectRemainingRewardsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn reward_funder(&mut self, reward_funder: solana_pubkey::Pubkey) -> &mut Self { - self.reward_funder = Some(reward_funder); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn reward_token_vault(&mut self, reward_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_token_vault = Some(reward_token_vault); - self - } - - #[inline(always)] - pub fn reward_vault_mint(&mut self, reward_vault_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_vault_mint = Some(reward_vault_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectRemainingRewards { - reward_funder: self.reward_funder.expect("reward_funder is not set"), - funder_token_account: self - .funder_token_account - .expect("funder_token_account is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - reward_token_vault: self - .reward_token_vault - .expect("reward_token_vault is not set"), - reward_vault_mint: self - .reward_vault_mint - .expect("reward_vault_mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self - .token_program2022 - .expect("token_program2022 is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - }; - let args = CollectRemainingRewardsInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `collect_remaining_rewards` CPI accounts. -pub struct CollectRemainingRewardsCpiAccounts<'a, 'b> { - pub reward_funder: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_remaining_rewards` CPI instruction. -pub struct CollectRemainingRewardsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub reward_funder: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_vault_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CollectRemainingRewardsInstructionArgs, -} - -impl<'a, 'b> CollectRemainingRewardsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectRemainingRewardsCpiAccounts<'a, 'b>, - args: CollectRemainingRewardsInstructionArgs, - ) -> Self { - Self { - __program: program, - reward_funder: accounts.reward_funder, - funder_token_account: accounts.funder_token_account, - pool_state: accounts.pool_state, - reward_token_vault: accounts.reward_token_vault, - reward_vault_mint: accounts.reward_vault_mint, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - memo_program: accounts.memo_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_funder.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.funder_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_vault_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CollectRemainingRewardsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.reward_funder.clone()); - account_infos.push(self.funder_token_account.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.reward_token_vault.clone()); - account_infos.push(self.reward_vault_mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.memo_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectRemainingRewards` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` reward_funder -/// 1. `[writable]` funder_token_account -/// 2. `[writable]` pool_state -/// 3. `[]` reward_token_vault -/// 4. `[]` reward_vault_mint -/// 5. `[]` token_program -/// 6. `[]` token_program2022 -/// 7. `[]` memo_program -#[derive(Clone, Debug)] -pub struct CollectRemainingRewardsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectRemainingRewardsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectRemainingRewardsCpiBuilderInstruction { - __program: program, - reward_funder: None, - funder_token_account: None, - pool_state: None, - reward_token_vault: None, - reward_vault_mint: None, - token_program: None, - token_program2022: None, - memo_program: None, - reward_index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn reward_funder( - &mut self, - reward_funder: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_funder = Some(reward_funder); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn reward_token_vault( - &mut self, - reward_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_token_vault = Some(reward_token_vault); - self - } - - #[inline(always)] - pub fn reward_vault_mint( - &mut self, - reward_vault_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_vault_mint = Some(reward_vault_mint); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CollectRemainingRewardsInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - }; - let instruction = CollectRemainingRewardsCpi { - __program: self.instruction.__program, - - reward_funder: self - .instruction - .reward_funder - .expect("reward_funder is not set"), - - funder_token_account: self - .instruction - .funder_token_account - .expect("funder_token_account is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - reward_token_vault: self - .instruction - .reward_token_vault - .expect("reward_token_vault is not set"), - - reward_vault_mint: self - .instruction - .reward_vault_mint - .expect("reward_vault_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectRemainingRewardsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - reward_funder: Option<&'b solana_account_info::AccountInfo<'a>>, - funder_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_vault_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/create_amm_config.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/create_amm_config.rs deleted file mode 100644 index 4c01de1a..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/create_amm_config.rs +++ /dev/null @@ -1,489 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateAmmConfig { - pub owner: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateAmmConfig { - pub fn instruction( - &self, - args: CreateAmmConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateAmmConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.owner, true)); - accounts.push(solana_instruction::AccountMeta::new(self.amm_config, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateAmmConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateAmmConfigInstructionData { - discriminator: [u8; 8], -} - -impl CreateAmmConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [137, 52, 237, 212, 215, 117, 108, 104], - } - } -} - -impl Default for CreateAmmConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateAmmConfigInstructionArgs { - pub index: u16, - pub tick_spacing: u16, - pub trade_fee_rate: u32, - pub protocol_fee_rate: u32, - pub fund_fee_rate: u32, -} - -/// Instruction builder for `CreateAmmConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` owner -/// 1. `[writable]` amm_config -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateAmmConfigBuilder { - owner: Option, - amm_config: Option, - system_program: Option, - index: Option, - tick_spacing: Option, - trade_fee_rate: Option, - protocol_fee_rate: Option, - fund_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl CreateAmmConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u16) -> &mut Self { - self.index = Some(index); - self - } - - #[inline(always)] - pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self { - self.tick_spacing = Some(tick_spacing); - self - } - - #[inline(always)] - pub fn trade_fee_rate(&mut self, trade_fee_rate: u32) -> &mut Self { - self.trade_fee_rate = Some(trade_fee_rate); - self - } - - #[inline(always)] - pub fn protocol_fee_rate(&mut self, protocol_fee_rate: u32) -> &mut Self { - self.protocol_fee_rate = Some(protocol_fee_rate); - self - } - - #[inline(always)] - pub fn fund_fee_rate(&mut self, fund_fee_rate: u32) -> &mut Self { - self.fund_fee_rate = Some(fund_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateAmmConfig { - owner: self.owner.expect("owner is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = CreateAmmConfigInstructionArgs { - index: self.index.clone().expect("index is not set"), - tick_spacing: self.tick_spacing.clone().expect("tick_spacing is not set"), - trade_fee_rate: self - .trade_fee_rate - .clone() - .expect("trade_fee_rate is not set"), - protocol_fee_rate: self - .protocol_fee_rate - .clone() - .expect("protocol_fee_rate is not set"), - fund_fee_rate: self - .fund_fee_rate - .clone() - .expect("fund_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_amm_config` CPI accounts. -pub struct CreateAmmConfigCpiAccounts<'a, 'b> { - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_amm_config` CPI instruction. -pub struct CreateAmmConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateAmmConfigInstructionArgs, -} - -impl<'a, 'b> CreateAmmConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateAmmConfigCpiAccounts<'a, 'b>, - args: CreateAmmConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - amm_config: accounts.amm_config, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.owner.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateAmmConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateAmmConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` owner -/// 1. `[writable]` amm_config -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateAmmConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateAmmConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateAmmConfigCpiBuilderInstruction { - __program: program, - owner: None, - amm_config: None, - system_program: None, - index: None, - tick_spacing: None, - trade_fee_rate: None, - protocol_fee_rate: None, - fund_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u16) -> &mut Self { - self.instruction.index = Some(index); - self - } - - #[inline(always)] - pub fn tick_spacing(&mut self, tick_spacing: u16) -> &mut Self { - self.instruction.tick_spacing = Some(tick_spacing); - self - } - - #[inline(always)] - pub fn trade_fee_rate(&mut self, trade_fee_rate: u32) -> &mut Self { - self.instruction.trade_fee_rate = Some(trade_fee_rate); - self - } - - #[inline(always)] - pub fn protocol_fee_rate(&mut self, protocol_fee_rate: u32) -> &mut Self { - self.instruction.protocol_fee_rate = Some(protocol_fee_rate); - self - } - - #[inline(always)] - pub fn fund_fee_rate(&mut self, fund_fee_rate: u32) -> &mut Self { - self.instruction.fund_fee_rate = Some(fund_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateAmmConfigInstructionArgs { - index: self.instruction.index.clone().expect("index is not set"), - tick_spacing: self - .instruction - .tick_spacing - .clone() - .expect("tick_spacing is not set"), - trade_fee_rate: self - .instruction - .trade_fee_rate - .clone() - .expect("trade_fee_rate is not set"), - protocol_fee_rate: self - .instruction - .protocol_fee_rate - .clone() - .expect("protocol_fee_rate is not set"), - fund_fee_rate: self - .instruction - .fund_fee_rate - .clone() - .expect("fund_fee_rate is not set"), - }; - let instruction = CreateAmmConfigCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateAmmConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - index: Option, - tick_spacing: Option, - trade_fee_rate: Option, - protocol_fee_rate: Option, - fund_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/create_operation_account.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/create_operation_account.rs deleted file mode 100644 index 6a15c637..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/create_operation_account.rs +++ /dev/null @@ -1,358 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateOperationAccount { - pub owner: solana_pubkey::Pubkey, - - pub operation_state: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateOperationAccount { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.owner, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.operation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateOperationAccountInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateOperationAccountInstructionData { - discriminator: [u8; 8], -} - -impl CreateOperationAccountInstructionData { - pub fn new() -> Self { - Self { - discriminator: [63, 87, 148, 33, 109, 35, 8, 104], - } - } -} - -impl Default for CreateOperationAccountInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateOperationAccount`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` owner -/// 1. `[writable]` operation_state -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateOperationAccountBuilder { - owner: Option, - operation_state: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl CreateOperationAccountBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn operation_state(&mut self, operation_state: solana_pubkey::Pubkey) -> &mut Self { - self.operation_state = Some(operation_state); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateOperationAccount { - owner: self.owner.expect("owner is not set"), - operation_state: self.operation_state.expect("operation_state is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_operation_account` CPI accounts. -pub struct CreateOperationAccountCpiAccounts<'a, 'b> { - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub operation_state: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_operation_account` CPI instruction. -pub struct CreateOperationAccountCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub operation_state: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateOperationAccountCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateOperationAccountCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - operation_state: accounts.operation_state, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.owner.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.operation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateOperationAccountInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.operation_state.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateOperationAccount` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` owner -/// 1. `[writable]` operation_state -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateOperationAccountCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateOperationAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateOperationAccountCpiBuilderInstruction { - __program: program, - owner: None, - operation_state: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn operation_state( - &mut self, - operation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.operation_state = Some(operation_state); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateOperationAccountCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - operation_state: self - .instruction - .operation_state - .expect("operation_state is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateOperationAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - operation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/create_pool.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/create_pool.rs deleted file mode 100644 index 88c791df..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/create_pool.rs +++ /dev/null @@ -1,847 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreatePool { - pub pool_creator: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub token_mint0: solana_pubkey::Pubkey, - - pub token_mint1: solana_pubkey::Pubkey, - - pub token_vault0: solana_pubkey::Pubkey, - - pub token_vault1: solana_pubkey::Pubkey, - - pub observation_state: solana_pubkey::Pubkey, - - pub tick_array_bitmap: solana_pubkey::Pubkey, - - pub token_program0: solana_pubkey::Pubkey, - - pub token_program1: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl CreatePool { - pub fn instruction(&self, args: CreatePoolInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreatePoolInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_creator, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_bitmap, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreatePoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePoolInstructionData { - discriminator: [u8; 8], -} - -impl CreatePoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [233, 146, 209, 142, 207, 104, 64, 188], - } - } -} - -impl Default for CreatePoolInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePoolInstructionArgs { - pub sqrt_price_x64: u128, - pub open_time: u64, -} - -/// Instruction builder for `CreatePool`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` pool_creator -/// 1. `[]` amm_config -/// 2. `[writable]` pool_state -/// 3. `[]` token_mint0 -/// 4. `[]` token_mint1 -/// 5. `[writable]` token_vault0 -/// 6. `[writable]` token_vault1 -/// 7. `[writable]` observation_state -/// 8. `[writable]` tick_array_bitmap -/// 9. `[]` token_program0 -/// 10. `[]` token_program1 -/// 11. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 12. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreatePoolBuilder { - pool_creator: Option, - amm_config: Option, - pool_state: Option, - token_mint0: Option, - token_mint1: Option, - token_vault0: Option, - token_vault1: Option, - observation_state: Option, - tick_array_bitmap: Option, - token_program0: Option, - token_program1: Option, - system_program: Option, - rent: Option, - sqrt_price_x64: Option, - open_time: Option, - __remaining_accounts: Vec, -} - -impl CreatePoolBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool_creator(&mut self, pool_creator: solana_pubkey::Pubkey) -> &mut Self { - self.pool_creator = Some(pool_creator); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn token_mint0(&mut self, token_mint0: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint0 = Some(token_mint0); - self - } - - #[inline(always)] - pub fn token_mint1(&mut self, token_mint1: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint1 = Some(token_mint1); - self - } - - #[inline(always)] - pub fn token_vault0(&mut self, token_vault0: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1(&mut self, token_vault1: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn tick_array_bitmap(&mut self, tick_array_bitmap: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_bitmap = Some(tick_array_bitmap); - self - } - - #[inline(always)] - pub fn token_program0(&mut self, token_program0: solana_pubkey::Pubkey) -> &mut Self { - self.token_program0 = Some(token_program0); - self - } - - #[inline(always)] - pub fn token_program1(&mut self, token_program1: solana_pubkey::Pubkey) -> &mut Self { - self.token_program1 = Some(token_program1); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn sqrt_price_x64(&mut self, sqrt_price_x64: u128) -> &mut Self { - self.sqrt_price_x64 = Some(sqrt_price_x64); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.open_time = Some(open_time); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreatePool { - pool_creator: self.pool_creator.expect("pool_creator is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - token_mint0: self.token_mint0.expect("token_mint0 is not set"), - token_mint1: self.token_mint1.expect("token_mint1 is not set"), - token_vault0: self.token_vault0.expect("token_vault0 is not set"), - token_vault1: self.token_vault1.expect("token_vault1 is not set"), - observation_state: self - .observation_state - .expect("observation_state is not set"), - tick_array_bitmap: self - .tick_array_bitmap - .expect("tick_array_bitmap is not set"), - token_program0: self.token_program0.expect("token_program0 is not set"), - token_program1: self.token_program1.expect("token_program1 is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = CreatePoolInstructionArgs { - sqrt_price_x64: self - .sqrt_price_x64 - .clone() - .expect("sqrt_price_x64 is not set"), - open_time: self.open_time.clone().expect("open_time is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_pool` CPI accounts. -pub struct CreatePoolCpiAccounts<'a, 'b> { - pub pool_creator: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint0: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_bitmap: &'b solana_account_info::AccountInfo<'a>, - - pub token_program0: &'b solana_account_info::AccountInfo<'a>, - - pub token_program1: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_pool` CPI instruction. -pub struct CreatePoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_creator: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint0: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_bitmap: &'b solana_account_info::AccountInfo<'a>, - - pub token_program0: &'b solana_account_info::AccountInfo<'a>, - - pub token_program1: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreatePoolInstructionArgs, -} - -impl<'a, 'b> CreatePoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreatePoolCpiAccounts<'a, 'b>, - args: CreatePoolInstructionArgs, - ) -> Self { - Self { - __program: program, - pool_creator: accounts.pool_creator, - amm_config: accounts.amm_config, - pool_state: accounts.pool_state, - token_mint0: accounts.token_mint0, - token_mint1: accounts.token_mint1, - token_vault0: accounts.token_vault0, - token_vault1: accounts.token_vault1, - observation_state: accounts.observation_state, - tick_array_bitmap: accounts.tick_array_bitmap, - token_program0: accounts.token_program0, - token_program1: accounts.token_program1, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_bitmap.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreatePoolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_creator.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.token_mint0.clone()); - account_infos.push(self.token_mint1.clone()); - account_infos.push(self.token_vault0.clone()); - account_infos.push(self.token_vault1.clone()); - account_infos.push(self.observation_state.clone()); - account_infos.push(self.tick_array_bitmap.clone()); - account_infos.push(self.token_program0.clone()); - account_infos.push(self.token_program1.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreatePool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` pool_creator -/// 1. `[]` amm_config -/// 2. `[writable]` pool_state -/// 3. `[]` token_mint0 -/// 4. `[]` token_mint1 -/// 5. `[writable]` token_vault0 -/// 6. `[writable]` token_vault1 -/// 7. `[writable]` observation_state -/// 8. `[writable]` tick_array_bitmap -/// 9. `[]` token_program0 -/// 10. `[]` token_program1 -/// 11. `[]` system_program -/// 12. `[]` rent -#[derive(Clone, Debug)] -pub struct CreatePoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreatePoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreatePoolCpiBuilderInstruction { - __program: program, - pool_creator: None, - amm_config: None, - pool_state: None, - token_mint0: None, - token_mint1: None, - token_vault0: None, - token_vault1: None, - observation_state: None, - tick_array_bitmap: None, - token_program0: None, - token_program1: None, - system_program: None, - rent: None, - sqrt_price_x64: None, - open_time: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_creator( - &mut self, - pool_creator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_creator = Some(pool_creator); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn token_mint0( - &mut self, - token_mint0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint0 = Some(token_mint0); - self - } - - #[inline(always)] - pub fn token_mint1( - &mut self, - token_mint1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint1 = Some(token_mint1); - self - } - - #[inline(always)] - pub fn token_vault0( - &mut self, - token_vault0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1( - &mut self, - token_vault1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn tick_array_bitmap( - &mut self, - tick_array_bitmap: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_bitmap = Some(tick_array_bitmap); - self - } - - #[inline(always)] - pub fn token_program0( - &mut self, - token_program0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program0 = Some(token_program0); - self - } - - #[inline(always)] - pub fn token_program1( - &mut self, - token_program1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program1 = Some(token_program1); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn sqrt_price_x64(&mut self, sqrt_price_x64: u128) -> &mut Self { - self.instruction.sqrt_price_x64 = Some(sqrt_price_x64); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.instruction.open_time = Some(open_time); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreatePoolInstructionArgs { - sqrt_price_x64: self - .instruction - .sqrt_price_x64 - .clone() - .expect("sqrt_price_x64 is not set"), - open_time: self - .instruction - .open_time - .clone() - .expect("open_time is not set"), - }; - let instruction = CreatePoolCpi { - __program: self.instruction.__program, - - pool_creator: self - .instruction - .pool_creator - .expect("pool_creator is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - token_mint0: self - .instruction - .token_mint0 - .expect("token_mint0 is not set"), - - token_mint1: self - .instruction - .token_mint1 - .expect("token_mint1 is not set"), - - token_vault0: self - .instruction - .token_vault0 - .expect("token_vault0 is not set"), - - token_vault1: self - .instruction - .token_vault1 - .expect("token_vault1 is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - - tick_array_bitmap: self - .instruction - .tick_array_bitmap - .expect("tick_array_bitmap is not set"), - - token_program0: self - .instruction - .token_program0 - .expect("token_program0 is not set"), - - token_program1: self - .instruction - .token_program1 - .expect("token_program1 is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreatePoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_creator: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault1: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_bitmap: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program1: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - sqrt_price_x64: Option, - open_time: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/decrease_liquidity.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/decrease_liquidity.rs deleted file mode 100644 index c73d4e48..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/decrease_liquidity.rs +++ /dev/null @@ -1,838 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct DecreaseLiquidity { - pub nft_owner: solana_pubkey::Pubkey, - - pub nft_account: solana_pubkey::Pubkey, - - pub personal_position: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub protocol_position: solana_pubkey::Pubkey, - - pub token_vault0: solana_pubkey::Pubkey, - - pub token_vault1: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, - - pub recipient_token_account0: solana_pubkey::Pubkey, - - pub recipient_token_account1: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl DecreaseLiquidity { - pub fn instruction( - &self, - args: DecreaseLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DecreaseLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.nft_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.personal_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DecreaseLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DecreaseLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl DecreaseLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [160, 38, 208, 111, 104, 91, 44, 1], - } - } -} - -impl Default for DecreaseLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DecreaseLiquidityInstructionArgs { - pub liquidity: u128, - pub amount0_min: u64, - pub amount1_min: u64, -} - -/// Instruction builder for `DecreaseLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` nft_owner -/// 1. `[]` nft_account -/// 2. `[writable]` personal_position -/// 3. `[writable]` pool_state -/// 4. `[writable]` protocol_position -/// 5. `[writable]` token_vault0 -/// 6. `[writable]` token_vault1 -/// 7. `[writable]` tick_array_lower -/// 8. `[writable]` tick_array_upper -/// 9. `[writable]` recipient_token_account0 -/// 10. `[writable]` recipient_token_account1 -/// 11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct DecreaseLiquidityBuilder { - nft_owner: Option, - nft_account: Option, - personal_position: Option, - pool_state: Option, - protocol_position: Option, - token_vault0: Option, - token_vault1: Option, - tick_array_lower: Option, - tick_array_upper: Option, - recipient_token_account0: Option, - recipient_token_account1: Option, - token_program: Option, - liquidity: Option, - amount0_min: Option, - amount1_min: Option, - __remaining_accounts: Vec, -} - -impl DecreaseLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn nft_owner(&mut self, nft_owner: solana_pubkey::Pubkey) -> &mut Self { - self.nft_owner = Some(nft_owner); - self - } - - #[inline(always)] - pub fn nft_account(&mut self, nft_account: solana_pubkey::Pubkey) -> &mut Self { - self.nft_account = Some(nft_account); - self - } - - #[inline(always)] - pub fn personal_position(&mut self, personal_position: solana_pubkey::Pubkey) -> &mut Self { - self.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position(&mut self, protocol_position: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn token_vault0(&mut self, token_vault0: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1(&mut self, token_vault1: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn recipient_token_account0( - &mut self, - recipient_token_account0: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account0 = Some(recipient_token_account0); - self - } - - #[inline(always)] - pub fn recipient_token_account1( - &mut self, - recipient_token_account1: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account1 = Some(recipient_token_account1); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_min(&mut self, amount0_min: u64) -> &mut Self { - self.amount0_min = Some(amount0_min); - self - } - - #[inline(always)] - pub fn amount1_min(&mut self, amount1_min: u64) -> &mut Self { - self.amount1_min = Some(amount1_min); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = DecreaseLiquidity { - nft_owner: self.nft_owner.expect("nft_owner is not set"), - nft_account: self.nft_account.expect("nft_account is not set"), - personal_position: self - .personal_position - .expect("personal_position is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - protocol_position: self - .protocol_position - .expect("protocol_position is not set"), - token_vault0: self.token_vault0.expect("token_vault0 is not set"), - token_vault1: self.token_vault1.expect("token_vault1 is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - recipient_token_account0: self - .recipient_token_account0 - .expect("recipient_token_account0 is not set"), - recipient_token_account1: self - .recipient_token_account1 - .expect("recipient_token_account1 is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = DecreaseLiquidityInstructionArgs { - liquidity: self.liquidity.clone().expect("liquidity is not set"), - amount0_min: self.amount0_min.clone().expect("amount0_min is not set"), - amount1_min: self.amount1_min.clone().expect("amount1_min is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `decrease_liquidity` CPI accounts. -pub struct DecreaseLiquidityCpiAccounts<'a, 'b> { - pub nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `decrease_liquidity` CPI instruction. -pub struct DecreaseLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DecreaseLiquidityInstructionArgs, -} - -impl<'a, 'b> DecreaseLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DecreaseLiquidityCpiAccounts<'a, 'b>, - args: DecreaseLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - nft_owner: accounts.nft_owner, - nft_account: accounts.nft_account, - personal_position: accounts.personal_position, - pool_state: accounts.pool_state, - protocol_position: accounts.protocol_position, - token_vault0: accounts.token_vault0, - token_vault1: accounts.token_vault1, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - recipient_token_account0: accounts.recipient_token_account0, - recipient_token_account1: accounts.recipient_token_account1, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.nft_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.personal_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DecreaseLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.nft_owner.clone()); - account_infos.push(self.nft_account.clone()); - account_infos.push(self.personal_position.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.protocol_position.clone()); - account_infos.push(self.token_vault0.clone()); - account_infos.push(self.token_vault1.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - account_infos.push(self.recipient_token_account0.clone()); - account_infos.push(self.recipient_token_account1.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `DecreaseLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` nft_owner -/// 1. `[]` nft_account -/// 2. `[writable]` personal_position -/// 3. `[writable]` pool_state -/// 4. `[writable]` protocol_position -/// 5. `[writable]` token_vault0 -/// 6. `[writable]` token_vault1 -/// 7. `[writable]` tick_array_lower -/// 8. `[writable]` tick_array_upper -/// 9. `[writable]` recipient_token_account0 -/// 10. `[writable]` recipient_token_account1 -/// 11. `[]` token_program -#[derive(Clone, Debug)] -pub struct DecreaseLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DecreaseLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DecreaseLiquidityCpiBuilderInstruction { - __program: program, - nft_owner: None, - nft_account: None, - personal_position: None, - pool_state: None, - protocol_position: None, - token_vault0: None, - token_vault1: None, - tick_array_lower: None, - tick_array_upper: None, - recipient_token_account0: None, - recipient_token_account1: None, - token_program: None, - liquidity: None, - amount0_min: None, - amount1_min: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn nft_owner(&mut self, nft_owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.nft_owner = Some(nft_owner); - self - } - - #[inline(always)] - pub fn nft_account( - &mut self, - nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.nft_account = Some(nft_account); - self - } - - #[inline(always)] - pub fn personal_position( - &mut self, - personal_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position( - &mut self, - protocol_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn token_vault0( - &mut self, - token_vault0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1( - &mut self, - token_vault1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn recipient_token_account0( - &mut self, - recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account0 = Some(recipient_token_account0); - self - } - - #[inline(always)] - pub fn recipient_token_account1( - &mut self, - recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account1 = Some(recipient_token_account1); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.instruction.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_min(&mut self, amount0_min: u64) -> &mut Self { - self.instruction.amount0_min = Some(amount0_min); - self - } - - #[inline(always)] - pub fn amount1_min(&mut self, amount1_min: u64) -> &mut Self { - self.instruction.amount1_min = Some(amount1_min); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DecreaseLiquidityInstructionArgs { - liquidity: self - .instruction - .liquidity - .clone() - .expect("liquidity is not set"), - amount0_min: self - .instruction - .amount0_min - .clone() - .expect("amount0_min is not set"), - amount1_min: self - .instruction - .amount1_min - .clone() - .expect("amount1_min is not set"), - }; - let instruction = DecreaseLiquidityCpi { - __program: self.instruction.__program, - - nft_owner: self.instruction.nft_owner.expect("nft_owner is not set"), - - nft_account: self - .instruction - .nft_account - .expect("nft_account is not set"), - - personal_position: self - .instruction - .personal_position - .expect("personal_position is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - protocol_position: self - .instruction - .protocol_position - .expect("protocol_position is not set"), - - token_vault0: self - .instruction - .token_vault0 - .expect("token_vault0 is not set"), - - token_vault1: self - .instruction - .token_vault1 - .expect("token_vault1 is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - - recipient_token_account0: self - .instruction - .recipient_token_account0 - .expect("recipient_token_account0 is not set"), - - recipient_token_account1: self - .instruction - .recipient_token_account1 - .expect("recipient_token_account1 is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DecreaseLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - nft_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - personal_position: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault1: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account0: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity: Option, - amount0_min: Option, - amount1_min: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/decrease_liquidity_v2.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/decrease_liquidity_v2.rs deleted file mode 100644 index f062f9f2..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/decrease_liquidity_v2.rs +++ /dev/null @@ -1,1008 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct DecreaseLiquidityV2 { - pub nft_owner: solana_pubkey::Pubkey, - - pub nft_account: solana_pubkey::Pubkey, - - pub personal_position: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub protocol_position: solana_pubkey::Pubkey, - - pub token_vault0: solana_pubkey::Pubkey, - - pub token_vault1: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, - - pub recipient_token_account0: solana_pubkey::Pubkey, - - pub recipient_token_account1: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token_program2022: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub vault0_mint: solana_pubkey::Pubkey, - - pub vault1_mint: solana_pubkey::Pubkey, -} - -impl DecreaseLiquidityV2 { - pub fn instruction( - &self, - args: DecreaseLiquidityV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DecreaseLiquidityV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.nft_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.personal_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DecreaseLiquidityV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DecreaseLiquidityV2InstructionData { - discriminator: [u8; 8], -} - -impl DecreaseLiquidityV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [58, 127, 188, 62, 79, 82, 196, 96], - } - } -} - -impl Default for DecreaseLiquidityV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DecreaseLiquidityV2InstructionArgs { - pub liquidity: u128, - pub amount0_min: u64, - pub amount1_min: u64, -} - -/// Instruction builder for `DecreaseLiquidityV2`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` nft_owner -/// 1. `[]` nft_account -/// 2. `[writable]` personal_position -/// 3. `[writable]` pool_state -/// 4. `[writable]` protocol_position -/// 5. `[writable]` token_vault0 -/// 6. `[writable]` token_vault1 -/// 7. `[writable]` tick_array_lower -/// 8. `[writable]` tick_array_upper -/// 9. `[writable]` recipient_token_account0 -/// 10. `[writable]` recipient_token_account1 -/// 11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 12. `[]` token_program2022 -/// 13. `[]` memo_program -/// 14. `[]` vault0_mint -/// 15. `[]` vault1_mint -#[derive(Clone, Debug, Default)] -pub struct DecreaseLiquidityV2Builder { - nft_owner: Option, - nft_account: Option, - personal_position: Option, - pool_state: Option, - protocol_position: Option, - token_vault0: Option, - token_vault1: Option, - tick_array_lower: Option, - tick_array_upper: Option, - recipient_token_account0: Option, - recipient_token_account1: Option, - token_program: Option, - token_program2022: Option, - memo_program: Option, - vault0_mint: Option, - vault1_mint: Option, - liquidity: Option, - amount0_min: Option, - amount1_min: Option, - __remaining_accounts: Vec, -} - -impl DecreaseLiquidityV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn nft_owner(&mut self, nft_owner: solana_pubkey::Pubkey) -> &mut Self { - self.nft_owner = Some(nft_owner); - self - } - - #[inline(always)] - pub fn nft_account(&mut self, nft_account: solana_pubkey::Pubkey) -> &mut Self { - self.nft_account = Some(nft_account); - self - } - - #[inline(always)] - pub fn personal_position(&mut self, personal_position: solana_pubkey::Pubkey) -> &mut Self { - self.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position(&mut self, protocol_position: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn token_vault0(&mut self, token_vault0: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1(&mut self, token_vault1: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn recipient_token_account0( - &mut self, - recipient_token_account0: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account0 = Some(recipient_token_account0); - self - } - - #[inline(always)] - pub fn recipient_token_account1( - &mut self, - recipient_token_account1: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account1 = Some(recipient_token_account1); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_min(&mut self, amount0_min: u64) -> &mut Self { - self.amount0_min = Some(amount0_min); - self - } - - #[inline(always)] - pub fn amount1_min(&mut self, amount1_min: u64) -> &mut Self { - self.amount1_min = Some(amount1_min); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = DecreaseLiquidityV2 { - nft_owner: self.nft_owner.expect("nft_owner is not set"), - nft_account: self.nft_account.expect("nft_account is not set"), - personal_position: self - .personal_position - .expect("personal_position is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - protocol_position: self - .protocol_position - .expect("protocol_position is not set"), - token_vault0: self.token_vault0.expect("token_vault0 is not set"), - token_vault1: self.token_vault1.expect("token_vault1 is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - recipient_token_account0: self - .recipient_token_account0 - .expect("recipient_token_account0 is not set"), - recipient_token_account1: self - .recipient_token_account1 - .expect("recipient_token_account1 is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self - .token_program2022 - .expect("token_program2022 is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - }; - let args = DecreaseLiquidityV2InstructionArgs { - liquidity: self.liquidity.clone().expect("liquidity is not set"), - amount0_min: self.amount0_min.clone().expect("amount0_min is not set"), - amount1_min: self.amount1_min.clone().expect("amount1_min is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `decrease_liquidity_v2` CPI accounts. -pub struct DecreaseLiquidityV2CpiAccounts<'a, 'b> { - pub nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, -} - -/// `decrease_liquidity_v2` CPI instruction. -pub struct DecreaseLiquidityV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DecreaseLiquidityV2InstructionArgs, -} - -impl<'a, 'b> DecreaseLiquidityV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DecreaseLiquidityV2CpiAccounts<'a, 'b>, - args: DecreaseLiquidityV2InstructionArgs, - ) -> Self { - Self { - __program: program, - nft_owner: accounts.nft_owner, - nft_account: accounts.nft_account, - personal_position: accounts.personal_position, - pool_state: accounts.pool_state, - protocol_position: accounts.protocol_position, - token_vault0: accounts.token_vault0, - token_vault1: accounts.token_vault1, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - recipient_token_account0: accounts.recipient_token_account0, - recipient_token_account1: accounts.recipient_token_account1, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - memo_program: accounts.memo_program, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.nft_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.personal_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DecreaseLiquidityV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.nft_owner.clone()); - account_infos.push(self.nft_account.clone()); - account_infos.push(self.personal_position.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.protocol_position.clone()); - account_infos.push(self.token_vault0.clone()); - account_infos.push(self.token_vault1.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - account_infos.push(self.recipient_token_account0.clone()); - account_infos.push(self.recipient_token_account1.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `DecreaseLiquidityV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` nft_owner -/// 1. `[]` nft_account -/// 2. `[writable]` personal_position -/// 3. `[writable]` pool_state -/// 4. `[writable]` protocol_position -/// 5. `[writable]` token_vault0 -/// 6. `[writable]` token_vault1 -/// 7. `[writable]` tick_array_lower -/// 8. `[writable]` tick_array_upper -/// 9. `[writable]` recipient_token_account0 -/// 10. `[writable]` recipient_token_account1 -/// 11. `[]` token_program -/// 12. `[]` token_program2022 -/// 13. `[]` memo_program -/// 14. `[]` vault0_mint -/// 15. `[]` vault1_mint -#[derive(Clone, Debug)] -pub struct DecreaseLiquidityV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DecreaseLiquidityV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DecreaseLiquidityV2CpiBuilderInstruction { - __program: program, - nft_owner: None, - nft_account: None, - personal_position: None, - pool_state: None, - protocol_position: None, - token_vault0: None, - token_vault1: None, - tick_array_lower: None, - tick_array_upper: None, - recipient_token_account0: None, - recipient_token_account1: None, - token_program: None, - token_program2022: None, - memo_program: None, - vault0_mint: None, - vault1_mint: None, - liquidity: None, - amount0_min: None, - amount1_min: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn nft_owner(&mut self, nft_owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.nft_owner = Some(nft_owner); - self - } - - #[inline(always)] - pub fn nft_account( - &mut self, - nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.nft_account = Some(nft_account); - self - } - - #[inline(always)] - pub fn personal_position( - &mut self, - personal_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position( - &mut self, - protocol_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn token_vault0( - &mut self, - token_vault0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1( - &mut self, - token_vault1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn recipient_token_account0( - &mut self, - recipient_token_account0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account0 = Some(recipient_token_account0); - self - } - - #[inline(always)] - pub fn recipient_token_account1( - &mut self, - recipient_token_account1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account1 = Some(recipient_token_account1); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.instruction.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_min(&mut self, amount0_min: u64) -> &mut Self { - self.instruction.amount0_min = Some(amount0_min); - self - } - - #[inline(always)] - pub fn amount1_min(&mut self, amount1_min: u64) -> &mut Self { - self.instruction.amount1_min = Some(amount1_min); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DecreaseLiquidityV2InstructionArgs { - liquidity: self - .instruction - .liquidity - .clone() - .expect("liquidity is not set"), - amount0_min: self - .instruction - .amount0_min - .clone() - .expect("amount0_min is not set"), - amount1_min: self - .instruction - .amount1_min - .clone() - .expect("amount1_min is not set"), - }; - let instruction = DecreaseLiquidityV2Cpi { - __program: self.instruction.__program, - - nft_owner: self.instruction.nft_owner.expect("nft_owner is not set"), - - nft_account: self - .instruction - .nft_account - .expect("nft_account is not set"), - - personal_position: self - .instruction - .personal_position - .expect("personal_position is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - protocol_position: self - .instruction - .protocol_position - .expect("protocol_position is not set"), - - token_vault0: self - .instruction - .token_vault0 - .expect("token_vault0 is not set"), - - token_vault1: self - .instruction - .token_vault1 - .expect("token_vault1 is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - - recipient_token_account0: self - .instruction - .recipient_token_account0 - .expect("recipient_token_account0 is not set"), - - recipient_token_account1: self - .instruction - .recipient_token_account1 - .expect("recipient_token_account1 is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DecreaseLiquidityV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - nft_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - personal_position: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault1: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account0: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity: Option, - amount0_min: Option, - amount1_min: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/increase_liquidity.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/increase_liquidity.rs deleted file mode 100644 index 1d37ca58..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/increase_liquidity.rs +++ /dev/null @@ -1,828 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct IncreaseLiquidity { - pub nft_owner: solana_pubkey::Pubkey, - - pub nft_account: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub protocol_position: solana_pubkey::Pubkey, - - pub personal_position: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, - - pub token_account0: solana_pubkey::Pubkey, - - pub token_account1: solana_pubkey::Pubkey, - - pub token_vault0: solana_pubkey::Pubkey, - - pub token_vault1: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl IncreaseLiquidity { - pub fn instruction( - &self, - args: IncreaseLiquidityInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: IncreaseLiquidityInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.nft_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.personal_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&IncreaseLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IncreaseLiquidityInstructionData { - discriminator: [u8; 8], -} - -impl IncreaseLiquidityInstructionData { - pub fn new() -> Self { - Self { - discriminator: [46, 156, 243, 118, 13, 205, 251, 178], - } - } -} - -impl Default for IncreaseLiquidityInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IncreaseLiquidityInstructionArgs { - pub liquidity: u128, - pub amount0_max: u64, - pub amount1_max: u64, -} - -/// Instruction builder for `IncreaseLiquidity`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` nft_owner -/// 1. `[]` nft_account -/// 2. `[writable]` pool_state -/// 3. `[writable]` protocol_position -/// 4. `[writable]` personal_position -/// 5. `[writable]` tick_array_lower -/// 6. `[writable]` tick_array_upper -/// 7. `[writable]` token_account0 -/// 8. `[writable]` token_account1 -/// 9. `[writable]` token_vault0 -/// 10. `[writable]` token_vault1 -/// 11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct IncreaseLiquidityBuilder { - nft_owner: Option, - nft_account: Option, - pool_state: Option, - protocol_position: Option, - personal_position: Option, - tick_array_lower: Option, - tick_array_upper: Option, - token_account0: Option, - token_account1: Option, - token_vault0: Option, - token_vault1: Option, - token_program: Option, - liquidity: Option, - amount0_max: Option, - amount1_max: Option, - __remaining_accounts: Vec, -} - -impl IncreaseLiquidityBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn nft_owner(&mut self, nft_owner: solana_pubkey::Pubkey) -> &mut Self { - self.nft_owner = Some(nft_owner); - self - } - - #[inline(always)] - pub fn nft_account(&mut self, nft_account: solana_pubkey::Pubkey) -> &mut Self { - self.nft_account = Some(nft_account); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position(&mut self, protocol_position: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn personal_position(&mut self, personal_position: solana_pubkey::Pubkey) -> &mut Self { - self.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn token_account0(&mut self, token_account0: solana_pubkey::Pubkey) -> &mut Self { - self.token_account0 = Some(token_account0); - self - } - - #[inline(always)] - pub fn token_account1(&mut self, token_account1: solana_pubkey::Pubkey) -> &mut Self { - self.token_account1 = Some(token_account1); - self - } - - #[inline(always)] - pub fn token_vault0(&mut self, token_vault0: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1(&mut self, token_vault1: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault1 = Some(token_vault1); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_max(&mut self, amount0_max: u64) -> &mut Self { - self.amount0_max = Some(amount0_max); - self - } - - #[inline(always)] - pub fn amount1_max(&mut self, amount1_max: u64) -> &mut Self { - self.amount1_max = Some(amount1_max); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = IncreaseLiquidity { - nft_owner: self.nft_owner.expect("nft_owner is not set"), - nft_account: self.nft_account.expect("nft_account is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - protocol_position: self - .protocol_position - .expect("protocol_position is not set"), - personal_position: self - .personal_position - .expect("personal_position is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - token_account0: self.token_account0.expect("token_account0 is not set"), - token_account1: self.token_account1.expect("token_account1 is not set"), - token_vault0: self.token_vault0.expect("token_vault0 is not set"), - token_vault1: self.token_vault1.expect("token_vault1 is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = IncreaseLiquidityInstructionArgs { - liquidity: self.liquidity.clone().expect("liquidity is not set"), - amount0_max: self.amount0_max.clone().expect("amount0_max is not set"), - amount1_max: self.amount1_max.clone().expect("amount1_max is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `increase_liquidity` CPI accounts. -pub struct IncreaseLiquidityCpiAccounts<'a, 'b> { - pub nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `increase_liquidity` CPI instruction. -pub struct IncreaseLiquidityCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: IncreaseLiquidityInstructionArgs, -} - -impl<'a, 'b> IncreaseLiquidityCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: IncreaseLiquidityCpiAccounts<'a, 'b>, - args: IncreaseLiquidityInstructionArgs, - ) -> Self { - Self { - __program: program, - nft_owner: accounts.nft_owner, - nft_account: accounts.nft_account, - pool_state: accounts.pool_state, - protocol_position: accounts.protocol_position, - personal_position: accounts.personal_position, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - token_account0: accounts.token_account0, - token_account1: accounts.token_account1, - token_vault0: accounts.token_vault0, - token_vault1: accounts.token_vault1, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.nft_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.personal_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&IncreaseLiquidityInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.nft_owner.clone()); - account_infos.push(self.nft_account.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.protocol_position.clone()); - account_infos.push(self.personal_position.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - account_infos.push(self.token_account0.clone()); - account_infos.push(self.token_account1.clone()); - account_infos.push(self.token_vault0.clone()); - account_infos.push(self.token_vault1.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `IncreaseLiquidity` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` nft_owner -/// 1. `[]` nft_account -/// 2. `[writable]` pool_state -/// 3. `[writable]` protocol_position -/// 4. `[writable]` personal_position -/// 5. `[writable]` tick_array_lower -/// 6. `[writable]` tick_array_upper -/// 7. `[writable]` token_account0 -/// 8. `[writable]` token_account1 -/// 9. `[writable]` token_vault0 -/// 10. `[writable]` token_vault1 -/// 11. `[]` token_program -#[derive(Clone, Debug)] -pub struct IncreaseLiquidityCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> IncreaseLiquidityCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(IncreaseLiquidityCpiBuilderInstruction { - __program: program, - nft_owner: None, - nft_account: None, - pool_state: None, - protocol_position: None, - personal_position: None, - tick_array_lower: None, - tick_array_upper: None, - token_account0: None, - token_account1: None, - token_vault0: None, - token_vault1: None, - token_program: None, - liquidity: None, - amount0_max: None, - amount1_max: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn nft_owner(&mut self, nft_owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.nft_owner = Some(nft_owner); - self - } - - #[inline(always)] - pub fn nft_account( - &mut self, - nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.nft_account = Some(nft_account); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position( - &mut self, - protocol_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn personal_position( - &mut self, - personal_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn token_account0( - &mut self, - token_account0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account0 = Some(token_account0); - self - } - - #[inline(always)] - pub fn token_account1( - &mut self, - token_account1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account1 = Some(token_account1); - self - } - - #[inline(always)] - pub fn token_vault0( - &mut self, - token_vault0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1( - &mut self, - token_vault1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.instruction.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_max(&mut self, amount0_max: u64) -> &mut Self { - self.instruction.amount0_max = Some(amount0_max); - self - } - - #[inline(always)] - pub fn amount1_max(&mut self, amount1_max: u64) -> &mut Self { - self.instruction.amount1_max = Some(amount1_max); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = IncreaseLiquidityInstructionArgs { - liquidity: self - .instruction - .liquidity - .clone() - .expect("liquidity is not set"), - amount0_max: self - .instruction - .amount0_max - .clone() - .expect("amount0_max is not set"), - amount1_max: self - .instruction - .amount1_max - .clone() - .expect("amount1_max is not set"), - }; - let instruction = IncreaseLiquidityCpi { - __program: self.instruction.__program, - - nft_owner: self.instruction.nft_owner.expect("nft_owner is not set"), - - nft_account: self - .instruction - .nft_account - .expect("nft_account is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - protocol_position: self - .instruction - .protocol_position - .expect("protocol_position is not set"), - - personal_position: self - .instruction - .personal_position - .expect("personal_position is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - - token_account0: self - .instruction - .token_account0 - .expect("token_account0 is not set"), - - token_account1: self - .instruction - .token_account1 - .expect("token_account1 is not set"), - - token_vault0: self - .instruction - .token_vault0 - .expect("token_vault0 is not set"), - - token_vault1: self - .instruction - .token_vault1 - .expect("token_vault1 is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct IncreaseLiquidityCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - nft_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_position: Option<&'b solana_account_info::AccountInfo<'a>>, - personal_position: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity: Option, - amount0_max: Option, - amount1_max: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/increase_liquidity_v2.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/increase_liquidity_v2.rs deleted file mode 100644 index d00263be..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/increase_liquidity_v2.rs +++ /dev/null @@ -1,976 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct IncreaseLiquidityV2 { - pub nft_owner: solana_pubkey::Pubkey, - - pub nft_account: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub protocol_position: solana_pubkey::Pubkey, - - pub personal_position: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, - - pub token_account0: solana_pubkey::Pubkey, - - pub token_account1: solana_pubkey::Pubkey, - - pub token_vault0: solana_pubkey::Pubkey, - - pub token_vault1: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token_program2022: solana_pubkey::Pubkey, - - pub vault0_mint: solana_pubkey::Pubkey, - - pub vault1_mint: solana_pubkey::Pubkey, -} - -impl IncreaseLiquidityV2 { - pub fn instruction( - &self, - args: IncreaseLiquidityV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: IncreaseLiquidityV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.nft_owner, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.personal_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&IncreaseLiquidityV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IncreaseLiquidityV2InstructionData { - discriminator: [u8; 8], -} - -impl IncreaseLiquidityV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [133, 29, 89, 223, 69, 238, 176, 10], - } - } -} - -impl Default for IncreaseLiquidityV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct IncreaseLiquidityV2InstructionArgs { - pub liquidity: u128, - pub amount0_max: u64, - pub amount1_max: u64, - pub base_flag: Option, -} - -/// Instruction builder for `IncreaseLiquidityV2`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` nft_owner -/// 1. `[]` nft_account -/// 2. `[writable]` pool_state -/// 3. `[writable]` protocol_position -/// 4. `[writable]` personal_position -/// 5. `[writable]` tick_array_lower -/// 6. `[writable]` tick_array_upper -/// 7. `[writable]` token_account0 -/// 8. `[writable]` token_account1 -/// 9. `[writable]` token_vault0 -/// 10. `[writable]` token_vault1 -/// 11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 12. `[]` token_program2022 -/// 13. `[]` vault0_mint -/// 14. `[]` vault1_mint -#[derive(Clone, Debug, Default)] -pub struct IncreaseLiquidityV2Builder { - nft_owner: Option, - nft_account: Option, - pool_state: Option, - protocol_position: Option, - personal_position: Option, - tick_array_lower: Option, - tick_array_upper: Option, - token_account0: Option, - token_account1: Option, - token_vault0: Option, - token_vault1: Option, - token_program: Option, - token_program2022: Option, - vault0_mint: Option, - vault1_mint: Option, - liquidity: Option, - amount0_max: Option, - amount1_max: Option, - base_flag: Option, - __remaining_accounts: Vec, -} - -impl IncreaseLiquidityV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn nft_owner(&mut self, nft_owner: solana_pubkey::Pubkey) -> &mut Self { - self.nft_owner = Some(nft_owner); - self - } - - #[inline(always)] - pub fn nft_account(&mut self, nft_account: solana_pubkey::Pubkey) -> &mut Self { - self.nft_account = Some(nft_account); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position(&mut self, protocol_position: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn personal_position(&mut self, personal_position: solana_pubkey::Pubkey) -> &mut Self { - self.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn token_account0(&mut self, token_account0: solana_pubkey::Pubkey) -> &mut Self { - self.token_account0 = Some(token_account0); - self - } - - #[inline(always)] - pub fn token_account1(&mut self, token_account1: solana_pubkey::Pubkey) -> &mut Self { - self.token_account1 = Some(token_account1); - self - } - - #[inline(always)] - pub fn token_vault0(&mut self, token_vault0: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1(&mut self, token_vault1: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault1 = Some(token_vault1); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_max(&mut self, amount0_max: u64) -> &mut Self { - self.amount0_max = Some(amount0_max); - self - } - - #[inline(always)] - pub fn amount1_max(&mut self, amount1_max: u64) -> &mut Self { - self.amount1_max = Some(amount1_max); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn base_flag(&mut self, base_flag: bool) -> &mut Self { - self.base_flag = Some(base_flag); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = IncreaseLiquidityV2 { - nft_owner: self.nft_owner.expect("nft_owner is not set"), - nft_account: self.nft_account.expect("nft_account is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - protocol_position: self - .protocol_position - .expect("protocol_position is not set"), - personal_position: self - .personal_position - .expect("personal_position is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - token_account0: self.token_account0.expect("token_account0 is not set"), - token_account1: self.token_account1.expect("token_account1 is not set"), - token_vault0: self.token_vault0.expect("token_vault0 is not set"), - token_vault1: self.token_vault1.expect("token_vault1 is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self - .token_program2022 - .expect("token_program2022 is not set"), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - }; - let args = IncreaseLiquidityV2InstructionArgs { - liquidity: self.liquidity.clone().expect("liquidity is not set"), - amount0_max: self.amount0_max.clone().expect("amount0_max is not set"), - amount1_max: self.amount1_max.clone().expect("amount1_max is not set"), - base_flag: self.base_flag.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `increase_liquidity_v2` CPI accounts. -pub struct IncreaseLiquidityV2CpiAccounts<'a, 'b> { - pub nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, -} - -/// `increase_liquidity_v2` CPI instruction. -pub struct IncreaseLiquidityV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: IncreaseLiquidityV2InstructionArgs, -} - -impl<'a, 'b> IncreaseLiquidityV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: IncreaseLiquidityV2CpiAccounts<'a, 'b>, - args: IncreaseLiquidityV2InstructionArgs, - ) -> Self { - Self { - __program: program, - nft_owner: accounts.nft_owner, - nft_account: accounts.nft_account, - pool_state: accounts.pool_state, - protocol_position: accounts.protocol_position, - personal_position: accounts.personal_position, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - token_account0: accounts.token_account0, - token_account1: accounts.token_account1, - token_vault0: accounts.token_vault0, - token_vault1: accounts.token_vault1, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.nft_owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.personal_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&IncreaseLiquidityV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.nft_owner.clone()); - account_infos.push(self.nft_account.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.protocol_position.clone()); - account_infos.push(self.personal_position.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - account_infos.push(self.token_account0.clone()); - account_infos.push(self.token_account1.clone()); - account_infos.push(self.token_vault0.clone()); - account_infos.push(self.token_vault1.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `IncreaseLiquidityV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` nft_owner -/// 1. `[]` nft_account -/// 2. `[writable]` pool_state -/// 3. `[writable]` protocol_position -/// 4. `[writable]` personal_position -/// 5. `[writable]` tick_array_lower -/// 6. `[writable]` tick_array_upper -/// 7. `[writable]` token_account0 -/// 8. `[writable]` token_account1 -/// 9. `[writable]` token_vault0 -/// 10. `[writable]` token_vault1 -/// 11. `[]` token_program -/// 12. `[]` token_program2022 -/// 13. `[]` vault0_mint -/// 14. `[]` vault1_mint -#[derive(Clone, Debug)] -pub struct IncreaseLiquidityV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> IncreaseLiquidityV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(IncreaseLiquidityV2CpiBuilderInstruction { - __program: program, - nft_owner: None, - nft_account: None, - pool_state: None, - protocol_position: None, - personal_position: None, - tick_array_lower: None, - tick_array_upper: None, - token_account0: None, - token_account1: None, - token_vault0: None, - token_vault1: None, - token_program: None, - token_program2022: None, - vault0_mint: None, - vault1_mint: None, - liquidity: None, - amount0_max: None, - amount1_max: None, - base_flag: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn nft_owner(&mut self, nft_owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.nft_owner = Some(nft_owner); - self - } - - #[inline(always)] - pub fn nft_account( - &mut self, - nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.nft_account = Some(nft_account); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position( - &mut self, - protocol_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn personal_position( - &mut self, - personal_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn token_account0( - &mut self, - token_account0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account0 = Some(token_account0); - self - } - - #[inline(always)] - pub fn token_account1( - &mut self, - token_account1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account1 = Some(token_account1); - self - } - - #[inline(always)] - pub fn token_vault0( - &mut self, - token_vault0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1( - &mut self, - token_vault1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.instruction.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_max(&mut self, amount0_max: u64) -> &mut Self { - self.instruction.amount0_max = Some(amount0_max); - self - } - - #[inline(always)] - pub fn amount1_max(&mut self, amount1_max: u64) -> &mut Self { - self.instruction.amount1_max = Some(amount1_max); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn base_flag(&mut self, base_flag: bool) -> &mut Self { - self.instruction.base_flag = Some(base_flag); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = IncreaseLiquidityV2InstructionArgs { - liquidity: self - .instruction - .liquidity - .clone() - .expect("liquidity is not set"), - amount0_max: self - .instruction - .amount0_max - .clone() - .expect("amount0_max is not set"), - amount1_max: self - .instruction - .amount1_max - .clone() - .expect("amount1_max is not set"), - base_flag: self.instruction.base_flag.clone(), - }; - let instruction = IncreaseLiquidityV2Cpi { - __program: self.instruction.__program, - - nft_owner: self.instruction.nft_owner.expect("nft_owner is not set"), - - nft_account: self - .instruction - .nft_account - .expect("nft_account is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - protocol_position: self - .instruction - .protocol_position - .expect("protocol_position is not set"), - - personal_position: self - .instruction - .personal_position - .expect("personal_position is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - - token_account0: self - .instruction - .token_account0 - .expect("token_account0 is not set"), - - token_account1: self - .instruction - .token_account1 - .expect("token_account1 is not set"), - - token_vault0: self - .instruction - .token_vault0 - .expect("token_vault0 is not set"), - - token_vault1: self - .instruction - .token_vault1 - .expect("token_vault1 is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct IncreaseLiquidityV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - nft_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_position: Option<&'b solana_account_info::AccountInfo<'a>>, - personal_position: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - liquidity: Option, - amount0_max: Option, - amount1_max: Option, - base_flag: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/initialize_reward.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/initialize_reward.rs deleted file mode 100644 index c8bac653..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/initialize_reward.rs +++ /dev/null @@ -1,756 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeReward { - pub reward_funder: solana_pubkey::Pubkey, - - pub funder_token_account: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub operation_state: solana_pubkey::Pubkey, - - pub reward_token_mint: solana_pubkey::Pubkey, - - pub reward_token_vault: solana_pubkey::Pubkey, - - pub reward_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl InitializeReward { - pub fn instruction( - &self, - args: InitializeRewardInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeRewardInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_funder, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.funder_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.reward_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.reward_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeRewardInstructionData { - discriminator: [u8; 8], -} - -impl InitializeRewardInstructionData { - pub fn new() -> Self { - Self { - discriminator: [95, 135, 192, 196, 242, 129, 230, 68], - } - } -} - -impl Default for InitializeRewardInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeRewardInstructionArgs { - pub open_time: u64, - pub end_time: u64, - pub emissions_per_second_x64: u128, -} - -/// Instruction builder for `InitializeReward`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` reward_funder -/// 1. `[writable]` funder_token_account -/// 2. `[]` amm_config -/// 3. `[writable]` pool_state -/// 4. `[]` operation_state -/// 5. `[]` reward_token_mint -/// 6. `[writable]` reward_token_vault -/// 7. `[]` reward_token_program -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeRewardBuilder { - reward_funder: Option, - funder_token_account: Option, - amm_config: Option, - pool_state: Option, - operation_state: Option, - reward_token_mint: Option, - reward_token_vault: Option, - reward_token_program: Option, - system_program: Option, - rent: Option, - open_time: Option, - end_time: Option, - emissions_per_second_x64: Option, - __remaining_accounts: Vec, -} - -impl InitializeRewardBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn reward_funder(&mut self, reward_funder: solana_pubkey::Pubkey) -> &mut Self { - self.reward_funder = Some(reward_funder); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn operation_state(&mut self, operation_state: solana_pubkey::Pubkey) -> &mut Self { - self.operation_state = Some(operation_state); - self - } - - #[inline(always)] - pub fn reward_token_mint(&mut self, reward_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.reward_token_mint = Some(reward_token_mint); - self - } - - #[inline(always)] - pub fn reward_token_vault(&mut self, reward_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.reward_token_vault = Some(reward_token_vault); - self - } - - #[inline(always)] - pub fn reward_token_program( - &mut self, - reward_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.reward_token_program = Some(reward_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.open_time = Some(open_time); - self - } - - #[inline(always)] - pub fn end_time(&mut self, end_time: u64) -> &mut Self { - self.end_time = Some(end_time); - self - } - - #[inline(always)] - pub fn emissions_per_second_x64(&mut self, emissions_per_second_x64: u128) -> &mut Self { - self.emissions_per_second_x64 = Some(emissions_per_second_x64); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeReward { - reward_funder: self.reward_funder.expect("reward_funder is not set"), - funder_token_account: self - .funder_token_account - .expect("funder_token_account is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - operation_state: self.operation_state.expect("operation_state is not set"), - reward_token_mint: self - .reward_token_mint - .expect("reward_token_mint is not set"), - reward_token_vault: self - .reward_token_vault - .expect("reward_token_vault is not set"), - reward_token_program: self - .reward_token_program - .expect("reward_token_program is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = InitializeRewardInstructionArgs { - open_time: self.open_time.clone().expect("open_time is not set"), - end_time: self.end_time.clone().expect("end_time is not set"), - emissions_per_second_x64: self - .emissions_per_second_x64 - .clone() - .expect("emissions_per_second_x64 is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_reward` CPI accounts. -pub struct InitializeRewardCpiAccounts<'a, 'b> { - pub reward_funder: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub operation_state: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_reward` CPI instruction. -pub struct InitializeRewardCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub reward_funder: &'b solana_account_info::AccountInfo<'a>, - - pub funder_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub operation_state: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub reward_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeRewardInstructionArgs, -} - -impl<'a, 'b> InitializeRewardCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeRewardCpiAccounts<'a, 'b>, - args: InitializeRewardInstructionArgs, - ) -> Self { - Self { - __program: program, - reward_funder: accounts.reward_funder, - funder_token_account: accounts.funder_token_account, - amm_config: accounts.amm_config, - pool_state: accounts.pool_state, - operation_state: accounts.operation_state, - reward_token_mint: accounts.reward_token_mint, - reward_token_vault: accounts.reward_token_vault, - reward_token_program: accounts.reward_token_program, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_funder.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.funder_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.reward_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.reward_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeRewardInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.reward_funder.clone()); - account_infos.push(self.funder_token_account.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.operation_state.clone()); - account_infos.push(self.reward_token_mint.clone()); - account_infos.push(self.reward_token_vault.clone()); - account_infos.push(self.reward_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeReward` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` reward_funder -/// 1. `[writable]` funder_token_account -/// 2. `[]` amm_config -/// 3. `[writable]` pool_state -/// 4. `[]` operation_state -/// 5. `[]` reward_token_mint -/// 6. `[writable]` reward_token_vault -/// 7. `[]` reward_token_program -/// 8. `[]` system_program -/// 9. `[]` rent -#[derive(Clone, Debug)] -pub struct InitializeRewardCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeRewardCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeRewardCpiBuilderInstruction { - __program: program, - reward_funder: None, - funder_token_account: None, - amm_config: None, - pool_state: None, - operation_state: None, - reward_token_mint: None, - reward_token_vault: None, - reward_token_program: None, - system_program: None, - rent: None, - open_time: None, - end_time: None, - emissions_per_second_x64: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn reward_funder( - &mut self, - reward_funder: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_funder = Some(reward_funder); - self - } - - #[inline(always)] - pub fn funder_token_account( - &mut self, - funder_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.funder_token_account = Some(funder_token_account); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn operation_state( - &mut self, - operation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.operation_state = Some(operation_state); - self - } - - #[inline(always)] - pub fn reward_token_mint( - &mut self, - reward_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_token_mint = Some(reward_token_mint); - self - } - - #[inline(always)] - pub fn reward_token_vault( - &mut self, - reward_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_token_vault = Some(reward_token_vault); - self - } - - #[inline(always)] - pub fn reward_token_program( - &mut self, - reward_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.reward_token_program = Some(reward_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.instruction.open_time = Some(open_time); - self - } - - #[inline(always)] - pub fn end_time(&mut self, end_time: u64) -> &mut Self { - self.instruction.end_time = Some(end_time); - self - } - - #[inline(always)] - pub fn emissions_per_second_x64(&mut self, emissions_per_second_x64: u128) -> &mut Self { - self.instruction.emissions_per_second_x64 = Some(emissions_per_second_x64); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeRewardInstructionArgs { - open_time: self - .instruction - .open_time - .clone() - .expect("open_time is not set"), - end_time: self - .instruction - .end_time - .clone() - .expect("end_time is not set"), - emissions_per_second_x64: self - .instruction - .emissions_per_second_x64 - .clone() - .expect("emissions_per_second_x64 is not set"), - }; - let instruction = InitializeRewardCpi { - __program: self.instruction.__program, - - reward_funder: self - .instruction - .reward_funder - .expect("reward_funder is not set"), - - funder_token_account: self - .instruction - .funder_token_account - .expect("funder_token_account is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - operation_state: self - .instruction - .operation_state - .expect("operation_state is not set"), - - reward_token_mint: self - .instruction - .reward_token_mint - .expect("reward_token_mint is not set"), - - reward_token_vault: self - .instruction - .reward_token_vault - .expect("reward_token_vault is not set"), - - reward_token_program: self - .instruction - .reward_token_program - .expect("reward_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeRewardCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - reward_funder: Option<&'b solana_account_info::AccountInfo<'a>>, - funder_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - operation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - open_time: Option, - end_time: Option, - emissions_per_second_x64: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/mod.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index ad45ced2..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#close_position; -pub(crate) mod r#collect_fund_fee; -pub(crate) mod r#collect_protocol_fee; -pub(crate) mod r#collect_remaining_rewards; -pub(crate) mod r#create_amm_config; -pub(crate) mod r#create_operation_account; -pub(crate) mod r#create_pool; -pub(crate) mod r#decrease_liquidity; -pub(crate) mod r#decrease_liquidity_v2; -pub(crate) mod r#increase_liquidity; -pub(crate) mod r#increase_liquidity_v2; -pub(crate) mod r#initialize_reward; -pub(crate) mod r#open_position; -pub(crate) mod r#open_position_v2; -pub(crate) mod r#open_position_with_token22_nft; -pub(crate) mod r#set_reward_params; -pub(crate) mod r#swap; -pub(crate) mod r#swap_router_base_in; -pub(crate) mod r#swap_v2; -pub(crate) mod r#transfer_reward_owner; -pub(crate) mod r#update_amm_config; -pub(crate) mod r#update_operation_account; -pub(crate) mod r#update_pool_status; -pub(crate) mod r#update_reward_infos; - -pub use self::{ - r#close_position::*, r#collect_fund_fee::*, r#collect_protocol_fee::*, - r#collect_remaining_rewards::*, r#create_amm_config::*, r#create_operation_account::*, - r#create_pool::*, r#decrease_liquidity::*, r#decrease_liquidity_v2::*, r#increase_liquidity::*, - r#increase_liquidity_v2::*, r#initialize_reward::*, r#open_position::*, r#open_position_v2::*, - r#open_position_with_token22_nft::*, r#set_reward_params::*, r#swap::*, - r#swap_router_base_in::*, r#swap_v2::*, r#transfer_reward_owner::*, r#update_amm_config::*, - r#update_operation_account::*, r#update_pool_status::*, r#update_reward_infos::*, -}; diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/open_position.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/open_position.rs deleted file mode 100644 index 9533e9d7..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/open_position.rs +++ /dev/null @@ -1,1229 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct OpenPosition { - pub payer: solana_pubkey::Pubkey, - - pub position_nft_owner: solana_pubkey::Pubkey, - - pub position_nft_mint: solana_pubkey::Pubkey, - - pub position_nft_account: solana_pubkey::Pubkey, - - pub metadata_account: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub protocol_position: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, - - pub personal_position: solana_pubkey::Pubkey, - - pub token_account0: solana_pubkey::Pubkey, - - pub token_account1: solana_pubkey::Pubkey, - - pub token_vault0: solana_pubkey::Pubkey, - - pub token_vault1: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, -} - -impl OpenPosition { - pub fn instruction( - &self, - args: OpenPositionInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: OpenPositionInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(19 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.metadata_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.personal_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&OpenPositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionInstructionData { - discriminator: [u8; 8], -} - -impl OpenPositionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [135, 128, 47, 77, 15, 152, 240, 49], - } - } -} - -impl Default for OpenPositionInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionInstructionArgs { - pub tick_lower_index: i32, - pub tick_upper_index: i32, - pub tick_array_lower_start_index: i32, - pub tick_array_upper_start_index: i32, - pub liquidity: u128, - pub amount0_max: u64, - pub amount1_max: u64, -} - -/// Instruction builder for `OpenPosition`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` position_nft_owner -/// 2. `[writable, signer]` position_nft_mint -/// 3. `[writable]` position_nft_account -/// 4. `[writable]` metadata_account -/// 5. `[writable]` pool_state -/// 6. `[writable]` protocol_position -/// 7. `[writable]` tick_array_lower -/// 8. `[writable]` tick_array_upper -/// 9. `[writable]` personal_position -/// 10. `[writable]` token_account0 -/// 11. `[writable]` token_account1 -/// 12. `[writable]` token_vault0 -/// 13. `[writable]` token_vault1 -/// 14. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 15. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 16. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 17. `[]` associated_token_program -/// 18. `[]` metadata_program -#[derive(Clone, Debug, Default)] -pub struct OpenPositionBuilder { - payer: Option, - position_nft_owner: Option, - position_nft_mint: Option, - position_nft_account: Option, - metadata_account: Option, - pool_state: Option, - protocol_position: Option, - tick_array_lower: Option, - tick_array_upper: Option, - personal_position: Option, - token_account0: Option, - token_account1: Option, - token_vault0: Option, - token_vault1: Option, - rent: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - metadata_program: Option, - tick_lower_index: Option, - tick_upper_index: Option, - tick_array_lower_start_index: Option, - tick_array_upper_start_index: Option, - liquidity: Option, - amount0_max: Option, - amount1_max: Option, - __remaining_accounts: Vec, -} - -impl OpenPositionBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn position_nft_owner(&mut self, position_nft_owner: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_owner = Some(position_nft_owner); - self - } - - #[inline(always)] - pub fn position_nft_mint(&mut self, position_nft_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_mint = Some(position_nft_mint); - self - } - - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn metadata_account(&mut self, metadata_account: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_account = Some(metadata_account); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position(&mut self, protocol_position: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn personal_position(&mut self, personal_position: solana_pubkey::Pubkey) -> &mut Self { - self.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn token_account0(&mut self, token_account0: solana_pubkey::Pubkey) -> &mut Self { - self.token_account0 = Some(token_account0); - self - } - - #[inline(always)] - pub fn token_account1(&mut self, token_account1: solana_pubkey::Pubkey) -> &mut Self { - self.token_account1 = Some(token_account1); - self - } - - #[inline(always)] - pub fn token_vault0(&mut self, token_vault0: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1(&mut self, token_vault1: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault1 = Some(token_vault1); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.tick_upper_index = Some(tick_upper_index); - self - } - - #[inline(always)] - pub fn tick_array_lower_start_index(&mut self, tick_array_lower_start_index: i32) -> &mut Self { - self.tick_array_lower_start_index = Some(tick_array_lower_start_index); - self - } - - #[inline(always)] - pub fn tick_array_upper_start_index(&mut self, tick_array_upper_start_index: i32) -> &mut Self { - self.tick_array_upper_start_index = Some(tick_array_upper_start_index); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_max(&mut self, amount0_max: u64) -> &mut Self { - self.amount0_max = Some(amount0_max); - self - } - - #[inline(always)] - pub fn amount1_max(&mut self, amount1_max: u64) -> &mut Self { - self.amount1_max = Some(amount1_max); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = OpenPosition { - payer: self.payer.expect("payer is not set"), - position_nft_owner: self - .position_nft_owner - .expect("position_nft_owner is not set"), - position_nft_mint: self - .position_nft_mint - .expect("position_nft_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - metadata_account: self.metadata_account.expect("metadata_account is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - protocol_position: self - .protocol_position - .expect("protocol_position is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - personal_position: self - .personal_position - .expect("personal_position is not set"), - token_account0: self.token_account0.expect("token_account0 is not set"), - token_account1: self.token_account1.expect("token_account1 is not set"), - token_vault0: self.token_vault0.expect("token_vault0 is not set"), - token_vault1: self.token_vault1.expect("token_vault1 is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - }; - let args = OpenPositionInstructionArgs { - tick_lower_index: self - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - tick_array_lower_start_index: self - .tick_array_lower_start_index - .clone() - .expect("tick_array_lower_start_index is not set"), - tick_array_upper_start_index: self - .tick_array_upper_start_index - .clone() - .expect("tick_array_upper_start_index is not set"), - liquidity: self.liquidity.clone().expect("liquidity is not set"), - amount0_max: self.amount0_max.clone().expect("amount0_max is not set"), - amount1_max: self.amount1_max.clone().expect("amount1_max is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `open_position` CPI accounts. -pub struct OpenPositionCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `open_position` CPI instruction. -pub struct OpenPositionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: OpenPositionInstructionArgs, -} - -impl<'a, 'b> OpenPositionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: OpenPositionCpiAccounts<'a, 'b>, - args: OpenPositionInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - position_nft_owner: accounts.position_nft_owner, - position_nft_mint: accounts.position_nft_mint, - position_nft_account: accounts.position_nft_account, - metadata_account: accounts.metadata_account, - pool_state: accounts.pool_state, - protocol_position: accounts.protocol_position, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - personal_position: accounts.personal_position, - token_account0: accounts.token_account0, - token_account1: accounts.token_account1, - token_vault0: accounts.token_vault0, - token_vault1: accounts.token_vault1, - rent: accounts.rent, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - metadata_program: accounts.metadata_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(19 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.metadata_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.personal_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&OpenPositionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(20 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.position_nft_owner.clone()); - account_infos.push(self.position_nft_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.metadata_account.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.protocol_position.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - account_infos.push(self.personal_position.clone()); - account_infos.push(self.token_account0.clone()); - account_infos.push(self.token_account1.clone()); - account_infos.push(self.token_vault0.clone()); - account_infos.push(self.token_vault1.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.metadata_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `OpenPosition` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` position_nft_owner -/// 2. `[writable, signer]` position_nft_mint -/// 3. `[writable]` position_nft_account -/// 4. `[writable]` metadata_account -/// 5. `[writable]` pool_state -/// 6. `[writable]` protocol_position -/// 7. `[writable]` tick_array_lower -/// 8. `[writable]` tick_array_upper -/// 9. `[writable]` personal_position -/// 10. `[writable]` token_account0 -/// 11. `[writable]` token_account1 -/// 12. `[writable]` token_vault0 -/// 13. `[writable]` token_vault1 -/// 14. `[]` rent -/// 15. `[]` system_program -/// 16. `[]` token_program -/// 17. `[]` associated_token_program -/// 18. `[]` metadata_program -#[derive(Clone, Debug)] -pub struct OpenPositionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> OpenPositionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(OpenPositionCpiBuilderInstruction { - __program: program, - payer: None, - position_nft_owner: None, - position_nft_mint: None, - position_nft_account: None, - metadata_account: None, - pool_state: None, - protocol_position: None, - tick_array_lower: None, - tick_array_upper: None, - personal_position: None, - token_account0: None, - token_account1: None, - token_vault0: None, - token_vault1: None, - rent: None, - system_program: None, - token_program: None, - associated_token_program: None, - metadata_program: None, - tick_lower_index: None, - tick_upper_index: None, - tick_array_lower_start_index: None, - tick_array_upper_start_index: None, - liquidity: None, - amount0_max: None, - amount1_max: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn position_nft_owner( - &mut self, - position_nft_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_owner = Some(position_nft_owner); - self - } - - #[inline(always)] - pub fn position_nft_mint( - &mut self, - position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_mint = Some(position_nft_mint); - self - } - - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn metadata_account( - &mut self, - metadata_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_account = Some(metadata_account); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position( - &mut self, - protocol_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn personal_position( - &mut self, - personal_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn token_account0( - &mut self, - token_account0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account0 = Some(token_account0); - self - } - - #[inline(always)] - pub fn token_account1( - &mut self, - token_account1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account1 = Some(token_account1); - self - } - - #[inline(always)] - pub fn token_vault0( - &mut self, - token_vault0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1( - &mut self, - token_vault1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.instruction.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.instruction.tick_upper_index = Some(tick_upper_index); - self - } - - #[inline(always)] - pub fn tick_array_lower_start_index(&mut self, tick_array_lower_start_index: i32) -> &mut Self { - self.instruction.tick_array_lower_start_index = Some(tick_array_lower_start_index); - self - } - - #[inline(always)] - pub fn tick_array_upper_start_index(&mut self, tick_array_upper_start_index: i32) -> &mut Self { - self.instruction.tick_array_upper_start_index = Some(tick_array_upper_start_index); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.instruction.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_max(&mut self, amount0_max: u64) -> &mut Self { - self.instruction.amount0_max = Some(amount0_max); - self - } - - #[inline(always)] - pub fn amount1_max(&mut self, amount1_max: u64) -> &mut Self { - self.instruction.amount1_max = Some(amount1_max); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = OpenPositionInstructionArgs { - tick_lower_index: self - .instruction - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .instruction - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - tick_array_lower_start_index: self - .instruction - .tick_array_lower_start_index - .clone() - .expect("tick_array_lower_start_index is not set"), - tick_array_upper_start_index: self - .instruction - .tick_array_upper_start_index - .clone() - .expect("tick_array_upper_start_index is not set"), - liquidity: self - .instruction - .liquidity - .clone() - .expect("liquidity is not set"), - amount0_max: self - .instruction - .amount0_max - .clone() - .expect("amount0_max is not set"), - amount1_max: self - .instruction - .amount1_max - .clone() - .expect("amount1_max is not set"), - }; - let instruction = OpenPositionCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - position_nft_owner: self - .instruction - .position_nft_owner - .expect("position_nft_owner is not set"), - - position_nft_mint: self - .instruction - .position_nft_mint - .expect("position_nft_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - metadata_account: self - .instruction - .metadata_account - .expect("metadata_account is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - protocol_position: self - .instruction - .protocol_position - .expect("protocol_position is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - - personal_position: self - .instruction - .personal_position - .expect("personal_position is not set"), - - token_account0: self - .instruction - .token_account0 - .expect("token_account0 is not set"), - - token_account1: self - .instruction - .token_account1 - .expect("token_account1 is not set"), - - token_vault0: self - .instruction - .token_vault0 - .expect("token_vault0 is not set"), - - token_vault1: self - .instruction - .token_vault1 - .expect("token_vault1 is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct OpenPositionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_position: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - personal_position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault1: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_lower_index: Option, - tick_upper_index: Option, - tick_array_lower_start_index: Option, - tick_array_upper_start_index: Option, - liquidity: Option, - amount0_max: Option, - amount1_max: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/open_position_v2.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/open_position_v2.rs deleted file mode 100644 index 5051a8dc..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/open_position_v2.rs +++ /dev/null @@ -1,1402 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct OpenPositionV2 { - pub payer: solana_pubkey::Pubkey, - - pub position_nft_owner: solana_pubkey::Pubkey, - - pub position_nft_mint: solana_pubkey::Pubkey, - - pub position_nft_account: solana_pubkey::Pubkey, - - pub metadata_account: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub protocol_position: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, - - pub personal_position: solana_pubkey::Pubkey, - - pub token_account0: solana_pubkey::Pubkey, - - pub token_account1: solana_pubkey::Pubkey, - - pub token_vault0: solana_pubkey::Pubkey, - - pub token_vault1: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - - pub token_program2022: solana_pubkey::Pubkey, - - pub vault0_mint: solana_pubkey::Pubkey, - - pub vault1_mint: solana_pubkey::Pubkey, -} - -impl OpenPositionV2 { - pub fn instruction( - &self, - args: OpenPositionV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: OpenPositionV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(22 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.metadata_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.personal_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&OpenPositionV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionV2InstructionData { - discriminator: [u8; 8], -} - -impl OpenPositionV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [77, 184, 74, 214, 112, 86, 241, 199], - } - } -} - -impl Default for OpenPositionV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionV2InstructionArgs { - pub tick_lower_index: i32, - pub tick_upper_index: i32, - pub tick_array_lower_start_index: i32, - pub tick_array_upper_start_index: i32, - pub liquidity: u128, - pub amount0_max: u64, - pub amount1_max: u64, - pub with_metadata: bool, - pub base_flag: Option, -} - -/// Instruction builder for `OpenPositionV2`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` position_nft_owner -/// 2. `[writable, signer]` position_nft_mint -/// 3. `[writable]` position_nft_account -/// 4. `[writable]` metadata_account -/// 5. `[writable]` pool_state -/// 6. `[writable]` protocol_position -/// 7. `[writable]` tick_array_lower -/// 8. `[writable]` tick_array_upper -/// 9. `[writable]` personal_position -/// 10. `[writable]` token_account0 -/// 11. `[writable]` token_account1 -/// 12. `[writable]` token_vault0 -/// 13. `[writable]` token_vault1 -/// 14. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 15. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 16. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 17. `[]` associated_token_program -/// 18. `[]` metadata_program -/// 19. `[]` token_program2022 -/// 20. `[]` vault0_mint -/// 21. `[]` vault1_mint -#[derive(Clone, Debug, Default)] -pub struct OpenPositionV2Builder { - payer: Option, - position_nft_owner: Option, - position_nft_mint: Option, - position_nft_account: Option, - metadata_account: Option, - pool_state: Option, - protocol_position: Option, - tick_array_lower: Option, - tick_array_upper: Option, - personal_position: Option, - token_account0: Option, - token_account1: Option, - token_vault0: Option, - token_vault1: Option, - rent: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - metadata_program: Option, - token_program2022: Option, - vault0_mint: Option, - vault1_mint: Option, - tick_lower_index: Option, - tick_upper_index: Option, - tick_array_lower_start_index: Option, - tick_array_upper_start_index: Option, - liquidity: Option, - amount0_max: Option, - amount1_max: Option, - with_metadata: Option, - base_flag: Option, - __remaining_accounts: Vec, -} - -impl OpenPositionV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn position_nft_owner(&mut self, position_nft_owner: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_owner = Some(position_nft_owner); - self - } - - #[inline(always)] - pub fn position_nft_mint(&mut self, position_nft_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_mint = Some(position_nft_mint); - self - } - - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn metadata_account(&mut self, metadata_account: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_account = Some(metadata_account); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position(&mut self, protocol_position: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn personal_position(&mut self, personal_position: solana_pubkey::Pubkey) -> &mut Self { - self.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn token_account0(&mut self, token_account0: solana_pubkey::Pubkey) -> &mut Self { - self.token_account0 = Some(token_account0); - self - } - - #[inline(always)] - pub fn token_account1(&mut self, token_account1: solana_pubkey::Pubkey) -> &mut Self { - self.token_account1 = Some(token_account1); - self - } - - #[inline(always)] - pub fn token_vault0(&mut self, token_vault0: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1(&mut self, token_vault1: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault1 = Some(token_vault1); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.tick_upper_index = Some(tick_upper_index); - self - } - - #[inline(always)] - pub fn tick_array_lower_start_index(&mut self, tick_array_lower_start_index: i32) -> &mut Self { - self.tick_array_lower_start_index = Some(tick_array_lower_start_index); - self - } - - #[inline(always)] - pub fn tick_array_upper_start_index(&mut self, tick_array_upper_start_index: i32) -> &mut Self { - self.tick_array_upper_start_index = Some(tick_array_upper_start_index); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_max(&mut self, amount0_max: u64) -> &mut Self { - self.amount0_max = Some(amount0_max); - self - } - - #[inline(always)] - pub fn amount1_max(&mut self, amount1_max: u64) -> &mut Self { - self.amount1_max = Some(amount1_max); - self - } - - #[inline(always)] - pub fn with_metadata(&mut self, with_metadata: bool) -> &mut Self { - self.with_metadata = Some(with_metadata); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn base_flag(&mut self, base_flag: bool) -> &mut Self { - self.base_flag = Some(base_flag); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = OpenPositionV2 { - payer: self.payer.expect("payer is not set"), - position_nft_owner: self - .position_nft_owner - .expect("position_nft_owner is not set"), - position_nft_mint: self - .position_nft_mint - .expect("position_nft_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - metadata_account: self.metadata_account.expect("metadata_account is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - protocol_position: self - .protocol_position - .expect("protocol_position is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - personal_position: self - .personal_position - .expect("personal_position is not set"), - token_account0: self.token_account0.expect("token_account0 is not set"), - token_account1: self.token_account1.expect("token_account1 is not set"), - token_vault0: self.token_vault0.expect("token_vault0 is not set"), - token_vault1: self.token_vault1.expect("token_vault1 is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - metadata_program: self.metadata_program.expect("metadata_program is not set"), - token_program2022: self - .token_program2022 - .expect("token_program2022 is not set"), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - }; - let args = OpenPositionV2InstructionArgs { - tick_lower_index: self - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - tick_array_lower_start_index: self - .tick_array_lower_start_index - .clone() - .expect("tick_array_lower_start_index is not set"), - tick_array_upper_start_index: self - .tick_array_upper_start_index - .clone() - .expect("tick_array_upper_start_index is not set"), - liquidity: self.liquidity.clone().expect("liquidity is not set"), - amount0_max: self.amount0_max.clone().expect("amount0_max is not set"), - amount1_max: self.amount1_max.clone().expect("amount1_max is not set"), - with_metadata: self - .with_metadata - .clone() - .expect("with_metadata is not set"), - base_flag: self.base_flag.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `open_position_v2` CPI accounts. -pub struct OpenPositionV2CpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, -} - -/// `open_position_v2` CPI instruction. -pub struct OpenPositionV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: OpenPositionV2InstructionArgs, -} - -impl<'a, 'b> OpenPositionV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: OpenPositionV2CpiAccounts<'a, 'b>, - args: OpenPositionV2InstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - position_nft_owner: accounts.position_nft_owner, - position_nft_mint: accounts.position_nft_mint, - position_nft_account: accounts.position_nft_account, - metadata_account: accounts.metadata_account, - pool_state: accounts.pool_state, - protocol_position: accounts.protocol_position, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - personal_position: accounts.personal_position, - token_account0: accounts.token_account0, - token_account1: accounts.token_account1, - token_vault0: accounts.token_vault0, - token_vault1: accounts.token_vault1, - rent: accounts.rent, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - metadata_program: accounts.metadata_program, - token_program2022: accounts.token_program2022, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(22 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.metadata_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.personal_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&OpenPositionV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(23 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.position_nft_owner.clone()); - account_infos.push(self.position_nft_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.metadata_account.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.protocol_position.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - account_infos.push(self.personal_position.clone()); - account_infos.push(self.token_account0.clone()); - account_infos.push(self.token_account1.clone()); - account_infos.push(self.token_vault0.clone()); - account_infos.push(self.token_vault1.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `OpenPositionV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` position_nft_owner -/// 2. `[writable, signer]` position_nft_mint -/// 3. `[writable]` position_nft_account -/// 4. `[writable]` metadata_account -/// 5. `[writable]` pool_state -/// 6. `[writable]` protocol_position -/// 7. `[writable]` tick_array_lower -/// 8. `[writable]` tick_array_upper -/// 9. `[writable]` personal_position -/// 10. `[writable]` token_account0 -/// 11. `[writable]` token_account1 -/// 12. `[writable]` token_vault0 -/// 13. `[writable]` token_vault1 -/// 14. `[]` rent -/// 15. `[]` system_program -/// 16. `[]` token_program -/// 17. `[]` associated_token_program -/// 18. `[]` metadata_program -/// 19. `[]` token_program2022 -/// 20. `[]` vault0_mint -/// 21. `[]` vault1_mint -#[derive(Clone, Debug)] -pub struct OpenPositionV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> OpenPositionV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(OpenPositionV2CpiBuilderInstruction { - __program: program, - payer: None, - position_nft_owner: None, - position_nft_mint: None, - position_nft_account: None, - metadata_account: None, - pool_state: None, - protocol_position: None, - tick_array_lower: None, - tick_array_upper: None, - personal_position: None, - token_account0: None, - token_account1: None, - token_vault0: None, - token_vault1: None, - rent: None, - system_program: None, - token_program: None, - associated_token_program: None, - metadata_program: None, - token_program2022: None, - vault0_mint: None, - vault1_mint: None, - tick_lower_index: None, - tick_upper_index: None, - tick_array_lower_start_index: None, - tick_array_upper_start_index: None, - liquidity: None, - amount0_max: None, - amount1_max: None, - with_metadata: None, - base_flag: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn position_nft_owner( - &mut self, - position_nft_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_owner = Some(position_nft_owner); - self - } - - #[inline(always)] - pub fn position_nft_mint( - &mut self, - position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_mint = Some(position_nft_mint); - self - } - - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn metadata_account( - &mut self, - metadata_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_account = Some(metadata_account); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position( - &mut self, - protocol_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn personal_position( - &mut self, - personal_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn token_account0( - &mut self, - token_account0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account0 = Some(token_account0); - self - } - - #[inline(always)] - pub fn token_account1( - &mut self, - token_account1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account1 = Some(token_account1); - self - } - - #[inline(always)] - pub fn token_vault0( - &mut self, - token_vault0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1( - &mut self, - token_vault1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.instruction.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.instruction.tick_upper_index = Some(tick_upper_index); - self - } - - #[inline(always)] - pub fn tick_array_lower_start_index(&mut self, tick_array_lower_start_index: i32) -> &mut Self { - self.instruction.tick_array_lower_start_index = Some(tick_array_lower_start_index); - self - } - - #[inline(always)] - pub fn tick_array_upper_start_index(&mut self, tick_array_upper_start_index: i32) -> &mut Self { - self.instruction.tick_array_upper_start_index = Some(tick_array_upper_start_index); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.instruction.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_max(&mut self, amount0_max: u64) -> &mut Self { - self.instruction.amount0_max = Some(amount0_max); - self - } - - #[inline(always)] - pub fn amount1_max(&mut self, amount1_max: u64) -> &mut Self { - self.instruction.amount1_max = Some(amount1_max); - self - } - - #[inline(always)] - pub fn with_metadata(&mut self, with_metadata: bool) -> &mut Self { - self.instruction.with_metadata = Some(with_metadata); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn base_flag(&mut self, base_flag: bool) -> &mut Self { - self.instruction.base_flag = Some(base_flag); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = OpenPositionV2InstructionArgs { - tick_lower_index: self - .instruction - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .instruction - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - tick_array_lower_start_index: self - .instruction - .tick_array_lower_start_index - .clone() - .expect("tick_array_lower_start_index is not set"), - tick_array_upper_start_index: self - .instruction - .tick_array_upper_start_index - .clone() - .expect("tick_array_upper_start_index is not set"), - liquidity: self - .instruction - .liquidity - .clone() - .expect("liquidity is not set"), - amount0_max: self - .instruction - .amount0_max - .clone() - .expect("amount0_max is not set"), - amount1_max: self - .instruction - .amount1_max - .clone() - .expect("amount1_max is not set"), - with_metadata: self - .instruction - .with_metadata - .clone() - .expect("with_metadata is not set"), - base_flag: self.instruction.base_flag.clone(), - }; - let instruction = OpenPositionV2Cpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - position_nft_owner: self - .instruction - .position_nft_owner - .expect("position_nft_owner is not set"), - - position_nft_mint: self - .instruction - .position_nft_mint - .expect("position_nft_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - metadata_account: self - .instruction - .metadata_account - .expect("metadata_account is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - protocol_position: self - .instruction - .protocol_position - .expect("protocol_position is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - - personal_position: self - .instruction - .personal_position - .expect("personal_position is not set"), - - token_account0: self - .instruction - .token_account0 - .expect("token_account0 is not set"), - - token_account1: self - .instruction - .token_account1 - .expect("token_account1 is not set"), - - token_vault0: self - .instruction - .token_vault0 - .expect("token_vault0 is not set"), - - token_vault1: self - .instruction - .token_vault1 - .expect("token_vault1 is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct OpenPositionV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_position: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - personal_position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault1: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_lower_index: Option, - tick_upper_index: Option, - tick_array_lower_start_index: Option, - tick_array_upper_start_index: Option, - liquidity: Option, - amount0_max: Option, - amount1_max: Option, - with_metadata: Option, - base_flag: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/open_position_with_token22_nft.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/open_position_with_token22_nft.rs deleted file mode 100644 index 81239354..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/open_position_with_token22_nft.rs +++ /dev/null @@ -1,1318 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct OpenPositionWithToken22Nft { - pub payer: solana_pubkey::Pubkey, - - pub position_nft_owner: solana_pubkey::Pubkey, - - pub position_nft_mint: solana_pubkey::Pubkey, - - pub position_nft_account: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub protocol_position: solana_pubkey::Pubkey, - - pub tick_array_lower: solana_pubkey::Pubkey, - - pub tick_array_upper: solana_pubkey::Pubkey, - - pub personal_position: solana_pubkey::Pubkey, - - pub token_account0: solana_pubkey::Pubkey, - - pub token_account1: solana_pubkey::Pubkey, - - pub token_vault0: solana_pubkey::Pubkey, - - pub token_vault1: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub token_program2022: solana_pubkey::Pubkey, - - pub vault0_mint: solana_pubkey::Pubkey, - - pub vault1_mint: solana_pubkey::Pubkey, -} - -impl OpenPositionWithToken22Nft { - pub fn instruction( - &self, - args: OpenPositionWithToken22NftInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: OpenPositionWithToken22NftInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(20 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.position_nft_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_mint, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.position_nft_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_lower, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.tick_array_upper, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.personal_position, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_account1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&OpenPositionWithToken22NftInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionWithToken22NftInstructionData { - discriminator: [u8; 8], -} - -impl OpenPositionWithToken22NftInstructionData { - pub fn new() -> Self { - Self { - discriminator: [77, 255, 174, 82, 125, 29, 201, 46], - } - } -} - -impl Default for OpenPositionWithToken22NftInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct OpenPositionWithToken22NftInstructionArgs { - pub tick_lower_index: i32, - pub tick_upper_index: i32, - pub tick_array_lower_start_index: i32, - pub tick_array_upper_start_index: i32, - pub liquidity: u128, - pub amount0_max: u64, - pub amount1_max: u64, - pub with_metadata: bool, - pub base_flag: Option, -} - -/// Instruction builder for `OpenPositionWithToken22Nft`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` position_nft_owner -/// 2. `[writable, signer]` position_nft_mint -/// 3. `[writable]` position_nft_account -/// 4. `[writable]` pool_state -/// 5. `[writable]` protocol_position -/// 6. `[writable]` tick_array_lower -/// 7. `[writable]` tick_array_upper -/// 8. `[writable]` personal_position -/// 9. `[writable]` token_account0 -/// 10. `[writable]` token_account1 -/// 11. `[writable]` token_vault0 -/// 12. `[writable]` token_vault1 -/// 13. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 14. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 15. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 16. `[]` associated_token_program -/// 17. `[]` token_program2022 -/// 18. `[]` vault0_mint -/// 19. `[]` vault1_mint -#[derive(Clone, Debug, Default)] -pub struct OpenPositionWithToken22NftBuilder { - payer: Option, - position_nft_owner: Option, - position_nft_mint: Option, - position_nft_account: Option, - pool_state: Option, - protocol_position: Option, - tick_array_lower: Option, - tick_array_upper: Option, - personal_position: Option, - token_account0: Option, - token_account1: Option, - token_vault0: Option, - token_vault1: Option, - rent: Option, - system_program: Option, - token_program: Option, - associated_token_program: Option, - token_program2022: Option, - vault0_mint: Option, - vault1_mint: Option, - tick_lower_index: Option, - tick_upper_index: Option, - tick_array_lower_start_index: Option, - tick_array_upper_start_index: Option, - liquidity: Option, - amount0_max: Option, - amount1_max: Option, - with_metadata: Option, - base_flag: Option, - __remaining_accounts: Vec, -} - -impl OpenPositionWithToken22NftBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn position_nft_owner(&mut self, position_nft_owner: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_owner = Some(position_nft_owner); - self - } - - #[inline(always)] - pub fn position_nft_mint(&mut self, position_nft_mint: solana_pubkey::Pubkey) -> &mut Self { - self.position_nft_mint = Some(position_nft_mint); - self - } - - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position(&mut self, protocol_position: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn personal_position(&mut self, personal_position: solana_pubkey::Pubkey) -> &mut Self { - self.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn token_account0(&mut self, token_account0: solana_pubkey::Pubkey) -> &mut Self { - self.token_account0 = Some(token_account0); - self - } - - #[inline(always)] - pub fn token_account1(&mut self, token_account1: solana_pubkey::Pubkey) -> &mut Self { - self.token_account1 = Some(token_account1); - self - } - - #[inline(always)] - pub fn token_vault0(&mut self, token_vault0: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1(&mut self, token_vault1: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault1 = Some(token_vault1); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.tick_upper_index = Some(tick_upper_index); - self - } - - #[inline(always)] - pub fn tick_array_lower_start_index(&mut self, tick_array_lower_start_index: i32) -> &mut Self { - self.tick_array_lower_start_index = Some(tick_array_lower_start_index); - self - } - - #[inline(always)] - pub fn tick_array_upper_start_index(&mut self, tick_array_upper_start_index: i32) -> &mut Self { - self.tick_array_upper_start_index = Some(tick_array_upper_start_index); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_max(&mut self, amount0_max: u64) -> &mut Self { - self.amount0_max = Some(amount0_max); - self - } - - #[inline(always)] - pub fn amount1_max(&mut self, amount1_max: u64) -> &mut Self { - self.amount1_max = Some(amount1_max); - self - } - - #[inline(always)] - pub fn with_metadata(&mut self, with_metadata: bool) -> &mut Self { - self.with_metadata = Some(with_metadata); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn base_flag(&mut self, base_flag: bool) -> &mut Self { - self.base_flag = Some(base_flag); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = OpenPositionWithToken22Nft { - payer: self.payer.expect("payer is not set"), - position_nft_owner: self - .position_nft_owner - .expect("position_nft_owner is not set"), - position_nft_mint: self - .position_nft_mint - .expect("position_nft_mint is not set"), - position_nft_account: self - .position_nft_account - .expect("position_nft_account is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - protocol_position: self - .protocol_position - .expect("protocol_position is not set"), - tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"), - tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"), - personal_position: self - .personal_position - .expect("personal_position is not set"), - token_account0: self.token_account0.expect("token_account0 is not set"), - token_account1: self.token_account1.expect("token_account1 is not set"), - token_vault0: self.token_vault0.expect("token_vault0 is not set"), - token_vault1: self.token_vault1.expect("token_vault1 is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self - .associated_token_program - .expect("associated_token_program is not set"), - token_program2022: self - .token_program2022 - .expect("token_program2022 is not set"), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - }; - let args = OpenPositionWithToken22NftInstructionArgs { - tick_lower_index: self - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - tick_array_lower_start_index: self - .tick_array_lower_start_index - .clone() - .expect("tick_array_lower_start_index is not set"), - tick_array_upper_start_index: self - .tick_array_upper_start_index - .clone() - .expect("tick_array_upper_start_index is not set"), - liquidity: self.liquidity.clone().expect("liquidity is not set"), - amount0_max: self.amount0_max.clone().expect("amount0_max is not set"), - amount1_max: self.amount1_max.clone().expect("amount1_max is not set"), - with_metadata: self - .with_metadata - .clone() - .expect("with_metadata is not set"), - base_flag: self.base_flag.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `open_position_with_token22_nft` CPI accounts. -pub struct OpenPositionWithToken22NftCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, -} - -/// `open_position_with_token22_nft` CPI instruction. -pub struct OpenPositionWithToken22NftCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_owner: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - - pub position_nft_account: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_position: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - - pub personal_position: &'b solana_account_info::AccountInfo<'a>, - - pub token_account0: &'b solana_account_info::AccountInfo<'a>, - - pub token_account1: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault0: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault1: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: OpenPositionWithToken22NftInstructionArgs, -} - -impl<'a, 'b> OpenPositionWithToken22NftCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: OpenPositionWithToken22NftCpiAccounts<'a, 'b>, - args: OpenPositionWithToken22NftInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - position_nft_owner: accounts.position_nft_owner, - position_nft_mint: accounts.position_nft_mint, - position_nft_account: accounts.position_nft_account, - pool_state: accounts.pool_state, - protocol_position: accounts.protocol_position, - tick_array_lower: accounts.tick_array_lower, - tick_array_upper: accounts.tick_array_upper, - personal_position: accounts.personal_position, - token_account0: accounts.token_account0, - token_account1: accounts.token_account1, - token_vault0: accounts.token_vault0, - token_vault1: accounts.token_vault1, - rent: accounts.rent, - system_program: accounts.system_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - token_program2022: accounts.token_program2022, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(20 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.position_nft_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.position_nft_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_lower.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array_upper.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.personal_position.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_account1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&OpenPositionWithToken22NftInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(21 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.position_nft_owner.clone()); - account_infos.push(self.position_nft_mint.clone()); - account_infos.push(self.position_nft_account.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.protocol_position.clone()); - account_infos.push(self.tick_array_lower.clone()); - account_infos.push(self.tick_array_upper.clone()); - account_infos.push(self.personal_position.clone()); - account_infos.push(self.token_account0.clone()); - account_infos.push(self.token_account1.clone()); - account_infos.push(self.token_vault0.clone()); - account_infos.push(self.token_vault1.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `OpenPositionWithToken22Nft` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` position_nft_owner -/// 2. `[writable, signer]` position_nft_mint -/// 3. `[writable]` position_nft_account -/// 4. `[writable]` pool_state -/// 5. `[writable]` protocol_position -/// 6. `[writable]` tick_array_lower -/// 7. `[writable]` tick_array_upper -/// 8. `[writable]` personal_position -/// 9. `[writable]` token_account0 -/// 10. `[writable]` token_account1 -/// 11. `[writable]` token_vault0 -/// 12. `[writable]` token_vault1 -/// 13. `[]` rent -/// 14. `[]` system_program -/// 15. `[]` token_program -/// 16. `[]` associated_token_program -/// 17. `[]` token_program2022 -/// 18. `[]` vault0_mint -/// 19. `[]` vault1_mint -#[derive(Clone, Debug)] -pub struct OpenPositionWithToken22NftCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> OpenPositionWithToken22NftCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(OpenPositionWithToken22NftCpiBuilderInstruction { - __program: program, - payer: None, - position_nft_owner: None, - position_nft_mint: None, - position_nft_account: None, - pool_state: None, - protocol_position: None, - tick_array_lower: None, - tick_array_upper: None, - personal_position: None, - token_account0: None, - token_account1: None, - token_vault0: None, - token_vault1: None, - rent: None, - system_program: None, - token_program: None, - associated_token_program: None, - token_program2022: None, - vault0_mint: None, - vault1_mint: None, - tick_lower_index: None, - tick_upper_index: None, - tick_array_lower_start_index: None, - tick_array_upper_start_index: None, - liquidity: None, - amount0_max: None, - amount1_max: None, - with_metadata: None, - base_flag: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn position_nft_owner( - &mut self, - position_nft_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_owner = Some(position_nft_owner); - self - } - - #[inline(always)] - pub fn position_nft_mint( - &mut self, - position_nft_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_mint = Some(position_nft_mint); - self - } - - #[inline(always)] - pub fn position_nft_account( - &mut self, - position_nft_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.position_nft_account = Some(position_nft_account); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn protocol_position( - &mut self, - protocol_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_position = Some(protocol_position); - self - } - - #[inline(always)] - pub fn tick_array_lower( - &mut self, - tick_array_lower: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_lower = Some(tick_array_lower); - self - } - - #[inline(always)] - pub fn tick_array_upper( - &mut self, - tick_array_upper: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array_upper = Some(tick_array_upper); - self - } - - #[inline(always)] - pub fn personal_position( - &mut self, - personal_position: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.personal_position = Some(personal_position); - self - } - - #[inline(always)] - pub fn token_account0( - &mut self, - token_account0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account0 = Some(token_account0); - self - } - - #[inline(always)] - pub fn token_account1( - &mut self, - token_account1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_account1 = Some(token_account1); - self - } - - #[inline(always)] - pub fn token_vault0( - &mut self, - token_vault0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault0 = Some(token_vault0); - self - } - - #[inline(always)] - pub fn token_vault1( - &mut self, - token_vault1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault1 = Some(token_vault1); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - #[inline(always)] - pub fn tick_lower_index(&mut self, tick_lower_index: i32) -> &mut Self { - self.instruction.tick_lower_index = Some(tick_lower_index); - self - } - - #[inline(always)] - pub fn tick_upper_index(&mut self, tick_upper_index: i32) -> &mut Self { - self.instruction.tick_upper_index = Some(tick_upper_index); - self - } - - #[inline(always)] - pub fn tick_array_lower_start_index(&mut self, tick_array_lower_start_index: i32) -> &mut Self { - self.instruction.tick_array_lower_start_index = Some(tick_array_lower_start_index); - self - } - - #[inline(always)] - pub fn tick_array_upper_start_index(&mut self, tick_array_upper_start_index: i32) -> &mut Self { - self.instruction.tick_array_upper_start_index = Some(tick_array_upper_start_index); - self - } - - #[inline(always)] - pub fn liquidity(&mut self, liquidity: u128) -> &mut Self { - self.instruction.liquidity = Some(liquidity); - self - } - - #[inline(always)] - pub fn amount0_max(&mut self, amount0_max: u64) -> &mut Self { - self.instruction.amount0_max = Some(amount0_max); - self - } - - #[inline(always)] - pub fn amount1_max(&mut self, amount1_max: u64) -> &mut Self { - self.instruction.amount1_max = Some(amount1_max); - self - } - - #[inline(always)] - pub fn with_metadata(&mut self, with_metadata: bool) -> &mut Self { - self.instruction.with_metadata = Some(with_metadata); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn base_flag(&mut self, base_flag: bool) -> &mut Self { - self.instruction.base_flag = Some(base_flag); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = OpenPositionWithToken22NftInstructionArgs { - tick_lower_index: self - .instruction - .tick_lower_index - .clone() - .expect("tick_lower_index is not set"), - tick_upper_index: self - .instruction - .tick_upper_index - .clone() - .expect("tick_upper_index is not set"), - tick_array_lower_start_index: self - .instruction - .tick_array_lower_start_index - .clone() - .expect("tick_array_lower_start_index is not set"), - tick_array_upper_start_index: self - .instruction - .tick_array_upper_start_index - .clone() - .expect("tick_array_upper_start_index is not set"), - liquidity: self - .instruction - .liquidity - .clone() - .expect("liquidity is not set"), - amount0_max: self - .instruction - .amount0_max - .clone() - .expect("amount0_max is not set"), - amount1_max: self - .instruction - .amount1_max - .clone() - .expect("amount1_max is not set"), - with_metadata: self - .instruction - .with_metadata - .clone() - .expect("with_metadata is not set"), - base_flag: self.instruction.base_flag.clone(), - }; - let instruction = OpenPositionWithToken22NftCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - position_nft_owner: self - .instruction - .position_nft_owner - .expect("position_nft_owner is not set"), - - position_nft_mint: self - .instruction - .position_nft_mint - .expect("position_nft_mint is not set"), - - position_nft_account: self - .instruction - .position_nft_account - .expect("position_nft_account is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - protocol_position: self - .instruction - .protocol_position - .expect("protocol_position is not set"), - - tick_array_lower: self - .instruction - .tick_array_lower - .expect("tick_array_lower is not set"), - - tick_array_upper: self - .instruction - .tick_array_upper - .expect("tick_array_upper is not set"), - - personal_position: self - .instruction - .personal_position - .expect("personal_position is not set"), - - token_account0: self - .instruction - .token_account0 - .expect("token_account0 is not set"), - - token_account1: self - .instruction - .token_account1 - .expect("token_account1 is not set"), - - token_vault0: self - .instruction - .token_vault0 - .expect("token_vault0 is not set"), - - token_vault1: self - .instruction - .token_vault1 - .expect("token_vault1 is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct OpenPositionWithToken22NftCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - position_nft_account: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_position: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>, - personal_position: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_account1: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault0: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault1: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_lower_index: Option, - tick_upper_index: Option, - tick_array_lower_start_index: Option, - tick_array_upper_start_index: Option, - liquidity: Option, - amount0_max: Option, - amount1_max: Option, - with_metadata: Option, - base_flag: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/set_reward_params.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/set_reward_params.rs deleted file mode 100644 index 4e2bc58a..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/set_reward_params.rs +++ /dev/null @@ -1,596 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SetRewardParams { - pub authority: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub operation_state: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token_program2022: solana_pubkey::Pubkey, -} - -impl SetRewardParams { - pub fn instruction( - &self, - args: SetRewardParamsInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SetRewardParamsInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.operation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SetRewardParamsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardParamsInstructionData { - discriminator: [u8; 8], -} - -impl SetRewardParamsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [112, 52, 167, 75, 32, 201, 211, 137], - } - } -} - -impl Default for SetRewardParamsInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SetRewardParamsInstructionArgs { - pub reward_index: u8, - pub emissions_per_second_x64: u128, - pub open_time: u64, - pub end_time: u64, -} - -/// Instruction builder for `SetRewardParams`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[]` amm_config -/// 2. `[writable]` pool_state -/// 3. `[]` operation_state -/// 4. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 5. `[]` token_program2022 -#[derive(Clone, Debug, Default)] -pub struct SetRewardParamsBuilder { - authority: Option, - amm_config: Option, - pool_state: Option, - operation_state: Option, - token_program: Option, - token_program2022: Option, - reward_index: Option, - emissions_per_second_x64: Option, - open_time: Option, - end_time: Option, - __remaining_accounts: Vec, -} - -impl SetRewardParamsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn operation_state(&mut self, operation_state: solana_pubkey::Pubkey) -> &mut Self { - self.operation_state = Some(operation_state); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn emissions_per_second_x64(&mut self, emissions_per_second_x64: u128) -> &mut Self { - self.emissions_per_second_x64 = Some(emissions_per_second_x64); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.open_time = Some(open_time); - self - } - - #[inline(always)] - pub fn end_time(&mut self, end_time: u64) -> &mut Self { - self.end_time = Some(end_time); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SetRewardParams { - authority: self.authority.expect("authority is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - operation_state: self.operation_state.expect("operation_state is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self - .token_program2022 - .expect("token_program2022 is not set"), - }; - let args = SetRewardParamsInstructionArgs { - reward_index: self.reward_index.clone().expect("reward_index is not set"), - emissions_per_second_x64: self - .emissions_per_second_x64 - .clone() - .expect("emissions_per_second_x64 is not set"), - open_time: self.open_time.clone().expect("open_time is not set"), - end_time: self.end_time.clone().expect("end_time is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `set_reward_params` CPI accounts. -pub struct SetRewardParamsCpiAccounts<'a, 'b> { - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub operation_state: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, -} - -/// `set_reward_params` CPI instruction. -pub struct SetRewardParamsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub operation_state: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SetRewardParamsInstructionArgs, -} - -impl<'a, 'b> SetRewardParamsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SetRewardParamsCpiAccounts<'a, 'b>, - args: SetRewardParamsInstructionArgs, - ) -> Self { - Self { - __program: program, - authority: accounts.authority, - amm_config: accounts.amm_config, - pool_state: accounts.pool_state, - operation_state: accounts.operation_state, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.operation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SetRewardParamsInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.operation_state.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SetRewardParams` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[]` amm_config -/// 2. `[writable]` pool_state -/// 3. `[]` operation_state -/// 4. `[]` token_program -/// 5. `[]` token_program2022 -#[derive(Clone, Debug)] -pub struct SetRewardParamsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SetRewardParamsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SetRewardParamsCpiBuilderInstruction { - __program: program, - authority: None, - amm_config: None, - pool_state: None, - operation_state: None, - token_program: None, - token_program2022: None, - reward_index: None, - emissions_per_second_x64: None, - open_time: None, - end_time: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn operation_state( - &mut self, - operation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.operation_state = Some(operation_state); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn reward_index(&mut self, reward_index: u8) -> &mut Self { - self.instruction.reward_index = Some(reward_index); - self - } - - #[inline(always)] - pub fn emissions_per_second_x64(&mut self, emissions_per_second_x64: u128) -> &mut Self { - self.instruction.emissions_per_second_x64 = Some(emissions_per_second_x64); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.instruction.open_time = Some(open_time); - self - } - - #[inline(always)] - pub fn end_time(&mut self, end_time: u64) -> &mut Self { - self.instruction.end_time = Some(end_time); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SetRewardParamsInstructionArgs { - reward_index: self - .instruction - .reward_index - .clone() - .expect("reward_index is not set"), - emissions_per_second_x64: self - .instruction - .emissions_per_second_x64 - .clone() - .expect("emissions_per_second_x64 is not set"), - open_time: self - .instruction - .open_time - .clone() - .expect("open_time is not set"), - end_time: self - .instruction - .end_time - .clone() - .expect("end_time is not set"), - }; - let instruction = SetRewardParamsCpi { - __program: self.instruction.__program, - - authority: self.instruction.authority.expect("authority is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - operation_state: self - .instruction - .operation_state - .expect("operation_state is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SetRewardParamsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - operation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - reward_index: Option, - emissions_per_second_x64: Option, - open_time: Option, - end_time: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/swap.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/swap.rs deleted file mode 100644 index d9ee1676..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/swap.rs +++ /dev/null @@ -1,763 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Swap { - pub payer: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub input_token_account: solana_pubkey::Pubkey, - - pub output_token_account: solana_pubkey::Pubkey, - - pub input_vault: solana_pubkey::Pubkey, - - pub output_vault: solana_pubkey::Pubkey, - - pub observation_state: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub tick_array: solana_pubkey::Pubkey, -} - -impl Swap { - pub fn instruction(&self, args: SwapInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.input_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.tick_array, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionData { - discriminator: [u8; 8], -} - -impl SwapInstructionData { - pub fn new() -> Self { - Self { - discriminator: [248, 198, 158, 145, 225, 117, 135, 200], - } - } -} - -impl Default for SwapInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapInstructionArgs { - pub amount: u64, - pub other_amount_threshold: u64, - pub sqrt_price_limit_x64: u128, - pub is_base_input: bool, -} - -/// Instruction builder for `Swap`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` amm_config -/// 2. `[writable]` pool_state -/// 3. `[writable]` input_token_account -/// 4. `[writable]` output_token_account -/// 5. `[writable]` input_vault -/// 6. `[writable]` output_vault -/// 7. `[writable]` observation_state -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[writable]` tick_array -#[derive(Clone, Debug, Default)] -pub struct SwapBuilder { - payer: Option, - amm_config: Option, - pool_state: Option, - input_token_account: Option, - output_token_account: Option, - input_vault: Option, - output_vault: Option, - observation_state: Option, - token_program: Option, - tick_array: Option, - amount: Option, - other_amount_threshold: Option, - sqrt_price_limit_x64: Option, - is_base_input: Option, - __remaining_accounts: Vec, -} - -impl SwapBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn input_token_account(&mut self, input_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_account = Some(input_token_account); - self - } - - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_account = Some(output_token_account); - self - } - - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn output_vault(&mut self, output_vault: solana_pubkey::Pubkey) -> &mut Self { - self.output_vault = Some(output_vault); - self - } - - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn tick_array(&mut self, tick_array: solana_pubkey::Pubkey) -> &mut Self { - self.tick_array = Some(tick_array); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_x64(&mut self, sqrt_price_limit_x64: u128) -> &mut Self { - self.sqrt_price_limit_x64 = Some(sqrt_price_limit_x64); - self - } - - #[inline(always)] - pub fn is_base_input(&mut self, is_base_input: bool) -> &mut Self { - self.is_base_input = Some(is_base_input); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Swap { - payer: self.payer.expect("payer is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - input_token_account: self - .input_token_account - .expect("input_token_account is not set"), - output_token_account: self - .output_token_account - .expect("output_token_account is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - output_vault: self.output_vault.expect("output_vault is not set"), - observation_state: self - .observation_state - .expect("observation_state is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - tick_array: self.tick_array.expect("tick_array is not set"), - }; - let args = SwapInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - sqrt_price_limit_x64: self - .sqrt_price_limit_x64 - .clone() - .expect("sqrt_price_limit_x64 is not set"), - is_base_input: self - .is_base_input - .clone() - .expect("is_base_input is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap` CPI accounts. -pub struct SwapCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap` CPI instruction. -pub struct SwapCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub tick_array: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapInstructionArgs, -} - -impl<'a, 'b> SwapCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapCpiAccounts<'a, 'b>, - args: SwapInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - amm_config: accounts.amm_config, - pool_state: accounts.pool_state, - input_token_account: accounts.input_token_account, - output_token_account: accounts.output_token_account, - input_vault: accounts.input_vault, - output_vault: accounts.output_vault, - observation_state: accounts.observation_state, - token_program: accounts.token_program, - tick_array: accounts.tick_array, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.tick_array.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.input_token_account.clone()); - account_infos.push(self.output_token_account.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.output_vault.clone()); - account_infos.push(self.observation_state.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.tick_array.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Swap` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` amm_config -/// 2. `[writable]` pool_state -/// 3. `[writable]` input_token_account -/// 4. `[writable]` output_token_account -/// 5. `[writable]` input_vault -/// 6. `[writable]` output_vault -/// 7. `[writable]` observation_state -/// 8. `[]` token_program -/// 9. `[writable]` tick_array -#[derive(Clone, Debug)] -pub struct SwapCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapCpiBuilderInstruction { - __program: program, - payer: None, - amm_config: None, - pool_state: None, - input_token_account: None, - output_token_account: None, - input_vault: None, - output_vault: None, - observation_state: None, - token_program: None, - tick_array: None, - amount: None, - other_amount_threshold: None, - sqrt_price_limit_x64: None, - is_base_input: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn input_token_account( - &mut self, - input_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_account = Some(input_token_account); - self - } - - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_account = Some(output_token_account); - self - } - - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn output_vault( - &mut self, - output_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_vault = Some(output_vault); - self - } - - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn tick_array( - &mut self, - tick_array: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.tick_array = Some(tick_array); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.instruction.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_x64(&mut self, sqrt_price_limit_x64: u128) -> &mut Self { - self.instruction.sqrt_price_limit_x64 = Some(sqrt_price_limit_x64); - self - } - - #[inline(always)] - pub fn is_base_input(&mut self, is_base_input: bool) -> &mut Self { - self.instruction.is_base_input = Some(is_base_input); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .instruction - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - sqrt_price_limit_x64: self - .instruction - .sqrt_price_limit_x64 - .clone() - .expect("sqrt_price_limit_x64 is not set"), - is_base_input: self - .instruction - .is_base_input - .clone() - .expect("is_base_input is not set"), - }; - let instruction = SwapCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - input_token_account: self - .instruction - .input_token_account - .expect("input_token_account is not set"), - - output_token_account: self - .instruction - .output_token_account - .expect("output_token_account is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - output_vault: self - .instruction - .output_vault - .expect("output_vault is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - tick_array: self.instruction.tick_array.expect("tick_array is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - output_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - tick_array: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - other_amount_threshold: Option, - sqrt_price_limit_x64: Option, - is_base_input: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/swap_router_base_in.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/swap_router_base_in.rs deleted file mode 100644 index 631c6064..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/swap_router_base_in.rs +++ /dev/null @@ -1,562 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SwapRouterBaseIn { - pub payer: solana_pubkey::Pubkey, - - pub input_token_account: solana_pubkey::Pubkey, - - pub input_token_mint: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token_program2022: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, -} - -impl SwapRouterBaseIn { - pub fn instruction( - &self, - args: SwapRouterBaseInInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapRouterBaseInInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.input_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.input_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapRouterBaseInInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapRouterBaseInInstructionData { - discriminator: [u8; 8], -} - -impl SwapRouterBaseInInstructionData { - pub fn new() -> Self { - Self { - discriminator: [69, 125, 115, 218, 245, 186, 242, 196], - } - } -} - -impl Default for SwapRouterBaseInInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapRouterBaseInInstructionArgs { - pub amount_in: u64, - pub amount_out_minimum: u64, -} - -/// Instruction builder for `SwapRouterBaseIn`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[writable]` input_token_account -/// 2. `[writable]` input_token_mint -/// 3. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 4. `[]` token_program2022 -/// 5. `[]` memo_program -#[derive(Clone, Debug, Default)] -pub struct SwapRouterBaseInBuilder { - payer: Option, - input_token_account: Option, - input_token_mint: Option, - token_program: Option, - token_program2022: Option, - memo_program: Option, - amount_in: Option, - amount_out_minimum: Option, - __remaining_accounts: Vec, -} - -impl SwapRouterBaseInBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn input_token_account(&mut self, input_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_account = Some(input_token_account); - self - } - - #[inline(always)] - pub fn input_token_mint(&mut self, input_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_mint = Some(input_token_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn amount_out_minimum(&mut self, amount_out_minimum: u64) -> &mut Self { - self.amount_out_minimum = Some(amount_out_minimum); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapRouterBaseIn { - payer: self.payer.expect("payer is not set"), - input_token_account: self - .input_token_account - .expect("input_token_account is not set"), - input_token_mint: self.input_token_mint.expect("input_token_mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self - .token_program2022 - .expect("token_program2022 is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - }; - let args = SwapRouterBaseInInstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - amount_out_minimum: self - .amount_out_minimum - .clone() - .expect("amount_out_minimum is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_router_base_in` CPI accounts. -pub struct SwapRouterBaseInCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_router_base_in` CPI instruction. -pub struct SwapRouterBaseInCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapRouterBaseInInstructionArgs, -} - -impl<'a, 'b> SwapRouterBaseInCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapRouterBaseInCpiAccounts<'a, 'b>, - args: SwapRouterBaseInInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - input_token_account: accounts.input_token_account, - input_token_mint: accounts.input_token_mint, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - memo_program: accounts.memo_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapRouterBaseInInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.input_token_account.clone()); - account_infos.push(self.input_token_mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.memo_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapRouterBaseIn` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[writable]` input_token_account -/// 2. `[writable]` input_token_mint -/// 3. `[]` token_program -/// 4. `[]` token_program2022 -/// 5. `[]` memo_program -#[derive(Clone, Debug)] -pub struct SwapRouterBaseInCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapRouterBaseInCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapRouterBaseInCpiBuilderInstruction { - __program: program, - payer: None, - input_token_account: None, - input_token_mint: None, - token_program: None, - token_program2022: None, - memo_program: None, - amount_in: None, - amount_out_minimum: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn input_token_account( - &mut self, - input_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_account = Some(input_token_account); - self - } - - #[inline(always)] - pub fn input_token_mint( - &mut self, - input_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_mint = Some(input_token_mint); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn amount_out_minimum(&mut self, amount_out_minimum: u64) -> &mut Self { - self.instruction.amount_out_minimum = Some(amount_out_minimum); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapRouterBaseInInstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - amount_out_minimum: self - .instruction - .amount_out_minimum - .clone() - .expect("amount_out_minimum is not set"), - }; - let instruction = SwapRouterBaseInCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - input_token_account: self - .instruction - .input_token_account - .expect("input_token_account is not set"), - - input_token_mint: self - .instruction - .input_token_mint - .expect("input_token_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapRouterBaseInCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - amount_out_minimum: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/swap_v2.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/swap_v2.rs deleted file mode 100644 index 38c0b0ba..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/swap_v2.rs +++ /dev/null @@ -1,899 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct SwapV2 { - pub payer: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - - pub input_token_account: solana_pubkey::Pubkey, - - pub output_token_account: solana_pubkey::Pubkey, - - pub input_vault: solana_pubkey::Pubkey, - - pub output_vault: solana_pubkey::Pubkey, - - pub observation_state: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub token_program2022: solana_pubkey::Pubkey, - - pub memo_program: solana_pubkey::Pubkey, - - pub input_vault_mint: solana_pubkey::Pubkey, - - pub output_vault_mint: solana_pubkey::Pubkey, -} - -impl SwapV2 { - pub fn instruction(&self, args: SwapV2InstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.input_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_vault_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_vault_mint, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapV2InstructionData { - discriminator: [u8; 8], -} - -impl SwapV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [43, 4, 237, 11, 26, 201, 30, 98], - } - } -} - -impl Default for SwapV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapV2InstructionArgs { - pub amount: u64, - pub other_amount_threshold: u64, - pub sqrt_price_limit_x64: u128, - pub is_base_input: bool, -} - -/// Instruction builder for `SwapV2`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` amm_config -/// 2. `[writable]` pool_state -/// 3. `[writable]` input_token_account -/// 4. `[writable]` output_token_account -/// 5. `[writable]` input_vault -/// 6. `[writable]` output_vault -/// 7. `[writable]` observation_state -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[]` token_program2022 -/// 10. `[]` memo_program -/// 11. `[]` input_vault_mint -/// 12. `[]` output_vault_mint -#[derive(Clone, Debug, Default)] -pub struct SwapV2Builder { - payer: Option, - amm_config: Option, - pool_state: Option, - input_token_account: Option, - output_token_account: Option, - input_vault: Option, - output_vault: Option, - observation_state: Option, - token_program: Option, - token_program2022: Option, - memo_program: Option, - input_vault_mint: Option, - output_vault_mint: Option, - amount: Option, - other_amount_threshold: Option, - sqrt_price_limit_x64: Option, - is_base_input: Option, - __remaining_accounts: Vec, -} - -impl SwapV2Builder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn input_token_account(&mut self, input_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_account = Some(input_token_account); - self - } - - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_account = Some(output_token_account); - self - } - - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn output_vault(&mut self, output_vault: solana_pubkey::Pubkey) -> &mut Self { - self.output_vault = Some(output_vault); - self - } - - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn input_vault_mint(&mut self, input_vault_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault_mint = Some(input_vault_mint); - self - } - - #[inline(always)] - pub fn output_vault_mint(&mut self, output_vault_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_vault_mint = Some(output_vault_mint); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_x64(&mut self, sqrt_price_limit_x64: u128) -> &mut Self { - self.sqrt_price_limit_x64 = Some(sqrt_price_limit_x64); - self - } - - #[inline(always)] - pub fn is_base_input(&mut self, is_base_input: bool) -> &mut Self { - self.is_base_input = Some(is_base_input); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapV2 { - payer: self.payer.expect("payer is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - input_token_account: self - .input_token_account - .expect("input_token_account is not set"), - output_token_account: self - .output_token_account - .expect("output_token_account is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - output_vault: self.output_vault.expect("output_vault is not set"), - observation_state: self - .observation_state - .expect("observation_state is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self - .token_program2022 - .expect("token_program2022 is not set"), - memo_program: self.memo_program.expect("memo_program is not set"), - input_vault_mint: self.input_vault_mint.expect("input_vault_mint is not set"), - output_vault_mint: self - .output_vault_mint - .expect("output_vault_mint is not set"), - }; - let args = SwapV2InstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - sqrt_price_limit_x64: self - .sqrt_price_limit_x64 - .clone() - .expect("sqrt_price_limit_x64 is not set"), - is_base_input: self - .is_base_input - .clone() - .expect("is_base_input is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_v2` CPI accounts. -pub struct SwapV2CpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_vault_mint: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_v2` CPI instruction. -pub struct SwapV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - - pub input_vault_mint: &'b solana_account_info::AccountInfo<'a>, - - pub output_vault_mint: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapV2InstructionArgs, -} - -impl<'a, 'b> SwapV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapV2CpiAccounts<'a, 'b>, - args: SwapV2InstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - amm_config: accounts.amm_config, - pool_state: accounts.pool_state, - input_token_account: accounts.input_token_account, - output_token_account: accounts.output_token_account, - input_vault: accounts.input_vault, - output_vault: accounts.output_vault, - observation_state: accounts.observation_state, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - memo_program: accounts.memo_program, - input_vault_mint: accounts.input_vault_mint, - output_vault_mint: accounts.output_vault_mint, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_vault_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_vault_mint.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.input_token_account.clone()); - account_infos.push(self.output_token_account.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.output_vault.clone()); - account_infos.push(self.observation_state.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.memo_program.clone()); - account_infos.push(self.input_vault_mint.clone()); - account_infos.push(self.output_vault_mint.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` amm_config -/// 2. `[writable]` pool_state -/// 3. `[writable]` input_token_account -/// 4. `[writable]` output_token_account -/// 5. `[writable]` input_vault -/// 6. `[writable]` output_vault -/// 7. `[writable]` observation_state -/// 8. `[]` token_program -/// 9. `[]` token_program2022 -/// 10. `[]` memo_program -/// 11. `[]` input_vault_mint -/// 12. `[]` output_vault_mint -#[derive(Clone, Debug)] -pub struct SwapV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapV2CpiBuilderInstruction { - __program: program, - payer: None, - amm_config: None, - pool_state: None, - input_token_account: None, - output_token_account: None, - input_vault: None, - output_vault: None, - observation_state: None, - token_program: None, - token_program2022: None, - memo_program: None, - input_vault_mint: None, - output_vault_mint: None, - amount: None, - other_amount_threshold: None, - sqrt_price_limit_x64: None, - is_base_input: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn input_token_account( - &mut self, - input_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_account = Some(input_token_account); - self - } - - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_account = Some(output_token_account); - self - } - - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - #[inline(always)] - pub fn output_vault( - &mut self, - output_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_vault = Some(output_vault); - self - } - - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn input_vault_mint( - &mut self, - input_vault_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault_mint = Some(input_vault_mint); - self - } - - #[inline(always)] - pub fn output_vault_mint( - &mut self, - output_vault_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_vault_mint = Some(output_vault_mint); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn other_amount_threshold(&mut self, other_amount_threshold: u64) -> &mut Self { - self.instruction.other_amount_threshold = Some(other_amount_threshold); - self - } - - #[inline(always)] - pub fn sqrt_price_limit_x64(&mut self, sqrt_price_limit_x64: u128) -> &mut Self { - self.instruction.sqrt_price_limit_x64 = Some(sqrt_price_limit_x64); - self - } - - #[inline(always)] - pub fn is_base_input(&mut self, is_base_input: bool) -> &mut Self { - self.instruction.is_base_input = Some(is_base_input); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapV2InstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - other_amount_threshold: self - .instruction - .other_amount_threshold - .clone() - .expect("other_amount_threshold is not set"), - sqrt_price_limit_x64: self - .instruction - .sqrt_price_limit_x64 - .clone() - .expect("sqrt_price_limit_x64 is not set"), - is_base_input: self - .instruction - .is_base_input - .clone() - .expect("is_base_input is not set"), - }; - let instruction = SwapV2Cpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - input_token_account: self - .instruction - .input_token_account - .expect("input_token_account is not set"), - - output_token_account: self - .instruction - .output_token_account - .expect("output_token_account is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - output_vault: self - .instruction - .output_vault - .expect("output_vault is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - - input_vault_mint: self - .instruction - .input_vault_mint - .expect("input_vault_mint is not set"), - - output_vault_mint: self - .instruction - .output_vault_mint - .expect("output_vault_mint is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - output_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_vault_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - other_amount_threshold: Option, - sqrt_price_limit_x64: Option, - is_base_input: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/transfer_reward_owner.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/transfer_reward_owner.rs deleted file mode 100644 index 01dd9e15..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/transfer_reward_owner.rs +++ /dev/null @@ -1,358 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct TransferRewardOwner { - pub authority: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, -} - -impl TransferRewardOwner { - pub fn instruction( - &self, - args: TransferRewardOwnerInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: TransferRewardOwnerInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&TransferRewardOwnerInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TransferRewardOwnerInstructionData { - discriminator: [u8; 8], -} - -impl TransferRewardOwnerInstructionData { - pub fn new() -> Self { - Self { - discriminator: [7, 22, 12, 83, 242, 43, 48, 121], - } - } -} - -impl Default for TransferRewardOwnerInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TransferRewardOwnerInstructionArgs { - pub new_owner: Pubkey, -} - -/// Instruction builder for `TransferRewardOwner`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[writable]` pool_state -#[derive(Clone, Debug, Default)] -pub struct TransferRewardOwnerBuilder { - authority: Option, - pool_state: Option, - new_owner: Option, - __remaining_accounts: Vec, -} - -impl TransferRewardOwnerBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn new_owner(&mut self, new_owner: Pubkey) -> &mut Self { - self.new_owner = Some(new_owner); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = TransferRewardOwner { - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - }; - let args = TransferRewardOwnerInstructionArgs { - new_owner: self.new_owner.clone().expect("new_owner is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `transfer_reward_owner` CPI accounts. -pub struct TransferRewardOwnerCpiAccounts<'a, 'b> { - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, -} - -/// `transfer_reward_owner` CPI instruction. -pub struct TransferRewardOwnerCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: TransferRewardOwnerInstructionArgs, -} - -impl<'a, 'b> TransferRewardOwnerCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: TransferRewardOwnerCpiAccounts<'a, 'b>, - args: TransferRewardOwnerInstructionArgs, - ) -> Self { - Self { - __program: program, - authority: accounts.authority, - pool_state: accounts.pool_state, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&TransferRewardOwnerInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `TransferRewardOwner` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[writable]` pool_state -#[derive(Clone, Debug)] -pub struct TransferRewardOwnerCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> TransferRewardOwnerCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(TransferRewardOwnerCpiBuilderInstruction { - __program: program, - authority: None, - pool_state: None, - new_owner: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn new_owner(&mut self, new_owner: Pubkey) -> &mut Self { - self.instruction.new_owner = Some(new_owner); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = TransferRewardOwnerInstructionArgs { - new_owner: self - .instruction - .new_owner - .clone() - .expect("new_owner is not set"), - }; - let instruction = TransferRewardOwnerCpi { - __program: self.instruction.__program, - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct TransferRewardOwnerCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - new_owner: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_amm_config.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_amm_config.rs deleted file mode 100644 index d8495fbf..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_amm_config.rs +++ /dev/null @@ -1,370 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateAmmConfig { - pub owner: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, -} - -impl UpdateAmmConfig { - pub fn instruction( - &self, - args: UpdateAmmConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateAmmConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm_config, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateAmmConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateAmmConfigInstructionData { - discriminator: [u8; 8], -} - -impl UpdateAmmConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [49, 60, 174, 136, 154, 28, 116, 200], - } - } -} - -impl Default for UpdateAmmConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateAmmConfigInstructionArgs { - pub param: u8, - pub value: u32, -} - -/// Instruction builder for `UpdateAmmConfig`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[writable]` amm_config -#[derive(Clone, Debug, Default)] -pub struct UpdateAmmConfigBuilder { - owner: Option, - amm_config: Option, - param: Option, - value: Option, - __remaining_accounts: Vec, -} - -impl UpdateAmmConfigBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.param = Some(param); - self - } - - #[inline(always)] - pub fn value(&mut self, value: u32) -> &mut Self { - self.value = Some(value); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateAmmConfig { - owner: self.owner.expect("owner is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - }; - let args = UpdateAmmConfigInstructionArgs { - param: self.param.clone().expect("param is not set"), - value: self.value.clone().expect("value is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_amm_config` CPI accounts. -pub struct UpdateAmmConfigCpiAccounts<'a, 'b> { - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_amm_config` CPI instruction. -pub struct UpdateAmmConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateAmmConfigInstructionArgs, -} - -impl<'a, 'b> UpdateAmmConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateAmmConfigCpiAccounts<'a, 'b>, - args: UpdateAmmConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - amm_config: accounts.amm_config, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_config.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateAmmConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.amm_config.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateAmmConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[writable]` amm_config -#[derive(Clone, Debug)] -pub struct UpdateAmmConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateAmmConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateAmmConfigCpiBuilderInstruction { - __program: program, - owner: None, - amm_config: None, - param: None, - value: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.instruction.param = Some(param); - self - } - - #[inline(always)] - pub fn value(&mut self, value: u32) -> &mut Self { - self.instruction.value = Some(value); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateAmmConfigInstructionArgs { - param: self.instruction.param.clone().expect("param is not set"), - value: self.instruction.value.clone().expect("value is not set"), - }; - let instruction = UpdateAmmConfigCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateAmmConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - param: Option, - value: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_operation_account.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_operation_account.rs deleted file mode 100644 index cb79ad76..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_operation_account.rs +++ /dev/null @@ -1,422 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateOperationAccount { - pub owner: solana_pubkey::Pubkey, - - pub operation_state: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl UpdateOperationAccount { - pub fn instruction( - &self, - args: UpdateOperationAccountInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateOperationAccountInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.operation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateOperationAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateOperationAccountInstructionData { - discriminator: [u8; 8], -} - -impl UpdateOperationAccountInstructionData { - pub fn new() -> Self { - Self { - discriminator: [127, 70, 119, 40, 188, 227, 61, 7], - } - } -} - -impl Default for UpdateOperationAccountInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateOperationAccountInstructionArgs { - pub param: u8, - pub keys: Vec, -} - -/// Instruction builder for `UpdateOperationAccount`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[writable]` operation_state -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct UpdateOperationAccountBuilder { - owner: Option, - operation_state: Option, - system_program: Option, - param: Option, - keys: Option>, - __remaining_accounts: Vec, -} - -impl UpdateOperationAccountBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn operation_state(&mut self, operation_state: solana_pubkey::Pubkey) -> &mut Self { - self.operation_state = Some(operation_state); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.param = Some(param); - self - } - - #[inline(always)] - pub fn keys(&mut self, keys: Vec) -> &mut Self { - self.keys = Some(keys); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateOperationAccount { - owner: self.owner.expect("owner is not set"), - operation_state: self.operation_state.expect("operation_state is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = UpdateOperationAccountInstructionArgs { - param: self.param.clone().expect("param is not set"), - keys: self.keys.clone().expect("keys is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_operation_account` CPI accounts. -pub struct UpdateOperationAccountCpiAccounts<'a, 'b> { - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub operation_state: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_operation_account` CPI instruction. -pub struct UpdateOperationAccountCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub operation_state: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateOperationAccountInstructionArgs, -} - -impl<'a, 'b> UpdateOperationAccountCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateOperationAccountCpiAccounts<'a, 'b>, - args: UpdateOperationAccountInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - operation_state: accounts.operation_state, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.operation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateOperationAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.operation_state.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateOperationAccount` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[writable]` operation_state -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct UpdateOperationAccountCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateOperationAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateOperationAccountCpiBuilderInstruction { - __program: program, - owner: None, - operation_state: None, - system_program: None, - param: None, - keys: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn operation_state( - &mut self, - operation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.operation_state = Some(operation_state); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.instruction.param = Some(param); - self - } - - #[inline(always)] - pub fn keys(&mut self, keys: Vec) -> &mut Self { - self.instruction.keys = Some(keys); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateOperationAccountInstructionArgs { - param: self.instruction.param.clone().expect("param is not set"), - keys: self.instruction.keys.clone().expect("keys is not set"), - }; - let instruction = UpdateOperationAccountCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - operation_state: self - .instruction - .operation_state - .expect("operation_state is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateOperationAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - operation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - param: Option, - keys: Option>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_pool_status.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_pool_status.rs deleted file mode 100644 index a1b18ee2..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_pool_status.rs +++ /dev/null @@ -1,353 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdatePoolStatus { - pub authority: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, -} - -impl UpdatePoolStatus { - pub fn instruction( - &self, - args: UpdatePoolStatusInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdatePoolStatusInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdatePoolStatusInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePoolStatusInstructionData { - discriminator: [u8; 8], -} - -impl UpdatePoolStatusInstructionData { - pub fn new() -> Self { - Self { - discriminator: [130, 87, 108, 6, 46, 224, 117, 123], - } - } -} - -impl Default for UpdatePoolStatusInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePoolStatusInstructionArgs { - pub status: u8, -} - -/// Instruction builder for `UpdatePoolStatus`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[writable]` pool_state -#[derive(Clone, Debug, Default)] -pub struct UpdatePoolStatusBuilder { - authority: Option, - pool_state: Option, - status: Option, - __remaining_accounts: Vec, -} - -impl UpdatePoolStatusBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn status(&mut self, status: u8) -> &mut Self { - self.status = Some(status); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdatePoolStatus { - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - }; - let args = UpdatePoolStatusInstructionArgs { - status: self.status.clone().expect("status is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_pool_status` CPI accounts. -pub struct UpdatePoolStatusCpiAccounts<'a, 'b> { - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_pool_status` CPI instruction. -pub struct UpdatePoolStatusCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdatePoolStatusInstructionArgs, -} - -impl<'a, 'b> UpdatePoolStatusCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdatePoolStatusCpiAccounts<'a, 'b>, - args: UpdatePoolStatusInstructionArgs, - ) -> Self { - Self { - __program: program, - authority: accounts.authority, - pool_state: accounts.pool_state, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdatePoolStatusInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdatePoolStatus` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[writable]` pool_state -#[derive(Clone, Debug)] -pub struct UpdatePoolStatusCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdatePoolStatusCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdatePoolStatusCpiBuilderInstruction { - __program: program, - authority: None, - pool_state: None, - status: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn status(&mut self, status: u8) -> &mut Self { - self.instruction.status = Some(status); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdatePoolStatusInstructionArgs { - status: self.instruction.status.clone().expect("status is not set"), - }; - let instruction = UpdatePoolStatusCpi { - __program: self.instruction.__program, - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdatePoolStatusCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - status: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_reward_infos.rs b/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_reward_infos.rs deleted file mode 100644 index c6f75149..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/instructions/update_reward_infos.rs +++ /dev/null @@ -1,277 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateRewardInfos { - pub pool_state: solana_pubkey::Pubkey, -} - -impl UpdateRewardInfos { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&UpdateRewardInfosInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateRewardInfosInstructionData { - discriminator: [u8; 8], -} - -impl UpdateRewardInfosInstructionData { - pub fn new() -> Self { - Self { - discriminator: [163, 172, 224, 52, 11, 154, 106, 223], - } - } -} - -impl Default for UpdateRewardInfosInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `UpdateRewardInfos`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool_state -#[derive(Clone, Debug, Default)] -pub struct UpdateRewardInfosBuilder { - pool_state: Option, - __remaining_accounts: Vec, -} - -impl UpdateRewardInfosBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateRewardInfos { - pool_state: self.pool_state.expect("pool_state is not set"), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `update_reward_infos` CPI accounts. -pub struct UpdateRewardInfosCpiAccounts<'a, 'b> { - pub pool_state: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_reward_infos` CPI instruction. -pub struct UpdateRewardInfosCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> UpdateRewardInfosCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateRewardInfosCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - pool_state: accounts.pool_state, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&UpdateRewardInfosInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::AMM_V3_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(2 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.pool_state.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateRewardInfos` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` pool_state -#[derive(Clone, Debug)] -pub struct UpdateRewardInfosCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateRewardInfosCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateRewardInfosCpiBuilderInstruction { - __program: program, - pool_state: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = UpdateRewardInfosCpi { - __program: self.instruction.__program, - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateRewardInfosCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/mod.rs b/crates/raydium-clmm-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/raydium-clmm-parser/src/generated_sdk/programs.rs b/crates/raydium-clmm-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 7d9ec6ba..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `amm_v3` program ID. -pub const AMM_V3_ID: Pubkey = pubkey!("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"); diff --git a/crates/raydium-clmm-parser/src/generated_sdk/shared.rs b/crates/raydium-clmm-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/types/mod.rs b/crates/raydium-clmm-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index d545d964..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#observation; -pub(crate) mod r#pool_status_bit_flag; -pub(crate) mod r#pool_status_bit_index; -pub(crate) mod r#position_reward_info; -pub(crate) mod r#reward_info; -pub(crate) mod r#reward_state; -pub(crate) mod r#tick_state; - -pub use self::{ - r#observation::*, r#pool_status_bit_flag::*, r#pool_status_bit_index::*, - r#position_reward_info::*, r#reward_info::*, r#reward_state::*, r#tick_state::*, -}; diff --git a/crates/raydium-clmm-parser/src/generated_sdk/types/observation.rs b/crates/raydium-clmm-parser/src/generated_sdk/types/observation.rs deleted file mode 100644 index 1e137c24..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/types/observation.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Observation { - pub block_timestamp: u32, - pub tick_cumulative: i64, - pub padding: [u64; 4], -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/types/pool_status_bit_flag.rs b/crates/raydium-clmm-parser/src/generated_sdk/types/pool_status_bit_flag.rs deleted file mode 100644 index 28bb547c..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/types/pool_status_bit_flag.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum PoolStatusBitFlag { - Enable, - Disable, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/types/pool_status_bit_index.rs b/crates/raydium-clmm-parser/src/generated_sdk/types/pool_status_bit_index.rs deleted file mode 100644 index 9c8ceae3..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/types/pool_status_bit_index.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum PoolStatusBitIndex { - OpenPositionOrIncreaseLiquidity, - DecreaseLiquidity, - CollectFee, - CollectReward, - Swap, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/types/position_reward_info.rs b/crates/raydium-clmm-parser/src/generated_sdk/types/position_reward_info.rs deleted file mode 100644 index ddcd21c1..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/types/position_reward_info.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PositionRewardInfo { - pub growth_inside_last_x64: u128, - pub reward_amount_owed: u64, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/types/reward_info.rs b/crates/raydium-clmm-parser/src/generated_sdk/types/reward_info.rs deleted file mode 100644 index ccbed471..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/types/reward_info.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RewardInfo { - pub reward_state: u8, - pub open_time: u64, - pub end_time: u64, - pub last_update_time: u64, - pub emissions_per_second_x64: u128, - pub reward_total_emissioned: u64, - pub reward_claimed: u64, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token_vault: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub authority: Pubkey, - pub reward_growth_global_x64: u128, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/types/reward_state.rs b/crates/raydium-clmm-parser/src/generated_sdk/types/reward_state.rs deleted file mode 100644 index 90874bae..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/types/reward_state.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum RewardState { - Uninitialized, - Initialized, - Opening, - Ended, -} diff --git a/crates/raydium-clmm-parser/src/generated_sdk/types/tick_state.rs b/crates/raydium-clmm-parser/src/generated_sdk/types/tick_state.rs deleted file mode 100644 index 16fd660f..00000000 --- a/crates/raydium-clmm-parser/src/generated_sdk/types/tick_state.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TickState { - pub tick: i32, - pub liquidity_net: i128, - pub liquidity_gross: u128, - pub fee_growth_outside0_x64: u128, - pub fee_growth_outside1_x64: u128, - pub reward_growths_outside_x64: [u128; 3], - pub padding: [u32; 13], -} diff --git a/crates/raydium-clmm-parser/src/lib.rs b/crates/raydium-clmm-parser/src/lib.rs deleted file mode 100644 index 8b8fee9f..00000000 --- a/crates/raydium-clmm-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = AMM_V3_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.raydium_clmm"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/raydium-cpmm-parser/Cargo.toml b/crates/raydium-cpmm-parser/Cargo.toml deleted file mode 100644 index 81faf7b3..00000000 --- a/crates/raydium-cpmm-parser/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "yellowstone-vixen-raydium-cpmm-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Raydium CPMM program" -license.workspace = true -repository.workspace = true -authors.workspace = true - -[dependencies] -prost.workspace = true -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info.workspace = true -solana-cpi.workspace = true -solana-decode-error.workspace = true -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction.workspace = true -solana-msg.workspace = true -solana-program-entrypoint.workspace = true -solana-program-error.workspace = true -borsh.workspace = true -num-derive.workspace = true -thiserror.workspace = true -num-traits.workspace = true -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build.workspace = true -protobuf-src.workspace = true \ No newline at end of file diff --git a/crates/raydium-cpmm-parser/build.rs b/crates/raydium-cpmm-parser/build.rs deleted file mode 100644 index 932b92ce..00000000 --- a/crates/raydium-cpmm-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/raydium_cpmm.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/raydium-cpmm-parser/idl.json b/crates/raydium-cpmm-parser/idl.json deleted file mode 100644 index 698e536a..00000000 --- a/crates/raydium-cpmm-parser/idl.json +++ /dev/null @@ -1,2055 +0,0 @@ -{ - "address": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C", - "metadata": { - "name": "raydium_cp_swap", - "version": "0.2.0", - "spec": "0.1.0", - "description": "Raydium constant product AMM, supports Token2022 and without Openbook" - }, - "instructions": [ - { - "name": "close_permission_pda", - "docs": [ - "Close a permission account", - "", - "# Arguments", - "", - "* `ctx`- The context of accounts", - "" - ], - "discriminator": [156, 84, 32, 118, 69, 135, 70, 123], - "accounts": [ - { - "name": "owner", - "writable": true, - "signer": true, - "address": "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - }, - { - "name": "permission_authority" - }, - { - "name": "permission", - "docs": [ - "Initialize config state account to store protocol owner address and fee rates." - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [112, 101, 114, 109, 105, 115, 115, 105, 111, 110] - }, - { - "kind": "account", - "path": "permission_authority" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "collect_creator_fee", - "docs": [ - "Collect the creator fee", - "", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "" - ], - "discriminator": [20, 22, 86, 123, 198, 28, 219, 132], - "accounts": [ - { - "name": "creator", - "docs": ["Only pool creator can collect fee"], - "writable": true, - "signer": true - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, 97, 117, 108, 116, 95, 97, 110, 100, 95, 108, 112, 95, - 109, 105, 110, 116, 95, 97, 117, 116, 104, 95, 115, 101, 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": ["Pool state stores accumulated protocol fee amount"], - "writable": true - }, - { - "name": "amm_config", - "docs": ["Amm config account stores fund_owner"] - }, - { - "name": "token_0_vault", - "docs": ["The address that holds pool tokens for token_0"], - "writable": true - }, - { - "name": "token_1_vault", - "docs": ["The address that holds pool tokens for token_1"], - "writable": true - }, - { - "name": "vault_0_mint", - "docs": ["The mint of token_0 vault"] - }, - { - "name": "vault_1_mint", - "docs": ["The mint of token_1 vault"] - }, - { - "name": "creator_token_0", - "docs": ["The address that receives the collected token_0 fund fees"], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "creator" - }, - { - "kind": "account", - "path": "token_0_program" - }, - { - "kind": "account", - "path": "vault_0_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": "creator_token_1", - "docs": ["The address that receives the collected token_1 fund fees"], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "creator" - }, - { - "kind": "account", - "path": "token_1_program" - }, - { - "kind": "account", - "path": "vault_1_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, - 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, - 219, 233, 248, 89 - ] - } - } - }, - { - "name": "token_0_program", - "docs": ["Spl token program or token program 2022"] - }, - { - "name": "token_1_program", - "docs": ["Spl token program or token program 2022"] - }, - { - "name": "associated_token_program", - "docs": ["Program to create an ATA for receiving position NFT"], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "docs": ["To create a new program account"], - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "collect_fund_fee", - "docs": [ - "Collect the fund fee accrued to the pool", - "", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `amount_0_requested` - The maximum amount of token_0 to send, can be 0 to collect fees in only token_1", - "* `amount_1_requested` - The maximum amount of token_1 to send, can be 0 to collect fees in only token_0", - "" - ], - "discriminator": [167, 138, 78, 149, 223, 194, 6, 126], - "accounts": [ - { - "name": "owner", - "docs": ["Only admin or fund_owner can collect fee now"], - "signer": true - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, 97, 117, 108, 116, 95, 97, 110, 100, 95, 108, 112, 95, - 109, 105, 110, 116, 95, 97, 117, 116, 104, 95, 115, 101, 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": ["Pool state stores accumulated protocol fee amount"], - "writable": true - }, - { - "name": "amm_config", - "docs": ["Amm config account stores fund_owner"] - }, - { - "name": "token_0_vault", - "docs": ["The address that holds pool tokens for token_0"], - "writable": true - }, - { - "name": "token_1_vault", - "docs": ["The address that holds pool tokens for token_1"], - "writable": true - }, - { - "name": "vault_0_mint", - "docs": ["The mint of token_0 vault"] - }, - { - "name": "vault_1_mint", - "docs": ["The mint of token_1 vault"] - }, - { - "name": "recipient_token_0_account", - "docs": ["The address that receives the collected token_0 fund fees"], - "writable": true - }, - { - "name": "recipient_token_1_account", - "docs": ["The address that receives the collected token_1 fund fees"], - "writable": true - }, - { - "name": "token_program", - "docs": ["The SPL program to perform token transfers"], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_program_2022", - "docs": ["The SPL program 2022 to perform token transfers"], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - } - ], - "args": [ - { - "name": "amount_0_requested", - "type": "u64" - }, - { - "name": "amount_1_requested", - "type": "u64" - } - ] - }, - { - "name": "collect_protocol_fee", - "docs": [ - "Collect the protocol fee accrued to the pool", - "", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `amount_0_requested` - The maximum amount of token_0 to send, can be 0 to collect fees in only token_1", - "* `amount_1_requested` - The maximum amount of token_1 to send, can be 0 to collect fees in only token_0", - "" - ], - "discriminator": [136, 136, 252, 221, 194, 66, 126, 89], - "accounts": [ - { - "name": "owner", - "docs": ["Only admin or owner can collect fee now"], - "signer": true - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, 97, 117, 108, 116, 95, 97, 110, 100, 95, 108, 112, 95, - 109, 105, 110, 116, 95, 97, 117, 116, 104, 95, 115, 101, 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": ["Pool state stores accumulated protocol fee amount"], - "writable": true - }, - { - "name": "amm_config", - "docs": ["Amm config account stores owner"] - }, - { - "name": "token_0_vault", - "docs": ["The address that holds pool tokens for token_0"], - "writable": true - }, - { - "name": "token_1_vault", - "docs": ["The address that holds pool tokens for token_1"], - "writable": true - }, - { - "name": "vault_0_mint", - "docs": ["The mint of token_0 vault"] - }, - { - "name": "vault_1_mint", - "docs": ["The mint of token_1 vault"] - }, - { - "name": "recipient_token_0_account", - "docs": [ - "The address that receives the collected token_0 protocol fees" - ], - "writable": true - }, - { - "name": "recipient_token_1_account", - "docs": [ - "The address that receives the collected token_1 protocol fees" - ], - "writable": true - }, - { - "name": "token_program", - "docs": ["The SPL program to perform token transfers"], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_program_2022", - "docs": ["The SPL program 2022 to perform token transfers"], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - } - ], - "args": [ - { - "name": "amount_0_requested", - "type": "u64" - }, - { - "name": "amount_1_requested", - "type": "u64" - } - ] - }, - { - "name": "create_amm_config", - "docs": [ - "# Arguments", - "", - "* `ctx`- The accounts needed by instruction.", - "* `index` - The index of amm config, there may be multiple config.", - "* `trade_fee_rate` - Trade fee rate, can be changed.", - "* `protocol_fee_rate` - The rate of protocol fee within trade fee.", - "* `fund_fee_rate` - The rate of fund fee within trade fee.", - "" - ], - "discriminator": [137, 52, 237, 212, 215, 117, 108, 104], - "accounts": [ - { - "name": "owner", - "docs": ["Address to be set as protocol owner."], - "writable": true, - "signer": true, - "address": "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - }, - { - "name": "amm_config", - "docs": [ - "Initialize config state account to store protocol owner address and fee rates." - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [97, 109, 109, 95, 99, 111, 110, 102, 105, 103] - }, - { - "kind": "arg", - "path": "index" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "index", - "type": "u16" - }, - { - "name": "trade_fee_rate", - "type": "u64" - }, - { - "name": "protocol_fee_rate", - "type": "u64" - }, - { - "name": "fund_fee_rate", - "type": "u64" - }, - { - "name": "create_pool_fee", - "type": "u64" - }, - { - "name": "creator_fee_rate", - "type": "u64" - } - ] - }, - { - "name": "create_permission_pda", - "docs": [ - "Create a permission account", - "", - "# Arguments", - "", - "* `ctx`- The context of accounts", - "" - ], - "discriminator": [135, 136, 2, 216, 137, 169, 181, 202], - "accounts": [ - { - "name": "owner", - "writable": true, - "signer": true, - "address": "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - }, - { - "name": "permission_authority" - }, - { - "name": "permission", - "docs": [ - "Initialize config state account to store protocol owner address and fee rates." - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [112, 101, 114, 109, 105, 115, 115, 105, 111, 110] - }, - { - "kind": "account", - "path": "permission_authority" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "deposit", - "docs": [ - "Deposit lp token to the pool", - "", - "# Arguments", - "", - "* `ctx`- The context of accounts", - "* `lp_token_amount` - Increased number of LPs", - "* `maximum_token_0_amount` - Maximum token 0 amount to deposit, prevents excessive slippage", - "* `maximum_token_1_amount` - Maximum token 1 amount to deposit, prevents excessive slippage", - "" - ], - "discriminator": [242, 35, 198, 137, 82, 225, 242, 182], - "accounts": [ - { - "name": "owner", - "docs": ["Pays to mint the position"], - "signer": true - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, 97, 117, 108, 116, 95, 97, 110, 100, 95, 108, 112, 95, - 109, 105, 110, 116, 95, 97, 117, 116, 104, 95, 115, 101, 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "writable": true - }, - { - "name": "owner_lp_token", - "docs": ["Owner lp token account"], - "writable": true - }, - { - "name": "token_0_account", - "docs": ["The payer's token account for token_0"], - "writable": true - }, - { - "name": "token_1_account", - "docs": ["The payer's token account for token_1"], - "writable": true - }, - { - "name": "token_0_vault", - "docs": ["The address that holds pool tokens for token_0"], - "writable": true - }, - { - "name": "token_1_vault", - "docs": ["The address that holds pool tokens for token_1"], - "writable": true - }, - { - "name": "token_program", - "docs": ["token Program"], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_program_2022", - "docs": ["Token program 2022"], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "vault_0_mint", - "docs": ["The mint of token_0 vault"] - }, - { - "name": "vault_1_mint", - "docs": ["The mint of token_1 vault"] - }, - { - "name": "lp_mint", - "docs": ["Lp token mint"], - "writable": true - } - ], - "args": [ - { - "name": "lp_token_amount", - "type": "u64" - }, - { - "name": "maximum_token_0_amount", - "type": "u64" - }, - { - "name": "maximum_token_1_amount", - "type": "u64" - } - ] - }, - { - "name": "initialize", - "docs": [ - "Creates a pool for the given token pair and the initial price", - "", - "# Arguments", - "", - "* `ctx`- The context of accounts", - "* `init_amount_0` - the initial amount_0 to deposit", - "* `init_amount_1` - the initial amount_1 to deposit", - "* `open_time` - the timestamp allowed for swap", - "" - ], - "discriminator": [175, 175, 109, 31, 13, 152, 155, 237], - "accounts": [ - { - "name": "creator", - "docs": ["Address paying to create the pool. Can be anyone"], - "writable": true, - "signer": true - }, - { - "name": "amm_config", - "docs": ["Which config the pool belongs to."] - }, - { - "name": "authority", - "docs": ["pool vault and lp mint authority"], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, 97, 117, 108, 116, 95, 97, 110, 100, 95, 108, 112, 95, - 109, 105, 110, 116, 95, 97, 117, 116, 104, 95, 115, 101, 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "PDA account:", - "seeds = [", - "POOL_SEED.as_bytes(),", - "amm_config.key().as_ref(),", - "token_0_mint.key().as_ref(),", - "token_1_mint.key().as_ref(),", - "],", - "", - "Or random account: must be signed by cli" - ], - "writable": true - }, - { - "name": "token_0_mint", - "docs": ["Token_0 mint, the key must smaller than token_1 mint."] - }, - { - "name": "token_1_mint", - "docs": ["Token_1 mint, the key must grater then token_0 mint."] - }, - { - "name": "lp_mint", - "docs": ["pool lp mint"], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, 111, 111, 108, 95, 108, 112, 95, 109, 105, 110, 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - } - ] - } - }, - { - "name": "creator_token_0", - "docs": ["payer token0 account"], - "writable": true - }, - { - "name": "creator_token_1", - "docs": ["creator token1 account"], - "writable": true - }, - { - "name": "creator_lp_token", - "docs": ["creator lp token account"], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "creator" - }, - { - "kind": "const", - "value": [ - 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, - 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, - 245, 133, 126, 255, 0, 169 - ] - }, - { - "kind": "account", - "path": "lp_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, - 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, - 219, 233, 248, 89 - ] - } - } - }, - { - "name": "token_0_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [112, 111, 111, 108, 95, 118, 97, 117, 108, 116] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "token_1_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [112, 111, 111, 108, 95, 118, 97, 117, 108, 116] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "token_1_mint" - } - ] - } - }, - { - "name": "create_pool_fee", - "docs": ["create pool fee account"], - "writable": true, - "address": "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8" - }, - { - "name": "observation_state", - "docs": ["an account to store oracle observations"], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [111, 98, 115, 101, 114, 118, 97, 116, 105, 111, 110] - }, - { - "kind": "account", - "path": "pool_state" - } - ] - } - }, - { - "name": "token_program", - "docs": ["Program to create mint account and mint tokens"], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_0_program", - "docs": ["Spl token program or token program 2022"] - }, - { - "name": "token_1_program", - "docs": ["Spl token program or token program 2022"] - }, - { - "name": "associated_token_program", - "docs": ["Program to create an ATA for receiving position NFT"], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "docs": ["To create a new program account"], - "address": "11111111111111111111111111111111" - }, - { - "name": "rent", - "docs": ["Sysvar for program account"], - "address": "SysvarRent111111111111111111111111111111111" - } - ], - "args": [ - { - "name": "init_amount_0", - "type": "u64" - }, - { - "name": "init_amount_1", - "type": "u64" - }, - { - "name": "open_time", - "type": "u64" - } - ] - }, - { - "name": "initialize_with_permission", - "docs": [ - "Create a pool with permission", - "", - "# Arguments", - "", - "* `ctx`- The context of accounts", - "* `init_amount_0` - the initial amount_0 to deposit", - "* `init_amount_1` - the initial amount_1 to deposit", - "* `open_time` - the timestamp allowed for swap", - "* `creator_fee_on` - creator fee model, 0:both token0 and token1 (depends on the input), 1: only token0, 2: only token1", - "" - ], - "discriminator": [63, 55, 254, 65, 49, 178, 89, 121], - "accounts": [ - { - "name": "payer", - "docs": ["Address paying to create the pool. Can be anyone"], - "writable": true, - "signer": true - }, - { - "name": "creator" - }, - { - "name": "amm_config", - "docs": ["Which config the pool belongs to."] - }, - { - "name": "authority", - "docs": ["pool vault and lp mint authority"], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, 97, 117, 108, 116, 95, 97, 110, 100, 95, 108, 112, 95, - 109, 105, 110, 116, 95, 97, 117, 116, 104, 95, 115, 101, 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "PDA account:", - "seeds = [", - "POOL_SEED.as_bytes(),", - "amm_config.key().as_ref(),", - "token_0_mint.key().as_ref(),", - "token_1_mint.key().as_ref(),", - "],", - "", - "Or random account: must be signed by cli" - ], - "writable": true - }, - { - "name": "token_0_mint", - "docs": ["Token_0 mint, the key must smaller than token_1 mint."] - }, - { - "name": "token_1_mint", - "docs": ["Token_1 mint, the key must grater then token_0 mint."] - }, - { - "name": "lp_mint", - "docs": ["pool lp mint"], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, 111, 111, 108, 95, 108, 112, 95, 109, 105, 110, 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - } - ] - } - }, - { - "name": "payer_token_0", - "docs": ["payer token0 account"], - "writable": true - }, - { - "name": "payer_token_1", - "docs": ["payer token1 account"], - "writable": true - }, - { - "name": "payer_lp_token", - "docs": ["payer lp token account"], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "payer" - }, - { - "kind": "const", - "value": [ - 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, - 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, - 245, 133, 126, 255, 0, 169 - ] - }, - { - "kind": "account", - "path": "lp_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, - 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, - 219, 233, 248, 89 - ] - } - } - }, - { - "name": "token_0_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [112, 111, 111, 108, 95, 118, 97, 117, 108, 116] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "token_0_mint" - } - ] - } - }, - { - "name": "token_1_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [112, 111, 111, 108, 95, 118, 97, 117, 108, 116] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "token_1_mint" - } - ] - } - }, - { - "name": "create_pool_fee", - "docs": ["create pool fee account"], - "writable": true, - "address": "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8" - }, - { - "name": "observation_state", - "docs": ["an account to store oracle observations"], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [111, 98, 115, 101, 114, 118, 97, 116, 105, 111, 110] - }, - { - "kind": "account", - "path": "pool_state" - } - ] - } - }, - { - "name": "permission", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [112, 101, 114, 109, 105, 115, 115, 105, 111, 110] - }, - { - "kind": "account", - "path": "payer" - } - ] - } - }, - { - "name": "token_program", - "docs": ["Program to create mint account and mint tokens"], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_0_program", - "docs": ["Spl token program or token program 2022"] - }, - { - "name": "token_1_program", - "docs": ["Spl token program or token program 2022"] - }, - { - "name": "associated_token_program", - "docs": ["Program to create an ATA for receiving position NFT"], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "docs": ["To create a new program account"], - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "init_amount_0", - "type": "u64" - }, - { - "name": "init_amount_1", - "type": "u64" - }, - { - "name": "open_time", - "type": "u64" - }, - { - "name": "creator_fee_on", - "type": { - "defined": { - "name": "CreatorFeeOn" - } - } - } - ] - }, - { - "name": "swap_base_input", - "docs": [ - "Swap the tokens in the pool base input amount", - "", - "# Arguments", - "", - "* `ctx`- The context of accounts", - "* `amount_in` - input amount to transfer, output to DESTINATION is based on the exchange rate", - "* `minimum_amount_out` - Minimum amount of output token, prevents excessive slippage", - "" - ], - "discriminator": [143, 190, 90, 218, 196, 30, 51, 222], - "accounts": [ - { - "name": "payer", - "docs": ["The user performing the swap"], - "signer": true - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, 97, 117, 108, 116, 95, 97, 110, 100, 95, 108, 112, 95, - 109, 105, 110, 116, 95, 97, 117, 116, 104, 95, 115, 101, 101, - 100 - ] - } - ] - } - }, - { - "name": "amm_config", - "docs": ["The factory state to read protocol fees"] - }, - { - "name": "pool_state", - "docs": [ - "The program account of the pool in which the swap will be performed" - ], - "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": "input_vault", - "docs": ["The vault token account for input token"], - "writable": true - }, - { - "name": "output_vault", - "docs": ["The vault token account for output token"], - "writable": true - }, - { - "name": "input_token_program", - "docs": ["SPL program for input token transfers"] - }, - { - "name": "output_token_program", - "docs": ["SPL program for output token transfers"] - }, - { - "name": "input_token_mint", - "docs": ["The mint of input token"] - }, - { - "name": "output_token_mint", - "docs": ["The mint of output token"] - }, - { - "name": "observation_state", - "docs": [ - "The program account for the most recent oracle observation" - ], - "writable": true - } - ], - "args": [ - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "minimum_amount_out", - "type": "u64" - } - ] - }, - { - "name": "swap_base_output", - "docs": [ - "Swap the tokens in the pool base output amount", - "", - "# Arguments", - "", - "* `ctx`- The context of accounts", - "* `max_amount_in` - input amount prevents excessive slippage", - "* `amount_out` - amount of output token", - "" - ], - "discriminator": [55, 217, 98, 86, 163, 74, 180, 173], - "accounts": [ - { - "name": "payer", - "docs": ["The user performing the swap"], - "signer": true - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, 97, 117, 108, 116, 95, 97, 110, 100, 95, 108, 112, 95, - 109, 105, 110, 116, 95, 97, 117, 116, 104, 95, 115, 101, 101, - 100 - ] - } - ] - } - }, - { - "name": "amm_config", - "docs": ["The factory state to read protocol fees"] - }, - { - "name": "pool_state", - "docs": [ - "The program account of the pool in which the swap will be performed" - ], - "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": "input_vault", - "docs": ["The vault token account for input token"], - "writable": true - }, - { - "name": "output_vault", - "docs": ["The vault token account for output token"], - "writable": true - }, - { - "name": "input_token_program", - "docs": ["SPL program for input token transfers"] - }, - { - "name": "output_token_program", - "docs": ["SPL program for output token transfers"] - }, - { - "name": "input_token_mint", - "docs": ["The mint of input token"] - }, - { - "name": "output_token_mint", - "docs": ["The mint of output token"] - }, - { - "name": "observation_state", - "docs": [ - "The program account for the most recent oracle observation" - ], - "writable": true - } - ], - "args": [ - { - "name": "max_amount_in", - "type": "u64" - }, - { - "name": "amount_out", - "type": "u64" - } - ] - }, - { - "name": "update_amm_config", - "docs": [ - "Updates the owner of the amm config", - "Must be called by the current owner or admin", - "", - "# Arguments", - "", - "* `ctx`- The context of accounts", - "* `trade_fee_rate`- The new trade fee rate of amm config, be set when `param` is 0", - "* `protocol_fee_rate`- The new protocol fee rate of amm config, be set when `param` is 1", - "* `fund_fee_rate`- The new fund fee rate of amm config, be set when `param` is 2", - "* `new_owner`- The config's new owner, be set when `param` is 3", - "* `new_fund_owner`- The config's new fund owner, be set when `param` is 4", - "* `param`- The value can be 0 | 1 | 2 | 3 | 4, otherwise will report a error", - "" - ], - "discriminator": [49, 60, 174, 136, 154, 28, 116, 200], - "accounts": [ - { - "name": "owner", - "docs": ["The amm config owner or admin"], - "signer": true, - "address": "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - }, - { - "name": "amm_config", - "docs": ["Amm config account to be changed"], - "writable": true - } - ], - "args": [ - { - "name": "param", - "type": "u8" - }, - { - "name": "value", - "type": "u64" - } - ] - }, - { - "name": "update_pool_status", - "docs": [ - "Update pool status for given value", - "", - "# Arguments", - "", - "* `ctx`- The context of accounts", - "* `status` - The value of status", - "" - ], - "discriminator": [130, 87, 108, 6, 46, 224, 117, 123], - "accounts": [ - { - "name": "authority", - "signer": true, - "address": "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - }, - { - "name": "pool_state", - "writable": true - } - ], - "args": [ - { - "name": "status", - "type": "u8" - } - ] - }, - { - "name": "withdraw", - "docs": [ - "Withdraw lp for token0 and token1", - "", - "# Arguments", - "", - "* `ctx`- The context of accounts", - "* `lp_token_amount` - Amount of pool tokens to burn. User receives an output of token a and b based on the percentage of the pool tokens that are returned.", - "* `minimum_token_0_amount` - Minimum amount of token 0 to receive, prevents excessive slippage", - "* `minimum_token_1_amount` - Minimum amount of token 1 to receive, prevents excessive slippage", - "" - ], - "discriminator": [183, 18, 70, 156, 148, 109, 161, 34], - "accounts": [ - { - "name": "owner", - "docs": ["Pays to mint the position"], - "signer": true - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, 97, 117, 108, 116, 95, 97, 110, 100, 95, 108, 112, 95, - 109, 105, 110, 116, 95, 97, 117, 116, 104, 95, 115, 101, 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": ["Pool state account"], - "writable": true - }, - { - "name": "owner_lp_token", - "docs": ["Owner lp token account"], - "writable": true - }, - { - "name": "token_0_account", - "docs": ["The token account for receive token_0,"], - "writable": true - }, - { - "name": "token_1_account", - "docs": ["The token account for receive token_1"], - "writable": true - }, - { - "name": "token_0_vault", - "docs": ["The address that holds pool tokens for token_0"], - "writable": true - }, - { - "name": "token_1_vault", - "docs": ["The address that holds pool tokens for token_1"], - "writable": true - }, - { - "name": "token_program", - "docs": ["token Program"], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "token_program_2022", - "docs": ["Token program 2022"], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "vault_0_mint", - "docs": ["The mint of token_0 vault"] - }, - { - "name": "vault_1_mint", - "docs": ["The mint of token_1 vault"] - }, - { - "name": "lp_mint", - "docs": ["Pool lp token mint"], - "writable": true - }, - { - "name": "memo_program", - "docs": ["memo program"], - "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" - } - ], - "args": [ - { - "name": "lp_token_amount", - "type": "u64" - }, - { - "name": "minimum_token_0_amount", - "type": "u64" - }, - { - "name": "minimum_token_1_amount", - "type": "u64" - } - ] - } - ], - "accounts": [ - { - "name": "AmmConfig", - "discriminator": [218, 244, 33, 104, 203, 203, 43, 111] - }, - { - "name": "ObservationState", - "discriminator": [122, 174, 197, 53, 129, 9, 165, 132] - }, - { - "name": "Permission", - "discriminator": [224, 83, 28, 79, 10, 253, 161, 28] - }, - { - "name": "PoolState", - "discriminator": [247, 237, 227, 245, 215, 195, 222, 70] - } - ], - "events": [ - { - "name": "LpChangeEvent", - "discriminator": [121, 163, 205, 201, 57, 218, 117, 60] - }, - { - "name": "SwapEvent", - "discriminator": [64, 198, 205, 232, 38, 8, 113, 226] - } - ], - "errors": [ - { - "code": 6000, - "name": "NotApproved", - "msg": "Not approved" - }, - { - "code": 6001, - "name": "InvalidOwner", - "msg": "Input account owner is not the program address" - }, - { - "code": 6002, - "name": "EmptySupply", - "msg": "Input token account empty" - }, - { - "code": 6003, - "name": "InvalidInput", - "msg": "InvalidInput" - }, - { - "code": 6004, - "name": "IncorrectLpMint", - "msg": "Address of the provided lp token mint is incorrect" - }, - { - "code": 6005, - "name": "ExceededSlippage", - "msg": "Exceeds desired slippage limit" - }, - { - "code": 6006, - "name": "ZeroTradingTokens", - "msg": "Given pool token amount results in zero trading tokens" - }, - { - "code": 6007, - "name": "NotSupportMint", - "msg": "Not support token_2022 mint extension" - }, - { - "code": 6008, - "name": "InvalidVault", - "msg": "invaild vault" - }, - { - "code": 6009, - "name": "InitLpAmountTooLess", - "msg": "Init lp amount is too less(Because 100 amount lp will be locked)" - }, - { - "code": 6010, - "name": "TransferFeeCalculateNotMatch", - "msg": "TransferFee calculate not match" - }, - { - "code": 6011, - "name": "MathOverflow", - "msg": "Math overflow" - }, - { - "code": 6012, - "name": "InsufficientVault", - "msg": "Insufficient vault" - }, - { - "code": 6013, - "name": "InvalidFeeModel", - "msg": "Invalid fee model" - }, - { - "code": 6014, - "name": "NoFeeCollect", - "msg": "Fee is zero" - } - ], - "types": [ - { - "name": "AmmConfig", - "docs": ["Holds the current owner of the factory"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "docs": ["Bump to identify PDA"], - "type": "u8" - }, - { - "name": "disable_create_pool", - "docs": ["Status to control if new pool can be create"], - "type": "bool" - }, - { - "name": "index", - "docs": ["Config index"], - "type": "u16" - }, - { - "name": "trade_fee_rate", - "docs": [ - "The trade fee, denominated in hundredths of a bip (10^-6)" - ], - "type": "u64" - }, - { - "name": "protocol_fee_rate", - "docs": ["The protocol fee"], - "type": "u64" - }, - { - "name": "fund_fee_rate", - "docs": [ - "The fund fee, denominated in hundredths of a bip (10^-6)" - ], - "type": "u64" - }, - { - "name": "create_pool_fee", - "docs": ["Fee for create a new pool"], - "type": "u64" - }, - { - "name": "protocol_owner", - "docs": ["Address of the protocol fee owner"], - "type": "pubkey" - }, - { - "name": "fund_owner", - "docs": ["Address of the fund fee owner"], - "type": "pubkey" - }, - { - "name": "creator_fee_rate", - "docs": [ - "The pool creator fee, denominated in hundredths of a bip (10^-6)" - ], - "type": "u64" - }, - { - "name": "padding", - "docs": ["padding"], - "type": { - "array": ["u64", 15] - } - } - ] - } - }, - { - "name": "CreatorFeeOn", - "type": { - "kind": "enum", - "variants": [ - { - "name": "BothToken" - }, - { - "name": "OnlyToken0" - }, - { - "name": "OnlyToken1" - } - ] - } - }, - { - "name": "LpChangeEvent", - "docs": ["Emitted when deposit and withdraw"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_id", - "type": "pubkey" - }, - { - "name": "lp_amount_before", - "type": "u64" - }, - { - "name": "token_0_vault_before", - "docs": ["pool vault sub trade fees"], - "type": "u64" - }, - { - "name": "token_1_vault_before", - "docs": ["pool vault sub trade fees"], - "type": "u64" - }, - { - "name": "token_0_amount", - "docs": ["calculate result without transfer fee"], - "type": "u64" - }, - { - "name": "token_1_amount", - "docs": ["calculate result without transfer fee"], - "type": "u64" - }, - { - "name": "token_0_transfer_fee", - "type": "u64" - }, - { - "name": "token_1_transfer_fee", - "type": "u64" - }, - { - "name": "change_type", - "type": "u8" - } - ] - } - }, - { - "name": "Observation", - "docs": ["The element of observations in ObservationState"], - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c", - "packed": true - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "block_timestamp", - "docs": ["The block timestamp of the observation"], - "type": "u64" - }, - { - "name": "cumulative_token_0_price_x32", - "docs": [ - "the cumulative of token0 price during the duration time, Q32.32, the remaining 64 bit for overflow" - ], - "type": "u128" - }, - { - "name": "cumulative_token_1_price_x32", - "docs": [ - "the cumulative of token1 price during the duration time, Q32.32, the remaining 64 bit for overflow" - ], - "type": "u128" - } - ] - } - }, - { - "name": "ObservationState", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c", - "packed": true - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "initialized", - "docs": ["Whether the ObservationState is initialized"], - "type": "bool" - }, - { - "name": "observation_index", - "docs": [ - "the most-recently updated index of the observations array" - ], - "type": "u16" - }, - { - "name": "pool_id", - "type": "pubkey" - }, - { - "name": "observations", - "docs": ["observation array"], - "type": { - "array": [ - { - "defined": { - "name": "Observation" - } - }, - 100 - ] - } - }, - { - "name": "padding", - "docs": ["padding for feature update"], - "type": { - "array": ["u64", 4] - } - } - ] - } - }, - { - "name": "Permission", - "docs": ["Holds the current owner of the factory"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": ["authority"], - "type": "pubkey" - }, - { - "name": "padding", - "docs": ["padding"], - "type": { - "array": ["u64", 30] - } - } - ] - } - }, - { - "name": "PoolState", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c", - "packed": true - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "amm_config", - "docs": ["Which config the pool belongs"], - "type": "pubkey" - }, - { - "name": "pool_creator", - "docs": ["pool creator"], - "type": "pubkey" - }, - { - "name": "token_0_vault", - "docs": ["Token A"], - "type": "pubkey" - }, - { - "name": "token_1_vault", - "docs": ["Token B"], - "type": "pubkey" - }, - { - "name": "lp_mint", - "docs": [ - "Pool tokens are issued when A or B tokens are deposited.", - "Pool tokens can be withdrawn back to the original A or B token." - ], - "type": "pubkey" - }, - { - "name": "token_0_mint", - "docs": ["Mint information for token A"], - "type": "pubkey" - }, - { - "name": "token_1_mint", - "docs": ["Mint information for token B"], - "type": "pubkey" - }, - { - "name": "token_0_program", - "docs": ["token_0 program"], - "type": "pubkey" - }, - { - "name": "token_1_program", - "docs": ["token_1 program"], - "type": "pubkey" - }, - { - "name": "observation_key", - "docs": ["observation account to store oracle data"], - "type": "pubkey" - }, - { - "name": "auth_bump", - "type": "u8" - }, - { - "name": "status", - "docs": [ - "Bitwise representation of the state of the pool", - "bit0, 1: disable deposit(value is 1), 0: normal", - "bit1, 1: disable withdraw(value is 2), 0: normal", - "bit2, 1: disable swap(value is 4), 0: normal" - ], - "type": "u8" - }, - { - "name": "lp_mint_decimals", - "type": "u8" - }, - { - "name": "mint_0_decimals", - "docs": ["mint0 and mint1 decimals"], - "type": "u8" - }, - { - "name": "mint_1_decimals", - "type": "u8" - }, - { - "name": "lp_supply", - "docs": ["True circulating supply without burns and lock ups"], - "type": "u64" - }, - { - "name": "protocol_fees_token_0", - "docs": [ - "The amounts of token_0 and token_1 that are owed to the liquidity provider." - ], - "type": "u64" - }, - { - "name": "protocol_fees_token_1", - "type": "u64" - }, - { - "name": "fund_fees_token_0", - "type": "u64" - }, - { - "name": "fund_fees_token_1", - "type": "u64" - }, - { - "name": "open_time", - "docs": ["The timestamp allowed for swap in the pool."], - "type": "u64" - }, - { - "name": "recent_epoch", - "docs": ["recent epoch"], - "type": "u64" - }, - { - "name": "creator_fee_on", - "docs": [ - "Creator fee collect mode", - "0: both token_0 and token_1 can be used as trade fees. It depends on what the input token is when swapping", - "1: only token_0 as trade fee", - "2: only token_1 as trade fee" - ], - "type": "u8" - }, - { - "name": "enable_creator_fee", - "type": "bool" - }, - { - "name": "padding1", - "type": { - "array": ["u8", 6] - } - }, - { - "name": "creator_fees_token_0", - "type": "u64" - }, - { - "name": "creator_fees_token_1", - "type": "u64" - }, - { - "name": "padding", - "docs": ["padding for future updates"], - "type": { - "array": ["u64", 28] - } - } - ] - } - }, - { - "name": "SwapEvent", - "docs": ["Emitted when swap"], - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_id", - "type": "pubkey" - }, - { - "name": "input_vault_before", - "docs": ["pool vault sub trade fees"], - "type": "u64" - }, - { - "name": "output_vault_before", - "docs": ["pool vault sub trade fees"], - "type": "u64" - }, - { - "name": "input_amount", - "docs": ["calculate result without transfer fee"], - "type": "u64" - }, - { - "name": "output_amount", - "docs": ["calculate result without transfer fee"], - "type": "u64" - }, - { - "name": "input_transfer_fee", - "type": "u64" - }, - { - "name": "output_transfer_fee", - "type": "u64" - }, - { - "name": "base_input", - "type": "bool" - }, - { - "name": "input_mint", - "type": "pubkey" - }, - { - "name": "output_mint", - "type": "pubkey" - }, - { - "name": "trade_fee", - "type": "u64" - }, - { - "name": "creator_fee", - "docs": ["Amount of fee tokens going to creator"], - "type": "u64" - }, - { - "name": "creator_fee_on_input", - "type": "bool" - } - ] - } - } - ] -} diff --git a/crates/raydium-cpmm-parser/proto/raydium_cpmm.proto b/crates/raydium-cpmm-parser/proto/raydium_cpmm.proto deleted file mode 100644 index 74a3a93a..00000000 --- a/crates/raydium-cpmm-parser/proto/raydium_cpmm.proto +++ /dev/null @@ -1,462 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.raydium_cpmm; - -message ClosePermissionPdaIx { - ClosePermissionPdaIxAccounts accounts = 1; -} - -message CollectCreatorFeeIx { - CollectCreatorFeeIxAccounts accounts = 1; -} - -message CollectFundFeeIx { - CollectFundFeeIxAccounts accounts = 1; - CollectFundFeeIxData data = 2; -} - -message CollectProtocolFeeIx { - CollectProtocolFeeIxAccounts accounts = 1; - CollectProtocolFeeIxData data = 2; -} - -message CreateAmmConfigIx { - CreateAmmConfigIxAccounts accounts = 1; - CreateAmmConfigIxData data = 2; -} - -message CreatePermissionPdaIx { - CreatePermissionPdaIxAccounts accounts = 1; -} - -message DepositIx { - DepositIxAccounts accounts = 1; - DepositIxData data = 2; -} - -message InitializeIx { - InitializeIxAccounts accounts = 1; - InitializeIxData data = 2; -} - -message InitializeWithPermissionIx { - InitializeWithPermissionIxAccounts accounts = 1; - InitializeWithPermissionIxData data = 2; -} - -message SwapBaseInputIx { - SwapBaseInputIxAccounts accounts = 1; - SwapBaseInputIxData data = 2; -} - -message SwapBaseOutputIx { - SwapBaseOutputIxAccounts accounts = 1; - SwapBaseOutputIxData data = 2; -} - -message UpdateAmmConfigIx { - UpdateAmmConfigIxAccounts accounts = 1; - UpdateAmmConfigIxData data = 2; -} - -message UpdatePoolStatusIx { - UpdatePoolStatusIxAccounts accounts = 1; - UpdatePoolStatusIxData data = 2; -} - -message WithdrawIx { - WithdrawIxAccounts accounts = 1; - WithdrawIxData data = 2; -} - - -enum CreatorFeeOn { - CreatorFeeOnBothToken = 0; - CreatorFeeOnOnlyToken0 = 1; - CreatorFeeOnOnlyToken1 = 2; -} - -message LpChangeEvent { - string pool_id = 1; - uint64 lp_amount_before = 2; - uint64 token0_vault_before = 3; - uint64 token1_vault_before = 4; - uint64 token0_amount = 5; - uint64 token1_amount = 6; - uint64 token0_transfer_fee = 7; - uint64 token1_transfer_fee = 8; - uint32 change_type = 9; -} - -message Observation { - uint64 block_timestamp = 1; - string cumulative_token0_price_x32 = 2; - string cumulative_token1_price_x32 = 3; -} - -message SwapEvent { - string pool_id = 1; - uint64 input_vault_before = 2; - uint64 output_vault_before = 3; - uint64 input_amount = 4; - uint64 output_amount = 5; - uint64 input_transfer_fee = 6; - uint64 output_transfer_fee = 7; - bool base_input = 8; - string input_mint = 9; - string output_mint = 10; - uint64 trade_fee = 11; - uint64 creator_fee = 12; - bool creator_fee_on_input = 13; -} - - -message AmmConfig { - uint32 bump = 1; - bool disable_create_pool = 2; - uint32 index = 3; - uint64 trade_fee_rate = 4; - uint64 protocol_fee_rate = 5; - uint64 fund_fee_rate = 6; - uint64 create_pool_fee = 7; - string protocol_owner = 8; - string fund_owner = 9; - uint64 creator_fee_rate = 10; - repeated uint64 padding = 11; -} - -message ObservationState { - bool initialized = 1; - uint32 observation_index = 2; - string pool_id = 3; - repeated Observation observations = 4; - repeated uint64 padding = 5; -} - -message Permission { - string authority = 1; - repeated uint64 padding = 2; -} - -message PoolState { - string amm_config = 1; - string pool_creator = 2; - string token0_vault = 3; - string token1_vault = 4; - string lp_mint = 5; - string token0_mint = 6; - string token1_mint = 7; - string token0_program = 8; - string token1_program = 9; - string observation_key = 10; - uint32 auth_bump = 11; - uint32 status = 12; - uint32 lp_mint_decimals = 13; - uint32 mint0_decimals = 14; - uint32 mint1_decimals = 15; - uint64 lp_supply = 16; - uint64 protocol_fees_token0 = 17; - uint64 protocol_fees_token1 = 18; - uint64 fund_fees_token0 = 19; - uint64 fund_fees_token1 = 20; - uint64 open_time = 21; - uint64 recent_epoch = 22; - uint32 creator_fee_on = 23; - bool enable_creator_fee = 24; - repeated uint32 padding1 = 25; - uint64 creator_fees_token0 = 26; - uint64 creator_fees_token1 = 27; - repeated uint64 padding = 28; -} - - -message ClosePermissionPdaIxAccounts { - string owner = 1; - string permission_authority = 2; - string permission = 3; - string system_program = 4; -} - - -message CollectCreatorFeeIxAccounts { - string creator = 1; - string authority = 2; - string pool_state = 3; - string amm_config = 4; - string token0_vault = 5; - string token1_vault = 6; - string vault0_mint = 7; - string vault1_mint = 8; - string creator_token0 = 9; - string creator_token1 = 10; - string token0_program = 11; - string token1_program = 12; - string associated_token_program = 13; - string system_program = 14; -} - - -message CollectFundFeeIxAccounts { - string owner = 1; - string authority = 2; - string pool_state = 3; - string amm_config = 4; - string token0_vault = 5; - string token1_vault = 6; - string vault0_mint = 7; - string vault1_mint = 8; - string recipient_token0_account = 9; - string recipient_token1_account = 10; - string token_program = 11; - string token_program2022 = 12; -} - -message CollectFundFeeIxData { - uint64 amount0_requested = 1; - uint64 amount1_requested = 2; -} - -message CollectProtocolFeeIxAccounts { - string owner = 1; - string authority = 2; - string pool_state = 3; - string amm_config = 4; - string token0_vault = 5; - string token1_vault = 6; - string vault0_mint = 7; - string vault1_mint = 8; - string recipient_token0_account = 9; - string recipient_token1_account = 10; - string token_program = 11; - string token_program2022 = 12; -} - -message CollectProtocolFeeIxData { - uint64 amount0_requested = 1; - uint64 amount1_requested = 2; -} - -message CreateAmmConfigIxAccounts { - string owner = 1; - string amm_config = 2; - string system_program = 3; -} - -message CreateAmmConfigIxData { - uint32 index = 1; - uint64 trade_fee_rate = 2; - uint64 protocol_fee_rate = 3; - uint64 fund_fee_rate = 4; - uint64 create_pool_fee = 5; - uint64 creator_fee_rate = 6; -} - -message CreatePermissionPdaIxAccounts { - string owner = 1; - string permission_authority = 2; - string permission = 3; - string system_program = 4; -} - - -message DepositIxAccounts { - string owner = 1; - string authority = 2; - string pool_state = 3; - string owner_lp_token = 4; - string token0_account = 5; - string token1_account = 6; - string token0_vault = 7; - string token1_vault = 8; - string token_program = 9; - string token_program2022 = 10; - string vault0_mint = 11; - string vault1_mint = 12; - string lp_mint = 13; -} - -message DepositIxData { - uint64 lp_token_amount = 1; - uint64 maximum_token0_amount = 2; - uint64 maximum_token1_amount = 3; -} - -message InitializeIxAccounts { - string creator = 1; - string amm_config = 2; - string authority = 3; - string pool_state = 4; - string token0_mint = 5; - string token1_mint = 6; - string lp_mint = 7; - string creator_token0 = 8; - string creator_token1 = 9; - string creator_lp_token = 10; - string token0_vault = 11; - string token1_vault = 12; - string create_pool_fee = 13; - string observation_state = 14; - string token_program = 15; - string token0_program = 16; - string token1_program = 17; - string associated_token_program = 18; - string system_program = 19; - string rent = 20; -} - -message InitializeIxData { - uint64 init_amount0 = 1; - uint64 init_amount1 = 2; - uint64 open_time = 3; -} - -message InitializeWithPermissionIxAccounts { - string payer = 1; - string creator = 2; - string amm_config = 3; - string authority = 4; - string pool_state = 5; - string token0_mint = 6; - string token1_mint = 7; - string lp_mint = 8; - string payer_token0 = 9; - string payer_token1 = 10; - string payer_lp_token = 11; - string token0_vault = 12; - string token1_vault = 13; - string create_pool_fee = 14; - string observation_state = 15; - string permission = 16; - string token_program = 17; - string token0_program = 18; - string token1_program = 19; - string associated_token_program = 20; - string system_program = 21; -} - -message InitializeWithPermissionIxData { - uint64 init_amount0 = 1; - uint64 init_amount1 = 2; - uint64 open_time = 3; - CreatorFeeOn creator_fee_on = 4; -} - -message SwapBaseInputIxAccounts { - string payer = 1; - string authority = 2; - string amm_config = 3; - string pool_state = 4; - string input_token_account = 5; - string output_token_account = 6; - string input_vault = 7; - string output_vault = 8; - string input_token_program = 9; - string output_token_program = 10; - string input_token_mint = 11; - string output_token_mint = 12; - string observation_state = 13; -} - -message SwapBaseInputIxData { - uint64 amount_in = 1; - uint64 minimum_amount_out = 2; -} - -message SwapBaseOutputIxAccounts { - string payer = 1; - string authority = 2; - string amm_config = 3; - string pool_state = 4; - string input_token_account = 5; - string output_token_account = 6; - string input_vault = 7; - string output_vault = 8; - string input_token_program = 9; - string output_token_program = 10; - string input_token_mint = 11; - string output_token_mint = 12; - string observation_state = 13; -} - -message SwapBaseOutputIxData { - uint64 max_amount_in = 1; - uint64 amount_out = 2; -} - -message UpdateAmmConfigIxAccounts { - string owner = 1; - string amm_config = 2; -} - -message UpdateAmmConfigIxData { - uint32 param = 1; - uint64 value = 2; -} - -message UpdatePoolStatusIxAccounts { - string authority = 1; - string pool_state = 2; -} - -message UpdatePoolStatusIxData { - uint32 status = 1; -} - -message WithdrawIxAccounts { - string owner = 1; - string authority = 2; - string pool_state = 3; - string owner_lp_token = 4; - string token0_account = 5; - string token1_account = 6; - string token0_vault = 7; - string token1_vault = 8; - string token_program = 9; - string token_program2022 = 10; - string vault0_mint = 11; - string vault1_mint = 12; - string lp_mint = 13; - string memo_program = 14; -} - -message WithdrawIxData { - uint64 lp_token_amount = 1; - uint64 minimum_token0_amount = 2; - uint64 minimum_token1_amount = 3; -} - - -message ProgramState { - oneof state_oneof { - AmmConfig amm_config = 1; - ObservationState observation_state = 2; - Permission permission = 3; - PoolState pool_state = 4; - } -} - -message ProgramIxs { - oneof ix_oneof { - ClosePermissionPdaIx close_permission_pda = 1; - CollectCreatorFeeIx collect_creator_fee = 2; - CollectFundFeeIx collect_fund_fee = 3; - CollectProtocolFeeIx collect_protocol_fee = 4; - CreateAmmConfigIx create_amm_config = 5; - CreatePermissionPdaIx create_permission_pda = 6; - DepositIx deposit = 7; - InitializeIx initialize = 8; - InitializeWithPermissionIx initialize_with_permission = 9; - SwapBaseInputIx swap_base_input = 10; - SwapBaseOutputIx swap_base_output = 11; - UpdateAmmConfigIx update_amm_config = 12; - UpdatePoolStatusIx update_pool_status = 13; - WithdrawIx withdraw = 14; - } -} - diff --git a/crates/raydium-cpmm-parser/src/generated_parser/accounts_parser.rs b/crates/raydium-cpmm-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index f1471427..00000000 --- a/crates/raydium-cpmm-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,233 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{AmmConfig, ObservationState, Permission, PoolState}, - deserialize_checked, ID, -}; - -/// RaydiumCpSwap Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum RaydiumCpSwapProgramState { - AmmConfig(AmmConfig), - ObservationState(ObservationState), - Permission(Permission), - PoolState(PoolState), -} - -impl RaydiumCpSwapProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [218, 244, 33, 104, 203, 203, 43, 111] => Ok(RaydiumCpSwapProgramState::AmmConfig( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [122, 174, 197, 53, 129, 9, 165, 132] => { - Ok(RaydiumCpSwapProgramState::ObservationState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [224, 83, 28, 79, 10, 253, 161, 28] => Ok(RaydiumCpSwapProgramState::Permission( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [247, 237, 227, 245, 215, 195, 222, 70] => Ok(RaydiumCpSwapProgramState::PoolState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = RaydiumCpSwapProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "raydium_cp_swap::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = RaydiumCpSwapProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, AmmConfig, RaydiumCpSwapProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for AmmConfig { - fn into_proto(self) -> proto_def::AmmConfig { - proto_def::AmmConfig { - bump: self.bump.into(), - disable_create_pool: self.disable_create_pool, - index: self.index.into(), - trade_fee_rate: self.trade_fee_rate, - protocol_fee_rate: self.protocol_fee_rate, - fund_fee_rate: self.fund_fee_rate, - create_pool_fee: self.create_pool_fee, - protocol_owner: self.protocol_owner.to_string(), - fund_owner: self.fund_owner.to_string(), - creator_fee_rate: self.creator_fee_rate, - padding: self.padding.to_vec(), - } - } - } - use super::ObservationState; - impl IntoProto for ObservationState { - fn into_proto(self) -> proto_def::ObservationState { - proto_def::ObservationState { - initialized: self.initialized, - observation_index: self.observation_index.into(), - pool_id: self.pool_id.to_string(), - observations: self - .observations - .into_iter() - .map(|x| x.into_proto()) - .collect(), - padding: self.padding.to_vec(), - } - } - } - use super::Permission; - impl IntoProto for Permission { - fn into_proto(self) -> proto_def::Permission { - proto_def::Permission { - authority: self.authority.to_string(), - padding: self.padding.to_vec(), - } - } - } - use super::PoolState; - impl IntoProto for PoolState { - fn into_proto(self) -> proto_def::PoolState { - proto_def::PoolState { - amm_config: self.amm_config.to_string(), - pool_creator: self.pool_creator.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - lp_mint: self.lp_mint.to_string(), - token0_mint: self.token0_mint.to_string(), - token1_mint: self.token1_mint.to_string(), - token0_program: self.token0_program.to_string(), - token1_program: self.token1_program.to_string(), - observation_key: self.observation_key.to_string(), - auth_bump: self.auth_bump.into(), - status: self.status.into(), - lp_mint_decimals: self.lp_mint_decimals.into(), - mint0_decimals: self.mint0_decimals.into(), - mint1_decimals: self.mint1_decimals.into(), - lp_supply: self.lp_supply, - protocol_fees_token0: self.protocol_fees_token0, - protocol_fees_token1: self.protocol_fees_token1, - fund_fees_token0: self.fund_fees_token0, - fund_fees_token1: self.fund_fees_token1, - open_time: self.open_time, - recent_epoch: self.recent_epoch, - creator_fee_on: self.creator_fee_on.into(), - enable_creator_fee: self.enable_creator_fee, - padding1: self.padding1.into_iter().map(|x| x.into()).collect(), - creator_fees_token0: self.creator_fees_token0, - creator_fees_token1: self.creator_fees_token1, - padding: self.padding.to_vec(), - } - } - } - - impl IntoProto for RaydiumCpSwapProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - RaydiumCpSwapProgramState::AmmConfig(data) => { - proto_def::program_state::StateOneof::AmmConfig(data.into_proto()) - }, - RaydiumCpSwapProgramState::ObservationState(data) => { - proto_def::program_state::StateOneof::ObservationState(data.into_proto()) - }, - RaydiumCpSwapProgramState::Permission(data) => { - proto_def::program_state::StateOneof::Permission(data.into_proto()) - }, - RaydiumCpSwapProgramState::PoolState(data) => { - proto_def::program_state::StateOneof::PoolState(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/raydium-cpmm-parser/src/generated_parser/instructions_parser.rs b/crates/raydium-cpmm-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index dfa6ca4d..00000000 --- a/crates/raydium-cpmm-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,1002 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - ClosePermissionPda as ClosePermissionPdaIxAccounts, - CollectCreatorFee as CollectCreatorFeeIxAccounts, - CollectFundFee as CollectFundFeeIxAccounts, - CollectFundFeeInstructionArgs as CollectFundFeeIxData, - CollectProtocolFee as CollectProtocolFeeIxAccounts, - CollectProtocolFeeInstructionArgs as CollectProtocolFeeIxData, - CreateAmmConfig as CreateAmmConfigIxAccounts, - CreateAmmConfigInstructionArgs as CreateAmmConfigIxData, - CreatePermissionPda as CreatePermissionPdaIxAccounts, Deposit as DepositIxAccounts, - DepositInstructionArgs as DepositIxData, Initialize as InitializeIxAccounts, - InitializeInstructionArgs as InitializeIxData, - InitializeWithPermission as InitializeWithPermissionIxAccounts, - InitializeWithPermissionInstructionArgs as InitializeWithPermissionIxData, - SwapBaseInput as SwapBaseInputIxAccounts, - SwapBaseInputInstructionArgs as SwapBaseInputIxData, - SwapBaseOutput as SwapBaseOutputIxAccounts, - SwapBaseOutputInstructionArgs as SwapBaseOutputIxData, - UpdateAmmConfig as UpdateAmmConfigIxAccounts, - UpdateAmmConfigInstructionArgs as UpdateAmmConfigIxData, - UpdatePoolStatus as UpdatePoolStatusIxAccounts, - UpdatePoolStatusInstructionArgs as UpdatePoolStatusIxData, Withdraw as WithdrawIxAccounts, - WithdrawInstructionArgs as WithdrawIxData, - }, - ID, -}; - -/// RaydiumCpSwap Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum RaydiumCpSwapProgramIx { - ClosePermissionPda(ClosePermissionPdaIxAccounts), - CollectCreatorFee(CollectCreatorFeeIxAccounts), - CollectFundFee(CollectFundFeeIxAccounts, CollectFundFeeIxData), - CollectProtocolFee(CollectProtocolFeeIxAccounts, CollectProtocolFeeIxData), - CreateAmmConfig(CreateAmmConfigIxAccounts, CreateAmmConfigIxData), - CreatePermissionPda(CreatePermissionPdaIxAccounts), - Deposit(DepositIxAccounts, DepositIxData), - Initialize(InitializeIxAccounts, InitializeIxData), - InitializeWithPermission( - InitializeWithPermissionIxAccounts, - InitializeWithPermissionIxData, - ), - SwapBaseInput(SwapBaseInputIxAccounts, SwapBaseInputIxData), - SwapBaseOutput(SwapBaseOutputIxAccounts, SwapBaseOutputIxData), - UpdateAmmConfig(UpdateAmmConfigIxAccounts, UpdateAmmConfigIxData), - UpdatePoolStatus(UpdatePoolStatusIxAccounts, UpdatePoolStatusIxData), - Withdraw(WithdrawIxAccounts, WithdrawIxData), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = RaydiumCpSwapProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "RaydiumCpSwap::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [156, 84, 32, 118, 69, 135, 70, 123] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClosePermissionPdaIxAccounts { - owner: next_account(accounts)?, - permission_authority: next_account(accounts)?, - permission: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(RaydiumCpSwapProgramIx::ClosePermissionPda(ix_accounts)) - }, - [20, 22, 86, 123, 198, 28, 219, 132] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectCreatorFeeIxAccounts { - creator: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - amm_config: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - creator_token0: next_account(accounts)?, - creator_token1: next_account(accounts)?, - token0_program: next_account(accounts)?, - token1_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(RaydiumCpSwapProgramIx::CollectCreatorFee(ix_accounts)) - }, - [167, 138, 78, 149, 223, 194, 6, 126] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectFundFeeIxAccounts { - owner: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - amm_config: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - recipient_token0_account: next_account(accounts)?, - recipient_token1_account: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - }; - let de_ix_data: CollectFundFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::CollectFundFee( - ix_accounts, - de_ix_data, - )) - }, - [136, 136, 252, 221, 194, 66, 126, 89] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectProtocolFeeIxAccounts { - owner: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - amm_config: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - recipient_token0_account: next_account(accounts)?, - recipient_token1_account: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - }; - let de_ix_data: CollectProtocolFeeIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::CollectProtocolFee( - ix_accounts, - de_ix_data, - )) - }, - [137, 52, 237, 212, 215, 117, 108, 104] => { - let expected_accounts_len = 3; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateAmmConfigIxAccounts { - owner: next_account(accounts)?, - amm_config: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: CreateAmmConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::CreateAmmConfig( - ix_accounts, - de_ix_data, - )) - }, - [135, 136, 2, 216, 137, 169, 181, 202] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreatePermissionPdaIxAccounts { - owner: next_account(accounts)?, - permission_authority: next_account(accounts)?, - permission: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(RaydiumCpSwapProgramIx::CreatePermissionPda(ix_accounts)) - }, - [242, 35, 198, 137, 82, 225, 242, 182] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = DepositIxAccounts { - owner: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - owner_lp_token: next_account(accounts)?, - token0_account: next_account(accounts)?, - token1_account: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - }; - let de_ix_data: DepositIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::Deposit(ix_accounts, de_ix_data)) - }, - [175, 175, 109, 31, 13, 152, 155, 237] => { - let expected_accounts_len = 20; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeIxAccounts { - creator: next_account(accounts)?, - amm_config: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - token0_mint: next_account(accounts)?, - token1_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - creator_token0: next_account(accounts)?, - creator_token1: next_account(accounts)?, - creator_lp_token: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - create_pool_fee: next_account(accounts)?, - observation_state: next_account(accounts)?, - token_program: next_account(accounts)?, - token0_program: next_account(accounts)?, - token1_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: InitializeIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::Initialize(ix_accounts, de_ix_data)) - }, - [63, 55, 254, 65, 49, 178, 89, 121] => { - let expected_accounts_len = 21; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeWithPermissionIxAccounts { - payer: next_account(accounts)?, - creator: next_account(accounts)?, - amm_config: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - token0_mint: next_account(accounts)?, - token1_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - payer_token0: next_account(accounts)?, - payer_token1: next_account(accounts)?, - payer_lp_token: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - create_pool_fee: next_account(accounts)?, - observation_state: next_account(accounts)?, - permission: next_account(accounts)?, - token_program: next_account(accounts)?, - token0_program: next_account(accounts)?, - token1_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: InitializeWithPermissionIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::InitializeWithPermission( - ix_accounts, - de_ix_data, - )) - }, - [143, 190, 90, 218, 196, 30, 51, 222] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapBaseInputIxAccounts { - payer: next_account(accounts)?, - authority: next_account(accounts)?, - amm_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - input_token_account: next_account(accounts)?, - output_token_account: next_account(accounts)?, - input_vault: next_account(accounts)?, - output_vault: next_account(accounts)?, - input_token_program: next_account(accounts)?, - output_token_program: next_account(accounts)?, - input_token_mint: next_account(accounts)?, - output_token_mint: next_account(accounts)?, - observation_state: next_account(accounts)?, - }; - let de_ix_data: SwapBaseInputIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::SwapBaseInput( - ix_accounts, - de_ix_data, - )) - }, - [55, 217, 98, 86, 163, 74, 180, 173] => { - let expected_accounts_len = 13; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SwapBaseOutputIxAccounts { - payer: next_account(accounts)?, - authority: next_account(accounts)?, - amm_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - input_token_account: next_account(accounts)?, - output_token_account: next_account(accounts)?, - input_vault: next_account(accounts)?, - output_vault: next_account(accounts)?, - input_token_program: next_account(accounts)?, - output_token_program: next_account(accounts)?, - input_token_mint: next_account(accounts)?, - output_token_mint: next_account(accounts)?, - observation_state: next_account(accounts)?, - }; - let de_ix_data: SwapBaseOutputIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::SwapBaseOutput( - ix_accounts, - de_ix_data, - )) - }, - [49, 60, 174, 136, 154, 28, 116, 200] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateAmmConfigIxAccounts { - owner: next_account(accounts)?, - amm_config: next_account(accounts)?, - }; - let de_ix_data: UpdateAmmConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::UpdateAmmConfig( - ix_accounts, - de_ix_data, - )) - }, - [130, 87, 108, 6, 46, 224, 117, 123] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdatePoolStatusIxAccounts { - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - }; - let de_ix_data: UpdatePoolStatusIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::UpdatePoolStatus( - ix_accounts, - de_ix_data, - )) - }, - [183, 18, 70, 156, 148, 109, 161, 34] => { - let expected_accounts_len = 14; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = WithdrawIxAccounts { - owner: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - owner_lp_token: next_account(accounts)?, - token0_account: next_account(accounts)?, - token1_account: next_account(accounts)?, - token0_vault: next_account(accounts)?, - token1_vault: next_account(accounts)?, - token_program: next_account(accounts)?, - token_program2022: next_account(accounts)?, - vault0_mint: next_account(accounts)?, - vault1_mint: next_account(accounts)?, - lp_mint: next_account(accounts)?, - memo_program: next_account(accounts)?, - }; - let de_ix_data: WithdrawIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumCpSwapProgramIx::Withdraw(ix_accounts, de_ix_data)) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{ClosePermissionPdaIxAccounts, InstructionParser, RaydiumCpSwapProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for ClosePermissionPdaIxAccounts { - fn into_proto(self) -> proto_def::ClosePermissionPdaIxAccounts { - proto_def::ClosePermissionPdaIxAccounts { - owner: self.owner.to_string(), - permission_authority: self.permission_authority.to_string(), - permission: self.permission.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CollectCreatorFeeIxAccounts; - impl IntoProto for CollectCreatorFeeIxAccounts { - fn into_proto(self) -> proto_def::CollectCreatorFeeIxAccounts { - proto_def::CollectCreatorFeeIxAccounts { - creator: self.creator.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - amm_config: self.amm_config.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - creator_token0: self.creator_token0.to_string(), - creator_token1: self.creator_token1.to_string(), - token0_program: self.token0_program.to_string(), - token1_program: self.token1_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CollectFundFeeIxAccounts; - impl IntoProto for CollectFundFeeIxAccounts { - fn into_proto(self) -> proto_def::CollectFundFeeIxAccounts { - proto_def::CollectFundFeeIxAccounts { - owner: self.owner.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - amm_config: self.amm_config.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - recipient_token0_account: self.recipient_token0_account.to_string(), - recipient_token1_account: self.recipient_token1_account.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - } - } - } - use super::CollectFundFeeIxData; - impl IntoProto for CollectFundFeeIxData { - fn into_proto(self) -> proto_def::CollectFundFeeIxData { - proto_def::CollectFundFeeIxData { - amount0_requested: self.amount0_requested, - amount1_requested: self.amount1_requested, - } - } - } - use super::CollectProtocolFeeIxAccounts; - impl IntoProto for CollectProtocolFeeIxAccounts { - fn into_proto(self) -> proto_def::CollectProtocolFeeIxAccounts { - proto_def::CollectProtocolFeeIxAccounts { - owner: self.owner.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - amm_config: self.amm_config.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - recipient_token0_account: self.recipient_token0_account.to_string(), - recipient_token1_account: self.recipient_token1_account.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - } - } - } - use super::CollectProtocolFeeIxData; - impl IntoProto for CollectProtocolFeeIxData { - fn into_proto(self) -> proto_def::CollectProtocolFeeIxData { - proto_def::CollectProtocolFeeIxData { - amount0_requested: self.amount0_requested, - amount1_requested: self.amount1_requested, - } - } - } - use super::CreateAmmConfigIxAccounts; - impl IntoProto for CreateAmmConfigIxAccounts { - fn into_proto(self) -> proto_def::CreateAmmConfigIxAccounts { - proto_def::CreateAmmConfigIxAccounts { - owner: self.owner.to_string(), - amm_config: self.amm_config.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreateAmmConfigIxData; - impl IntoProto for CreateAmmConfigIxData { - fn into_proto(self) -> proto_def::CreateAmmConfigIxData { - proto_def::CreateAmmConfigIxData { - index: self.index.into(), - trade_fee_rate: self.trade_fee_rate, - protocol_fee_rate: self.protocol_fee_rate, - fund_fee_rate: self.fund_fee_rate, - create_pool_fee: self.create_pool_fee, - creator_fee_rate: self.creator_fee_rate, - } - } - } - use super::CreatePermissionPdaIxAccounts; - impl IntoProto for CreatePermissionPdaIxAccounts { - fn into_proto(self) -> proto_def::CreatePermissionPdaIxAccounts { - proto_def::CreatePermissionPdaIxAccounts { - owner: self.owner.to_string(), - permission_authority: self.permission_authority.to_string(), - permission: self.permission.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::DepositIxAccounts; - impl IntoProto for DepositIxAccounts { - fn into_proto(self) -> proto_def::DepositIxAccounts { - proto_def::DepositIxAccounts { - owner: self.owner.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - owner_lp_token: self.owner_lp_token.to_string(), - token0_account: self.token0_account.to_string(), - token1_account: self.token1_account.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - } - } - } - use super::DepositIxData; - impl IntoProto for DepositIxData { - fn into_proto(self) -> proto_def::DepositIxData { - proto_def::DepositIxData { - lp_token_amount: self.lp_token_amount, - maximum_token0_amount: self.maximum_token0_amount, - maximum_token1_amount: self.maximum_token1_amount, - } - } - } - use super::InitializeIxAccounts; - impl IntoProto for InitializeIxAccounts { - fn into_proto(self) -> proto_def::InitializeIxAccounts { - proto_def::InitializeIxAccounts { - creator: self.creator.to_string(), - amm_config: self.amm_config.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - token0_mint: self.token0_mint.to_string(), - token1_mint: self.token1_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - creator_token0: self.creator_token0.to_string(), - creator_token1: self.creator_token1.to_string(), - creator_lp_token: self.creator_lp_token.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - create_pool_fee: self.create_pool_fee.to_string(), - observation_state: self.observation_state.to_string(), - token_program: self.token_program.to_string(), - token0_program: self.token0_program.to_string(), - token1_program: self.token1_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::InitializeIxData; - impl IntoProto for InitializeIxData { - fn into_proto(self) -> proto_def::InitializeIxData { - proto_def::InitializeIxData { - init_amount0: self.init_amount0, - init_amount1: self.init_amount1, - open_time: self.open_time, - } - } - } - use super::InitializeWithPermissionIxAccounts; - impl IntoProto - for InitializeWithPermissionIxAccounts - { - fn into_proto(self) -> proto_def::InitializeWithPermissionIxAccounts { - proto_def::InitializeWithPermissionIxAccounts { - payer: self.payer.to_string(), - creator: self.creator.to_string(), - amm_config: self.amm_config.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - token0_mint: self.token0_mint.to_string(), - token1_mint: self.token1_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - payer_token0: self.payer_token0.to_string(), - payer_token1: self.payer_token1.to_string(), - payer_lp_token: self.payer_lp_token.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - create_pool_fee: self.create_pool_fee.to_string(), - observation_state: self.observation_state.to_string(), - permission: self.permission.to_string(), - token_program: self.token_program.to_string(), - token0_program: self.token0_program.to_string(), - token1_program: self.token1_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializeWithPermissionIxData; - impl IntoProto for InitializeWithPermissionIxData { - fn into_proto(self) -> proto_def::InitializeWithPermissionIxData { - proto_def::InitializeWithPermissionIxData { - init_amount0: self.init_amount0, - init_amount1: self.init_amount1, - open_time: self.open_time, - creator_fee_on: self.creator_fee_on as i32, - } - } - } - use super::SwapBaseInputIxAccounts; - impl IntoProto for SwapBaseInputIxAccounts { - fn into_proto(self) -> proto_def::SwapBaseInputIxAccounts { - proto_def::SwapBaseInputIxAccounts { - payer: self.payer.to_string(), - authority: self.authority.to_string(), - amm_config: self.amm_config.to_string(), - pool_state: self.pool_state.to_string(), - input_token_account: self.input_token_account.to_string(), - output_token_account: self.output_token_account.to_string(), - input_vault: self.input_vault.to_string(), - output_vault: self.output_vault.to_string(), - input_token_program: self.input_token_program.to_string(), - output_token_program: self.output_token_program.to_string(), - input_token_mint: self.input_token_mint.to_string(), - output_token_mint: self.output_token_mint.to_string(), - observation_state: self.observation_state.to_string(), - } - } - } - use super::SwapBaseInputIxData; - impl IntoProto for SwapBaseInputIxData { - fn into_proto(self) -> proto_def::SwapBaseInputIxData { - proto_def::SwapBaseInputIxData { - amount_in: self.amount_in, - minimum_amount_out: self.minimum_amount_out, - } - } - } - use super::SwapBaseOutputIxAccounts; - impl IntoProto for SwapBaseOutputIxAccounts { - fn into_proto(self) -> proto_def::SwapBaseOutputIxAccounts { - proto_def::SwapBaseOutputIxAccounts { - payer: self.payer.to_string(), - authority: self.authority.to_string(), - amm_config: self.amm_config.to_string(), - pool_state: self.pool_state.to_string(), - input_token_account: self.input_token_account.to_string(), - output_token_account: self.output_token_account.to_string(), - input_vault: self.input_vault.to_string(), - output_vault: self.output_vault.to_string(), - input_token_program: self.input_token_program.to_string(), - output_token_program: self.output_token_program.to_string(), - input_token_mint: self.input_token_mint.to_string(), - output_token_mint: self.output_token_mint.to_string(), - observation_state: self.observation_state.to_string(), - } - } - } - use super::SwapBaseOutputIxData; - impl IntoProto for SwapBaseOutputIxData { - fn into_proto(self) -> proto_def::SwapBaseOutputIxData { - proto_def::SwapBaseOutputIxData { - max_amount_in: self.max_amount_in, - amount_out: self.amount_out, - } - } - } - use super::UpdateAmmConfigIxAccounts; - impl IntoProto for UpdateAmmConfigIxAccounts { - fn into_proto(self) -> proto_def::UpdateAmmConfigIxAccounts { - proto_def::UpdateAmmConfigIxAccounts { - owner: self.owner.to_string(), - amm_config: self.amm_config.to_string(), - } - } - } - use super::UpdateAmmConfigIxData; - impl IntoProto for UpdateAmmConfigIxData { - fn into_proto(self) -> proto_def::UpdateAmmConfigIxData { - proto_def::UpdateAmmConfigIxData { - param: self.param.into(), - value: self.value, - } - } - } - use super::UpdatePoolStatusIxAccounts; - impl IntoProto for UpdatePoolStatusIxAccounts { - fn into_proto(self) -> proto_def::UpdatePoolStatusIxAccounts { - proto_def::UpdatePoolStatusIxAccounts { - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - } - } - } - use super::UpdatePoolStatusIxData; - impl IntoProto for UpdatePoolStatusIxData { - fn into_proto(self) -> proto_def::UpdatePoolStatusIxData { - proto_def::UpdatePoolStatusIxData { - status: self.status.into(), - } - } - } - use super::WithdrawIxAccounts; - impl IntoProto for WithdrawIxAccounts { - fn into_proto(self) -> proto_def::WithdrawIxAccounts { - proto_def::WithdrawIxAccounts { - owner: self.owner.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - owner_lp_token: self.owner_lp_token.to_string(), - token0_account: self.token0_account.to_string(), - token1_account: self.token1_account.to_string(), - token0_vault: self.token0_vault.to_string(), - token1_vault: self.token1_vault.to_string(), - token_program: self.token_program.to_string(), - token_program2022: self.token_program2022.to_string(), - vault0_mint: self.vault0_mint.to_string(), - vault1_mint: self.vault1_mint.to_string(), - lp_mint: self.lp_mint.to_string(), - memo_program: self.memo_program.to_string(), - } - } - } - use super::WithdrawIxData; - impl IntoProto for WithdrawIxData { - fn into_proto(self) -> proto_def::WithdrawIxData { - proto_def::WithdrawIxData { - lp_token_amount: self.lp_token_amount, - minimum_token0_amount: self.minimum_token0_amount, - minimum_token1_amount: self.minimum_token1_amount, - } - } - } - - impl IntoProto for RaydiumCpSwapProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - RaydiumCpSwapProgramIx::ClosePermissionPda(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClosePermissionPda( - proto_def::ClosePermissionPdaIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::CollectCreatorFee(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectCreatorFee( - proto_def::CollectCreatorFeeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::CollectFundFee(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectFundFee( - proto_def::CollectFundFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::CollectProtocolFee(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectProtocolFee( - proto_def::CollectProtocolFeeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::CreateAmmConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateAmmConfig( - proto_def::CreateAmmConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::CreatePermissionPda(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreatePermissionPda( - proto_def::CreatePermissionPdaIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::Deposit(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Deposit( - proto_def::DepositIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::Initialize(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Initialize( - proto_def::InitializeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::InitializeWithPermission(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeWithPermission( - proto_def::InitializeWithPermissionIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - RaydiumCpSwapProgramIx::SwapBaseInput(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapBaseInput( - proto_def::SwapBaseInputIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::SwapBaseOutput(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SwapBaseOutput( - proto_def::SwapBaseOutputIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::UpdateAmmConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateAmmConfig( - proto_def::UpdateAmmConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::UpdatePoolStatus(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdatePoolStatus( - proto_def::UpdatePoolStatusIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumCpSwapProgramIx::Withdraw(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Withdraw( - proto_def::WithdrawIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/raydium-cpmm-parser/src/generated_parser/mod.rs b/crates/raydium-cpmm-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/raydium-cpmm-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/raydium-cpmm-parser/src/generated_parser/proto_helpers.rs b/crates/raydium-cpmm-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index 6e0a6447..00000000 --- a/crates/raydium-cpmm-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,58 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::LpChangeEvent}; - impl IntoProto for LpChangeEvent { - fn into_proto(self) -> proto_def::LpChangeEvent { - proto_def::LpChangeEvent { - pool_id: self.pool_id.to_string(), - lp_amount_before: self.lp_amount_before, - token0_vault_before: self.token0_vault_before, - token1_vault_before: self.token1_vault_before, - token0_amount: self.token0_amount, - token1_amount: self.token1_amount, - token0_transfer_fee: self.token0_transfer_fee, - token1_transfer_fee: self.token1_transfer_fee, - change_type: self.change_type.into(), - } - } - } - use crate::types::Observation; - impl IntoProto for Observation { - fn into_proto(self) -> proto_def::Observation { - proto_def::Observation { - block_timestamp: self.block_timestamp, - cumulative_token0_price_x32: self.cumulative_token0_price_x32.to_string(), - cumulative_token1_price_x32: self.cumulative_token1_price_x32.to_string(), - } - } - } - use crate::types::SwapEvent; - impl IntoProto for SwapEvent { - fn into_proto(self) -> proto_def::SwapEvent { - proto_def::SwapEvent { - pool_id: self.pool_id.to_string(), - input_vault_before: self.input_vault_before, - output_vault_before: self.output_vault_before, - input_amount: self.input_amount, - output_amount: self.output_amount, - input_transfer_fee: self.input_transfer_fee, - output_transfer_fee: self.output_transfer_fee, - base_input: self.base_input, - input_mint: self.input_mint.to_string(), - output_mint: self.output_mint.to_string(), - trade_fee: self.trade_fee, - creator_fee: self.creator_fee, - creator_fee_on_input: self.creator_fee_on_input, - } - } - } -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/accounts/amm_config.rs b/crates/raydium-cpmm-parser/src/generated_sdk/accounts/amm_config.rs deleted file mode 100644 index 501ddc61..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/accounts/amm_config.rs +++ /dev/null @@ -1,159 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct AmmConfig { - pub discriminator: [u8; 8], - /// Bump to identify PDA - pub bump: u8, - /// Status to control if new pool can be create - pub disable_create_pool: bool, - /// Config index - pub index: u16, - /// The trade fee, denominated in hundredths of a bip (10^-6) - pub trade_fee_rate: u64, - /// The protocol fee - pub protocol_fee_rate: u64, - /// The fund fee, denominated in hundredths of a bip (10^-6) - pub fund_fee_rate: u64, - /// Fee for create a new pool - pub create_pool_fee: u64, - /// Address of the protocol fee owner - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_owner: Pubkey, - /// Address of the fund fee owner - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fund_owner: Pubkey, - /// The pool creator fee, denominated in hundredths of a bip (10^-6) - pub creator_fee_rate: u64, - /// padding - pub padding: [u64; 15], -} - -pub const AMM_CONFIG_DISCRIMINATOR: [u8; 8] = [218, 244, 33, 104, 203, 203, 43, 111]; - -impl AmmConfig { - pub const LEN: usize = 236; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for AmmConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_amm_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = AmmConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_amm_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_amm_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = AmmConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for AmmConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for AmmConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for AmmConfig { - fn owner() -> Pubkey { crate::RAYDIUM_CP_SWAP_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for AmmConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for AmmConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/accounts/mod.rs b/crates/raydium-cpmm-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index c63ab492..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#amm_config; -pub(crate) mod r#observation_state; -pub(crate) mod r#permission; -pub(crate) mod r#pool_state; - -pub use self::{r#amm_config::*, r#observation_state::*, r#permission::*, r#pool_state::*}; diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/accounts/observation_state.rs b/crates/raydium-cpmm-parser/src/generated_sdk/accounts/observation_state.rs deleted file mode 100644 index 0044bb76..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/accounts/observation_state.rs +++ /dev/null @@ -1,145 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::Observation; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ObservationState { - pub discriminator: [u8; 8], - /// Whether the ObservationState is initialized - pub initialized: bool, - /// the most-recently updated index of the observations array - pub observation_index: u16, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_id: Pubkey, - /// observation array - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub observations: [Observation; 100], - /// padding for feature update - pub padding: [u64; 4], -} - -pub const OBSERVATION_STATE_DISCRIMINATOR: [u8; 8] = [122, 174, 197, 53, 129, 9, 165, 132]; - -impl ObservationState { - pub const LEN: usize = 4075; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for ObservationState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_observation_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_observation_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_observation_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = ObservationState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_observation_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_observation_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_observation_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = ObservationState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for ObservationState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for ObservationState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for ObservationState { - fn owner() -> Pubkey { crate::RAYDIUM_CP_SWAP_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for ObservationState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for ObservationState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/accounts/permission.rs b/crates/raydium-cpmm-parser/src/generated_sdk/accounts/permission.rs deleted file mode 100644 index aa22ec23..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/accounts/permission.rs +++ /dev/null @@ -1,137 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Permission { - pub discriminator: [u8; 8], - /// authority - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub authority: Pubkey, - /// padding - pub padding: [u64; 30], -} - -pub const PERMISSION_DISCRIMINATOR: [u8; 8] = [224, 83, 28, 79, 10, 253, 161, 28]; - -impl Permission { - pub const LEN: usize = 280; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Permission { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_permission( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_permission(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_permission( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = Permission::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_permission( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_permission(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_permission( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = Permission::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for Permission { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for Permission {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for Permission { - fn owner() -> Pubkey { crate::RAYDIUM_CP_SWAP_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for Permission {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for Permission { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/accounts/pool_state.rs b/crates/raydium-cpmm-parser/src/generated_sdk/accounts/pool_state.rs deleted file mode 100644 index 227f81ba..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/accounts/pool_state.rs +++ /dev/null @@ -1,222 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolState { - pub discriminator: [u8; 8], - /// Which config the pool belongs - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub amm_config: Pubkey, - /// pool creator - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_creator: Pubkey, - /// Token A - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token0_vault: Pubkey, - /// Token B - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token1_vault: Pubkey, - /// Pool tokens are issued when A or B tokens are deposited. - /// Pool tokens can be withdrawn back to the original A or B token. - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub lp_mint: Pubkey, - /// Mint information for token A - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token0_mint: Pubkey, - /// Mint information for token B - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token1_mint: Pubkey, - /// token_0 program - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token0_program: Pubkey, - /// token_1 program - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub token1_program: Pubkey, - /// observation account to store oracle data - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub observation_key: Pubkey, - pub auth_bump: u8, - /// Bitwise representation of the state of the pool - /// bit0, 1: disable deposit(value is 1), 0: normal - /// bit1, 1: disable withdraw(value is 2), 0: normal - /// bit2, 1: disable swap(value is 4), 0: normal - pub status: u8, - pub lp_mint_decimals: u8, - /// mint0 and mint1 decimals - pub mint0_decimals: u8, - pub mint1_decimals: u8, - /// True circulating supply without burns and lock ups - pub lp_supply: u64, - /// The amounts of token_0 and token_1 that are owed to the liquidity provider. - pub protocol_fees_token0: u64, - pub protocol_fees_token1: u64, - pub fund_fees_token0: u64, - pub fund_fees_token1: u64, - /// The timestamp allowed for swap in the pool. - pub open_time: u64, - /// recent epoch - pub recent_epoch: u64, - /// Creator fee collect mode - /// 0: both token_0 and token_1 can be used as trade fees. It depends on what the input token is when swapping - /// 1: only token_0 as trade fee - /// 2: only token_1 as trade fee - pub creator_fee_on: u8, - pub enable_creator_fee: bool, - pub padding1: [u8; 6], - pub creator_fees_token0: u64, - pub creator_fees_token1: u64, - /// padding for future updates - pub padding: [u64; 28], -} - -pub const POOL_STATE_DISCRIMINATOR: [u8; 8] = [247, 237, 227, 245, 215, 195, 222, 70]; - -impl PoolState { - pub const LEN: usize = 637; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PoolState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_pool_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PoolState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_pool_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PoolState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PoolState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PoolState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PoolState { - fn owner() -> Pubkey { crate::RAYDIUM_CP_SWAP_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PoolState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PoolState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/errors/mod.rs b/crates/raydium-cpmm-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 164fee89..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod raydium_cp_swap; - -pub use self::raydium_cp_swap::RaydiumCpSwapError; diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/errors/raydium_cp_swap.rs b/crates/raydium-cpmm-parser/src/generated_sdk/errors/raydium_cp_swap.rs deleted file mode 100644 index a5d67775..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/errors/raydium_cp_swap.rs +++ /dev/null @@ -1,70 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum RaydiumCpSwapError { - /// 6000 - Not approved - #[error("Not approved")] - NotApproved = 0x1770, - /// 6001 - Input account owner is not the program address - #[error("Input account owner is not the program address")] - InvalidOwner = 0x1771, - /// 6002 - Input token account empty - #[error("Input token account empty")] - EmptySupply = 0x1772, - /// 6003 - InvalidInput - #[error("InvalidInput")] - InvalidInput = 0x1773, - /// 6004 - Address of the provided lp token mint is incorrect - #[error("Address of the provided lp token mint is incorrect")] - IncorrectLpMint = 0x1774, - /// 6005 - Exceeds desired slippage limit - #[error("Exceeds desired slippage limit")] - ExceededSlippage = 0x1775, - /// 6006 - Given pool token amount results in zero trading tokens - #[error("Given pool token amount results in zero trading tokens")] - ZeroTradingTokens = 0x1776, - /// 6007 - Not support token_2022 mint extension - #[error("Not support token_2022 mint extension")] - NotSupportMint = 0x1777, - /// 6008 - invaild vault - #[error("invaild vault")] - InvalidVault = 0x1778, - /// 6009 - Init lp amount is too less(Because 100 amount lp will be locked) - #[error("Init lp amount is too less(Because 100 amount lp will be locked)")] - InitLpAmountTooLess = 0x1779, - /// 6010 - TransferFee calculate not match - #[error("TransferFee calculate not match")] - TransferFeeCalculateNotMatch = 0x177a, - /// 6011 - Math overflow - #[error("Math overflow")] - MathOverflow = 0x177b, - /// 6012 - Insufficient vault - #[error("Insufficient vault")] - InsufficientVault = 0x177c, - /// 6013 - Invalid fee model - #[error("Invalid fee model")] - InvalidFeeModel = 0x177d, - /// 6014 - Fee is zero - #[error("Fee is zero")] - NoFeeCollect = 0x177e, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for RaydiumCpSwapError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for RaydiumCpSwapError { - fn type_of() -> &'static str { "RaydiumCpSwapError" } -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/close_permission_pda.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/close_permission_pda.rs deleted file mode 100644 index 731ba5f1..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/close_permission_pda.rs +++ /dev/null @@ -1,406 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLOSE_PERMISSION_PDA_DISCRIMINATOR: [u8; 8] = [156, 84, 32, 118, 69, 135, 70, 123]; - -/// Accounts. -#[derive(Debug)] -pub struct ClosePermissionPda { - pub owner: solana_pubkey::Pubkey, - - pub permission_authority: solana_pubkey::Pubkey, - /// Initialize config state account to store protocol owner address and fee rates. - pub permission: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl ClosePermissionPda { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.owner, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.permission_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.permission, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClosePermissionPdaInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClosePermissionPdaInstructionData { - discriminator: [u8; 8], -} - -impl ClosePermissionPdaInstructionData { - pub fn new() -> Self { - Self { - discriminator: [156, 84, 32, 118, 69, 135, 70, 123], - } - } -} - -impl Default for ClosePermissionPdaInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClosePermissionPda`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer, optional]` owner (default to `GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ`) -/// 1. `[]` permission_authority -/// 2. `[writable]` permission -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct ClosePermissionPdaBuilder { - owner: Option, - permission_authority: Option, - permission: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl ClosePermissionPdaBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ']` - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn permission_authority( - &mut self, - permission_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.permission_authority = Some(permission_authority); - self - } - - /// Initialize config state account to store protocol owner address and fee rates. - #[inline(always)] - pub fn permission(&mut self, permission: solana_pubkey::Pubkey) -> &mut Self { - self.permission = Some(permission); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClosePermissionPda { - owner: self.owner.unwrap_or(solana_pubkey::pubkey!( - "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - )), - permission_authority: self - .permission_authority - .expect("permission_authority is not set"), - permission: self.permission.expect("permission is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `close_permission_pda` CPI accounts. -pub struct ClosePermissionPdaCpiAccounts<'a, 'b> { - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub permission_authority: &'b solana_account_info::AccountInfo<'a>, - /// Initialize config state account to store protocol owner address and fee rates. - pub permission: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `close_permission_pda` CPI instruction. -pub struct ClosePermissionPdaCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub permission_authority: &'b solana_account_info::AccountInfo<'a>, - /// Initialize config state account to store protocol owner address and fee rates. - pub permission: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClosePermissionPdaCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClosePermissionPdaCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - permission_authority: accounts.permission_authority, - permission: accounts.permission, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.owner.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.permission_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.permission.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClosePermissionPdaInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.permission_authority.clone()); - account_infos.push(self.permission.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClosePermissionPda` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` owner -/// 1. `[]` permission_authority -/// 2. `[writable]` permission -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct ClosePermissionPdaCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClosePermissionPdaCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClosePermissionPdaCpiBuilderInstruction { - __program: program, - owner: None, - permission_authority: None, - permission: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn permission_authority( - &mut self, - permission_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.permission_authority = Some(permission_authority); - self - } - - /// Initialize config state account to store protocol owner address and fee rates. - #[inline(always)] - pub fn permission( - &mut self, - permission: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.permission = Some(permission); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClosePermissionPdaCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - permission_authority: self - .instruction - .permission_authority - .expect("permission_authority is not set"), - - permission: self.instruction.permission.expect("permission is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClosePermissionPdaCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - permission_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - permission: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/collect_creator_fee.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/collect_creator_fee.rs deleted file mode 100644 index e650dd19..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/collect_creator_fee.rs +++ /dev/null @@ -1,844 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const COLLECT_CREATOR_FEE_DISCRIMINATOR: [u8; 8] = [20, 22, 86, 123, 198, 28, 219, 132]; - -/// Accounts. -#[derive(Debug)] -pub struct CollectCreatorFee { - /// Only pool creator can collect fee - pub creator: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - /// Pool state stores accumulated protocol fee amount - pub pool_state: solana_pubkey::Pubkey, - /// Amm config account stores fund_owner - pub amm_config: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_0 - pub token0_vault: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_1 - pub token1_vault: solana_pubkey::Pubkey, - /// The mint of token_0 vault - pub vault0_mint: solana_pubkey::Pubkey, - /// The mint of token_1 vault - pub vault1_mint: solana_pubkey::Pubkey, - /// The address that receives the collected token_0 fund fees - pub creator_token0: solana_pubkey::Pubkey, - /// The address that receives the collected token_1 fund fees - pub creator_token1: solana_pubkey::Pubkey, - /// Spl token program or token program 2022 - pub token0_program: solana_pubkey::Pubkey, - /// Spl token program or token program 2022 - pub token1_program: solana_pubkey::Pubkey, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: solana_pubkey::Pubkey, - /// To create a new program account - pub system_program: solana_pubkey::Pubkey, -} - -impl CollectCreatorFee { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.creator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_token0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_token1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token0_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token1_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CollectCreatorFeeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectCreatorFeeInstructionData { - discriminator: [u8; 8], -} - -impl CollectCreatorFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [20, 22, 86, 123, 198, 28, 219, 132], - } - } -} - -impl Default for CollectCreatorFeeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CollectCreatorFee`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` amm_config -/// 4. `[writable]` token0_vault -/// 5. `[writable]` token1_vault -/// 6. `[]` vault0_mint -/// 7. `[]` vault1_mint -/// 8. `[writable]` creator_token0 -/// 9. `[writable]` creator_token1 -/// 10. `[]` token0_program -/// 11. `[]` token1_program -/// 12. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 13. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CollectCreatorFeeBuilder { - creator: Option, - authority: Option, - pool_state: Option, - amm_config: Option, - token0_vault: Option, - token1_vault: Option, - vault0_mint: Option, - vault1_mint: Option, - creator_token0: Option, - creator_token1: Option, - token0_program: Option, - token1_program: Option, - associated_token_program: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl CollectCreatorFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// Only pool creator can collect fee - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Pool state stores accumulated protocol fee amount - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Amm config account stores fund_owner - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - /// The address that receives the collected token_0 fund fees - #[inline(always)] - pub fn creator_token0(&mut self, creator_token0: solana_pubkey::Pubkey) -> &mut Self { - self.creator_token0 = Some(creator_token0); - self - } - - /// The address that receives the collected token_1 fund fees - #[inline(always)] - pub fn creator_token1(&mut self, creator_token1: solana_pubkey::Pubkey) -> &mut Self { - self.creator_token1 = Some(creator_token1); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token0_program(&mut self, token0_program: solana_pubkey::Pubkey) -> &mut Self { - self.token0_program = Some(token0_program); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token1_program(&mut self, token1_program: solana_pubkey::Pubkey) -> &mut Self { - self.token1_program = Some(token1_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Program to create an ATA for receiving position NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// To create a new program account - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectCreatorFee { - creator: self.creator.expect("creator is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - creator_token0: self.creator_token0.expect("creator_token0 is not set"), - creator_token1: self.creator_token1.expect("creator_token1 is not set"), - token0_program: self.token0_program.expect("token0_program is not set"), - token1_program: self.token1_program.expect("token1_program is not set"), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `collect_creator_fee` CPI accounts. -pub struct CollectCreatorFeeCpiAccounts<'a, 'b> { - /// Only pool creator can collect fee - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state stores accumulated protocol fee amount - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Amm config account stores fund_owner - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_0 fund fees - pub creator_token0: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_1 fund fees - pub creator_token1: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token0_program: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token1_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// To create a new program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_creator_fee` CPI instruction. -pub struct CollectCreatorFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Only pool creator can collect fee - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state stores accumulated protocol fee amount - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Amm config account stores fund_owner - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_0 fund fees - pub creator_token0: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_1 fund fees - pub creator_token1: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token0_program: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token1_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// To create a new program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CollectCreatorFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectCreatorFeeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - creator: accounts.creator, - authority: accounts.authority, - pool_state: accounts.pool_state, - amm_config: accounts.amm_config, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - creator_token0: accounts.creator_token0, - creator_token1: accounts.creator_token1, - token0_program: accounts.token0_program, - token1_program: accounts.token1_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_token0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_token1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token0_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token1_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CollectCreatorFeeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - account_infos.push(self.creator_token0.clone()); - account_infos.push(self.creator_token1.clone()); - account_infos.push(self.token0_program.clone()); - account_infos.push(self.token1_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectCreatorFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` amm_config -/// 4. `[writable]` token0_vault -/// 5. `[writable]` token1_vault -/// 6. `[]` vault0_mint -/// 7. `[]` vault1_mint -/// 8. `[writable]` creator_token0 -/// 9. `[writable]` creator_token1 -/// 10. `[]` token0_program -/// 11. `[]` token1_program -/// 12. `[]` associated_token_program -/// 13. `[]` system_program -#[derive(Clone, Debug)] -pub struct CollectCreatorFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectCreatorFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectCreatorFeeCpiBuilderInstruction { - __program: program, - creator: None, - authority: None, - pool_state: None, - amm_config: None, - token0_vault: None, - token1_vault: None, - vault0_mint: None, - vault1_mint: None, - creator_token0: None, - creator_token1: None, - token0_program: None, - token1_program: None, - associated_token_program: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Only pool creator can collect fee - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Pool state stores accumulated protocol fee amount - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Amm config account stores fund_owner - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - /// The address that receives the collected token_0 fund fees - #[inline(always)] - pub fn creator_token0( - &mut self, - creator_token0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_token0 = Some(creator_token0); - self - } - - /// The address that receives the collected token_1 fund fees - #[inline(always)] - pub fn creator_token1( - &mut self, - creator_token1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_token1 = Some(creator_token1); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token0_program( - &mut self, - token0_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_program = Some(token0_program); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token1_program( - &mut self, - token1_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_program = Some(token1_program); - self - } - - /// Program to create an ATA for receiving position NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// To create a new program account - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CollectCreatorFeeCpi { - __program: self.instruction.__program, - - creator: self.instruction.creator.expect("creator is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - - creator_token0: self - .instruction - .creator_token0 - .expect("creator_token0 is not set"), - - creator_token1: self - .instruction - .creator_token1 - .expect("creator_token1 is not set"), - - token0_program: self - .instruction - .token0_program - .expect("token0_program is not set"), - - token1_program: self - .instruction - .token1_program - .expect("token1_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectCreatorFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_token0: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_token1: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/collect_fund_fee.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/collect_fund_fee.rs deleted file mode 100644 index a15e9bba..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/collect_fund_fee.rs +++ /dev/null @@ -1,837 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const COLLECT_FUND_FEE_DISCRIMINATOR: [u8; 8] = [167, 138, 78, 149, 223, 194, 6, 126]; - -/// Accounts. -#[derive(Debug)] -pub struct CollectFundFee { - /// Only admin or fund_owner can collect fee now - pub owner: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - /// Pool state stores accumulated protocol fee amount - pub pool_state: solana_pubkey::Pubkey, - /// Amm config account stores fund_owner - pub amm_config: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_0 - pub token0_vault: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_1 - pub token1_vault: solana_pubkey::Pubkey, - /// The mint of token_0 vault - pub vault0_mint: solana_pubkey::Pubkey, - /// The mint of token_1 vault - pub vault1_mint: solana_pubkey::Pubkey, - /// The address that receives the collected token_0 fund fees - pub recipient_token0_account: solana_pubkey::Pubkey, - /// The address that receives the collected token_1 fund fees - pub recipient_token1_account: solana_pubkey::Pubkey, - /// The SPL program to perform token transfers - pub token_program: solana_pubkey::Pubkey, - /// The SPL program 2022 to perform token transfers - pub token_program2022: solana_pubkey::Pubkey, -} - -impl CollectFundFee { - pub fn instruction( - &self, - args: CollectFundFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CollectFundFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token0_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token1_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CollectFundFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectFundFeeInstructionData { - discriminator: [u8; 8], -} - -impl CollectFundFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [167, 138, 78, 149, 223, 194, 6, 126], - } - } -} - -impl Default for CollectFundFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectFundFeeInstructionArgs { - pub amount0_requested: u64, - pub amount1_requested: u64, -} - -/// Instruction builder for `CollectFundFee`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` amm_config -/// 4. `[writable]` token0_vault -/// 5. `[writable]` token1_vault -/// 6. `[]` vault0_mint -/// 7. `[]` vault1_mint -/// 8. `[writable]` recipient_token0_account -/// 9. `[writable]` recipient_token1_account -/// 10. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 11. `[optional]` token_program2022 (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -#[derive(Clone, Debug, Default)] -pub struct CollectFundFeeBuilder { - owner: Option, - authority: Option, - pool_state: Option, - amm_config: Option, - token0_vault: Option, - token1_vault: Option, - vault0_mint: Option, - vault1_mint: Option, - recipient_token0_account: Option, - recipient_token1_account: Option, - token_program: Option, - token_program2022: Option, - amount0_requested: Option, - amount1_requested: Option, - __remaining_accounts: Vec, -} - -impl CollectFundFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// Only admin or fund_owner can collect fee now - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Pool state stores accumulated protocol fee amount - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Amm config account stores fund_owner - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - /// The address that receives the collected token_0 fund fees - #[inline(always)] - pub fn recipient_token0_account( - &mut self, - recipient_token0_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token0_account = Some(recipient_token0_account); - self - } - - /// The address that receives the collected token_1 fund fees - #[inline(always)] - pub fn recipient_token1_account( - &mut self, - recipient_token1_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token1_account = Some(recipient_token1_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// The SPL program to perform token transfers - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// The SPL program 2022 to perform token transfers - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn amount0_requested(&mut self, amount0_requested: u64) -> &mut Self { - self.amount0_requested = Some(amount0_requested); - self - } - - #[inline(always)] - pub fn amount1_requested(&mut self, amount1_requested: u64) -> &mut Self { - self.amount1_requested = Some(amount1_requested); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectFundFee { - owner: self.owner.expect("owner is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - recipient_token0_account: self - .recipient_token0_account - .expect("recipient_token0_account is not set"), - recipient_token1_account: self - .recipient_token1_account - .expect("recipient_token1_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self.token_program2022.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - }; - let args = CollectFundFeeInstructionArgs { - amount0_requested: self - .amount0_requested - .clone() - .expect("amount0_requested is not set"), - amount1_requested: self - .amount1_requested - .clone() - .expect("amount1_requested is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `collect_fund_fee` CPI accounts. -pub struct CollectFundFeeCpiAccounts<'a, 'b> { - /// Only admin or fund_owner can collect fee now - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state stores accumulated protocol fee amount - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Amm config account stores fund_owner - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_0 fund fees - pub recipient_token0_account: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_1 fund fees - pub recipient_token1_account: &'b solana_account_info::AccountInfo<'a>, - /// The SPL program to perform token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The SPL program 2022 to perform token transfers - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_fund_fee` CPI instruction. -pub struct CollectFundFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Only admin or fund_owner can collect fee now - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state stores accumulated protocol fee amount - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Amm config account stores fund_owner - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_0 fund fees - pub recipient_token0_account: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_1 fund fees - pub recipient_token1_account: &'b solana_account_info::AccountInfo<'a>, - /// The SPL program to perform token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The SPL program 2022 to perform token transfers - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CollectFundFeeInstructionArgs, -} - -impl<'a, 'b> CollectFundFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectFundFeeCpiAccounts<'a, 'b>, - args: CollectFundFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - authority: accounts.authority, - pool_state: accounts.pool_state, - amm_config: accounts.amm_config, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - recipient_token0_account: accounts.recipient_token0_account, - recipient_token1_account: accounts.recipient_token1_account, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token0_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token1_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CollectFundFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - account_infos.push(self.recipient_token0_account.clone()); - account_infos.push(self.recipient_token1_account.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectFundFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` amm_config -/// 4. `[writable]` token0_vault -/// 5. `[writable]` token1_vault -/// 6. `[]` vault0_mint -/// 7. `[]` vault1_mint -/// 8. `[writable]` recipient_token0_account -/// 9. `[writable]` recipient_token1_account -/// 10. `[]` token_program -/// 11. `[]` token_program2022 -#[derive(Clone, Debug)] -pub struct CollectFundFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectFundFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectFundFeeCpiBuilderInstruction { - __program: program, - owner: None, - authority: None, - pool_state: None, - amm_config: None, - token0_vault: None, - token1_vault: None, - vault0_mint: None, - vault1_mint: None, - recipient_token0_account: None, - recipient_token1_account: None, - token_program: None, - token_program2022: None, - amount0_requested: None, - amount1_requested: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Only admin or fund_owner can collect fee now - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Pool state stores accumulated protocol fee amount - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Amm config account stores fund_owner - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - /// The address that receives the collected token_0 fund fees - #[inline(always)] - pub fn recipient_token0_account( - &mut self, - recipient_token0_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token0_account = Some(recipient_token0_account); - self - } - - /// The address that receives the collected token_1 fund fees - #[inline(always)] - pub fn recipient_token1_account( - &mut self, - recipient_token1_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token1_account = Some(recipient_token1_account); - self - } - - /// The SPL program to perform token transfers - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// The SPL program 2022 to perform token transfers - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn amount0_requested(&mut self, amount0_requested: u64) -> &mut Self { - self.instruction.amount0_requested = Some(amount0_requested); - self - } - - #[inline(always)] - pub fn amount1_requested(&mut self, amount1_requested: u64) -> &mut Self { - self.instruction.amount1_requested = Some(amount1_requested); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CollectFundFeeInstructionArgs { - amount0_requested: self - .instruction - .amount0_requested - .clone() - .expect("amount0_requested is not set"), - amount1_requested: self - .instruction - .amount1_requested - .clone() - .expect("amount1_requested is not set"), - }; - let instruction = CollectFundFeeCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - - recipient_token0_account: self - .instruction - .recipient_token0_account - .expect("recipient_token0_account is not set"), - - recipient_token1_account: self - .instruction - .recipient_token1_account - .expect("recipient_token1_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectFundFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token0_account: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token1_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - amount0_requested: Option, - amount1_requested: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/collect_protocol_fee.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/collect_protocol_fee.rs deleted file mode 100644 index c15d6651..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/collect_protocol_fee.rs +++ /dev/null @@ -1,837 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const COLLECT_PROTOCOL_FEE_DISCRIMINATOR: [u8; 8] = [136, 136, 252, 221, 194, 66, 126, 89]; - -/// Accounts. -#[derive(Debug)] -pub struct CollectProtocolFee { - /// Only admin or owner can collect fee now - pub owner: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - /// Pool state stores accumulated protocol fee amount - pub pool_state: solana_pubkey::Pubkey, - /// Amm config account stores owner - pub amm_config: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_0 - pub token0_vault: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_1 - pub token1_vault: solana_pubkey::Pubkey, - /// The mint of token_0 vault - pub vault0_mint: solana_pubkey::Pubkey, - /// The mint of token_1 vault - pub vault1_mint: solana_pubkey::Pubkey, - /// The address that receives the collected token_0 protocol fees - pub recipient_token0_account: solana_pubkey::Pubkey, - /// The address that receives the collected token_1 protocol fees - pub recipient_token1_account: solana_pubkey::Pubkey, - /// The SPL program to perform token transfers - pub token_program: solana_pubkey::Pubkey, - /// The SPL program 2022 to perform token transfers - pub token_program2022: solana_pubkey::Pubkey, -} - -impl CollectProtocolFee { - pub fn instruction( - &self, - args: CollectProtocolFeeInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CollectProtocolFeeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token0_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token1_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CollectProtocolFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectProtocolFeeInstructionData { - discriminator: [u8; 8], -} - -impl CollectProtocolFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [136, 136, 252, 221, 194, 66, 126, 89], - } - } -} - -impl Default for CollectProtocolFeeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectProtocolFeeInstructionArgs { - pub amount0_requested: u64, - pub amount1_requested: u64, -} - -/// Instruction builder for `CollectProtocolFee`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` amm_config -/// 4. `[writable]` token0_vault -/// 5. `[writable]` token1_vault -/// 6. `[]` vault0_mint -/// 7. `[]` vault1_mint -/// 8. `[writable]` recipient_token0_account -/// 9. `[writable]` recipient_token1_account -/// 10. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 11. `[optional]` token_program2022 (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -#[derive(Clone, Debug, Default)] -pub struct CollectProtocolFeeBuilder { - owner: Option, - authority: Option, - pool_state: Option, - amm_config: Option, - token0_vault: Option, - token1_vault: Option, - vault0_mint: Option, - vault1_mint: Option, - recipient_token0_account: Option, - recipient_token1_account: Option, - token_program: Option, - token_program2022: Option, - amount0_requested: Option, - amount1_requested: Option, - __remaining_accounts: Vec, -} - -impl CollectProtocolFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// Only admin or owner can collect fee now - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Pool state stores accumulated protocol fee amount - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Amm config account stores owner - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - /// The address that receives the collected token_0 protocol fees - #[inline(always)] - pub fn recipient_token0_account( - &mut self, - recipient_token0_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token0_account = Some(recipient_token0_account); - self - } - - /// The address that receives the collected token_1 protocol fees - #[inline(always)] - pub fn recipient_token1_account( - &mut self, - recipient_token1_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token1_account = Some(recipient_token1_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// The SPL program to perform token transfers - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// The SPL program 2022 to perform token transfers - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn amount0_requested(&mut self, amount0_requested: u64) -> &mut Self { - self.amount0_requested = Some(amount0_requested); - self - } - - #[inline(always)] - pub fn amount1_requested(&mut self, amount1_requested: u64) -> &mut Self { - self.amount1_requested = Some(amount1_requested); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectProtocolFee { - owner: self.owner.expect("owner is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - recipient_token0_account: self - .recipient_token0_account - .expect("recipient_token0_account is not set"), - recipient_token1_account: self - .recipient_token1_account - .expect("recipient_token1_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self.token_program2022.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - }; - let args = CollectProtocolFeeInstructionArgs { - amount0_requested: self - .amount0_requested - .clone() - .expect("amount0_requested is not set"), - amount1_requested: self - .amount1_requested - .clone() - .expect("amount1_requested is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `collect_protocol_fee` CPI accounts. -pub struct CollectProtocolFeeCpiAccounts<'a, 'b> { - /// Only admin or owner can collect fee now - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state stores accumulated protocol fee amount - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Amm config account stores owner - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_0 protocol fees - pub recipient_token0_account: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_1 protocol fees - pub recipient_token1_account: &'b solana_account_info::AccountInfo<'a>, - /// The SPL program to perform token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The SPL program 2022 to perform token transfers - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_protocol_fee` CPI instruction. -pub struct CollectProtocolFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Only admin or owner can collect fee now - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state stores accumulated protocol fee amount - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Amm config account stores owner - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_0 protocol fees - pub recipient_token0_account: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected token_1 protocol fees - pub recipient_token1_account: &'b solana_account_info::AccountInfo<'a>, - /// The SPL program to perform token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The SPL program 2022 to perform token transfers - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CollectProtocolFeeInstructionArgs, -} - -impl<'a, 'b> CollectProtocolFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectProtocolFeeCpiAccounts<'a, 'b>, - args: CollectProtocolFeeInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - authority: accounts.authority, - pool_state: accounts.pool_state, - amm_config: accounts.amm_config, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - recipient_token0_account: accounts.recipient_token0_account, - recipient_token1_account: accounts.recipient_token1_account, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token0_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token1_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CollectProtocolFeeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - account_infos.push(self.recipient_token0_account.clone()); - account_infos.push(self.recipient_token1_account.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectProtocolFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` amm_config -/// 4. `[writable]` token0_vault -/// 5. `[writable]` token1_vault -/// 6. `[]` vault0_mint -/// 7. `[]` vault1_mint -/// 8. `[writable]` recipient_token0_account -/// 9. `[writable]` recipient_token1_account -/// 10. `[]` token_program -/// 11. `[]` token_program2022 -#[derive(Clone, Debug)] -pub struct CollectProtocolFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectProtocolFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectProtocolFeeCpiBuilderInstruction { - __program: program, - owner: None, - authority: None, - pool_state: None, - amm_config: None, - token0_vault: None, - token1_vault: None, - vault0_mint: None, - vault1_mint: None, - recipient_token0_account: None, - recipient_token1_account: None, - token_program: None, - token_program2022: None, - amount0_requested: None, - amount1_requested: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Only admin or owner can collect fee now - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Pool state stores accumulated protocol fee amount - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Amm config account stores owner - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - /// The address that receives the collected token_0 protocol fees - #[inline(always)] - pub fn recipient_token0_account( - &mut self, - recipient_token0_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token0_account = Some(recipient_token0_account); - self - } - - /// The address that receives the collected token_1 protocol fees - #[inline(always)] - pub fn recipient_token1_account( - &mut self, - recipient_token1_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token1_account = Some(recipient_token1_account); - self - } - - /// The SPL program to perform token transfers - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// The SPL program 2022 to perform token transfers - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - #[inline(always)] - pub fn amount0_requested(&mut self, amount0_requested: u64) -> &mut Self { - self.instruction.amount0_requested = Some(amount0_requested); - self - } - - #[inline(always)] - pub fn amount1_requested(&mut self, amount1_requested: u64) -> &mut Self { - self.instruction.amount1_requested = Some(amount1_requested); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CollectProtocolFeeInstructionArgs { - amount0_requested: self - .instruction - .amount0_requested - .clone() - .expect("amount0_requested is not set"), - amount1_requested: self - .instruction - .amount1_requested - .clone() - .expect("amount1_requested is not set"), - }; - let instruction = CollectProtocolFeeCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - - recipient_token0_account: self - .instruction - .recipient_token0_account - .expect("recipient_token0_account is not set"), - - recipient_token1_account: self - .instruction - .recipient_token1_account - .expect("recipient_token1_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectProtocolFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token0_account: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token1_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - amount0_requested: Option, - amount1_requested: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/create_amm_config.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/create_amm_config.rs deleted file mode 100644 index abc800ce..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/create_amm_config.rs +++ /dev/null @@ -1,528 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CREATE_AMM_CONFIG_DISCRIMINATOR: [u8; 8] = [137, 52, 237, 212, 215, 117, 108, 104]; - -/// Accounts. -#[derive(Debug)] -pub struct CreateAmmConfig { - /// Address to be set as protocol owner. - pub owner: solana_pubkey::Pubkey, - /// Initialize config state account to store protocol owner address and fee rates. - pub amm_config: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateAmmConfig { - pub fn instruction( - &self, - args: CreateAmmConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateAmmConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.owner, true)); - accounts.push(solana_instruction::AccountMeta::new(self.amm_config, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateAmmConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateAmmConfigInstructionData { - discriminator: [u8; 8], -} - -impl CreateAmmConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [137, 52, 237, 212, 215, 117, 108, 104], - } - } -} - -impl Default for CreateAmmConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateAmmConfigInstructionArgs { - pub index: u16, - pub trade_fee_rate: u64, - pub protocol_fee_rate: u64, - pub fund_fee_rate: u64, - pub create_pool_fee: u64, - pub creator_fee_rate: u64, -} - -/// Instruction builder for `CreateAmmConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer, optional]` owner (default to `GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ`) -/// 1. `[writable]` amm_config -/// 2. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateAmmConfigBuilder { - owner: Option, - amm_config: Option, - system_program: Option, - index: Option, - trade_fee_rate: Option, - protocol_fee_rate: Option, - fund_fee_rate: Option, - create_pool_fee: Option, - creator_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl CreateAmmConfigBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ']` - /// Address to be set as protocol owner. - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Initialize config state account to store protocol owner address and fee rates. - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u16) -> &mut Self { - self.index = Some(index); - self - } - - #[inline(always)] - pub fn trade_fee_rate(&mut self, trade_fee_rate: u64) -> &mut Self { - self.trade_fee_rate = Some(trade_fee_rate); - self - } - - #[inline(always)] - pub fn protocol_fee_rate(&mut self, protocol_fee_rate: u64) -> &mut Self { - self.protocol_fee_rate = Some(protocol_fee_rate); - self - } - - #[inline(always)] - pub fn fund_fee_rate(&mut self, fund_fee_rate: u64) -> &mut Self { - self.fund_fee_rate = Some(fund_fee_rate); - self - } - - #[inline(always)] - pub fn create_pool_fee(&mut self, create_pool_fee: u64) -> &mut Self { - self.create_pool_fee = Some(create_pool_fee); - self - } - - #[inline(always)] - pub fn creator_fee_rate(&mut self, creator_fee_rate: u64) -> &mut Self { - self.creator_fee_rate = Some(creator_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateAmmConfig { - owner: self.owner.unwrap_or(solana_pubkey::pubkey!( - "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - )), - amm_config: self.amm_config.expect("amm_config is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = CreateAmmConfigInstructionArgs { - index: self.index.clone().expect("index is not set"), - trade_fee_rate: self - .trade_fee_rate - .clone() - .expect("trade_fee_rate is not set"), - protocol_fee_rate: self - .protocol_fee_rate - .clone() - .expect("protocol_fee_rate is not set"), - fund_fee_rate: self - .fund_fee_rate - .clone() - .expect("fund_fee_rate is not set"), - create_pool_fee: self - .create_pool_fee - .clone() - .expect("create_pool_fee is not set"), - creator_fee_rate: self - .creator_fee_rate - .clone() - .expect("creator_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_amm_config` CPI accounts. -pub struct CreateAmmConfigCpiAccounts<'a, 'b> { - /// Address to be set as protocol owner. - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Initialize config state account to store protocol owner address and fee rates. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_amm_config` CPI instruction. -pub struct CreateAmmConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Address to be set as protocol owner. - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Initialize config state account to store protocol owner address and fee rates. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateAmmConfigInstructionArgs, -} - -impl<'a, 'b> CreateAmmConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateAmmConfigCpiAccounts<'a, 'b>, - args: CreateAmmConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - amm_config: accounts.amm_config, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.owner.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateAmmConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateAmmConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` owner -/// 1. `[writable]` amm_config -/// 2. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateAmmConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateAmmConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateAmmConfigCpiBuilderInstruction { - __program: program, - owner: None, - amm_config: None, - system_program: None, - index: None, - trade_fee_rate: None, - protocol_fee_rate: None, - fund_fee_rate: None, - create_pool_fee: None, - creator_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Address to be set as protocol owner. - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Initialize config state account to store protocol owner address and fee rates. - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u16) -> &mut Self { - self.instruction.index = Some(index); - self - } - - #[inline(always)] - pub fn trade_fee_rate(&mut self, trade_fee_rate: u64) -> &mut Self { - self.instruction.trade_fee_rate = Some(trade_fee_rate); - self - } - - #[inline(always)] - pub fn protocol_fee_rate(&mut self, protocol_fee_rate: u64) -> &mut Self { - self.instruction.protocol_fee_rate = Some(protocol_fee_rate); - self - } - - #[inline(always)] - pub fn fund_fee_rate(&mut self, fund_fee_rate: u64) -> &mut Self { - self.instruction.fund_fee_rate = Some(fund_fee_rate); - self - } - - #[inline(always)] - pub fn create_pool_fee(&mut self, create_pool_fee: u64) -> &mut Self { - self.instruction.create_pool_fee = Some(create_pool_fee); - self - } - - #[inline(always)] - pub fn creator_fee_rate(&mut self, creator_fee_rate: u64) -> &mut Self { - self.instruction.creator_fee_rate = Some(creator_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateAmmConfigInstructionArgs { - index: self.instruction.index.clone().expect("index is not set"), - trade_fee_rate: self - .instruction - .trade_fee_rate - .clone() - .expect("trade_fee_rate is not set"), - protocol_fee_rate: self - .instruction - .protocol_fee_rate - .clone() - .expect("protocol_fee_rate is not set"), - fund_fee_rate: self - .instruction - .fund_fee_rate - .clone() - .expect("fund_fee_rate is not set"), - create_pool_fee: self - .instruction - .create_pool_fee - .clone() - .expect("create_pool_fee is not set"), - creator_fee_rate: self - .instruction - .creator_fee_rate - .clone() - .expect("creator_fee_rate is not set"), - }; - let instruction = CreateAmmConfigCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateAmmConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - index: Option, - trade_fee_rate: Option, - protocol_fee_rate: Option, - fund_fee_rate: Option, - create_pool_fee: Option, - creator_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/create_permission_pda.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/create_permission_pda.rs deleted file mode 100644 index 1e46b86a..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/create_permission_pda.rs +++ /dev/null @@ -1,406 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CREATE_PERMISSION_PDA_DISCRIMINATOR: [u8; 8] = [135, 136, 2, 216, 137, 169, 181, 202]; - -/// Accounts. -#[derive(Debug)] -pub struct CreatePermissionPda { - pub owner: solana_pubkey::Pubkey, - - pub permission_authority: solana_pubkey::Pubkey, - /// Initialize config state account to store protocol owner address and fee rates. - pub permission: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl CreatePermissionPda { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.owner, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.permission_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.permission, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreatePermissionPdaInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePermissionPdaInstructionData { - discriminator: [u8; 8], -} - -impl CreatePermissionPdaInstructionData { - pub fn new() -> Self { - Self { - discriminator: [135, 136, 2, 216, 137, 169, 181, 202], - } - } -} - -impl Default for CreatePermissionPdaInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreatePermissionPda`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer, optional]` owner (default to `GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ`) -/// 1. `[]` permission_authority -/// 2. `[writable]` permission -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreatePermissionPdaBuilder { - owner: Option, - permission_authority: Option, - permission: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl CreatePermissionPdaBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ']` - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn permission_authority( - &mut self, - permission_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.permission_authority = Some(permission_authority); - self - } - - /// Initialize config state account to store protocol owner address and fee rates. - #[inline(always)] - pub fn permission(&mut self, permission: solana_pubkey::Pubkey) -> &mut Self { - self.permission = Some(permission); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreatePermissionPda { - owner: self.owner.unwrap_or(solana_pubkey::pubkey!( - "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - )), - permission_authority: self - .permission_authority - .expect("permission_authority is not set"), - permission: self.permission.expect("permission is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_permission_pda` CPI accounts. -pub struct CreatePermissionPdaCpiAccounts<'a, 'b> { - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub permission_authority: &'b solana_account_info::AccountInfo<'a>, - /// Initialize config state account to store protocol owner address and fee rates. - pub permission: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_permission_pda` CPI instruction. -pub struct CreatePermissionPdaCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub permission_authority: &'b solana_account_info::AccountInfo<'a>, - /// Initialize config state account to store protocol owner address and fee rates. - pub permission: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreatePermissionPdaCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreatePermissionPdaCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - permission_authority: accounts.permission_authority, - permission: accounts.permission, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.owner.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.permission_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.permission.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreatePermissionPdaInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.permission_authority.clone()); - account_infos.push(self.permission.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreatePermissionPda` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` owner -/// 1. `[]` permission_authority -/// 2. `[writable]` permission -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreatePermissionPdaCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreatePermissionPdaCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreatePermissionPdaCpiBuilderInstruction { - __program: program, - owner: None, - permission_authority: None, - permission: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn permission_authority( - &mut self, - permission_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.permission_authority = Some(permission_authority); - self - } - - /// Initialize config state account to store protocol owner address and fee rates. - #[inline(always)] - pub fn permission( - &mut self, - permission: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.permission = Some(permission); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreatePermissionPdaCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - permission_authority: self - .instruction - .permission_authority - .expect("permission_authority is not set"), - - permission: self.instruction.permission.expect("permission is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreatePermissionPdaCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - permission_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - permission: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/deposit.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/deposit.rs deleted file mode 100644 index fb50e27c..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/deposit.rs +++ /dev/null @@ -1,885 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const DEPOSIT_DISCRIMINATOR: [u8; 8] = [242, 35, 198, 137, 82, 225, 242, 182]; - -/// Accounts. -#[derive(Debug)] -pub struct Deposit { - /// Pays to mint the position - pub owner: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, - /// Owner lp token account - pub owner_lp_token: solana_pubkey::Pubkey, - /// The payer's token account for token_0 - pub token0_account: solana_pubkey::Pubkey, - /// The payer's token account for token_1 - pub token1_account: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_0 - pub token0_vault: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_1 - pub token1_vault: solana_pubkey::Pubkey, - /// token Program - pub token_program: solana_pubkey::Pubkey, - /// Token program 2022 - pub token_program2022: solana_pubkey::Pubkey, - /// The mint of token_0 vault - pub vault0_mint: solana_pubkey::Pubkey, - /// The mint of token_1 vault - pub vault1_mint: solana_pubkey::Pubkey, - /// Lp token mint - pub lp_mint: solana_pubkey::Pubkey, -} - -impl Deposit { - pub fn instruction(&self, args: DepositInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: DepositInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.owner_lp_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&DepositInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositInstructionData { - discriminator: [u8; 8], -} - -impl DepositInstructionData { - pub fn new() -> Self { - Self { - discriminator: [242, 35, 198, 137, 82, 225, 242, 182], - } - } -} - -impl Default for DepositInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DepositInstructionArgs { - pub lp_token_amount: u64, - pub maximum_token0_amount: u64, - pub maximum_token1_amount: u64, -} - -/// Instruction builder for `Deposit`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[writable]` owner_lp_token -/// 4. `[writable]` token0_account -/// 5. `[writable]` token1_account -/// 6. `[writable]` token0_vault -/// 7. `[writable]` token1_vault -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[optional]` token_program2022 (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 10. `[]` vault0_mint -/// 11. `[]` vault1_mint -/// 12. `[writable]` lp_mint -#[derive(Clone, Debug, Default)] -pub struct DepositBuilder { - owner: Option, - authority: Option, - pool_state: Option, - owner_lp_token: Option, - token0_account: Option, - token1_account: Option, - token0_vault: Option, - token1_vault: Option, - token_program: Option, - token_program2022: Option, - vault0_mint: Option, - vault1_mint: Option, - lp_mint: Option, - lp_token_amount: Option, - maximum_token0_amount: Option, - maximum_token1_amount: Option, - __remaining_accounts: Vec, -} - -impl DepositBuilder { - pub fn new() -> Self { Self::default() } - - /// Pays to mint the position - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Owner lp token account - #[inline(always)] - pub fn owner_lp_token(&mut self, owner_lp_token: solana_pubkey::Pubkey) -> &mut Self { - self.owner_lp_token = Some(owner_lp_token); - self - } - - /// The payer's token account for token_0 - #[inline(always)] - pub fn token0_account(&mut self, token0_account: solana_pubkey::Pubkey) -> &mut Self { - self.token0_account = Some(token0_account); - self - } - - /// The payer's token account for token_1 - #[inline(always)] - pub fn token1_account(&mut self, token1_account: solana_pubkey::Pubkey) -> &mut Self { - self.token1_account = Some(token1_account); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token Program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// Token program 2022 - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - /// Lp token mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn lp_token_amount(&mut self, lp_token_amount: u64) -> &mut Self { - self.lp_token_amount = Some(lp_token_amount); - self - } - - #[inline(always)] - pub fn maximum_token0_amount(&mut self, maximum_token0_amount: u64) -> &mut Self { - self.maximum_token0_amount = Some(maximum_token0_amount); - self - } - - #[inline(always)] - pub fn maximum_token1_amount(&mut self, maximum_token1_amount: u64) -> &mut Self { - self.maximum_token1_amount = Some(maximum_token1_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Deposit { - owner: self.owner.expect("owner is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - owner_lp_token: self.owner_lp_token.expect("owner_lp_token is not set"), - token0_account: self.token0_account.expect("token0_account is not set"), - token1_account: self.token1_account.expect("token1_account is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self.token_program2022.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - }; - let args = DepositInstructionArgs { - lp_token_amount: self - .lp_token_amount - .clone() - .expect("lp_token_amount is not set"), - maximum_token0_amount: self - .maximum_token0_amount - .clone() - .expect("maximum_token0_amount is not set"), - maximum_token1_amount: self - .maximum_token1_amount - .clone() - .expect("maximum_token1_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `deposit` CPI accounts. -pub struct DepositCpiAccounts<'a, 'b> { - /// Pays to mint the position - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Owner lp token account - pub owner_lp_token: &'b solana_account_info::AccountInfo<'a>, - /// The payer's token account for token_0 - pub token0_account: &'b solana_account_info::AccountInfo<'a>, - /// The payer's token account for token_1 - pub token1_account: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// token Program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program 2022 - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// Lp token mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, -} - -/// `deposit` CPI instruction. -pub struct DepositCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pays to mint the position - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Owner lp token account - pub owner_lp_token: &'b solana_account_info::AccountInfo<'a>, - /// The payer's token account for token_0 - pub token0_account: &'b solana_account_info::AccountInfo<'a>, - /// The payer's token account for token_1 - pub token1_account: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// token Program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program 2022 - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// Lp token mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: DepositInstructionArgs, -} - -impl<'a, 'b> DepositCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: DepositCpiAccounts<'a, 'b>, - args: DepositInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - authority: accounts.authority, - pool_state: accounts.pool_state, - owner_lp_token: accounts.owner_lp_token, - token0_account: accounts.token0_account, - token1_account: accounts.token1_account, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - lp_mint: accounts.lp_mint, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.owner_lp_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&DepositInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.owner_lp_token.clone()); - account_infos.push(self.token0_account.clone()); - account_infos.push(self.token1_account.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - account_infos.push(self.lp_mint.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Deposit` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[writable]` owner_lp_token -/// 4. `[writable]` token0_account -/// 5. `[writable]` token1_account -/// 6. `[writable]` token0_vault -/// 7. `[writable]` token1_vault -/// 8. `[]` token_program -/// 9. `[]` token_program2022 -/// 10. `[]` vault0_mint -/// 11. `[]` vault1_mint -/// 12. `[writable]` lp_mint -#[derive(Clone, Debug)] -pub struct DepositCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> DepositCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(DepositCpiBuilderInstruction { - __program: program, - owner: None, - authority: None, - pool_state: None, - owner_lp_token: None, - token0_account: None, - token1_account: None, - token0_vault: None, - token1_vault: None, - token_program: None, - token_program2022: None, - vault0_mint: None, - vault1_mint: None, - lp_mint: None, - lp_token_amount: None, - maximum_token0_amount: None, - maximum_token1_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pays to mint the position - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Owner lp token account - #[inline(always)] - pub fn owner_lp_token( - &mut self, - owner_lp_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.owner_lp_token = Some(owner_lp_token); - self - } - - /// The payer's token account for token_0 - #[inline(always)] - pub fn token0_account( - &mut self, - token0_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_account = Some(token0_account); - self - } - - /// The payer's token account for token_1 - #[inline(always)] - pub fn token1_account( - &mut self, - token1_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_account = Some(token1_account); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - /// token Program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Token program 2022 - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - /// Lp token mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn lp_token_amount(&mut self, lp_token_amount: u64) -> &mut Self { - self.instruction.lp_token_amount = Some(lp_token_amount); - self - } - - #[inline(always)] - pub fn maximum_token0_amount(&mut self, maximum_token0_amount: u64) -> &mut Self { - self.instruction.maximum_token0_amount = Some(maximum_token0_amount); - self - } - - #[inline(always)] - pub fn maximum_token1_amount(&mut self, maximum_token1_amount: u64) -> &mut Self { - self.instruction.maximum_token1_amount = Some(maximum_token1_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = DepositInstructionArgs { - lp_token_amount: self - .instruction - .lp_token_amount - .clone() - .expect("lp_token_amount is not set"), - maximum_token0_amount: self - .instruction - .maximum_token0_amount - .clone() - .expect("maximum_token0_amount is not set"), - maximum_token1_amount: self - .instruction - .maximum_token1_amount - .clone() - .expect("maximum_token1_amount is not set"), - }; - let instruction = DepositCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - owner_lp_token: self - .instruction - .owner_lp_token - .expect("owner_lp_token is not set"), - - token0_account: self - .instruction - .token0_account - .expect("token0_account is not set"), - - token1_account: self - .instruction - .token1_account - .expect("token1_account is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct DepositCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - owner_lp_token: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_token_amount: Option, - maximum_token0_amount: Option, - maximum_token1_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/initialize.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/initialize.rs deleted file mode 100644 index 98a8c33c..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/initialize.rs +++ /dev/null @@ -1,1226 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const INITIALIZE_DISCRIMINATOR: [u8; 8] = [175, 175, 109, 31, 13, 152, 155, 237]; - -/// Accounts. -#[derive(Debug)] -pub struct Initialize { - /// Address paying to create the pool. Can be anyone - pub creator: solana_pubkey::Pubkey, - /// Which config the pool belongs to. - pub amm_config: solana_pubkey::Pubkey, - /// pool vault and lp mint authority - pub authority: solana_pubkey::Pubkey, - /// PDA account: - /// seeds = [ - /// POOL_SEED.as_bytes(), - /// amm_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// - /// Or random account: must be signed by cli - pub pool_state: solana_pubkey::Pubkey, - /// Token_0 mint, the key must smaller than token_1 mint. - pub token0_mint: solana_pubkey::Pubkey, - /// Token_1 mint, the key must grater then token_0 mint. - pub token1_mint: solana_pubkey::Pubkey, - /// pool lp mint - pub lp_mint: solana_pubkey::Pubkey, - /// payer token0 account - pub creator_token0: solana_pubkey::Pubkey, - /// creator token1 account - pub creator_token1: solana_pubkey::Pubkey, - /// creator lp token account - pub creator_lp_token: solana_pubkey::Pubkey, - - pub token0_vault: solana_pubkey::Pubkey, - - pub token1_vault: solana_pubkey::Pubkey, - /// create pool fee account - pub create_pool_fee: solana_pubkey::Pubkey, - /// an account to store oracle observations - pub observation_state: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_program: solana_pubkey::Pubkey, - /// Spl token program or token program 2022 - pub token0_program: solana_pubkey::Pubkey, - /// Spl token program or token program 2022 - pub token1_program: solana_pubkey::Pubkey, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: solana_pubkey::Pubkey, - /// To create a new program account - pub system_program: solana_pubkey::Pubkey, - /// Sysvar for program account - pub rent: solana_pubkey::Pubkey, -} - -impl Initialize { - pub fn instruction(&self, args: InitializeInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(20 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.creator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_token0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_token1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_lp_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.create_pool_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token0_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token1_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionData { - discriminator: [u8; 8], -} - -impl InitializeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [175, 175, 109, 31, 13, 152, 155, 237], - } - } -} - -impl Default for InitializeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionArgs { - pub init_amount0: u64, - pub init_amount1: u64, - pub open_time: u64, -} - -/// Instruction builder for `Initialize`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[]` amm_config -/// 2. `[]` authority -/// 3. `[writable]` pool_state -/// 4. `[]` token0_mint -/// 5. `[]` token1_mint -/// 6. `[writable]` lp_mint -/// 7. `[writable]` creator_token0 -/// 8. `[writable]` creator_token1 -/// 9. `[writable]` creator_lp_token -/// 10. `[writable]` token0_vault -/// 11. `[writable]` token1_vault -/// 12. `[writable, optional]` create_pool_fee (default to `DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8`) -/// 13. `[writable]` observation_state -/// 14. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 15. `[]` token0_program -/// 16. `[]` token1_program -/// 17. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 18. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 19. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeBuilder { - creator: Option, - amm_config: Option, - authority: Option, - pool_state: Option, - token0_mint: Option, - token1_mint: Option, - lp_mint: Option, - creator_token0: Option, - creator_token1: Option, - creator_lp_token: Option, - token0_vault: Option, - token1_vault: Option, - create_pool_fee: Option, - observation_state: Option, - token_program: Option, - token0_program: Option, - token1_program: Option, - associated_token_program: Option, - system_program: Option, - rent: Option, - init_amount0: Option, - init_amount1: Option, - open_time: Option, - __remaining_accounts: Vec, -} - -impl InitializeBuilder { - pub fn new() -> Self { Self::default() } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - /// pool vault and lp mint authority - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// PDA account: - /// seeds = [ - /// POOL_SEED.as_bytes(), - /// amm_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// - /// Or random account: must be signed by cli - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Token_0 mint, the key must smaller than token_1 mint. - #[inline(always)] - pub fn token0_mint(&mut self, token0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token0_mint = Some(token0_mint); - self - } - - /// Token_1 mint, the key must grater then token_0 mint. - #[inline(always)] - pub fn token1_mint(&mut self, token1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token1_mint = Some(token1_mint); - self - } - - /// pool lp mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// payer token0 account - #[inline(always)] - pub fn creator_token0(&mut self, creator_token0: solana_pubkey::Pubkey) -> &mut Self { - self.creator_token0 = Some(creator_token0); - self - } - - /// creator token1 account - #[inline(always)] - pub fn creator_token1(&mut self, creator_token1: solana_pubkey::Pubkey) -> &mut Self { - self.creator_token1 = Some(creator_token1); - self - } - - /// creator lp token account - #[inline(always)] - pub fn creator_lp_token(&mut self, creator_lp_token: solana_pubkey::Pubkey) -> &mut Self { - self.creator_lp_token = Some(creator_lp_token); - self - } - - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - /// `[optional account, default to 'DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8']` - /// create pool fee account - #[inline(always)] - pub fn create_pool_fee(&mut self, create_pool_fee: solana_pubkey::Pubkey) -> &mut Self { - self.create_pool_fee = Some(create_pool_fee); - self - } - - /// an account to store oracle observations - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token0_program(&mut self, token0_program: solana_pubkey::Pubkey) -> &mut Self { - self.token0_program = Some(token0_program); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token1_program(&mut self, token1_program: solana_pubkey::Pubkey) -> &mut Self { - self.token1_program = Some(token1_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Program to create an ATA for receiving position NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// To create a new program account - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Sysvar for program account - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn init_amount0(&mut self, init_amount0: u64) -> &mut Self { - self.init_amount0 = Some(init_amount0); - self - } - - #[inline(always)] - pub fn init_amount1(&mut self, init_amount1: u64) -> &mut Self { - self.init_amount1 = Some(init_amount1); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.open_time = Some(open_time); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Initialize { - creator: self.creator.expect("creator is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - token0_mint: self.token0_mint.expect("token0_mint is not set"), - token1_mint: self.token1_mint.expect("token1_mint is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - creator_token0: self.creator_token0.expect("creator_token0 is not set"), - creator_token1: self.creator_token1.expect("creator_token1 is not set"), - creator_lp_token: self.creator_lp_token.expect("creator_lp_token is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - create_pool_fee: self.create_pool_fee.unwrap_or(solana_pubkey::pubkey!( - "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8" - )), - observation_state: self - .observation_state - .expect("observation_state is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token0_program: self.token0_program.expect("token0_program is not set"), - token1_program: self.token1_program.expect("token1_program is not set"), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = InitializeInstructionArgs { - init_amount0: self.init_amount0.clone().expect("init_amount0 is not set"), - init_amount1: self.init_amount1.clone().expect("init_amount1 is not set"), - open_time: self.open_time.clone().expect("open_time is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize` CPI accounts. -pub struct InitializeCpiAccounts<'a, 'b> { - /// Address paying to create the pool. Can be anyone - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// pool vault and lp mint authority - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// PDA account: - /// seeds = [ - /// POOL_SEED.as_bytes(), - /// amm_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// - /// Or random account: must be signed by cli - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Token_0 mint, the key must smaller than token_1 mint. - pub token0_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token_1 mint, the key must grater then token_0 mint. - pub token1_mint: &'b solana_account_info::AccountInfo<'a>, - /// pool lp mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// payer token0 account - pub creator_token0: &'b solana_account_info::AccountInfo<'a>, - /// creator token1 account - pub creator_token1: &'b solana_account_info::AccountInfo<'a>, - /// creator lp token account - pub creator_lp_token: &'b solana_account_info::AccountInfo<'a>, - - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// create pool fee account - pub create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - /// an account to store oracle observations - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token0_program: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token1_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// To create a new program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Sysvar for program account - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize` CPI instruction. -pub struct InitializeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// pool vault and lp mint authority - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// PDA account: - /// seeds = [ - /// POOL_SEED.as_bytes(), - /// amm_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// - /// Or random account: must be signed by cli - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Token_0 mint, the key must smaller than token_1 mint. - pub token0_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token_1 mint, the key must grater then token_0 mint. - pub token1_mint: &'b solana_account_info::AccountInfo<'a>, - /// pool lp mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// payer token0 account - pub creator_token0: &'b solana_account_info::AccountInfo<'a>, - /// creator token1 account - pub creator_token1: &'b solana_account_info::AccountInfo<'a>, - /// creator lp token account - pub creator_lp_token: &'b solana_account_info::AccountInfo<'a>, - - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// create pool fee account - pub create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - /// an account to store oracle observations - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token0_program: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token1_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// To create a new program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Sysvar for program account - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeInstructionArgs, -} - -impl<'a, 'b> InitializeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCpiAccounts<'a, 'b>, - args: InitializeInstructionArgs, - ) -> Self { - Self { - __program: program, - creator: accounts.creator, - amm_config: accounts.amm_config, - authority: accounts.authority, - pool_state: accounts.pool_state, - token0_mint: accounts.token0_mint, - token1_mint: accounts.token1_mint, - lp_mint: accounts.lp_mint, - creator_token0: accounts.creator_token0, - creator_token1: accounts.creator_token1, - creator_lp_token: accounts.creator_lp_token, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - create_pool_fee: accounts.create_pool_fee, - observation_state: accounts.observation_state, - token_program: accounts.token_program, - token0_program: accounts.token0_program, - token1_program: accounts.token1_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(20 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_token0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_token1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_lp_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.create_pool_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token0_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token1_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(21 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.token0_mint.clone()); - account_infos.push(self.token1_mint.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.creator_token0.clone()); - account_infos.push(self.creator_token1.clone()); - account_infos.push(self.creator_lp_token.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.create_pool_fee.clone()); - account_infos.push(self.observation_state.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token0_program.clone()); - account_infos.push(self.token1_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Initialize` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[]` amm_config -/// 2. `[]` authority -/// 3. `[writable]` pool_state -/// 4. `[]` token0_mint -/// 5. `[]` token1_mint -/// 6. `[writable]` lp_mint -/// 7. `[writable]` creator_token0 -/// 8. `[writable]` creator_token1 -/// 9. `[writable]` creator_lp_token -/// 10. `[writable]` token0_vault -/// 11. `[writable]` token1_vault -/// 12. `[writable]` create_pool_fee -/// 13. `[writable]` observation_state -/// 14. `[]` token_program -/// 15. `[]` token0_program -/// 16. `[]` token1_program -/// 17. `[]` associated_token_program -/// 18. `[]` system_program -/// 19. `[]` rent -#[derive(Clone, Debug)] -pub struct InitializeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCpiBuilderInstruction { - __program: program, - creator: None, - amm_config: None, - authority: None, - pool_state: None, - token0_mint: None, - token1_mint: None, - lp_mint: None, - creator_token0: None, - creator_token1: None, - creator_lp_token: None, - token0_vault: None, - token1_vault: None, - create_pool_fee: None, - observation_state: None, - token_program: None, - token0_program: None, - token1_program: None, - associated_token_program: None, - system_program: None, - rent: None, - init_amount0: None, - init_amount1: None, - open_time: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - /// pool vault and lp mint authority - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// PDA account: - /// seeds = [ - /// POOL_SEED.as_bytes(), - /// amm_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// - /// Or random account: must be signed by cli - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Token_0 mint, the key must smaller than token_1 mint. - #[inline(always)] - pub fn token0_mint( - &mut self, - token0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_mint = Some(token0_mint); - self - } - - /// Token_1 mint, the key must grater then token_0 mint. - #[inline(always)] - pub fn token1_mint( - &mut self, - token1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_mint = Some(token1_mint); - self - } - - /// pool lp mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// payer token0 account - #[inline(always)] - pub fn creator_token0( - &mut self, - creator_token0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_token0 = Some(creator_token0); - self - } - - /// creator token1 account - #[inline(always)] - pub fn creator_token1( - &mut self, - creator_token1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_token1 = Some(creator_token1); - self - } - - /// creator lp token account - #[inline(always)] - pub fn creator_lp_token( - &mut self, - creator_lp_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_lp_token = Some(creator_lp_token); - self - } - - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - /// create pool fee account - #[inline(always)] - pub fn create_pool_fee( - &mut self, - create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.create_pool_fee = Some(create_pool_fee); - self - } - - /// an account to store oracle observations - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token0_program( - &mut self, - token0_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_program = Some(token0_program); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token1_program( - &mut self, - token1_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_program = Some(token1_program); - self - } - - /// Program to create an ATA for receiving position NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// To create a new program account - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Sysvar for program account - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn init_amount0(&mut self, init_amount0: u64) -> &mut Self { - self.instruction.init_amount0 = Some(init_amount0); - self - } - - #[inline(always)] - pub fn init_amount1(&mut self, init_amount1: u64) -> &mut Self { - self.instruction.init_amount1 = Some(init_amount1); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.instruction.open_time = Some(open_time); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeInstructionArgs { - init_amount0: self - .instruction - .init_amount0 - .clone() - .expect("init_amount0 is not set"), - init_amount1: self - .instruction - .init_amount1 - .clone() - .expect("init_amount1 is not set"), - open_time: self - .instruction - .open_time - .clone() - .expect("open_time is not set"), - }; - let instruction = InitializeCpi { - __program: self.instruction.__program, - - creator: self.instruction.creator.expect("creator is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - token0_mint: self - .instruction - .token0_mint - .expect("token0_mint is not set"), - - token1_mint: self - .instruction - .token1_mint - .expect("token1_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - creator_token0: self - .instruction - .creator_token0 - .expect("creator_token0 is not set"), - - creator_token1: self - .instruction - .creator_token1 - .expect("creator_token1 is not set"), - - creator_lp_token: self - .instruction - .creator_lp_token - .expect("creator_lp_token is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - create_pool_fee: self - .instruction - .create_pool_fee - .expect("create_pool_fee is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token0_program: self - .instruction - .token0_program - .expect("token0_program is not set"), - - token1_program: self - .instruction - .token1_program - .expect("token1_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_token0: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_token1: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_lp_token: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - create_pool_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - init_amount0: Option, - init_amount1: Option, - open_time: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/initialize_with_permission.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/initialize_with_permission.rs deleted file mode 100644 index a629002c..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/initialize_with_permission.rs +++ /dev/null @@ -1,1288 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::CreatorFeeOn; - -pub const INITIALIZE_WITH_PERMISSION_DISCRIMINATOR: [u8; 8] = [63, 55, 254, 65, 49, 178, 89, 121]; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeWithPermission { - /// Address paying to create the pool. Can be anyone - pub payer: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - /// Which config the pool belongs to. - pub amm_config: solana_pubkey::Pubkey, - /// pool vault and lp mint authority - pub authority: solana_pubkey::Pubkey, - /// PDA account: - /// seeds = [ - /// POOL_SEED.as_bytes(), - /// amm_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// - /// Or random account: must be signed by cli - pub pool_state: solana_pubkey::Pubkey, - /// Token_0 mint, the key must smaller than token_1 mint. - pub token0_mint: solana_pubkey::Pubkey, - /// Token_1 mint, the key must grater then token_0 mint. - pub token1_mint: solana_pubkey::Pubkey, - /// pool lp mint - pub lp_mint: solana_pubkey::Pubkey, - /// payer token0 account - pub payer_token0: solana_pubkey::Pubkey, - /// payer token1 account - pub payer_token1: solana_pubkey::Pubkey, - /// payer lp token account - pub payer_lp_token: solana_pubkey::Pubkey, - - pub token0_vault: solana_pubkey::Pubkey, - - pub token1_vault: solana_pubkey::Pubkey, - /// create pool fee account - pub create_pool_fee: solana_pubkey::Pubkey, - /// an account to store oracle observations - pub observation_state: solana_pubkey::Pubkey, - - pub permission: solana_pubkey::Pubkey, - /// Program to create mint account and mint tokens - pub token_program: solana_pubkey::Pubkey, - /// Spl token program or token program 2022 - pub token0_program: solana_pubkey::Pubkey, - /// Spl token program or token program 2022 - pub token1_program: solana_pubkey::Pubkey, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: solana_pubkey::Pubkey, - /// To create a new program account - pub system_program: solana_pubkey::Pubkey, -} - -impl InitializeWithPermission { - pub fn instruction( - &self, - args: InitializeWithPermissionInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeWithPermissionInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(21 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token0, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_token1, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.payer_lp_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.create_pool_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.permission, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token0_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token1_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeWithPermissionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeWithPermissionInstructionData { - discriminator: [u8; 8], -} - -impl InitializeWithPermissionInstructionData { - pub fn new() -> Self { - Self { - discriminator: [63, 55, 254, 65, 49, 178, 89, 121], - } - } -} - -impl Default for InitializeWithPermissionInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeWithPermissionInstructionArgs { - pub init_amount0: u64, - pub init_amount1: u64, - pub open_time: u64, - pub creator_fee_on: CreatorFeeOn, -} - -/// Instruction builder for `InitializeWithPermission`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` creator -/// 2. `[]` amm_config -/// 3. `[]` authority -/// 4. `[writable]` pool_state -/// 5. `[]` token0_mint -/// 6. `[]` token1_mint -/// 7. `[writable]` lp_mint -/// 8. `[writable]` payer_token0 -/// 9. `[writable]` payer_token1 -/// 10. `[writable]` payer_lp_token -/// 11. `[writable]` token0_vault -/// 12. `[writable]` token1_vault -/// 13. `[writable, optional]` create_pool_fee (default to `DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8`) -/// 14. `[writable]` observation_state -/// 15. `[]` permission -/// 16. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 17. `[]` token0_program -/// 18. `[]` token1_program -/// 19. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 20. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeWithPermissionBuilder { - payer: Option, - creator: Option, - amm_config: Option, - authority: Option, - pool_state: Option, - token0_mint: Option, - token1_mint: Option, - lp_mint: Option, - payer_token0: Option, - payer_token1: Option, - payer_lp_token: Option, - token0_vault: Option, - token1_vault: Option, - create_pool_fee: Option, - observation_state: Option, - permission: Option, - token_program: Option, - token0_program: Option, - token1_program: Option, - associated_token_program: Option, - system_program: Option, - init_amount0: Option, - init_amount1: Option, - open_time: Option, - creator_fee_on: Option, - __remaining_accounts: Vec, -} - -impl InitializeWithPermissionBuilder { - pub fn new() -> Self { Self::default() } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - /// pool vault and lp mint authority - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// PDA account: - /// seeds = [ - /// POOL_SEED.as_bytes(), - /// amm_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// - /// Or random account: must be signed by cli - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Token_0 mint, the key must smaller than token_1 mint. - #[inline(always)] - pub fn token0_mint(&mut self, token0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token0_mint = Some(token0_mint); - self - } - - /// Token_1 mint, the key must grater then token_0 mint. - #[inline(always)] - pub fn token1_mint(&mut self, token1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token1_mint = Some(token1_mint); - self - } - - /// pool lp mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// payer token0 account - #[inline(always)] - pub fn payer_token0(&mut self, payer_token0: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token0 = Some(payer_token0); - self - } - - /// payer token1 account - #[inline(always)] - pub fn payer_token1(&mut self, payer_token1: solana_pubkey::Pubkey) -> &mut Self { - self.payer_token1 = Some(payer_token1); - self - } - - /// payer lp token account - #[inline(always)] - pub fn payer_lp_token(&mut self, payer_lp_token: solana_pubkey::Pubkey) -> &mut Self { - self.payer_lp_token = Some(payer_lp_token); - self - } - - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - /// `[optional account, default to 'DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8']` - /// create pool fee account - #[inline(always)] - pub fn create_pool_fee(&mut self, create_pool_fee: solana_pubkey::Pubkey) -> &mut Self { - self.create_pool_fee = Some(create_pool_fee); - self - } - - /// an account to store oracle observations - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn permission(&mut self, permission: solana_pubkey::Pubkey) -> &mut Self { - self.permission = Some(permission); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token0_program(&mut self, token0_program: solana_pubkey::Pubkey) -> &mut Self { - self.token0_program = Some(token0_program); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token1_program(&mut self, token1_program: solana_pubkey::Pubkey) -> &mut Self { - self.token1_program = Some(token1_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Program to create an ATA for receiving position NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// To create a new program account - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn init_amount0(&mut self, init_amount0: u64) -> &mut Self { - self.init_amount0 = Some(init_amount0); - self - } - - #[inline(always)] - pub fn init_amount1(&mut self, init_amount1: u64) -> &mut Self { - self.init_amount1 = Some(init_amount1); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.open_time = Some(open_time); - self - } - - #[inline(always)] - pub fn creator_fee_on(&mut self, creator_fee_on: CreatorFeeOn) -> &mut Self { - self.creator_fee_on = Some(creator_fee_on); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeWithPermission { - payer: self.payer.expect("payer is not set"), - creator: self.creator.expect("creator is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - token0_mint: self.token0_mint.expect("token0_mint is not set"), - token1_mint: self.token1_mint.expect("token1_mint is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - payer_token0: self.payer_token0.expect("payer_token0 is not set"), - payer_token1: self.payer_token1.expect("payer_token1 is not set"), - payer_lp_token: self.payer_lp_token.expect("payer_lp_token is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - create_pool_fee: self.create_pool_fee.unwrap_or(solana_pubkey::pubkey!( - "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8" - )), - observation_state: self - .observation_state - .expect("observation_state is not set"), - permission: self.permission.expect("permission is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token0_program: self.token0_program.expect("token0_program is not set"), - token1_program: self.token1_program.expect("token1_program is not set"), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = InitializeWithPermissionInstructionArgs { - init_amount0: self.init_amount0.clone().expect("init_amount0 is not set"), - init_amount1: self.init_amount1.clone().expect("init_amount1 is not set"), - open_time: self.open_time.clone().expect("open_time is not set"), - creator_fee_on: self - .creator_fee_on - .clone() - .expect("creator_fee_on is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_with_permission` CPI accounts. -pub struct InitializeWithPermissionCpiAccounts<'a, 'b> { - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// pool vault and lp mint authority - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// PDA account: - /// seeds = [ - /// POOL_SEED.as_bytes(), - /// amm_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// - /// Or random account: must be signed by cli - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Token_0 mint, the key must smaller than token_1 mint. - pub token0_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token_1 mint, the key must grater then token_0 mint. - pub token1_mint: &'b solana_account_info::AccountInfo<'a>, - /// pool lp mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// payer token0 account - pub payer_token0: &'b solana_account_info::AccountInfo<'a>, - /// payer token1 account - pub payer_token1: &'b solana_account_info::AccountInfo<'a>, - /// payer lp token account - pub payer_lp_token: &'b solana_account_info::AccountInfo<'a>, - - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// create pool fee account - pub create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - /// an account to store oracle observations - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub permission: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token0_program: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token1_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// To create a new program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_with_permission` CPI instruction. -pub struct InitializeWithPermissionCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Address paying to create the pool. Can be anyone - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Which config the pool belongs to. - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// pool vault and lp mint authority - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// PDA account: - /// seeds = [ - /// POOL_SEED.as_bytes(), - /// amm_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// - /// Or random account: must be signed by cli - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Token_0 mint, the key must smaller than token_1 mint. - pub token0_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token_1 mint, the key must grater then token_0 mint. - pub token1_mint: &'b solana_account_info::AccountInfo<'a>, - /// pool lp mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// payer token0 account - pub payer_token0: &'b solana_account_info::AccountInfo<'a>, - /// payer token1 account - pub payer_token1: &'b solana_account_info::AccountInfo<'a>, - /// payer lp token account - pub payer_lp_token: &'b solana_account_info::AccountInfo<'a>, - - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// create pool fee account - pub create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - /// an account to store oracle observations - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - - pub permission: &'b solana_account_info::AccountInfo<'a>, - /// Program to create mint account and mint tokens - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token0_program: &'b solana_account_info::AccountInfo<'a>, - /// Spl token program or token program 2022 - pub token1_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving position NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// To create a new program account - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeWithPermissionInstructionArgs, -} - -impl<'a, 'b> InitializeWithPermissionCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeWithPermissionCpiAccounts<'a, 'b>, - args: InitializeWithPermissionInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - creator: accounts.creator, - amm_config: accounts.amm_config, - authority: accounts.authority, - pool_state: accounts.pool_state, - token0_mint: accounts.token0_mint, - token1_mint: accounts.token1_mint, - lp_mint: accounts.lp_mint, - payer_token0: accounts.payer_token0, - payer_token1: accounts.payer_token1, - payer_lp_token: accounts.payer_lp_token, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - create_pool_fee: accounts.create_pool_fee, - observation_state: accounts.observation_state, - permission: accounts.permission, - token_program: accounts.token_program, - token0_program: accounts.token0_program, - token1_program: accounts.token1_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(21 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token0.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_token1.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.payer_lp_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.create_pool_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.permission.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token0_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token1_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeWithPermissionInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(22 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.token0_mint.clone()); - account_infos.push(self.token1_mint.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.payer_token0.clone()); - account_infos.push(self.payer_token1.clone()); - account_infos.push(self.payer_lp_token.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.create_pool_fee.clone()); - account_infos.push(self.observation_state.clone()); - account_infos.push(self.permission.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token0_program.clone()); - account_infos.push(self.token1_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeWithPermission` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` creator -/// 2. `[]` amm_config -/// 3. `[]` authority -/// 4. `[writable]` pool_state -/// 5. `[]` token0_mint -/// 6. `[]` token1_mint -/// 7. `[writable]` lp_mint -/// 8. `[writable]` payer_token0 -/// 9. `[writable]` payer_token1 -/// 10. `[writable]` payer_lp_token -/// 11. `[writable]` token0_vault -/// 12. `[writable]` token1_vault -/// 13. `[writable]` create_pool_fee -/// 14. `[writable]` observation_state -/// 15. `[]` permission -/// 16. `[]` token_program -/// 17. `[]` token0_program -/// 18. `[]` token1_program -/// 19. `[]` associated_token_program -/// 20. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeWithPermissionCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeWithPermissionCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeWithPermissionCpiBuilderInstruction { - __program: program, - payer: None, - creator: None, - amm_config: None, - authority: None, - pool_state: None, - token0_mint: None, - token1_mint: None, - lp_mint: None, - payer_token0: None, - payer_token1: None, - payer_lp_token: None, - token0_vault: None, - token1_vault: None, - create_pool_fee: None, - observation_state: None, - permission: None, - token_program: None, - token0_program: None, - token1_program: None, - associated_token_program: None, - system_program: None, - init_amount0: None, - init_amount1: None, - open_time: None, - creator_fee_on: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Address paying to create the pool. Can be anyone - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Which config the pool belongs to. - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - /// pool vault and lp mint authority - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// PDA account: - /// seeds = [ - /// POOL_SEED.as_bytes(), - /// amm_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// - /// Or random account: must be signed by cli - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Token_0 mint, the key must smaller than token_1 mint. - #[inline(always)] - pub fn token0_mint( - &mut self, - token0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_mint = Some(token0_mint); - self - } - - /// Token_1 mint, the key must grater then token_0 mint. - #[inline(always)] - pub fn token1_mint( - &mut self, - token1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_mint = Some(token1_mint); - self - } - - /// pool lp mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// payer token0 account - #[inline(always)] - pub fn payer_token0( - &mut self, - payer_token0: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token0 = Some(payer_token0); - self - } - - /// payer token1 account - #[inline(always)] - pub fn payer_token1( - &mut self, - payer_token1: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_token1 = Some(payer_token1); - self - } - - /// payer lp token account - #[inline(always)] - pub fn payer_lp_token( - &mut self, - payer_lp_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.payer_lp_token = Some(payer_lp_token); - self - } - - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - /// create pool fee account - #[inline(always)] - pub fn create_pool_fee( - &mut self, - create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.create_pool_fee = Some(create_pool_fee); - self - } - - /// an account to store oracle observations - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn permission( - &mut self, - permission: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.permission = Some(permission); - self - } - - /// Program to create mint account and mint tokens - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token0_program( - &mut self, - token0_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_program = Some(token0_program); - self - } - - /// Spl token program or token program 2022 - #[inline(always)] - pub fn token1_program( - &mut self, - token1_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_program = Some(token1_program); - self - } - - /// Program to create an ATA for receiving position NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// To create a new program account - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn init_amount0(&mut self, init_amount0: u64) -> &mut Self { - self.instruction.init_amount0 = Some(init_amount0); - self - } - - #[inline(always)] - pub fn init_amount1(&mut self, init_amount1: u64) -> &mut Self { - self.instruction.init_amount1 = Some(init_amount1); - self - } - - #[inline(always)] - pub fn open_time(&mut self, open_time: u64) -> &mut Self { - self.instruction.open_time = Some(open_time); - self - } - - #[inline(always)] - pub fn creator_fee_on(&mut self, creator_fee_on: CreatorFeeOn) -> &mut Self { - self.instruction.creator_fee_on = Some(creator_fee_on); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeWithPermissionInstructionArgs { - init_amount0: self - .instruction - .init_amount0 - .clone() - .expect("init_amount0 is not set"), - init_amount1: self - .instruction - .init_amount1 - .clone() - .expect("init_amount1 is not set"), - open_time: self - .instruction - .open_time - .clone() - .expect("open_time is not set"), - creator_fee_on: self - .instruction - .creator_fee_on - .clone() - .expect("creator_fee_on is not set"), - }; - let instruction = InitializeWithPermissionCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - token0_mint: self - .instruction - .token0_mint - .expect("token0_mint is not set"), - - token1_mint: self - .instruction - .token1_mint - .expect("token1_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - payer_token0: self - .instruction - .payer_token0 - .expect("payer_token0 is not set"), - - payer_token1: self - .instruction - .payer_token1 - .expect("payer_token1 is not set"), - - payer_lp_token: self - .instruction - .payer_lp_token - .expect("payer_lp_token is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - create_pool_fee: self - .instruction - .create_pool_fee - .expect("create_pool_fee is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - - permission: self.instruction.permission.expect("permission is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token0_program: self - .instruction - .token0_program - .expect("token0_program is not set"), - - token1_program: self - .instruction - .token1_program - .expect("token1_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeWithPermissionCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token0: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_token1: Option<&'b solana_account_info::AccountInfo<'a>>, - payer_lp_token: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - create_pool_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - permission: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - init_amount0: Option, - init_amount1: Option, - open_time: Option, - creator_fee_on: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/mod.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index 84c03309..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#close_permission_pda; -pub(crate) mod r#collect_creator_fee; -pub(crate) mod r#collect_fund_fee; -pub(crate) mod r#collect_protocol_fee; -pub(crate) mod r#create_amm_config; -pub(crate) mod r#create_permission_pda; -pub(crate) mod r#deposit; -pub(crate) mod r#initialize; -pub(crate) mod r#initialize_with_permission; -pub(crate) mod r#swap_base_input; -pub(crate) mod r#swap_base_output; -pub(crate) mod r#update_amm_config; -pub(crate) mod r#update_pool_status; -pub(crate) mod r#withdraw; - -pub use self::{ - r#close_permission_pda::*, r#collect_creator_fee::*, r#collect_fund_fee::*, - r#collect_protocol_fee::*, r#create_amm_config::*, r#create_permission_pda::*, r#deposit::*, - r#initialize::*, r#initialize_with_permission::*, r#swap_base_input::*, r#swap_base_output::*, - r#update_amm_config::*, r#update_pool_status::*, r#withdraw::*, -}; diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/swap_base_input.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/swap_base_input.rs deleted file mode 100644 index b2c89bb9..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/swap_base_input.rs +++ /dev/null @@ -1,880 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const SWAP_BASE_INPUT_DISCRIMINATOR: [u8; 8] = [143, 190, 90, 218, 196, 30, 51, 222]; - -/// Accounts. -#[derive(Debug)] -pub struct SwapBaseInput { - /// The user performing the swap - pub payer: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - /// The factory state to read protocol fees - pub amm_config: solana_pubkey::Pubkey, - /// The program account of the pool in which the swap will be performed - pub pool_state: solana_pubkey::Pubkey, - /// The user token account for input token - pub input_token_account: solana_pubkey::Pubkey, - /// The user token account for output token - pub output_token_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub input_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub output_vault: solana_pubkey::Pubkey, - /// SPL program for input token transfers - pub input_token_program: solana_pubkey::Pubkey, - /// SPL program for output token transfers - pub output_token_program: solana_pubkey::Pubkey, - /// The mint of input token - pub input_token_mint: solana_pubkey::Pubkey, - /// The mint of output token - pub output_token_mint: solana_pubkey::Pubkey, - /// The program account for the most recent oracle observation - pub observation_state: solana_pubkey::Pubkey, -} - -impl SwapBaseInput { - pub fn instruction( - &self, - args: SwapBaseInputInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapBaseInputInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.input_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapBaseInputInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapBaseInputInstructionData { - discriminator: [u8; 8], -} - -impl SwapBaseInputInstructionData { - pub fn new() -> Self { - Self { - discriminator: [143, 190, 90, 218, 196, 30, 51, 222], - } - } -} - -impl Default for SwapBaseInputInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapBaseInputInstructionArgs { - pub amount_in: u64, - pub minimum_amount_out: u64, -} - -/// Instruction builder for `SwapBaseInput`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` amm_config -/// 3. `[writable]` pool_state -/// 4. `[writable]` input_token_account -/// 5. `[writable]` output_token_account -/// 6. `[writable]` input_vault -/// 7. `[writable]` output_vault -/// 8. `[]` input_token_program -/// 9. `[]` output_token_program -/// 10. `[]` input_token_mint -/// 11. `[]` output_token_mint -/// 12. `[writable]` observation_state -#[derive(Clone, Debug, Default)] -pub struct SwapBaseInputBuilder { - payer: Option, - authority: Option, - amm_config: Option, - pool_state: Option, - input_token_account: Option, - output_token_account: Option, - input_vault: Option, - output_vault: Option, - input_token_program: Option, - output_token_program: Option, - input_token_mint: Option, - output_token_mint: Option, - observation_state: Option, - amount_in: Option, - minimum_amount_out: Option, - __remaining_accounts: Vec, -} - -impl SwapBaseInputBuilder { - pub fn new() -> Self { Self::default() } - - /// The user performing the swap - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// The factory state to read protocol fees - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - /// The program account of the pool in which the swap will be performed - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The user token account for input token - #[inline(always)] - pub fn input_token_account(&mut self, input_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_account = Some(input_token_account); - self - } - - /// The user token account for output token - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_account = Some(output_token_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn output_vault(&mut self, output_vault: solana_pubkey::Pubkey) -> &mut Self { - self.output_vault = Some(output_vault); - self - } - - /// SPL program for input token transfers - #[inline(always)] - pub fn input_token_program(&mut self, input_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_program = Some(input_token_program); - self - } - - /// SPL program for output token transfers - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_program = Some(output_token_program); - self - } - - /// The mint of input token - #[inline(always)] - pub fn input_token_mint(&mut self, input_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_mint = Some(input_token_mint); - self - } - - /// The mint of output token - #[inline(always)] - pub fn output_token_mint(&mut self, output_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_token_mint = Some(output_token_mint); - self - } - - /// The program account for the most recent oracle observation - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.minimum_amount_out = Some(minimum_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapBaseInput { - payer: self.payer.expect("payer is not set"), - authority: self.authority.expect("authority is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - input_token_account: self - .input_token_account - .expect("input_token_account is not set"), - output_token_account: self - .output_token_account - .expect("output_token_account is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - output_vault: self.output_vault.expect("output_vault is not set"), - input_token_program: self - .input_token_program - .expect("input_token_program is not set"), - output_token_program: self - .output_token_program - .expect("output_token_program is not set"), - input_token_mint: self.input_token_mint.expect("input_token_mint is not set"), - output_token_mint: self - .output_token_mint - .expect("output_token_mint is not set"), - observation_state: self - .observation_state - .expect("observation_state is not set"), - }; - let args = SwapBaseInputInstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - minimum_amount_out: self - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_base_input` CPI accounts. -pub struct SwapBaseInputCpiAccounts<'a, 'b> { - /// The user performing the swap - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// The factory state to read protocol fees - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The program account of the pool in which the swap will be performed - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for input token - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for output token - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for output token transfers - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - /// The mint of input token - pub input_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of output token - pub output_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The program account for the most recent oracle observation - pub observation_state: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_base_input` CPI instruction. -pub struct SwapBaseInputCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// The factory state to read protocol fees - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The program account of the pool in which the swap will be performed - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for input token - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for output token - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for output token transfers - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - /// The mint of input token - pub input_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of output token - pub output_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The program account for the most recent oracle observation - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapBaseInputInstructionArgs, -} - -impl<'a, 'b> SwapBaseInputCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapBaseInputCpiAccounts<'a, 'b>, - args: SwapBaseInputInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - authority: accounts.authority, - amm_config: accounts.amm_config, - pool_state: accounts.pool_state, - input_token_account: accounts.input_token_account, - output_token_account: accounts.output_token_account, - input_vault: accounts.input_vault, - output_vault: accounts.output_vault, - input_token_program: accounts.input_token_program, - output_token_program: accounts.output_token_program, - input_token_mint: accounts.input_token_mint, - output_token_mint: accounts.output_token_mint, - observation_state: accounts.observation_state, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapBaseInputInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.input_token_account.clone()); - account_infos.push(self.output_token_account.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.output_vault.clone()); - account_infos.push(self.input_token_program.clone()); - account_infos.push(self.output_token_program.clone()); - account_infos.push(self.input_token_mint.clone()); - account_infos.push(self.output_token_mint.clone()); - account_infos.push(self.observation_state.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapBaseInput` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` amm_config -/// 3. `[writable]` pool_state -/// 4. `[writable]` input_token_account -/// 5. `[writable]` output_token_account -/// 6. `[writable]` input_vault -/// 7. `[writable]` output_vault -/// 8. `[]` input_token_program -/// 9. `[]` output_token_program -/// 10. `[]` input_token_mint -/// 11. `[]` output_token_mint -/// 12. `[writable]` observation_state -#[derive(Clone, Debug)] -pub struct SwapBaseInputCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapBaseInputCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapBaseInputCpiBuilderInstruction { - __program: program, - payer: None, - authority: None, - amm_config: None, - pool_state: None, - input_token_account: None, - output_token_account: None, - input_vault: None, - output_vault: None, - input_token_program: None, - output_token_program: None, - input_token_mint: None, - output_token_mint: None, - observation_state: None, - amount_in: None, - minimum_amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The user performing the swap - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// The factory state to read protocol fees - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - /// The program account of the pool in which the swap will be performed - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The user token account for input token - #[inline(always)] - pub fn input_token_account( - &mut self, - input_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_account = Some(input_token_account); - self - } - - /// The user token account for output token - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_account = Some(output_token_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn output_vault( - &mut self, - output_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_vault = Some(output_vault); - self - } - - /// SPL program for input token transfers - #[inline(always)] - pub fn input_token_program( - &mut self, - input_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_program = Some(input_token_program); - self - } - - /// SPL program for output token transfers - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_program = Some(output_token_program); - self - } - - /// The mint of input token - #[inline(always)] - pub fn input_token_mint( - &mut self, - input_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_mint = Some(input_token_mint); - self - } - - /// The mint of output token - #[inline(always)] - pub fn output_token_mint( - &mut self, - output_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_mint = Some(output_token_mint); - self - } - - /// The program account for the most recent oracle observation - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.instruction.minimum_amount_out = Some(minimum_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapBaseInputInstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - minimum_amount_out: self - .instruction - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - }; - let instruction = SwapBaseInputCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - input_token_account: self - .instruction - .input_token_account - .expect("input_token_account is not set"), - - output_token_account: self - .instruction - .output_token_account - .expect("output_token_account is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - output_vault: self - .instruction - .output_vault - .expect("output_vault is not set"), - - input_token_program: self - .instruction - .input_token_program - .expect("input_token_program is not set"), - - output_token_program: self - .instruction - .output_token_program - .expect("output_token_program is not set"), - - input_token_mint: self - .instruction - .input_token_mint - .expect("input_token_mint is not set"), - - output_token_mint: self - .instruction - .output_token_mint - .expect("output_token_mint is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapBaseInputCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - output_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - minimum_amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/swap_base_output.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/swap_base_output.rs deleted file mode 100644 index 3a3afbe7..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/swap_base_output.rs +++ /dev/null @@ -1,880 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const SWAP_BASE_OUTPUT_DISCRIMINATOR: [u8; 8] = [55, 217, 98, 86, 163, 74, 180, 173]; - -/// Accounts. -#[derive(Debug)] -pub struct SwapBaseOutput { - /// The user performing the swap - pub payer: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - /// The factory state to read protocol fees - pub amm_config: solana_pubkey::Pubkey, - /// The program account of the pool in which the swap will be performed - pub pool_state: solana_pubkey::Pubkey, - /// The user token account for input token - pub input_token_account: solana_pubkey::Pubkey, - /// The user token account for output token - pub output_token_account: solana_pubkey::Pubkey, - /// The vault token account for input token - pub input_vault: solana_pubkey::Pubkey, - /// The vault token account for output token - pub output_vault: solana_pubkey::Pubkey, - /// SPL program for input token transfers - pub input_token_program: solana_pubkey::Pubkey, - /// SPL program for output token transfers - pub output_token_program: solana_pubkey::Pubkey, - /// The mint of input token - pub input_token_mint: solana_pubkey::Pubkey, - /// The mint of output token - pub output_token_mint: solana_pubkey::Pubkey, - /// The program account for the most recent oracle observation - pub observation_state: solana_pubkey::Pubkey, -} - -impl SwapBaseOutput { - pub fn instruction( - &self, - args: SwapBaseOutputInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SwapBaseOutputInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.input_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.input_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.output_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.input_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.output_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.observation_state, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SwapBaseOutputInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapBaseOutputInstructionData { - discriminator: [u8; 8], -} - -impl SwapBaseOutputInstructionData { - pub fn new() -> Self { - Self { - discriminator: [55, 217, 98, 86, 163, 74, 180, 173], - } - } -} - -impl Default for SwapBaseOutputInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapBaseOutputInstructionArgs { - pub max_amount_in: u64, - pub amount_out: u64, -} - -/// Instruction builder for `SwapBaseOutput`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` amm_config -/// 3. `[writable]` pool_state -/// 4. `[writable]` input_token_account -/// 5. `[writable]` output_token_account -/// 6. `[writable]` input_vault -/// 7. `[writable]` output_vault -/// 8. `[]` input_token_program -/// 9. `[]` output_token_program -/// 10. `[]` input_token_mint -/// 11. `[]` output_token_mint -/// 12. `[writable]` observation_state -#[derive(Clone, Debug, Default)] -pub struct SwapBaseOutputBuilder { - payer: Option, - authority: Option, - amm_config: Option, - pool_state: Option, - input_token_account: Option, - output_token_account: Option, - input_vault: Option, - output_vault: Option, - input_token_program: Option, - output_token_program: Option, - input_token_mint: Option, - output_token_mint: Option, - observation_state: Option, - max_amount_in: Option, - amount_out: Option, - __remaining_accounts: Vec, -} - -impl SwapBaseOutputBuilder { - pub fn new() -> Self { Self::default() } - - /// The user performing the swap - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// The factory state to read protocol fees - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - /// The program account of the pool in which the swap will be performed - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The user token account for input token - #[inline(always)] - pub fn input_token_account(&mut self, input_token_account: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_account = Some(input_token_account); - self - } - - /// The user token account for output token - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_account = Some(output_token_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn input_vault(&mut self, input_vault: solana_pubkey::Pubkey) -> &mut Self { - self.input_vault = Some(input_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn output_vault(&mut self, output_vault: solana_pubkey::Pubkey) -> &mut Self { - self.output_vault = Some(output_vault); - self - } - - /// SPL program for input token transfers - #[inline(always)] - pub fn input_token_program(&mut self, input_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_program = Some(input_token_program); - self - } - - /// SPL program for output token transfers - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.output_token_program = Some(output_token_program); - self - } - - /// The mint of input token - #[inline(always)] - pub fn input_token_mint(&mut self, input_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.input_token_mint = Some(input_token_mint); - self - } - - /// The mint of output token - #[inline(always)] - pub fn output_token_mint(&mut self, output_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.output_token_mint = Some(output_token_mint); - self - } - - /// The program account for the most recent oracle observation - #[inline(always)] - pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self { - self.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn max_amount_in(&mut self, max_amount_in: u64) -> &mut Self { - self.max_amount_in = Some(max_amount_in); - self - } - - #[inline(always)] - pub fn amount_out(&mut self, amount_out: u64) -> &mut Self { - self.amount_out = Some(amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SwapBaseOutput { - payer: self.payer.expect("payer is not set"), - authority: self.authority.expect("authority is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - input_token_account: self - .input_token_account - .expect("input_token_account is not set"), - output_token_account: self - .output_token_account - .expect("output_token_account is not set"), - input_vault: self.input_vault.expect("input_vault is not set"), - output_vault: self.output_vault.expect("output_vault is not set"), - input_token_program: self - .input_token_program - .expect("input_token_program is not set"), - output_token_program: self - .output_token_program - .expect("output_token_program is not set"), - input_token_mint: self.input_token_mint.expect("input_token_mint is not set"), - output_token_mint: self - .output_token_mint - .expect("output_token_mint is not set"), - observation_state: self - .observation_state - .expect("observation_state is not set"), - }; - let args = SwapBaseOutputInstructionArgs { - max_amount_in: self - .max_amount_in - .clone() - .expect("max_amount_in is not set"), - amount_out: self.amount_out.clone().expect("amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `swap_base_output` CPI accounts. -pub struct SwapBaseOutputCpiAccounts<'a, 'b> { - /// The user performing the swap - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// The factory state to read protocol fees - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The program account of the pool in which the swap will be performed - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for input token - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for output token - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for output token transfers - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - /// The mint of input token - pub input_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of output token - pub output_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The program account for the most recent oracle observation - pub observation_state: &'b solana_account_info::AccountInfo<'a>, -} - -/// `swap_base_output` CPI instruction. -pub struct SwapBaseOutputCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// The factory state to read protocol fees - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The program account of the pool in which the swap will be performed - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for input token - pub input_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The user token account for output token - pub output_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for input token - pub input_vault: &'b solana_account_info::AccountInfo<'a>, - /// The vault token account for output token - pub output_vault: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub input_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for output token transfers - pub output_token_program: &'b solana_account_info::AccountInfo<'a>, - /// The mint of input token - pub input_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of output token - pub output_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The program account for the most recent oracle observation - pub observation_state: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SwapBaseOutputInstructionArgs, -} - -impl<'a, 'b> SwapBaseOutputCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SwapBaseOutputCpiAccounts<'a, 'b>, - args: SwapBaseOutputInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - authority: accounts.authority, - amm_config: accounts.amm_config, - pool_state: accounts.pool_state, - input_token_account: accounts.input_token_account, - output_token_account: accounts.output_token_account, - input_vault: accounts.input_vault, - output_vault: accounts.output_vault, - input_token_program: accounts.input_token_program, - output_token_program: accounts.output_token_program, - input_token_mint: accounts.input_token_mint, - output_token_mint: accounts.output_token_mint, - observation_state: accounts.observation_state, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.input_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.output_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.input_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.output_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.observation_state.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SwapBaseOutputInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(14 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.input_token_account.clone()); - account_infos.push(self.output_token_account.clone()); - account_infos.push(self.input_vault.clone()); - account_infos.push(self.output_vault.clone()); - account_infos.push(self.input_token_program.clone()); - account_infos.push(self.output_token_program.clone()); - account_infos.push(self.input_token_mint.clone()); - account_infos.push(self.output_token_mint.clone()); - account_infos.push(self.observation_state.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SwapBaseOutput` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` amm_config -/// 3. `[writable]` pool_state -/// 4. `[writable]` input_token_account -/// 5. `[writable]` output_token_account -/// 6. `[writable]` input_vault -/// 7. `[writable]` output_vault -/// 8. `[]` input_token_program -/// 9. `[]` output_token_program -/// 10. `[]` input_token_mint -/// 11. `[]` output_token_mint -/// 12. `[writable]` observation_state -#[derive(Clone, Debug)] -pub struct SwapBaseOutputCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SwapBaseOutputCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SwapBaseOutputCpiBuilderInstruction { - __program: program, - payer: None, - authority: None, - amm_config: None, - pool_state: None, - input_token_account: None, - output_token_account: None, - input_vault: None, - output_vault: None, - input_token_program: None, - output_token_program: None, - input_token_mint: None, - output_token_mint: None, - observation_state: None, - max_amount_in: None, - amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The user performing the swap - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// The factory state to read protocol fees - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - /// The program account of the pool in which the swap will be performed - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The user token account for input token - #[inline(always)] - pub fn input_token_account( - &mut self, - input_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_account = Some(input_token_account); - self - } - - /// The user token account for output token - #[inline(always)] - pub fn output_token_account( - &mut self, - output_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_account = Some(output_token_account); - self - } - - /// The vault token account for input token - #[inline(always)] - pub fn input_vault( - &mut self, - input_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_vault = Some(input_vault); - self - } - - /// The vault token account for output token - #[inline(always)] - pub fn output_vault( - &mut self, - output_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_vault = Some(output_vault); - self - } - - /// SPL program for input token transfers - #[inline(always)] - pub fn input_token_program( - &mut self, - input_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_program = Some(input_token_program); - self - } - - /// SPL program for output token transfers - #[inline(always)] - pub fn output_token_program( - &mut self, - output_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_program = Some(output_token_program); - self - } - - /// The mint of input token - #[inline(always)] - pub fn input_token_mint( - &mut self, - input_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.input_token_mint = Some(input_token_mint); - self - } - - /// The mint of output token - #[inline(always)] - pub fn output_token_mint( - &mut self, - output_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.output_token_mint = Some(output_token_mint); - self - } - - /// The program account for the most recent oracle observation - #[inline(always)] - pub fn observation_state( - &mut self, - observation_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.observation_state = Some(observation_state); - self - } - - #[inline(always)] - pub fn max_amount_in(&mut self, max_amount_in: u64) -> &mut Self { - self.instruction.max_amount_in = Some(max_amount_in); - self - } - - #[inline(always)] - pub fn amount_out(&mut self, amount_out: u64) -> &mut Self { - self.instruction.amount_out = Some(amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SwapBaseOutputInstructionArgs { - max_amount_in: self - .instruction - .max_amount_in - .clone() - .expect("max_amount_in is not set"), - amount_out: self - .instruction - .amount_out - .clone() - .expect("amount_out is not set"), - }; - let instruction = SwapBaseOutputCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - input_token_account: self - .instruction - .input_token_account - .expect("input_token_account is not set"), - - output_token_account: self - .instruction - .output_token_account - .expect("output_token_account is not set"), - - input_vault: self - .instruction - .input_vault - .expect("input_vault is not set"), - - output_vault: self - .instruction - .output_vault - .expect("output_vault is not set"), - - input_token_program: self - .instruction - .input_token_program - .expect("input_token_program is not set"), - - output_token_program: self - .instruction - .output_token_program - .expect("output_token_program is not set"), - - input_token_mint: self - .instruction - .input_token_mint - .expect("input_token_mint is not set"), - - output_token_mint: self - .instruction - .output_token_mint - .expect("output_token_mint is not set"), - - observation_state: self - .instruction - .observation_state - .expect("observation_state is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SwapBaseOutputCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - input_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - output_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - input_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - output_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - observation_state: Option<&'b solana_account_info::AccountInfo<'a>>, - max_amount_in: Option, - amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/update_amm_config.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/update_amm_config.rs deleted file mode 100644 index b72a9c58..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/update_amm_config.rs +++ /dev/null @@ -1,381 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const UPDATE_AMM_CONFIG_DISCRIMINATOR: [u8; 8] = [49, 60, 174, 136, 154, 28, 116, 200]; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateAmmConfig { - /// The amm config owner or admin - pub owner: solana_pubkey::Pubkey, - /// Amm config account to be changed - pub amm_config: solana_pubkey::Pubkey, -} - -impl UpdateAmmConfig { - pub fn instruction( - &self, - args: UpdateAmmConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateAmmConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm_config, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateAmmConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateAmmConfigInstructionData { - discriminator: [u8; 8], -} - -impl UpdateAmmConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [49, 60, 174, 136, 154, 28, 116, 200], - } - } -} - -impl Default for UpdateAmmConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateAmmConfigInstructionArgs { - pub param: u8, - pub value: u64, -} - -/// Instruction builder for `UpdateAmmConfig`. -/// -/// ### Accounts: -/// -/// 0. `[signer, optional]` owner (default to `GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ`) -/// 1. `[writable]` amm_config -#[derive(Clone, Debug, Default)] -pub struct UpdateAmmConfigBuilder { - owner: Option, - amm_config: Option, - param: Option, - value: Option, - __remaining_accounts: Vec, -} - -impl UpdateAmmConfigBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ']` - /// The amm config owner or admin - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Amm config account to be changed - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.param = Some(param); - self - } - - #[inline(always)] - pub fn value(&mut self, value: u64) -> &mut Self { - self.value = Some(value); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateAmmConfig { - owner: self.owner.unwrap_or(solana_pubkey::pubkey!( - "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - )), - amm_config: self.amm_config.expect("amm_config is not set"), - }; - let args = UpdateAmmConfigInstructionArgs { - param: self.param.clone().expect("param is not set"), - value: self.value.clone().expect("value is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_amm_config` CPI accounts. -pub struct UpdateAmmConfigCpiAccounts<'a, 'b> { - /// The amm config owner or admin - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Amm config account to be changed - pub amm_config: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_amm_config` CPI instruction. -pub struct UpdateAmmConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The amm config owner or admin - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Amm config account to be changed - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateAmmConfigInstructionArgs, -} - -impl<'a, 'b> UpdateAmmConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateAmmConfigCpiAccounts<'a, 'b>, - args: UpdateAmmConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - amm_config: accounts.amm_config, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_config.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateAmmConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.amm_config.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateAmmConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[writable]` amm_config -#[derive(Clone, Debug)] -pub struct UpdateAmmConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateAmmConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateAmmConfigCpiBuilderInstruction { - __program: program, - owner: None, - amm_config: None, - param: None, - value: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The amm config owner or admin - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Amm config account to be changed - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.instruction.param = Some(param); - self - } - - #[inline(always)] - pub fn value(&mut self, value: u64) -> &mut Self { - self.instruction.value = Some(value); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateAmmConfigInstructionArgs { - param: self.instruction.param.clone().expect("param is not set"), - value: self.instruction.value.clone().expect("value is not set"), - }; - let instruction = UpdateAmmConfigCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateAmmConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - param: Option, - value: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/update_pool_status.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/update_pool_status.rs deleted file mode 100644 index 01d40333..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/update_pool_status.rs +++ /dev/null @@ -1,358 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const UPDATE_POOL_STATUS_DISCRIMINATOR: [u8; 8] = [130, 87, 108, 6, 46, 224, 117, 123]; - -/// Accounts. -#[derive(Debug)] -pub struct UpdatePoolStatus { - pub authority: solana_pubkey::Pubkey, - - pub pool_state: solana_pubkey::Pubkey, -} - -impl UpdatePoolStatus { - pub fn instruction( - &self, - args: UpdatePoolStatusInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdatePoolStatusInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdatePoolStatusInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePoolStatusInstructionData { - discriminator: [u8; 8], -} - -impl UpdatePoolStatusInstructionData { - pub fn new() -> Self { - Self { - discriminator: [130, 87, 108, 6, 46, 224, 117, 123], - } - } -} - -impl Default for UpdatePoolStatusInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePoolStatusInstructionArgs { - pub status: u8, -} - -/// Instruction builder for `UpdatePoolStatus`. -/// -/// ### Accounts: -/// -/// 0. `[signer, optional]` authority (default to `GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ`) -/// 1. `[writable]` pool_state -#[derive(Clone, Debug, Default)] -pub struct UpdatePoolStatusBuilder { - authority: Option, - pool_state: Option, - status: Option, - __remaining_accounts: Vec, -} - -impl UpdatePoolStatusBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ']` - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn status(&mut self, status: u8) -> &mut Self { - self.status = Some(status); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdatePoolStatus { - authority: self.authority.unwrap_or(solana_pubkey::pubkey!( - "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - )), - pool_state: self.pool_state.expect("pool_state is not set"), - }; - let args = UpdatePoolStatusInstructionArgs { - status: self.status.clone().expect("status is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_pool_status` CPI accounts. -pub struct UpdatePoolStatusCpiAccounts<'a, 'b> { - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_pool_status` CPI instruction. -pub struct UpdatePoolStatusCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdatePoolStatusInstructionArgs, -} - -impl<'a, 'b> UpdatePoolStatusCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdatePoolStatusCpiAccounts<'a, 'b>, - args: UpdatePoolStatusInstructionArgs, - ) -> Self { - Self { - __program: program, - authority: accounts.authority, - pool_state: accounts.pool_state, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdatePoolStatusInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdatePoolStatus` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` authority -/// 1. `[writable]` pool_state -#[derive(Clone, Debug)] -pub struct UpdatePoolStatusCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdatePoolStatusCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdatePoolStatusCpiBuilderInstruction { - __program: program, - authority: None, - pool_state: None, - status: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - #[inline(always)] - pub fn status(&mut self, status: u8) -> &mut Self { - self.instruction.status = Some(status); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdatePoolStatusInstructionArgs { - status: self.instruction.status.clone().expect("status is not set"), - }; - let instruction = UpdatePoolStatusCpi { - __program: self.instruction.__program, - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdatePoolStatusCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - status: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/withdraw.rs b/crates/raydium-cpmm-parser/src/generated_sdk/instructions/withdraw.rs deleted file mode 100644 index 08174fc9..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/instructions/withdraw.rs +++ /dev/null @@ -1,934 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const WITHDRAW_DISCRIMINATOR: [u8; 8] = [183, 18, 70, 156, 148, 109, 161, 34]; - -/// Accounts. -#[derive(Debug)] -pub struct Withdraw { - /// Pays to mint the position - pub owner: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - /// Pool state account - pub pool_state: solana_pubkey::Pubkey, - /// Owner lp token account - pub owner_lp_token: solana_pubkey::Pubkey, - /// The token account for receive token_0, - pub token0_account: solana_pubkey::Pubkey, - /// The token account for receive token_1 - pub token1_account: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_0 - pub token0_vault: solana_pubkey::Pubkey, - /// The address that holds pool tokens for token_1 - pub token1_vault: solana_pubkey::Pubkey, - /// token Program - pub token_program: solana_pubkey::Pubkey, - /// Token program 2022 - pub token_program2022: solana_pubkey::Pubkey, - /// The mint of token_0 vault - pub vault0_mint: solana_pubkey::Pubkey, - /// The mint of token_1 vault - pub vault1_mint: solana_pubkey::Pubkey, - /// Pool lp token mint - pub lp_mint: solana_pubkey::Pubkey, - /// memo program - pub memo_program: solana_pubkey::Pubkey, -} - -impl Withdraw { - pub fn instruction(&self, args: WithdrawInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: WithdrawInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.owner_lp_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token0_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token1_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program2022, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault0_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault1_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.memo_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawInstructionData { - discriminator: [u8; 8], -} - -impl WithdrawInstructionData { - pub fn new() -> Self { - Self { - discriminator: [183, 18, 70, 156, 148, 109, 161, 34], - } - } -} - -impl Default for WithdrawInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct WithdrawInstructionArgs { - pub lp_token_amount: u64, - pub minimum_token0_amount: u64, - pub minimum_token1_amount: u64, -} - -/// Instruction builder for `Withdraw`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[writable]` owner_lp_token -/// 4. `[writable]` token0_account -/// 5. `[writable]` token1_account -/// 6. `[writable]` token0_vault -/// 7. `[writable]` token1_vault -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[optional]` token_program2022 (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 10. `[]` vault0_mint -/// 11. `[]` vault1_mint -/// 12. `[writable]` lp_mint -/// 13. `[optional]` memo_program (default to `MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr`) -#[derive(Clone, Debug, Default)] -pub struct WithdrawBuilder { - owner: Option, - authority: Option, - pool_state: Option, - owner_lp_token: Option, - token0_account: Option, - token1_account: Option, - token0_vault: Option, - token1_vault: Option, - token_program: Option, - token_program2022: Option, - vault0_mint: Option, - vault1_mint: Option, - lp_mint: Option, - memo_program: Option, - lp_token_amount: Option, - minimum_token0_amount: Option, - minimum_token1_amount: Option, - __remaining_accounts: Vec, -} - -impl WithdrawBuilder { - pub fn new() -> Self { Self::default() } - - /// Pays to mint the position - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Pool state account - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Owner lp token account - #[inline(always)] - pub fn owner_lp_token(&mut self, owner_lp_token: solana_pubkey::Pubkey) -> &mut Self { - self.owner_lp_token = Some(owner_lp_token); - self - } - - /// The token account for receive token_0, - #[inline(always)] - pub fn token0_account(&mut self, token0_account: solana_pubkey::Pubkey) -> &mut Self { - self.token0_account = Some(token0_account); - self - } - - /// The token account for receive token_1 - #[inline(always)] - pub fn token1_account(&mut self, token1_account: solana_pubkey::Pubkey) -> &mut Self { - self.token1_account = Some(token1_account); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token1_vault = Some(token1_vault); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// token Program - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// Token program 2022 - #[inline(always)] - pub fn token_program2022(&mut self, token_program2022: solana_pubkey::Pubkey) -> &mut Self { - self.token_program2022 = Some(token_program2022); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint(&mut self, vault0_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint(&mut self, vault1_mint: solana_pubkey::Pubkey) -> &mut Self { - self.vault1_mint = Some(vault1_mint); - self - } - - /// Pool lp token mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// `[optional account, default to 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr']` - /// memo program - #[inline(always)] - pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self { - self.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn lp_token_amount(&mut self, lp_token_amount: u64) -> &mut Self { - self.lp_token_amount = Some(lp_token_amount); - self - } - - #[inline(always)] - pub fn minimum_token0_amount(&mut self, minimum_token0_amount: u64) -> &mut Self { - self.minimum_token0_amount = Some(minimum_token0_amount); - self - } - - #[inline(always)] - pub fn minimum_token1_amount(&mut self, minimum_token1_amount: u64) -> &mut Self { - self.minimum_token1_amount = Some(minimum_token1_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Withdraw { - owner: self.owner.expect("owner is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - owner_lp_token: self.owner_lp_token.expect("owner_lp_token is not set"), - token0_account: self.token0_account.expect("token0_account is not set"), - token1_account: self.token1_account.expect("token1_account is not set"), - token0_vault: self.token0_vault.expect("token0_vault is not set"), - token1_vault: self.token1_vault.expect("token1_vault is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - token_program2022: self.token_program2022.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - vault0_mint: self.vault0_mint.expect("vault0_mint is not set"), - vault1_mint: self.vault1_mint.expect("vault1_mint is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - memo_program: self.memo_program.unwrap_or(solana_pubkey::pubkey!( - "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" - )), - }; - let args = WithdrawInstructionArgs { - lp_token_amount: self - .lp_token_amount - .clone() - .expect("lp_token_amount is not set"), - minimum_token0_amount: self - .minimum_token0_amount - .clone() - .expect("minimum_token0_amount is not set"), - minimum_token1_amount: self - .minimum_token1_amount - .clone() - .expect("minimum_token1_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `withdraw` CPI accounts. -pub struct WithdrawCpiAccounts<'a, 'b> { - /// Pays to mint the position - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state account - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Owner lp token account - pub owner_lp_token: &'b solana_account_info::AccountInfo<'a>, - /// The token account for receive token_0, - pub token0_account: &'b solana_account_info::AccountInfo<'a>, - /// The token account for receive token_1 - pub token1_account: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// token Program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program 2022 - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// Pool lp token mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// memo program - pub memo_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `withdraw` CPI instruction. -pub struct WithdrawCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Pays to mint the position - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state account - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Owner lp token account - pub owner_lp_token: &'b solana_account_info::AccountInfo<'a>, - /// The token account for receive token_0, - pub token0_account: &'b solana_account_info::AccountInfo<'a>, - /// The token account for receive token_1 - pub token1_account: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_0 - pub token0_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for token_1 - pub token1_vault: &'b solana_account_info::AccountInfo<'a>, - /// token Program - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program 2022 - pub token_program2022: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_0 vault - pub vault0_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of token_1 vault - pub vault1_mint: &'b solana_account_info::AccountInfo<'a>, - /// Pool lp token mint - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - /// memo program - pub memo_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: WithdrawInstructionArgs, -} - -impl<'a, 'b> WithdrawCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: WithdrawCpiAccounts<'a, 'b>, - args: WithdrawInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - authority: accounts.authority, - pool_state: accounts.pool_state, - owner_lp_token: accounts.owner_lp_token, - token0_account: accounts.token0_account, - token1_account: accounts.token1_account, - token0_vault: accounts.token0_vault, - token1_vault: accounts.token1_vault, - token_program: accounts.token_program, - token_program2022: accounts.token_program2022, - vault0_mint: accounts.vault0_mint, - vault1_mint: accounts.vault1_mint, - lp_mint: accounts.lp_mint, - memo_program: accounts.memo_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.owner_lp_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token0_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token1_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program2022.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault0_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault1_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.memo_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&WithdrawInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_CP_SWAP_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.owner_lp_token.clone()); - account_infos.push(self.token0_account.clone()); - account_infos.push(self.token1_account.clone()); - account_infos.push(self.token0_vault.clone()); - account_infos.push(self.token1_vault.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.token_program2022.clone()); - account_infos.push(self.vault0_mint.clone()); - account_infos.push(self.vault1_mint.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.memo_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Withdraw` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[writable]` owner_lp_token -/// 4. `[writable]` token0_account -/// 5. `[writable]` token1_account -/// 6. `[writable]` token0_vault -/// 7. `[writable]` token1_vault -/// 8. `[]` token_program -/// 9. `[]` token_program2022 -/// 10. `[]` vault0_mint -/// 11. `[]` vault1_mint -/// 12. `[writable]` lp_mint -/// 13. `[]` memo_program -#[derive(Clone, Debug)] -pub struct WithdrawCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(WithdrawCpiBuilderInstruction { - __program: program, - owner: None, - authority: None, - pool_state: None, - owner_lp_token: None, - token0_account: None, - token1_account: None, - token0_vault: None, - token1_vault: None, - token_program: None, - token_program2022: None, - vault0_mint: None, - vault1_mint: None, - lp_mint: None, - memo_program: None, - lp_token_amount: None, - minimum_token0_amount: None, - minimum_token1_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Pays to mint the position - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Pool state account - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Owner lp token account - #[inline(always)] - pub fn owner_lp_token( - &mut self, - owner_lp_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.owner_lp_token = Some(owner_lp_token); - self - } - - /// The token account for receive token_0, - #[inline(always)] - pub fn token0_account( - &mut self, - token0_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_account = Some(token0_account); - self - } - - /// The token account for receive token_1 - #[inline(always)] - pub fn token1_account( - &mut self, - token1_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_account = Some(token1_account); - self - } - - /// The address that holds pool tokens for token_0 - #[inline(always)] - pub fn token0_vault( - &mut self, - token0_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token0_vault = Some(token0_vault); - self - } - - /// The address that holds pool tokens for token_1 - #[inline(always)] - pub fn token1_vault( - &mut self, - token1_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token1_vault = Some(token1_vault); - self - } - - /// token Program - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Token program 2022 - #[inline(always)] - pub fn token_program2022( - &mut self, - token_program2022: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program2022 = Some(token_program2022); - self - } - - /// The mint of token_0 vault - #[inline(always)] - pub fn vault0_mint( - &mut self, - vault0_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault0_mint = Some(vault0_mint); - self - } - - /// The mint of token_1 vault - #[inline(always)] - pub fn vault1_mint( - &mut self, - vault1_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault1_mint = Some(vault1_mint); - self - } - - /// Pool lp token mint - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - /// memo program - #[inline(always)] - pub fn memo_program( - &mut self, - memo_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.memo_program = Some(memo_program); - self - } - - #[inline(always)] - pub fn lp_token_amount(&mut self, lp_token_amount: u64) -> &mut Self { - self.instruction.lp_token_amount = Some(lp_token_amount); - self - } - - #[inline(always)] - pub fn minimum_token0_amount(&mut self, minimum_token0_amount: u64) -> &mut Self { - self.instruction.minimum_token0_amount = Some(minimum_token0_amount); - self - } - - #[inline(always)] - pub fn minimum_token1_amount(&mut self, minimum_token1_amount: u64) -> &mut Self { - self.instruction.minimum_token1_amount = Some(minimum_token1_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = WithdrawInstructionArgs { - lp_token_amount: self - .instruction - .lp_token_amount - .clone() - .expect("lp_token_amount is not set"), - minimum_token0_amount: self - .instruction - .minimum_token0_amount - .clone() - .expect("minimum_token0_amount is not set"), - minimum_token1_amount: self - .instruction - .minimum_token1_amount - .clone() - .expect("minimum_token1_amount is not set"), - }; - let instruction = WithdrawCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - owner_lp_token: self - .instruction - .owner_lp_token - .expect("owner_lp_token is not set"), - - token0_account: self - .instruction - .token0_account - .expect("token0_account is not set"), - - token1_account: self - .instruction - .token1_account - .expect("token1_account is not set"), - - token0_vault: self - .instruction - .token0_vault - .expect("token0_vault is not set"), - - token1_vault: self - .instruction - .token1_vault - .expect("token1_vault is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - token_program2022: self - .instruction - .token_program2022 - .expect("token_program2022 is not set"), - - vault0_mint: self - .instruction - .vault0_mint - .expect("vault0_mint is not set"), - - vault1_mint: self - .instruction - .vault1_mint - .expect("vault1_mint is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - memo_program: self - .instruction - .memo_program - .expect("memo_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct WithdrawCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - owner_lp_token: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program2022: Option<&'b solana_account_info::AccountInfo<'a>>, - vault0_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vault1_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - memo_program: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_token_amount: Option, - minimum_token0_amount: Option, - minimum_token1_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/mod.rs b/crates/raydium-cpmm-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/programs.rs b/crates/raydium-cpmm-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 90c0b9fc..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `raydium_cp_swap` program ID. -pub const RAYDIUM_CP_SWAP_ID: Pubkey = pubkey!("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"); diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/shared.rs b/crates/raydium-cpmm-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/types/creator_fee_on.rs b/crates/raydium-cpmm-parser/src/generated_sdk/types/creator_fee_on.rs deleted file mode 100644 index 4b38141c..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/types/creator_fee_on.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum CreatorFeeOn { - BothToken, - OnlyToken0, - OnlyToken1, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/types/lp_change_event.rs b/crates/raydium-cpmm-parser/src/generated_sdk/types/lp_change_event.rs deleted file mode 100644 index 52ec62de..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/types/lp_change_event.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Emitted when deposit and withdraw -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LpChangeEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_id: Pubkey, - pub lp_amount_before: u64, - /// pool vault sub trade fees - pub token0_vault_before: u64, - /// pool vault sub trade fees - pub token1_vault_before: u64, - /// calculate result without transfer fee - pub token0_amount: u64, - /// calculate result without transfer fee - pub token1_amount: u64, - pub token0_transfer_fee: u64, - pub token1_transfer_fee: u64, - pub change_type: u8, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/types/mod.rs b/crates/raydium-cpmm-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index 1f28ee74..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#creator_fee_on; -pub(crate) mod r#lp_change_event; -pub(crate) mod r#observation; -pub(crate) mod r#swap_event; - -pub use self::{r#creator_fee_on::*, r#lp_change_event::*, r#observation::*, r#swap_event::*}; diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/types/observation.rs b/crates/raydium-cpmm-parser/src/generated_sdk/types/observation.rs deleted file mode 100644 index 076eeff8..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/types/observation.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// The element of observations in ObservationState -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Observation { - /// The block timestamp of the observation - pub block_timestamp: u64, - /// the cumulative of token0 price during the duration time, Q32.32, the remaining 64 bit for overflow - pub cumulative_token0_price_x32: u128, - /// the cumulative of token1 price during the duration time, Q32.32, the remaining 64 bit for overflow - pub cumulative_token1_price_x32: u128, -} diff --git a/crates/raydium-cpmm-parser/src/generated_sdk/types/swap_event.rs b/crates/raydium-cpmm-parser/src/generated_sdk/types/swap_event.rs deleted file mode 100644 index 75524f9f..00000000 --- a/crates/raydium-cpmm-parser/src/generated_sdk/types/swap_event.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Emitted when swap -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SwapEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_id: Pubkey, - /// pool vault sub trade fees - pub input_vault_before: u64, - /// pool vault sub trade fees - pub output_vault_before: u64, - /// calculate result without transfer fee - pub input_amount: u64, - /// calculate result without transfer fee - pub output_amount: u64, - pub input_transfer_fee: u64, - pub output_transfer_fee: u64, - pub base_input: bool, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub input_mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub output_mint: Pubkey, - pub trade_fee: u64, - /// Amount of fee tokens going to creator - pub creator_fee: u64, - pub creator_fee_on_input: bool, -} diff --git a/crates/raydium-cpmm-parser/src/lib.rs b/crates/raydium-cpmm-parser/src/lib.rs deleted file mode 100644 index ad46809c..00000000 --- a/crates/raydium-cpmm-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = RAYDIUM_CP_SWAP_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.raydium_cpmm"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/raydium-launchpad-parser/Cargo.toml b/crates/raydium-launchpad-parser/Cargo.toml deleted file mode 100644 index 71e36ceb..00000000 --- a/crates/raydium-launchpad-parser/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "yellowstone-vixen-raydium-launchpad-parser" -version.workspace = true -edition.workspace = true -license.workspace = true -repository.workspace = true -authors.workspace = true - -[dependencies] -prost = { workspace = true } -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info = { workspace = true } -solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction = { workspace = true } -solana-msg = { workspace = true } -solana-program-entrypoint = { workspace = true } -solana-program-error = { workspace = true } -borsh = { workspace = true } -num-derive = { workspace = true } -thiserror = { workspace = true } -num-traits = { workspace = true } -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build = { workspace = true } -protobuf-src = { workspace = true } \ No newline at end of file diff --git a/crates/raydium-launchpad-parser/build.rs b/crates/raydium-launchpad-parser/build.rs deleted file mode 100644 index 04172339..00000000 --- a/crates/raydium-launchpad-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - std::env::set_var("PROTOC", protobuf_src::protoc()); - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/raydium_launchpad.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/raydium-launchpad-parser/idl.json b/crates/raydium-launchpad-parser/idl.json deleted file mode 100644 index 70c90c59..00000000 --- a/crates/raydium-launchpad-parser/idl.json +++ /dev/null @@ -1,5783 +0,0 @@ -{ - "address": "LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj", - "metadata": { - "name": "raydium_launchpad", - "version": "0.2.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "buy_exact_in", - "docs": [ - "Use the given amount of quote tokens to purchase base tokens.", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `amount_in` - Amount of quote token to purchase", - "* `minimum_amount_out` - Minimum amount of base token to receive (slippage protection)", - "* `share_fee_rate` - Fee rate for the share", - "" - ], - "discriminator": [ - 250, - 234, - 13, - 123, - 213, - 156, - 19, - 236 - ], - "accounts": [ - { - "name": "payer", - "docs": [ - "The user performing the swap operation", - "Must sign the transaction and pay for fees" - ], - "signer": true - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault operations", - "Generated using AUTH_SEED" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "global_config", - "docs": [ - "Global configuration account containing protocol-wide settings", - "Used to read protocol fee rates and curve type" - ] - }, - { - "name": "platform_config", - "docs": [ - "Platform configuration account containing platform-wide settings", - "Used to read platform fee rate" - ] - }, - { - "name": "pool_state", - "docs": [ - "The pool state account where the swap will be performed", - "Contains current pool parameters and balances" - ], - "writable": true - }, - { - "name": "user_base_token", - "docs": [ - "The user's token account for base tokens (tokens being bought)", - "Will receive the output tokens after the swap" - ], - "writable": true - }, - { - "name": "user_quote_token", - "docs": [ - "The user's token account for quote tokens (tokens being sold)", - "Will be debited for the input amount" - ], - "writable": true - }, - { - "name": "base_vault", - "docs": [ - "The pool's vault for base tokens", - "Will be debited to send tokens to the user" - ], - "writable": true - }, - { - "name": "quote_vault", - "docs": [ - "The pool's vault for quote tokens", - "Will receive the input tokens from the user" - ], - "writable": true - }, - { - "name": "base_token_mint", - "docs": [ - "The mint of the base token", - "Used for transfer fee calculations if applicable" - ] - }, - { - "name": "quote_token_mint", - "docs": [ - "The mint of the quote token" - ] - }, - { - "name": "base_token_program", - "docs": [ - "SPL Token program for base token transfers" - ] - }, - { - "name": "quote_token_program", - "docs": [ - "SPL Token program for quote token transfers" - ], - "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": "minimum_amount_out", - "type": "u64" - }, - { - "name": "share_fee_rate", - "type": "u64" - } - ] - }, - { - "name": "buy_exact_out", - "docs": [ - "Use quote tokens to purchase the given amount of base tokens.", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `amount_out` - Amount of base token to receive", - "* `maximum_amount_in` - Maximum amount of quote token to purchase (slippage protection)", - "* `share_fee_rate` - Fee rate for the share" - ], - "discriminator": [ - 24, - 211, - 116, - 40, - 105, - 3, - 153, - 56 - ], - "accounts": [ - { - "name": "payer", - "docs": [ - "The user performing the swap operation", - "Must sign the transaction and pay for fees" - ], - "signer": true - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault operations", - "Generated using AUTH_SEED" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "global_config", - "docs": [ - "Global configuration account containing protocol-wide settings", - "Used to read protocol fee rates and curve type" - ] - }, - { - "name": "platform_config", - "docs": [ - "Platform configuration account containing platform-wide settings", - "Used to read platform fee rate" - ] - }, - { - "name": "pool_state", - "docs": [ - "The pool state account where the swap will be performed", - "Contains current pool parameters and balances" - ], - "writable": true - }, - { - "name": "user_base_token", - "docs": [ - "The user's token account for base tokens (tokens being bought)", - "Will receive the output tokens after the swap" - ], - "writable": true - }, - { - "name": "user_quote_token", - "docs": [ - "The user's token account for quote tokens (tokens being sold)", - "Will be debited for the input amount" - ], - "writable": true - }, - { - "name": "base_vault", - "docs": [ - "The pool's vault for base tokens", - "Will be debited to send tokens to the user" - ], - "writable": true - }, - { - "name": "quote_vault", - "docs": [ - "The pool's vault for quote tokens", - "Will receive the input tokens from the user" - ], - "writable": true - }, - { - "name": "base_token_mint", - "docs": [ - "The mint of the base token", - "Used for transfer fee calculations if applicable" - ] - }, - { - "name": "quote_token_mint", - "docs": [ - "The mint of the quote token" - ] - }, - { - "name": "base_token_program", - "docs": [ - "SPL Token program for base token transfers" - ] - }, - { - "name": "quote_token_program", - "docs": [ - "SPL Token program for quote token transfers" - ], - "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_out", - "type": "u64" - }, - { - "name": "maximum_amount_in", - "type": "u64" - }, - { - "name": "share_fee_rate", - "type": "u64" - } - ] - }, - { - "name": "claim_creator_fee", - "docs": [ - "Claim the fee from the exclusive creator fee vault.", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "" - ], - "discriminator": [ - 26, - 97, - 138, - 203, - 132, - 171, - 141, - 252 - ], - "accounts": [ - { - "name": "creator", - "docs": [ - "The pool creator" - ], - "writable": true, - "signer": true - }, - { - "name": "fee_vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 114, - 101, - 97, - 116, - 111, - 114, - 95, - 102, - 101, - 101, - 95, - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "creator_fee_vault", - "docs": [ - "The creator fee vault" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "creator" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "recipient_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "creator" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "quote_mint", - "docs": [ - "The mint for the quote token" - ] - }, - { - "name": "token_program", - "docs": [ - "SPL Token program for the quote token" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "associated_token_program", - "docs": [ - "Required for associated token program" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - } - ], - "args": [] - }, - { - "name": "claim_platform_fee", - "docs": [ - "Claim platform fee", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "" - ], - "discriminator": [ - 156, - 39, - 208, - 135, - 76, - 237, - 61, - 72 - ], - "accounts": [ - { - "name": "platform_fee_wallet", - "docs": [ - "Only the wallet stored in platform_config can collect platform fees" - ], - "writable": true, - "signer": true - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault and mint operations", - "Generated using AUTH_SEED" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "Account that stores the pool's state and parameters", - "PDA generated using POOL_SEED and both token mints" - ], - "writable": true - }, - { - "name": "platform_config", - "docs": [ - "The platform config account" - ] - }, - { - "name": "quote_vault", - "writable": true - }, - { - "name": "recipient_token_account", - "docs": [ - "The address that receives the collected quote token fees" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "platform_fee_wallet" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "quote_mint", - "docs": [ - "The mint of quote token vault" - ] - }, - { - "name": "token_program", - "docs": [ - "SPL program for input token transfers" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "associated_token_program", - "docs": [ - "Required for associated token program" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - } - ], - "args": [] - }, - { - "name": "claim_platform_fee_from_vault", - "docs": [ - "Claim the fee from the exclusive platform fee vault.", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "" - ], - "discriminator": [ - 117, - 241, - 198, - 168, - 248, - 218, - 80, - 29 - ], - "accounts": [ - { - "name": "platform_fee_wallet", - "docs": [ - "Only the wallet stored in platform_config can collect platform fees" - ], - "writable": true, - "signer": true - }, - { - "name": "fee_vault_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 108, - 97, - 116, - 102, - 111, - 114, - 109, - 95, - 102, - 101, - 101, - 95, - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "platform_config", - "docs": [ - "The platform config account" - ] - }, - { - "name": "platform_fee_vault", - "docs": [ - "The platform fee vault" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "platform_config" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "recipient_token_account", - "docs": [ - "The address that receives the collected quote token fees" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "platform_fee_wallet" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "quote_mint", - "docs": [ - "The mint of quote token vault" - ] - }, - { - "name": "token_program", - "docs": [ - "SPL program for input token transfers" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "associated_token_program", - "docs": [ - "Required for associated token program" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - } - ], - "args": [] - }, - { - "name": "claim_vested_token", - "docs": [ - "Claim vested token", - "# Arguments" - ], - "discriminator": [ - 49, - 33, - 104, - 30, - 189, - 157, - 79, - 35 - ], - "accounts": [ - { - "name": "beneficiary", - "docs": [ - "The beneficiary of the vesting account" - ], - "writable": true, - "signer": true - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault and mint operations", - "Generated using AUTH_SEED" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "Account that stores the pool's state and parameters", - "PDA generated using POOL_SEED and both token mints" - ], - "writable": true - }, - { - "name": "vesting_record", - "docs": [ - "The vesting record account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 101, - 115, - 116, - 105, - 110, - 103 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "beneficiary" - } - ] - } - }, - { - "name": "base_vault", - "docs": [ - "The pool's vault for base tokens", - "Will be debited to send tokens to the user" - ], - "writable": true - }, - { - "name": "user_base_token", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "beneficiary" - }, - { - "kind": "account", - "path": "base_token_program" - }, - { - "kind": "account", - "path": "base_token_mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "base_token_mint", - "docs": [ - "The mint for the base token (token being sold)", - "Created in this instruction with specified decimals" - ] - }, - { - "name": "base_token_program", - "docs": [ - "SPL Token program for the base token", - "Must be the standard Token program" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "associated_token_program", - "docs": [ - "Required for associated token program" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - } - ], - "args": [] - }, - { - "name": "collect_fee", - "docs": [ - "Collects accumulated fees from the pool", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "" - ], - "discriminator": [ - 60, - 173, - 247, - 103, - 4, - 93, - 130, - 48 - ], - "accounts": [ - { - "name": "owner", - "docs": [ - "Only protocol_fee_owner saved in global_config can collect protocol fee now" - ], - "signer": true - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "Pool state stores accumulated protocol fee amount" - ], - "writable": true - }, - { - "name": "global_config", - "docs": [ - "Global config account stores owner" - ] - }, - { - "name": "quote_vault", - "docs": [ - "The address that holds pool tokens for quote token" - ], - "writable": true - }, - { - "name": "quote_mint", - "docs": [ - "The mint of quote token vault" - ] - }, - { - "name": "recipient_token_account", - "docs": [ - "The address that receives the collected quote token fees" - ], - "writable": true - }, - { - "name": "token_program", - "docs": [ - "SPL program for input token transfers" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - } - ], - "args": [] - }, - { - "name": "collect_migrate_fee", - "docs": [ - "Collects migrate fees from the pool", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "" - ], - "discriminator": [ - 255, - 186, - 150, - 223, - 235, - 118, - 201, - 186 - ], - "accounts": [ - { - "name": "owner", - "docs": [ - "Only migrate_fee_owner saved in global_config can collect migrate fee now" - ], - "signer": true - }, - { - "name": "authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "Pool state stores accumulated protocol fee amount" - ], - "writable": true - }, - { - "name": "global_config", - "docs": [ - "Global config account stores owner" - ] - }, - { - "name": "quote_vault", - "docs": [ - "The address that holds pool tokens for quote token" - ], - "writable": true - }, - { - "name": "quote_mint", - "docs": [ - "The mint of quote token vault" - ] - }, - { - "name": "recipient_token_account", - "docs": [ - "The address that receives the collected quote token fees" - ], - "writable": true - }, - { - "name": "token_program", - "docs": [ - "SPL program for input token transfers" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - } - ], - "args": [] - }, - { - "name": "create_config", - "docs": [ - "Creates a new configuration", - "# Arguments", - "", - "* `ctx` - The accounts needed by instruction", - "* `curve_type` - The type of bonding curve (0: ConstantProduct)", - "* `index` - The index of config, there may be multiple config with the same curve type.", - "* `trade_fee_rate` - Trade fee rate, must be less than RATE_DENOMINATOR_VALUE", - "" - ], - "discriminator": [ - 201, - 207, - 243, - 114, - 75, - 111, - 47, - 189 - ], - "accounts": [ - { - "name": "owner", - "docs": [ - "The protocol owner/admin account", - "Must match the predefined admin address", - "Has authority to create and modify protocol configurations" - ], - "writable": true, - "signer": true, - "address": "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - }, - { - "name": "global_config", - "docs": [ - "Global configuration account that stores protocol-wide settings", - "PDA generated using GLOBAL_CONFIG_SEED, quote token mint, and curve type", - "Stores fee rates and protocol parameters" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 103, - 108, - 111, - 98, - 97, - 108, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "quote_token_mint" - }, - { - "kind": "arg", - "path": "curve_type" - }, - { - "kind": "arg", - "path": "index" - } - ] - } - }, - { - "name": "quote_token_mint", - "docs": [ - "The mint address of the quote token (token used for buying)", - "This will be the standard token used for all pools with this config" - ] - }, - { - "name": "protocol_fee_owner", - "docs": [ - "Account that will receive protocol fees" - ] - }, - { - "name": "migrate_fee_owner", - "docs": [ - "Account that will receive migrate fees" - ] - }, - { - "name": "migrate_to_amm_wallet", - "docs": [ - "The control wallet address for migrating to amm" - ] - }, - { - "name": "migrate_to_cpswap_wallet", - "docs": [ - "The control wallet address for migrating to cpswap" - ] - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "curve_type", - "type": "u8" - }, - { - "name": "index", - "type": "u16" - }, - { - "name": "migrate_fee", - "type": "u64" - }, - { - "name": "trade_fee_rate", - "type": "u64" - } - ] - }, - { - "name": "create_platform_config", - "docs": [ - "Create platform config account", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "# Fields", - "* `fee_rate` - Fee rate of the platform", - "* `name` - Name of the platform", - "* `web` - Website of the platform", - "* `img` - Image link of the platform", - "" - ], - "discriminator": [ - 176, - 90, - 196, - 175, - 253, - 113, - 220, - 20 - ], - "accounts": [ - { - "name": "platform_admin", - "docs": [ - "The account paying for the initialization costs" - ], - "writable": true, - "signer": true - }, - { - "name": "platform_fee_wallet" - }, - { - "name": "platform_nft_wallet" - }, - { - "name": "platform_config", - "docs": [ - "The platform config account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 108, - 97, - 116, - 102, - 111, - 114, - 109, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "platform_admin" - } - ] - } - }, - { - "name": "cpswap_config" - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "transfer_fee_extension_authority" - } - ], - "args": [ - { - "name": "platform_params", - "type": { - "defined": { - "name": "PlatformParams" - } - } - } - ] - }, - { - "name": "create_vesting_account", - "docs": [ - "Create vesting account", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `share` - The share amount of base token to be vested", - "" - ], - "discriminator": [ - 129, - 178, - 2, - 13, - 217, - 172, - 230, - 218 - ], - "accounts": [ - { - "name": "creator", - "docs": [ - "The account paying for the initialization costs", - "This can be any account with sufficient SOL to cover the transaction" - ], - "writable": true, - "signer": true - }, - { - "name": "beneficiary", - "docs": [ - "The beneficiary is used to receive the allocated linear release of tokens.", - "Once this account is set, it cannot be modified, so please ensure the validity of this account,", - "otherwise, the unlocked tokens will not be claimable." - ], - "writable": true - }, - { - "name": "pool_state", - "docs": [ - "The pool state account" - ], - "writable": true - }, - { - "name": "vesting_record", - "docs": [ - "The vesting record account" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 101, - 115, - 116, - 105, - 110, - 103 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "beneficiary" - } - ] - } - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "share_amount", - "type": "u64" - } - ] - }, - { - "name": "initialize", - "docs": [ - "Initializes a new trading pool", - "# Arguments", - "", - "* `ctx` - The context of accounts containing pool and token information", - "" - ], - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "payer", - "docs": [ - "The account paying for the initialization costs", - "This can be any account with sufficient SOL to cover the transaction" - ], - "writable": true, - "signer": true - }, - { - "name": "creator" - }, - { - "name": "global_config", - "docs": [ - "Global configuration account containing protocol-wide settings", - "Includes settings like quote token mint and fee parameters" - ] - }, - { - "name": "platform_config", - "docs": [ - "Platform configuration account containing platform info", - "Includes settings like the fee_rate, name, web, img of the platform" - ] - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault and mint operations", - "Generated using AUTH_SEED" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "Account that stores the pool's state and parameters", - "PDA generated using POOL_SEED and both token mints" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "base_mint" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "base_mint", - "docs": [ - "The mint for the base token (token being sold)", - "Created in this instruction with specified decimals" - ], - "writable": true, - "signer": true - }, - { - "name": "quote_mint", - "docs": [ - "The mint for the quote token (token used to buy)", - "Must match the quote_mint specified in global config" - ] - }, - { - "name": "base_vault", - "docs": [ - "Token account that holds the pool's base tokens", - "PDA generated using POOL_VAULT_SEED" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "base_mint" - } - ] - } - }, - { - "name": "quote_vault", - "docs": [ - "Token account that holds the pool's quote tokens", - "PDA generated using POOL_VAULT_SEED" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "metadata_account", - "docs": [ - "Account to store the base token's metadata", - "Created using Metaplex metadata program" - ], - "writable": true - }, - { - "name": "base_token_program", - "docs": [ - "SPL Token program for the base token", - "Must be the standard Token program" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "quote_token_program", - "docs": [ - "SPL Token program for the quote token" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "metadata_program", - "docs": [ - "Metaplex Token Metadata program", - "Used to create metadata for the base token" - ], - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "rent_program", - "docs": [ - "Required for rent exempt calculations" - ], - "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": "base_mint_param", - "type": { - "defined": { - "name": "MintParams" - } - } - }, - { - "name": "curve_param", - "type": { - "defined": { - "name": "CurveParams" - } - } - }, - { - "name": "vesting_param", - "type": { - "defined": { - "name": "VestingParams" - } - } - } - ] - }, - { - "name": "initialize_v2", - "docs": [ - "Initializes a new trading pool", - "# Arguments", - "", - "* `ctx` - The context of accounts containing pool and token information", - "" - ], - "discriminator": [ - 67, - 153, - 175, - 39, - 218, - 16, - 38, - 32 - ], - "accounts": [ - { - "name": "payer", - "docs": [ - "The account paying for the initialization costs", - "This can be any account with sufficient SOL to cover the transaction" - ], - "writable": true, - "signer": true - }, - { - "name": "creator" - }, - { - "name": "global_config", - "docs": [ - "Global configuration account containing protocol-wide settings", - "Includes settings like quote token mint and fee parameters" - ] - }, - { - "name": "platform_config", - "docs": [ - "Platform configuration account containing platform info", - "Includes settings like the fee_rate, name, web, img of the platform" - ] - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault and mint operations", - "Generated using AUTH_SEED" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "Account that stores the pool's state and parameters", - "PDA generated using POOL_SEED and both token mints" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "base_mint" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "base_mint", - "docs": [ - "The mint for the base token (token being sold)", - "Created in this instruction with specified decimals" - ], - "writable": true, - "signer": true - }, - { - "name": "quote_mint", - "docs": [ - "The mint for the quote token (token used to buy)", - "Must match the quote_mint specified in global config" - ] - }, - { - "name": "base_vault", - "docs": [ - "Token account that holds the pool's base tokens", - "PDA generated using POOL_VAULT_SEED" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "base_mint" - } - ] - } - }, - { - "name": "quote_vault", - "docs": [ - "Token account that holds the pool's quote tokens", - "PDA generated using POOL_VAULT_SEED" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "metadata_account", - "docs": [ - "Account to store the base token's metadata", - "Created using Metaplex metadata program" - ], - "writable": true - }, - { - "name": "base_token_program", - "docs": [ - "SPL Token program for the base token", - "Must be the standard Token program" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "quote_token_program", - "docs": [ - "SPL Token program for the quote token" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "metadata_program", - "docs": [ - "Metaplex Token Metadata program", - "Used to create metadata for the base token" - ], - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "rent_program", - "docs": [ - "Required for rent exempt calculations" - ], - "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": "base_mint_param", - "type": { - "defined": { - "name": "MintParams" - } - } - }, - { - "name": "curve_param", - "type": { - "defined": { - "name": "CurveParams" - } - } - }, - { - "name": "vesting_param", - "type": { - "defined": { - "name": "VestingParams" - } - } - }, - { - "name": "amm_fee_on", - "type": { - "defined": { - "name": "AmmCreatorFeeOn" - } - } - } - ] - }, - { - "name": "initialize_with_token_2022", - "docs": [ - "Initializes a new trading pool with base token belongs to spl-token-2022,", - "pool created by this instruction must be migrated to cpswap after fundraising ends, i.e., curve_param.migrate_type = 1", - "# Arguments", - "", - "* `ctx` - The context of accounts containing pool and token information", - "" - ], - "discriminator": [ - 37, - 190, - 126, - 222, - 44, - 154, - 171, - 17 - ], - "accounts": [ - { - "name": "payer", - "docs": [ - "The account paying for the initialization costs", - "This can be any account with sufficient SOL to cover the transaction" - ], - "writable": true, - "signer": true - }, - { - "name": "creator" - }, - { - "name": "global_config", - "docs": [ - "Global configuration account containing protocol-wide settings", - "Includes settings like quote token mint and fee parameters" - ] - }, - { - "name": "platform_config", - "docs": [ - "Platform configuration account containing platform info", - "Includes settings like the fee_rate, name, web, img of the platform" - ] - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault and mint operations", - "Generated using AUTH_SEED" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "Account that stores the pool's state and parameters", - "PDA generated using POOL_SEED and both token mints" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "base_mint" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "base_mint", - "docs": [ - "The mint for the base token (token being sold)", - "Created in this instruction with specified decimals" - ], - "writable": true, - "signer": true - }, - { - "name": "quote_mint", - "docs": [ - "The mint for the quote token (token used to buy)", - "Must match the quote_mint specified in global config" - ] - }, - { - "name": "base_vault", - "docs": [ - "Token account that holds the pool's base tokens", - "PDA generated using POOL_VAULT_SEED" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "base_mint" - } - ] - } - }, - { - "name": "quote_vault", - "docs": [ - "Token account that holds the pool's quote tokens", - "PDA generated using POOL_VAULT_SEED" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "pool_state" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "base_token_program", - "docs": [ - "SPL Token program for the base token" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "name": "quote_token_program", - "docs": [ - "SPL Token program for the quote token" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "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": "base_mint_param", - "type": { - "defined": { - "name": "MintParams" - } - } - }, - { - "name": "curve_param", - "type": { - "defined": { - "name": "CurveParams" - } - } - }, - { - "name": "vesting_param", - "type": { - "defined": { - "name": "VestingParams" - } - } - }, - { - "name": "amm_fee_on", - "type": { - "defined": { - "name": "AmmCreatorFeeOn" - } - } - }, - { - "name": "transfer_fee_extension_param", - "type": { - "option": { - "defined": { - "name": "TransferFeeExtensionParams" - } - } - } - } - ] - }, - { - "name": "migrate_to_amm", - "docs": [ - "# Arguments", - "", - "* `ctx` - The context of accounts", - "" - ], - "discriminator": [ - 207, - 82, - 192, - 145, - 254, - 207, - 145, - 223 - ], - "accounts": [ - { - "name": "payer", - "docs": [ - "Only migrate_to_amm_wallet can migrate to cpswap pool", - "This signer must match the migrate_to_amm_wallet saved in global_config" - ], - "writable": true, - "signer": true - }, - { - "name": "base_mint", - "docs": [ - "The mint for the base token (token being sold)" - ] - }, - { - "name": "quote_mint", - "docs": [ - "The mint for the quote token (token used to buy)" - ] - }, - { - "name": "openbook_program", - "address": "srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX" - }, - { - "name": "market", - "docs": [ - "Account created and asigned to openbook_program but not been initialized" - ], - "writable": true - }, - { - "name": "request_queue", - "docs": [ - "Account created and asigned to openbook_program but not been initialized" - ], - "writable": true - }, - { - "name": "event_queue", - "docs": [ - "Account created and asigned to openbook_program but not been initialized" - ], - "writable": true - }, - { - "name": "bids", - "docs": [ - "Account created and asigned to openbook_program but not been initialized" - ], - "writable": true - }, - { - "name": "asks", - "docs": [ - "Account created and asigned to openbook_program but not been initialized" - ], - "writable": true - }, - { - "name": "market_vault_signer" - }, - { - "name": "market_base_vault", - "docs": [ - "Token account that holds the market's base tokens" - ], - "writable": true - }, - { - "name": "market_quote_vault", - "docs": [ - "Token account that holds the market's quote tokens" - ], - "writable": true - }, - { - "name": "amm_program", - "address": "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" - }, - { - "name": "amm_pool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "amm_program" - }, - { - "kind": "account", - "path": "market" - }, - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 97, - 115, - 115, - 111, - 99, - 105, - 97, - 116, - 101, - 100, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "account", - "path": "amm_program" - } - } - }, - { - "name": "amm_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 32, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ], - "program": { - "kind": "account", - "path": "amm_program" - } - } - }, - { - "name": "amm_open_orders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "amm_program" - }, - { - "kind": "account", - "path": "market" - }, - { - "kind": "const", - "value": [ - 111, - 112, - 101, - 110, - 95, - 111, - 114, - 100, - 101, - 114, - 95, - 97, - 115, - 115, - 111, - 99, - 105, - 97, - 116, - 101, - 100, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "account", - "path": "amm_program" - } - } - }, - { - "name": "amm_lp_mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "amm_program" - }, - { - "kind": "account", - "path": "market" - }, - { - "kind": "const", - "value": [ - 108, - 112, - 95, - 109, - 105, - 110, - 116, - 95, - 97, - 115, - 115, - 111, - 99, - 105, - 97, - 116, - 101, - 100, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "account", - "path": "amm_program" - } - } - }, - { - "name": "amm_base_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "amm_program" - }, - { - "kind": "account", - "path": "market" - }, - { - "kind": "const", - "value": [ - 99, - 111, - 105, - 110, - 95, - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 115, - 115, - 111, - 99, - 105, - 97, - 116, - 101, - 100, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "account", - "path": "amm_program" - } - } - }, - { - "name": "amm_quote_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "amm_program" - }, - { - "kind": "account", - "path": "market" - }, - { - "kind": "const", - "value": [ - 112, - 99, - 95, - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 115, - 115, - 111, - 99, - 105, - 97, - 116, - 101, - 100, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "account", - "path": "amm_program" - } - } - }, - { - "name": "amm_target_orders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "amm_program" - }, - { - "kind": "account", - "path": "market" - }, - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 97, - 115, - 115, - 111, - 99, - 105, - 97, - 116, - 101, - 100, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "account", - "path": "amm_program" - } - } - }, - { - "name": "amm_config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "account", - "path": "amm_program" - } - } - }, - { - "name": "amm_create_fee_destination", - "writable": true - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault operations", - "Generated using AUTH_SEED" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "Account that stores the pool's state and parameters", - "PDA generated using POOL_SEED and both token mints" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "base_mint" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "global_config", - "docs": [ - "Global config account stores owner" - ] - }, - { - "name": "base_vault", - "docs": [ - "The pool's vault for base tokens", - "Will be fully drained during migration" - ], - "writable": true - }, - { - "name": "quote_vault", - "docs": [ - "The pool's vault for quote tokens", - "Will be fully drained during migration" - ], - "writable": true - }, - { - "name": "pool_lp_token", - "writable": true - }, - { - "name": "spl_token_program", - "docs": [ - "SPL Token program for the base token", - "Must be the standard Token program" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "docs": [ - "Program to create an ATA for receiving fee NFT" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "rent_program", - "docs": [ - "Required for rent exempt calculations" - ], - "address": "SysvarRent111111111111111111111111111111111" - } - ], - "args": [ - { - "name": "base_lot_size", - "type": "u64" - }, - { - "name": "quote_lot_size", - "type": "u64" - }, - { - "name": "market_vault_signer_nonce", - "type": "u8" - } - ] - }, - { - "name": "migrate_to_cpswap", - "docs": [ - "# Arguments", - "", - "* `ctx` - The context of accounts", - "" - ], - "discriminator": [ - 136, - 92, - 200, - 103, - 28, - 218, - 144, - 140 - ], - "accounts": [ - { - "name": "payer", - "docs": [ - "Only migrate_to_cpswap_wallet can migrate to cpswap pool", - "This signer must match the migrate_to_cpswap_wallet saved in global_config" - ], - "writable": true, - "signer": true - }, - { - "name": "base_mint", - "docs": [ - "The mint for the base token (token being sold)" - ], - "writable": true - }, - { - "name": "quote_mint", - "docs": [ - "The mint for the quote token (token used to buy)" - ] - }, - { - "name": "platform_config", - "docs": [ - "Platform configuration account containing platform-wide settings", - "Used to read platform fee rate" - ] - }, - { - "name": "cpswap_program", - "address": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - }, - { - "name": "cpswap_pool", - "docs": [ - "PDA account:", - "seeds = [", - "b\"pool\",", - "cpswap_config.key().as_ref(),", - "token_0_mint.key().as_ref(),", - "token_1_mint.key().as_ref(),", - "],", - "seeds::program = cpswap_program,", - "", - "Or random account: must be signed by cli" - ], - "writable": true - }, - { - "name": "cpswap_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 110, - 100, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "account", - "path": "cpswap_program" - } - } - }, - { - "name": "cpswap_lp_mint", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 108, - 112, - 95, - 109, - 105, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "cpswap_pool" - } - ], - "program": { - "kind": "account", - "path": "cpswap_program" - } - } - }, - { - "name": "cpswap_base_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "cpswap_pool" - }, - { - "kind": "account", - "path": "base_mint" - } - ], - "program": { - "kind": "account", - "path": "cpswap_program" - } - } - }, - { - "name": "cpswap_quote_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "cpswap_pool" - }, - { - "kind": "account", - "path": "quote_mint" - } - ], - "program": { - "kind": "account", - "path": "cpswap_program" - } - } - }, - { - "name": "cpswap_config" - }, - { - "name": "cpswap_create_pool_fee", - "writable": true - }, - { - "name": "cpswap_observation", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 111, - 98, - 115, - 101, - 114, - 118, - 97, - 116, - 105, - 111, - 110 - ] - }, - { - "kind": "account", - "path": "cpswap_pool" - } - ], - "program": { - "kind": "account", - "path": "cpswap_program" - } - } - }, - { - "name": "lock_program", - "address": "LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE" - }, - { - "name": "lock_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 107, - 95, - 99, - 112, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121, - 95, - 115, - 101, - 101, - 100 - ] - } - ], - "program": { - "kind": "account", - "path": "lock_program" - } - } - }, - { - "name": "lock_lp_vault", - "writable": true - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault operations", - "Generated using AUTH_SEED" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "pool_state", - "docs": [ - "Account that stores the pool's state and parameters", - "PDA generated using POOL_SEED and both token mints" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "base_mint" - }, - { - "kind": "account", - "path": "quote_mint" - } - ] - } - }, - { - "name": "global_config", - "docs": [ - "Global config account stores owner" - ] - }, - { - "name": "base_vault", - "docs": [ - "The pool's vault for base tokens", - "Will be fully drained during migration" - ], - "writable": true - }, - { - "name": "quote_vault", - "docs": [ - "The pool's vault for quote tokens", - "Will be fully drained during migration" - ], - "writable": true - }, - { - "name": "pool_lp_token", - "writable": true - }, - { - "name": "base_token_program", - "docs": [ - "SPL Token program for the base token", - "Must be the standard Token program" - ] - }, - { - "name": "quote_token_program", - "docs": [ - "SPL Token program for the quote token" - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "docs": [ - "Program to create an ATA for receiving fee NFT" - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "docs": [ - "Required for account creation" - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "rent_program", - "docs": [ - "Required for rent exempt calculations" - ], - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "metadata_program", - "docs": [ - "Program to create NFT metadata accunt" - ], - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - } - ], - "args": [] - }, - { - "name": "remove_platform_curve_param", - "docs": [ - "Remove platform launch param", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `index` - The index of the curve param to remove", - "" - ], - "discriminator": [ - 27, - 30, - 62, - 169, - 93, - 224, - 24, - 145 - ], - "accounts": [ - { - "name": "platform_admin", - "docs": [ - "The account paying for the initialization costs" - ], - "signer": true - }, - { - "name": "platform_config", - "docs": [ - "Platform config account to be changed" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 108, - 97, - 116, - 102, - 111, - 114, - 109, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "platform_admin" - } - ] - } - } - ], - "args": [ - { - "name": "index", - "type": "u8" - } - ] - }, - { - "name": "sell_exact_in", - "docs": [ - "Use the given amount of base tokens to sell for quote tokens.", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `amount_in` - Amount of base token to sell", - "* `minimum_amount_out` - Minimum amount of quote token to receive (slippage protection)", - "* `share_fee_rate` - Fee rate for the share", - "" - ], - "discriminator": [ - 149, - 39, - 222, - 155, - 211, - 124, - 152, - 26 - ], - "accounts": [ - { - "name": "payer", - "docs": [ - "The user performing the swap operation", - "Must sign the transaction and pay for fees" - ], - "signer": true - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault operations", - "Generated using AUTH_SEED" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "global_config", - "docs": [ - "Global configuration account containing protocol-wide settings", - "Used to read protocol fee rates and curve type" - ] - }, - { - "name": "platform_config", - "docs": [ - "Platform configuration account containing platform-wide settings", - "Used to read platform fee rate" - ] - }, - { - "name": "pool_state", - "docs": [ - "The pool state account where the swap will be performed", - "Contains current pool parameters and balances" - ], - "writable": true - }, - { - "name": "user_base_token", - "docs": [ - "The user's token account for base tokens (tokens being bought)", - "Will receive the output tokens after the swap" - ], - "writable": true - }, - { - "name": "user_quote_token", - "docs": [ - "The user's token account for quote tokens (tokens being sold)", - "Will be debited for the input amount" - ], - "writable": true - }, - { - "name": "base_vault", - "docs": [ - "The pool's vault for base tokens", - "Will be debited to send tokens to the user" - ], - "writable": true - }, - { - "name": "quote_vault", - "docs": [ - "The pool's vault for quote tokens", - "Will receive the input tokens from the user" - ], - "writable": true - }, - { - "name": "base_token_mint", - "docs": [ - "The mint of the base token", - "Used for transfer fee calculations if applicable" - ] - }, - { - "name": "quote_token_mint", - "docs": [ - "The mint of the quote token" - ] - }, - { - "name": "base_token_program", - "docs": [ - "SPL Token program for base token transfers" - ] - }, - { - "name": "quote_token_program", - "docs": [ - "SPL Token program for quote token transfers" - ], - "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": "minimum_amount_out", - "type": "u64" - }, - { - "name": "share_fee_rate", - "type": "u64" - } - ] - }, - { - "name": "sell_exact_out", - "docs": [ - "Sell base tokens for the given amount of quote tokens.", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `amount_out` - Amount of quote token to receive", - "* `maximum_amount_in` - Maximum amount of base token to purchase (slippage protection)", - "* `share_fee_rate` - Fee rate for the share", - "" - ], - "discriminator": [ - 95, - 200, - 71, - 34, - 8, - 9, - 11, - 166 - ], - "accounts": [ - { - "name": "payer", - "docs": [ - "The user performing the swap operation", - "Must sign the transaction and pay for fees" - ], - "signer": true - }, - { - "name": "authority", - "docs": [ - "PDA that acts as the authority for pool vault operations", - "Generated using AUTH_SEED" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 97, - 117, - 108, - 116, - 95, - 97, - 117, - 116, - 104, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "global_config", - "docs": [ - "Global configuration account containing protocol-wide settings", - "Used to read protocol fee rates and curve type" - ] - }, - { - "name": "platform_config", - "docs": [ - "Platform configuration account containing platform-wide settings", - "Used to read platform fee rate" - ] - }, - { - "name": "pool_state", - "docs": [ - "The pool state account where the swap will be performed", - "Contains current pool parameters and balances" - ], - "writable": true - }, - { - "name": "user_base_token", - "docs": [ - "The user's token account for base tokens (tokens being bought)", - "Will receive the output tokens after the swap" - ], - "writable": true - }, - { - "name": "user_quote_token", - "docs": [ - "The user's token account for quote tokens (tokens being sold)", - "Will be debited for the input amount" - ], - "writable": true - }, - { - "name": "base_vault", - "docs": [ - "The pool's vault for base tokens", - "Will be debited to send tokens to the user" - ], - "writable": true - }, - { - "name": "quote_vault", - "docs": [ - "The pool's vault for quote tokens", - "Will receive the input tokens from the user" - ], - "writable": true - }, - { - "name": "base_token_mint", - "docs": [ - "The mint of the base token", - "Used for transfer fee calculations if applicable" - ] - }, - { - "name": "quote_token_mint", - "docs": [ - "The mint of the quote token" - ] - }, - { - "name": "base_token_program", - "docs": [ - "SPL Token program for base token transfers" - ] - }, - { - "name": "quote_token_program", - "docs": [ - "SPL Token program for quote token transfers" - ], - "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_out", - "type": "u64" - }, - { - "name": "maximum_amount_in", - "type": "u64" - }, - { - "name": "share_fee_rate", - "type": "u64" - } - ] - }, - { - "name": "update_config", - "docs": [ - "Updates configuration parameters", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `param` - Parameter to update:", - "- 0: Update trade_fee_rate", - "- 1: Update fee owner", - "* `value` - New value for the selected parameter", - "" - ], - "discriminator": [ - 29, - 158, - 252, - 191, - 10, - 83, - 219, - 99 - ], - "accounts": [ - { - "name": "owner", - "docs": [ - "The global config owner or admin" - ], - "signer": true, - "address": "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - }, - { - "name": "global_config", - "docs": [ - "Global config account to be changed" - ], - "writable": true - } - ], - "args": [ - { - "name": "param", - "type": "u8" - }, - { - "name": "value", - "type": "u64" - } - ] - }, - { - "name": "update_platform_config", - "docs": [ - "Update platform config", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `param` - Parameter to update", - "" - ], - "discriminator": [ - 195, - 60, - 76, - 129, - 146, - 45, - 67, - 143 - ], - "accounts": [ - { - "name": "platform_admin", - "docs": [ - "The account paying for the initialization costs" - ], - "signer": true - }, - { - "name": "platform_config", - "docs": [ - "Platform config account to be changed" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 108, - 97, - 116, - 102, - 111, - 114, - 109, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "platform_admin" - } - ] - } - } - ], - "args": [ - { - "name": "param", - "type": { - "defined": { - "name": "PlatformConfigParam" - } - } - } - ] - }, - { - "name": "update_platform_curve_param", - "docs": [ - "Update platform launch param", - "# Arguments", - "", - "* `ctx` - The context of accounts", - "* `bonding_curve_param` - Parameter to update", - "" - ], - "discriminator": [ - 138, - 144, - 138, - 250, - 220, - 128, - 4, - 57 - ], - "accounts": [ - { - "name": "platform_admin", - "docs": [ - "The account paying for the initialization costs" - ], - "writable": true, - "signer": true - }, - { - "name": "platform_config", - "docs": [ - "Platform config account to be changed" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 108, - 97, - 116, - 102, - 111, - 114, - 109, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "platform_admin" - } - ] - } - }, - { - "name": "global_config", - "docs": [ - "Global configuration account containing protocol-wide settings", - "Includes settings like quote token mint and fee parameters" - ] - }, - { - "name": "system_program", - "docs": [ - "System program for lamport transfers" - ], - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "index", - "type": "u8" - }, - { - "name": "bonding_curve_param", - "type": { - "defined": { - "name": "BondingCurveParam" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "GlobalConfig", - "discriminator": [ - 149, - 8, - 156, - 202, - 160, - 252, - 176, - 217 - ] - }, - { - "name": "PlatformConfig", - "discriminator": [ - 160, - 78, - 128, - 0, - 248, - 83, - 230, - 160 - ] - }, - { - "name": "PoolState", - "discriminator": [ - 247, - 237, - 227, - 245, - 215, - 195, - 222, - 70 - ] - }, - { - "name": "VestingRecord", - "discriminator": [ - 106, - 243, - 221, - 205, - 230, - 126, - 85, - 83 - ] - } - ], - "events": [ - { - "name": "ClaimVestedEvent", - "discriminator": [ - 21, - 194, - 114, - 87, - 120, - 211, - 226, - 32 - ] - }, - { - "name": "CreateVestingEvent", - "discriminator": [ - 150, - 152, - 11, - 179, - 52, - 210, - 191, - 125 - ] - }, - { - "name": "PoolCreateEvent", - "discriminator": [ - 151, - 215, - 226, - 9, - 118, - 161, - 115, - 174 - ] - }, - { - "name": "TradeEvent", - "discriminator": [ - 189, - 219, - 127, - 211, - 78, - 230, - 97, - 238 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "NotApproved", - "msg": "Not approved" - }, - { - "code": 6001, - "name": "InvalidOwner", - "msg": "Input account owner is not the program address" - }, - { - "code": 6002, - "name": "InvalidInput", - "msg": "InvalidInput" - }, - { - "code": 6003, - "name": "InputNotMatchCurveConfig", - "msg": "The input params are not match with curve type in config" - }, - { - "code": 6004, - "name": "ExceededSlippage", - "msg": "Exceeds desired slippage limit" - }, - { - "code": 6005, - "name": "PoolFunding", - "msg": "Pool funding" - }, - { - "code": 6006, - "name": "PoolMigrated", - "msg": "Pool migrated" - }, - { - "code": 6007, - "name": "MigrateTypeNotMatch", - "msg": "Migrate type not match" - }, - { - "code": 6008, - "name": "MathOverflow", - "msg": "Math overflow" - }, - { - "code": 6009, - "name": "NoAssetsToCollect", - "msg": "No assets to collect" - }, - { - "code": 6010, - "name": "VestingRatioTooHigh", - "msg": "Vesting ratio too high" - }, - { - "code": 6011, - "name": "VestingSettingEnded", - "msg": "Vesting setting ended" - }, - { - "code": 6012, - "name": "VestingNotStarted", - "msg": "Vesting not started" - }, - { - "code": 6013, - "name": "NoVestingSchedule", - "msg": "No vesting schedule" - }, - { - "code": 6014, - "name": "InvalidPlatformInfo", - "msg": "The platform info input is invalid" - }, - { - "code": 6015, - "name": "PoolNotMigrated", - "msg": "Pool not migrated" - }, - { - "code": 6016, - "name": "InvalidCpSwapConfig", - "msg": "The input cp swap config account is invalid" - }, - { - "code": 6017, - "name": "NoSupportExtension", - "msg": "No support extension" - }, - { - "code": 6018, - "name": "NotEnoughRemainingAccounts", - "msg": "Not enough remaining accounts" - }, - { - "code": 6019, - "name": "TransferFeeCalculateNotMatch", - "msg": "TransferFee calculate not match" - }, - { - "code": 6020, - "name": "CurveParamIsNotExist", - "msg": "Curve param is not exist" - } - ], - "types": [ - { - "name": "AmmCreatorFeeOn", - "docs": [ - "migrate to cpmm, creator fee on quote token or both token" - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "QuoteToken" - }, - { - "name": "BothToken" - } - ] - } - }, - { - "name": "BondingCurveParam", - "type": { - "kind": "struct", - "fields": [ - { - "name": "migrate_type", - "docs": [ - "Migrate to AMM or CpSwap, 0: amm, 1: cpswap,", - "Neither 0 nor 1: invalid" - ], - "type": "u8" - }, - { - "name": "migrate_cpmm_fee_on", - "docs": [ - "The migrate fee on, 0 means fee on the quote token, 1 means fee on both token", - "Neither 0 nor 1: invalid" - ], - "type": "u8" - }, - { - "name": "supply", - "docs": [ - "The supply of the token,", - "0: invalid" - ], - "type": "u64" - }, - { - "name": "total_base_sell", - "docs": [ - "The total base sell of the token", - "0: invalid" - ], - "type": "u64" - }, - { - "name": "total_quote_fund_raising", - "docs": [ - "The total quote fund raising of the token", - "0: invalid" - ], - "type": "u64" - }, - { - "name": "total_locked_amount", - "docs": [ - "total amount of tokens to be unlocked", - "u64::MAX: invalid" - ], - "type": "u64" - }, - { - "name": "cliff_period", - "docs": [ - "Waiting time in seconds before unlocking after fundraising ends", - "u64::MAX: invalid" - ], - "type": "u64" - }, - { - "name": "unlock_period", - "docs": [ - "Unlocking period in seconds", - "u64::MAX: invalid" - ], - "type": "u64" - } - ] - } - }, - { - "name": "ClaimVestedEvent", - "docs": [ - "Emitted when vesting token claimed by beneficiary" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_state", - "type": "pubkey" - }, - { - "name": "beneficiary", - "type": "pubkey" - }, - { - "name": "claim_amount", - "type": "u64" - } - ] - } - }, - { - "name": "ConstantCurve", - "type": { - "kind": "struct", - "fields": [ - { - "name": "supply", - "type": "u64" - }, - { - "name": "total_base_sell", - "type": "u64" - }, - { - "name": "total_quote_fund_raising", - "type": "u64" - }, - { - "name": "migrate_type", - "type": "u8" - } - ] - } - }, - { - "name": "CreateVestingEvent", - "docs": [ - "Emitted when vest_account created" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_state", - "type": "pubkey" - }, - { - "name": "beneficiary", - "type": "pubkey" - }, - { - "name": "share_amount", - "type": "u64" - } - ] - } - }, - { - "name": "CurveParams", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Constant", - "fields": [ - { - "name": "data", - "type": { - "defined": { - "name": "ConstantCurve" - } - } - } - ] - }, - { - "name": "Fixed", - "fields": [ - { - "name": "data", - "type": { - "defined": { - "name": "FixedCurve" - } - } - } - ] - }, - { - "name": "Linear", - "fields": [ - { - "name": "data", - "type": { - "defined": { - "name": "LinearCurve" - } - } - } - ] - } - ] - } - }, - { - "name": "FixedCurve", - "type": { - "kind": "struct", - "fields": [ - { - "name": "supply", - "type": "u64" - }, - { - "name": "total_quote_fund_raising", - "type": "u64" - }, - { - "name": "migrate_type", - "type": "u8" - } - ] - } - }, - { - "name": "GlobalConfig", - "docs": [ - "Holds the current owner of the factory" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "epoch", - "docs": [ - "Account update epoch" - ], - "type": "u64" - }, - { - "name": "curve_type", - "docs": [ - "0: Constant Product Curve", - "1: Fixed Price Curve", - "2: Linear Price Curve" - ], - "type": "u8" - }, - { - "name": "index", - "docs": [ - "Config index" - ], - "type": "u16" - }, - { - "name": "migrate_fee", - "docs": [ - "The fee of migrate to amm" - ], - "type": "u64" - }, - { - "name": "trade_fee_rate", - "docs": [ - "The trade fee rate, denominated in hundredths of a bip (10^-6)" - ], - "type": "u64" - }, - { - "name": "max_share_fee_rate", - "docs": [ - "The maximum share fee rate, denominated in hundredths of a bip (10^-6)" - ], - "type": "u64" - }, - { - "name": "min_base_supply", - "docs": [ - "The minimum base supply, the value without decimals" - ], - "type": "u64" - }, - { - "name": "max_lock_rate", - "docs": [ - "The maximum lock rate, denominated in hundredths of a bip (10^-6)" - ], - "type": "u64" - }, - { - "name": "min_base_sell_rate", - "docs": [ - "The minimum base sell rate, denominated in hundredths of a bip (10^-6)" - ], - "type": "u64" - }, - { - "name": "min_base_migrate_rate", - "docs": [ - "The minimum base migrate rate, denominated in hundredths of a bip (10^-6)" - ], - "type": "u64" - }, - { - "name": "min_quote_fund_raising", - "docs": [ - "The minimum quote fund raising, the value with decimals" - ], - "type": "u64" - }, - { - "name": "quote_mint", - "docs": [ - "Mint information for quote token" - ], - "type": "pubkey" - }, - { - "name": "protocol_fee_owner", - "docs": [ - "Protocol Fee owner" - ], - "type": "pubkey" - }, - { - "name": "migrate_fee_owner", - "docs": [ - "Migrate Fee owner" - ], - "type": "pubkey" - }, - { - "name": "migrate_to_amm_wallet", - "docs": [ - "Migrate to amm control wallet" - ], - "type": "pubkey" - }, - { - "name": "migrate_to_cpswap_wallet", - "docs": [ - "Migrate to cpswap wallet" - ], - "type": "pubkey" - }, - { - "name": "padding", - "docs": [ - "padding for future updates" - ], - "type": { - "array": [ - "u64", - 16 - ] - } - } - ] - } - }, - { - "name": "LinearCurve", - "type": { - "kind": "struct", - "fields": [ - { - "name": "supply", - "type": "u64" - }, - { - "name": "total_quote_fund_raising", - "type": "u64" - }, - { - "name": "migrate_type", - "type": "u8" - } - ] - } - }, - { - "name": "MigrateNftInfo", - "docs": [ - "Represents the parameters for initializing a platform config account(Only support MigrateType::CPSWAP)", - "# Fields", - "* `platform_scale` - Scale of the platform liquidity quantity rights will be converted into NFT", - "* `creator_scale` - Scale of the token creator liquidity quantity rights will be converted into NFT", - "* `burn_scale` - Scale of liquidity directly to burn", - "", - "* platform_scale + creator_scale + burn_scale = RATE_DENOMINATOR_VALUE" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "platform_scale", - "type": "u64" - }, - { - "name": "creator_scale", - "type": "u64" - }, - { - "name": "burn_scale", - "type": "u64" - } - ] - } - }, - { - "name": "MintParams", - "docs": [ - "Represents the parameters for initializing a new token mint", - "# Fields", - "* `decimals` - Number of decimal places for the token", - "* `name` - Name of the token", - "* `symbol` - Symbol/ticker of the token", - "* `uri` - URI pointing to token metadata" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "decimals", - "type": "u8" - }, - { - "name": "name", - "type": "string" - }, - { - "name": "symbol", - "type": "string" - }, - { - "name": "uri", - "type": "string" - } - ] - } - }, - { - "name": "PlatformConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "epoch", - "docs": [ - "The epoch for update interval" - ], - "type": "u64" - }, - { - "name": "platform_fee_wallet", - "docs": [ - "The platform fee wallet" - ], - "type": "pubkey" - }, - { - "name": "platform_nft_wallet", - "docs": [ - "The platform nft wallet to receive the platform NFT after migration if platform_scale is not 0(Only support MigrateType::CPSWAP)" - ], - "type": "pubkey" - }, - { - "name": "platform_scale", - "docs": [ - "Scale of the platform liquidity quantity rights will be converted into NFT(Only support MigrateType::CPSWAP)" - ], - "type": "u64" - }, - { - "name": "creator_scale", - "docs": [ - "Scale of the token creator liquidity quantity rights will be converted into NFT(Only support MigrateType::CPSWAP)" - ], - "type": "u64" - }, - { - "name": "burn_scale", - "docs": [ - "Scale of liquidity directly to burn" - ], - "type": "u64" - }, - { - "name": "fee_rate", - "docs": [ - "The platform fee rate" - ], - "type": "u64" - }, - { - "name": "name", - "docs": [ - "The platform name" - ], - "type": { - "array": [ - "u8", - 64 - ] - } - }, - { - "name": "web", - "docs": [ - "The platform website" - ], - "type": { - "array": [ - "u8", - 256 - ] - } - }, - { - "name": "img", - "docs": [ - "The platform img link" - ], - "type": { - "array": [ - "u8", - 256 - ] - } - }, - { - "name": "cpswap_config", - "docs": [ - "The platform specifies the trade fee rate after migration to cp swap" - ], - "type": "pubkey" - }, - { - "name": "creator_fee_rate", - "docs": [ - "Creator fee rate" - ], - "type": "u64" - }, - { - "name": "transfer_fee_extension_auth", - "docs": [ - "If the base token belongs to token2022, then you can choose to support the transferfeeConfig extension, which includes permissions such as `transfer_fee_config_authority`` and `withdraw_withheld_authority`.", - "When initializing mint, `withdraw_withheld_authority` and `transfer_fee_config_authority` both belongs to the contract.", - "Once the token is migrated to AMM, the authorities will be reset to this value" - ], - "type": "pubkey" - }, - { - "name": "padding", - "docs": [ - "padding for future updates" - ], - "type": { - "array": [ - "u8", - 180 - ] - } - }, - { - "name": "curve_params", - "docs": [ - "The parameters for launching the pool" - ], - "type": { - "vec": { - "defined": { - "name": "PlatformCurveParam" - } - } - } - } - ] - } - }, - { - "name": "PlatformConfigInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "fee_wallet", - "type": "pubkey" - }, - { - "name": "nft_wallet", - "type": "pubkey" - }, - { - "name": "migrate_nft_info", - "type": { - "defined": { - "name": "MigrateNftInfo" - } - } - }, - { - "name": "fee_rate", - "type": "u64" - }, - { - "name": "name", - "type": "string" - }, - { - "name": "web", - "type": "string" - }, - { - "name": "img", - "type": "string" - }, - { - "name": "transfer_fee_extension_auth", - "type": "pubkey" - }, - { - "name": "creator_fee_rate", - "type": "u64" - } - ] - } - }, - { - "name": "PlatformConfigParam", - "type": { - "kind": "enum", - "variants": [ - { - "name": "FeeWallet", - "fields": [ - "pubkey" - ] - }, - { - "name": "NFTWallet", - "fields": [ - "pubkey" - ] - }, - { - "name": "MigrateNftInfo", - "fields": [ - { - "defined": { - "name": "MigrateNftInfo" - } - } - ] - }, - { - "name": "FeeRate", - "fields": [ - "u64" - ] - }, - { - "name": "Name", - "fields": [ - "string" - ] - }, - { - "name": "Web", - "fields": [ - "string" - ] - }, - { - "name": "Img", - "fields": [ - "string" - ] - }, - { - "name": "CpSwapConfig" - }, - { - "name": "AllInfo", - "fields": [ - { - "defined": { - "name": "PlatformConfigInfo" - } - } - ] - } - ] - } - }, - { - "name": "PlatformCurveParam", - "type": { - "kind": "struct", - "fields": [ - { - "name": "epoch", - "docs": [ - "The epoch for update interval, 0 means not update" - ], - "type": "u64" - }, - { - "name": "index", - "docs": [ - "The curve params index" - ], - "type": "u8" - }, - { - "name": "global_config", - "docs": [ - "The global config address" - ], - "type": "pubkey" - }, - { - "name": "bonding_curve_param", - "docs": [ - "bonding curve param" - ], - "type": { - "defined": { - "name": "BondingCurveParam" - } - } - }, - { - "name": "padding", - "docs": [ - "padding for future updates" - ], - "type": { - "array": [ - "u64", - 50 - ] - } - } - ] - } - }, - { - "name": "PlatformParams", - "docs": [ - "Represents the parameters for initializing a platform config account", - "# Fields", - "* `migrate_nft_info` - The platform configures liquidity info during migration(Only support MigrateType::CPSWAP)", - "* `fee_rate` - Fee rate of the platform", - "* `name` - Name of the platform", - "* `web` - Website of the platform", - "* `img` - Image link of the platform", - "/// * `creator_fee_rate` - The fee rate charged by the creator for each transaction." - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "migrate_nft_info", - "type": { - "defined": { - "name": "MigrateNftInfo" - } - } - }, - { - "name": "fee_rate", - "type": "u64" - }, - { - "name": "name", - "type": "string" - }, - { - "name": "web", - "type": "string" - }, - { - "name": "img", - "type": "string" - }, - { - "name": "creator_fee_rate", - "type": "u64" - } - ] - } - }, - { - "name": "PoolCreateEvent", - "docs": [ - "Emitted when pool created" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_state", - "type": "pubkey" - }, - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "config", - "type": "pubkey" - }, - { - "name": "base_mint_param", - "type": { - "defined": { - "name": "MintParams" - } - } - }, - { - "name": "curve_param", - "type": { - "defined": { - "name": "CurveParams" - } - } - }, - { - "name": "vesting_param", - "type": { - "defined": { - "name": "VestingParams" - } - } - }, - { - "name": "amm_fee_on", - "type": { - "defined": { - "name": "AmmCreatorFeeOn" - } - } - } - ] - } - }, - { - "name": "PoolState", - "docs": [ - "Represents the state of a trading pool in the protocol", - "Stores all essential information about pool balances, fees, and configuration" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "epoch", - "docs": [ - "Account update epoch" - ], - "type": "u64" - }, - { - "name": "auth_bump", - "docs": [ - "Bump seed used for PDA address derivation" - ], - "type": "u8" - }, - { - "name": "status", - "docs": [ - "Current status of the pool", - "* 0: Pool is funding", - "* 1: Pool funding is end, waiting for migration", - "* 2: Pool migration is done" - ], - "type": "u8" - }, - { - "name": "base_decimals", - "docs": [ - "Decimals of the pool base token" - ], - "type": "u8" - }, - { - "name": "quote_decimals", - "docs": [ - "Decimals of the pool quote token" - ], - "type": "u8" - }, - { - "name": "migrate_type", - "docs": [ - "Migrate to AMM or CpSwap, 0: amm, 1: cpswap" - ], - "type": "u8" - }, - { - "name": "supply", - "docs": [ - "Supply of the pool base token" - ], - "type": "u64" - }, - { - "name": "total_base_sell", - "docs": [ - "Total sell amount of the base token" - ], - "type": "u64" - }, - { - "name": "virtual_base", - "docs": [ - "For different curves, virtual_base and virtual_quote have different meanings", - "For constant product curve, virtual_base and virtual_quote are virtual liquidity, virtual_quote/virtual_base is the initial price", - "For linear price curve, virtual_base is the price slope parameter a, virtual_quote has no effect", - "For fixed price curve, virtual_quote/virtual_base is the initial price" - ], - "type": "u64" - }, - { - "name": "virtual_quote", - "type": "u64" - }, - { - "name": "real_base", - "docs": [ - "Actual base token amount in the pool", - "Represents the real tokens available for trading" - ], - "type": "u64" - }, - { - "name": "real_quote", - "docs": [ - "Actual quote token amount in the pool", - "Represents the real tokens available for trading" - ], - "type": "u64" - }, - { - "name": "total_quote_fund_raising", - "docs": [ - "The total quote fund raising of the pool" - ], - "type": "u64" - }, - { - "name": "quote_protocol_fee", - "docs": [ - "Accumulated trading fees in quote tokens", - "Can be collected by the protocol fee owner" - ], - "type": "u64" - }, - { - "name": "platform_fee", - "docs": [ - "Accumulated platform fees in quote tokens", - "Can be collected by the platform wallet stored in platform config" - ], - "type": "u64" - }, - { - "name": "migrate_fee", - "docs": [ - "The fee of migrate to amm" - ], - "type": "u64" - }, - { - "name": "vesting_schedule", - "docs": [ - "Vesting schedule for the base token" - ], - "type": { - "defined": { - "name": "VestingSchedule" - } - } - }, - { - "name": "global_config", - "docs": [ - "Public key of the global configuration account", - "Contains protocol-wide settings this pool adheres to" - ], - "type": "pubkey" - }, - { - "name": "platform_config", - "docs": [ - "Public key of the platform configuration account", - "Contains platform-wide settings this pool adheres to" - ], - "type": "pubkey" - }, - { - "name": "base_mint", - "docs": [ - "Public key of the base mint address" - ], - "type": "pubkey" - }, - { - "name": "quote_mint", - "docs": [ - "Public key of the quote mint address" - ], - "type": "pubkey" - }, - { - "name": "base_vault", - "docs": [ - "Public key of the base token vault", - "Holds the actual base tokens owned by the pool" - ], - "type": "pubkey" - }, - { - "name": "quote_vault", - "docs": [ - "Public key of the quote token vault", - "Holds the actual quote tokens owned by the pool" - ], - "type": "pubkey" - }, - { - "name": "creator", - "docs": [ - "The creator of base token" - ], - "type": "pubkey" - }, - { - "name": "token_program_flag", - "docs": [ - "token program bits", - "bit0: base token program flag", - "0: spl_token_program", - "1: token_program_2022", - "", - "bit1: quote token program flag", - "0: spl_token_program", - "1: token_program_2022" - ], - "type": "u8" - }, - { - "name": "amm_creator_fee_on", - "docs": [ - "migrate to cpmm, creator fee on quote token or both token" - ], - "type": { - "defined": { - "name": "AmmCreatorFeeOn" - } - } - }, - { - "name": "padding", - "docs": [ - "padding for future updates" - ], - "type": { - "array": [ - "u8", - 62 - ] - } - } - ] - } - }, - { - "name": "PoolStatus", - "docs": [ - "Represents the different states a pool can be in", - "* Fund - Initial state where pool is accepting funds", - "* Migrate - Pool funding has ended and waiting for migration", - "* Trade - Pool migration is complete and amm trading is enabled" - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "Fund" - }, - { - "name": "Migrate" - }, - { - "name": "Trade" - } - ] - } - }, - { - "name": "TradeDirection", - "docs": [ - "Specifies the direction of a trade in the bonding curve", - "This is important because curves can treat tokens differently through weights or offsets" - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "Buy" - }, - { - "name": "Sell" - } - ] - } - }, - { - "name": "TradeEvent", - "docs": [ - "Emitted when trade process" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool_state", - "type": "pubkey" - }, - { - "name": "total_base_sell", - "type": "u64" - }, - { - "name": "virtual_base", - "type": "u64" - }, - { - "name": "virtual_quote", - "type": "u64" - }, - { - "name": "real_base_before", - "type": "u64" - }, - { - "name": "real_quote_before", - "type": "u64" - }, - { - "name": "real_base_after", - "type": "u64" - }, - { - "name": "real_quote_after", - "type": "u64" - }, - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "amount_out", - "type": "u64" - }, - { - "name": "protocol_fee", - "type": "u64" - }, - { - "name": "platform_fee", - "type": "u64" - }, - { - "name": "creator_fee", - "type": "u64" - }, - { - "name": "share_fee", - "type": "u64" - }, - { - "name": "trade_direction", - "type": { - "defined": { - "name": "TradeDirection" - } - } - }, - { - "name": "pool_status", - "type": { - "defined": { - "name": "PoolStatus" - } - } - }, - { - "name": "exact_in", - "type": "bool" - } - ] - } - }, - { - "name": "TransferFeeExtensionParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "transfer_fee_basis_points", - "docs": [ - "denominator is 10000, currently, this value cannot exceed 5%, which is 500." - ], - "type": "u16" - }, - { - "name": "maximum_fee", - "docs": [ - "Maximum fee on each transfers, the value must exceed supply * transfer_fee_basis_points / 10000" - ], - "type": "u64" - } - ] - } - }, - { - "name": "VestingParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "total_locked_amount", - "type": "u64" - }, - { - "name": "cliff_period", - "type": "u64" - }, - { - "name": "unlock_period", - "type": "u64" - } - ] - } - }, - { - "name": "VestingRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "epoch", - "docs": [ - "Account update epoch" - ], - "type": "u64" - }, - { - "name": "pool", - "docs": [ - "The pool state account" - ], - "type": "pubkey" - }, - { - "name": "beneficiary", - "docs": [ - "The beneficiary of the vesting account" - ], - "type": "pubkey" - }, - { - "name": "claimed_amount", - "docs": [ - "The amount of tokens claimed" - ], - "type": "u64" - }, - { - "name": "token_share_amount", - "docs": [ - "The share amount of the token to be vested" - ], - "type": "u64" - }, - { - "name": "padding", - "docs": [ - "padding for future updates" - ], - "type": { - "array": [ - "u64", - 8 - ] - } - } - ] - } - }, - { - "name": "VestingSchedule", - "type": { - "kind": "struct", - "fields": [ - { - "name": "total_locked_amount", - "type": "u64" - }, - { - "name": "cliff_period", - "type": "u64" - }, - { - "name": "unlock_period", - "type": "u64" - }, - { - "name": "start_time", - "type": "u64" - }, - { - "name": "allocated_share_amount", - "docs": [ - "Total allocated share amount of the base token, not greater than total_locked_amount" - ], - "type": "u64" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/crates/raydium-launchpad-parser/proto/raydium_launchpad.proto b/crates/raydium-launchpad-parser/proto/raydium_launchpad.proto deleted file mode 100644 index 738f9ff4..00000000 --- a/crates/raydium-launchpad-parser/proto/raydium_launchpad.proto +++ /dev/null @@ -1,854 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.raydium_launchpad; - -message CurveParamsConstant { - ConstantCurve data = 1; -} - -message CurveParamsFixed { - FixedCurve data = 1; -} - -message CurveParamsLinear { - LinearCurve data = 1; -} - -message PlatformConfigParamFeeWallet { - string field_0 = 1; -} - -message PlatformConfigParamNFTWallet { - string field_0 = 1; -} - -message PlatformConfigParamMigrateNftInfo { - MigrateNftInfo field_0 = 1; -} - -message PlatformConfigParamFeeRate { - uint64 field_0 = 1; -} - -message PlatformConfigParamName { - string field_0 = 1; -} - -message PlatformConfigParamWeb { - string field_0 = 1; -} - -message PlatformConfigParamImg { - string field_0 = 1; -} - -message PlatformConfigParamCpSwapConfig { } - -message PlatformConfigParamAllInfo { - PlatformConfigInfo field_0 = 1; -} - -message BuyExactInIx { - BuyExactInIxAccounts accounts = 1; - BuyExactInIxData data = 2; -} - -message BuyExactOutIx { - BuyExactOutIxAccounts accounts = 1; - BuyExactOutIxData data = 2; -} - -message ClaimCreatorFeeIx { - ClaimCreatorFeeIxAccounts accounts = 1; -} - -message ClaimPlatformFeeIx { - ClaimPlatformFeeIxAccounts accounts = 1; -} - -message ClaimPlatformFeeFromVaultIx { - ClaimPlatformFeeFromVaultIxAccounts accounts = 1; -} - -message ClaimVestedTokenIx { - ClaimVestedTokenIxAccounts accounts = 1; -} - -message CollectFeeIx { - CollectFeeIxAccounts accounts = 1; -} - -message CollectMigrateFeeIx { - CollectMigrateFeeIxAccounts accounts = 1; -} - -message CreateConfigIx { - CreateConfigIxAccounts accounts = 1; - CreateConfigIxData data = 2; -} - -message CreatePlatformConfigIx { - CreatePlatformConfigIxAccounts accounts = 1; - CreatePlatformConfigIxData data = 2; -} - -message CreateVestingAccountIx { - CreateVestingAccountIxAccounts accounts = 1; - CreateVestingAccountIxData data = 2; -} - -message InitializeIx { - InitializeIxAccounts accounts = 1; - InitializeIxData data = 2; -} - -message InitializeV2Ix { - InitializeV2IxAccounts accounts = 1; - InitializeV2IxData data = 2; -} - -message InitializeWithToken2022Ix { - InitializeWithToken2022IxAccounts accounts = 1; - InitializeWithToken2022IxData data = 2; -} - -message MigrateToAmmIx { - MigrateToAmmIxAccounts accounts = 1; - MigrateToAmmIxData data = 2; -} - -message MigrateToCpswapIx { - MigrateToCpswapIxAccounts accounts = 1; -} - -message RemovePlatformCurveParamIx { - RemovePlatformCurveParamIxAccounts accounts = 1; - RemovePlatformCurveParamIxData data = 2; -} - -message SellExactInIx { - SellExactInIxAccounts accounts = 1; - SellExactInIxData data = 2; -} - -message SellExactOutIx { - SellExactOutIxAccounts accounts = 1; - SellExactOutIxData data = 2; -} - -message UpdateConfigIx { - UpdateConfigIxAccounts accounts = 1; - UpdateConfigIxData data = 2; -} - -message UpdatePlatformConfigIx { - UpdatePlatformConfigIxAccounts accounts = 1; - UpdatePlatformConfigIxData data = 2; -} - -message UpdatePlatformCurveParamIx { - UpdatePlatformCurveParamIxAccounts accounts = 1; - UpdatePlatformCurveParamIxData data = 2; -} - - -enum AmmCreatorFeeOn { - AmmCreatorFeeOnQuoteToken = 0; - AmmCreatorFeeOnBothToken = 1; -} - -message BondingCurveParam { - uint32 migrate_type = 1; - uint32 migrate_cpmm_fee_on = 2; - uint64 supply = 3; - uint64 total_base_sell = 4; - uint64 total_quote_fund_raising = 5; - uint64 total_locked_amount = 6; - uint64 cliff_period = 7; - uint64 unlock_period = 8; -} - -message ClaimVestedEvent { - string pool_state = 1; - string beneficiary = 2; - uint64 claim_amount = 3; -} - -message ConstantCurve { - uint64 supply = 1; - uint64 total_base_sell = 2; - uint64 total_quote_fund_raising = 3; - uint32 migrate_type = 4; -} - -message CreateVestingEvent { - string pool_state = 1; - string beneficiary = 2; - uint64 share_amount = 3; -} - -message CurveParams { - oneof variant{ - CurveParamsConstant constant = 1; - CurveParamsFixed fixed = 2; - CurveParamsLinear linear = 3; - } -} - -message FixedCurve { - uint64 supply = 1; - uint64 total_quote_fund_raising = 2; - uint32 migrate_type = 3; -} - -message LinearCurve { - uint64 supply = 1; - uint64 total_quote_fund_raising = 2; - uint32 migrate_type = 3; -} - -message MigrateNftInfo { - uint64 platform_scale = 1; - uint64 creator_scale = 2; - uint64 burn_scale = 3; -} - -message MintParams { - uint32 decimals = 1; - string name = 2; - string symbol = 3; - string uri = 4; -} - -message PlatformConfigInfo { - string fee_wallet = 1; - string nft_wallet = 2; - MigrateNftInfo migrate_nft_info = 3; - uint64 fee_rate = 4; - string name = 5; - string web = 6; - string img = 7; - string transfer_fee_extension_auth = 8; - uint64 creator_fee_rate = 9; -} - -message PlatformConfigParam { - oneof variant{ - PlatformConfigParamFeeWallet fee_wallet = 1; - PlatformConfigParamNFTWallet n_f_t_wallet = 2; - PlatformConfigParamMigrateNftInfo migrate_nft_info = 3; - PlatformConfigParamFeeRate fee_rate = 4; - PlatformConfigParamName name = 5; - PlatformConfigParamWeb web = 6; - PlatformConfigParamImg img = 7; - PlatformConfigParamCpSwapConfig cp_swap_config = 8; - PlatformConfigParamAllInfo all_info = 9; - } -} - -message PlatformCurveParam { - uint64 epoch = 1; - uint32 index = 2; - string global_config = 3; - BondingCurveParam bonding_curve_param = 4; - repeated uint64 padding = 5; -} - -message PoolCreateEvent { - string pool_state = 1; - string creator = 2; - string config = 3; - MintParams base_mint_param = 4; - CurveParams curve_param = 5; - VestingParams vesting_param = 6; - AmmCreatorFeeOn amm_fee_on = 7; -} - -enum PoolStatus { - PoolStatusFund = 0; - PoolStatusMigrate = 1; - PoolStatusTrade = 2; -} - -enum TradeDirection { - TradeDirectionBuy = 0; - TradeDirectionSell = 1; -} - -message TradeEvent { - string pool_state = 1; - uint64 total_base_sell = 2; - uint64 virtual_base = 3; - uint64 virtual_quote = 4; - uint64 real_base_before = 5; - uint64 real_quote_before = 6; - uint64 real_base_after = 7; - uint64 real_quote_after = 8; - uint64 amount_in = 9; - uint64 amount_out = 10; - uint64 protocol_fee = 11; - uint64 platform_fee = 12; - uint64 creator_fee = 13; - uint64 share_fee = 14; - TradeDirection trade_direction = 15; - PoolStatus pool_status = 16; - bool exact_in = 17; -} - -message TransferFeeExtensionParams { - uint32 transfer_fee_basis_points = 1; - uint64 maximum_fee = 2; -} - -message VestingParams { - uint64 total_locked_amount = 1; - uint64 cliff_period = 2; - uint64 unlock_period = 3; -} - -message VestingSchedule { - uint64 total_locked_amount = 1; - uint64 cliff_period = 2; - uint64 unlock_period = 3; - uint64 start_time = 4; - uint64 allocated_share_amount = 5; -} - - -message GlobalConfig { - uint64 epoch = 1; - uint32 curve_type = 2; - uint32 index = 3; - uint64 migrate_fee = 4; - uint64 trade_fee_rate = 5; - uint64 max_share_fee_rate = 6; - uint64 min_base_supply = 7; - uint64 max_lock_rate = 8; - uint64 min_base_sell_rate = 9; - uint64 min_base_migrate_rate = 10; - uint64 min_quote_fund_raising = 11; - string quote_mint = 12; - string protocol_fee_owner = 13; - string migrate_fee_owner = 14; - string migrate_to_amm_wallet = 15; - string migrate_to_cpswap_wallet = 16; - repeated uint64 padding = 17; -} - -message PlatformConfig { - uint64 epoch = 1; - string platform_fee_wallet = 2; - string platform_nft_wallet = 3; - uint64 platform_scale = 4; - uint64 creator_scale = 5; - uint64 burn_scale = 6; - uint64 fee_rate = 7; - repeated uint32 name = 8; - repeated uint32 web = 9; - repeated uint32 img = 10; - string cpswap_config = 11; - uint64 creator_fee_rate = 12; - string transfer_fee_extension_auth = 13; - repeated uint32 padding = 14; - repeated PlatformCurveParam curve_params = 15; -} - -message PoolState { - uint64 epoch = 1; - uint32 auth_bump = 2; - uint32 status = 3; - uint32 base_decimals = 4; - uint32 quote_decimals = 5; - uint32 migrate_type = 6; - uint64 supply = 7; - uint64 total_base_sell = 8; - uint64 virtual_base = 9; - uint64 virtual_quote = 10; - uint64 real_base = 11; - uint64 real_quote = 12; - uint64 total_quote_fund_raising = 13; - uint64 quote_protocol_fee = 14; - uint64 platform_fee = 15; - uint64 migrate_fee = 16; - VestingSchedule vesting_schedule = 17; - string global_config = 18; - string platform_config = 19; - string base_mint = 20; - string quote_mint = 21; - string base_vault = 22; - string quote_vault = 23; - string creator = 24; - uint32 token_program_flag = 25; - AmmCreatorFeeOn amm_creator_fee_on = 26; - repeated uint32 padding = 27; -} - -message VestingRecord { - uint64 epoch = 1; - string pool = 2; - string beneficiary = 3; - uint64 claimed_amount = 4; - uint64 token_share_amount = 5; - repeated uint64 padding = 6; -} - - -message BuyExactInIxAccounts { - string payer = 1; - string authority = 2; - string global_config = 3; - string platform_config = 4; - string pool_state = 5; - string user_base_token = 6; - string user_quote_token = 7; - string base_vault = 8; - string quote_vault = 9; - string base_token_mint = 10; - string quote_token_mint = 11; - string base_token_program = 12; - string quote_token_program = 13; - string event_authority = 14; - string program = 15; -} - -message BuyExactInIxData { - uint64 amount_in = 1; - uint64 minimum_amount_out = 2; - uint64 share_fee_rate = 3; -} - -message BuyExactOutIxAccounts { - string payer = 1; - string authority = 2; - string global_config = 3; - string platform_config = 4; - string pool_state = 5; - string user_base_token = 6; - string user_quote_token = 7; - string base_vault = 8; - string quote_vault = 9; - string base_token_mint = 10; - string quote_token_mint = 11; - string base_token_program = 12; - string quote_token_program = 13; - string event_authority = 14; - string program = 15; -} - -message BuyExactOutIxData { - uint64 amount_out = 1; - uint64 maximum_amount_in = 2; - uint64 share_fee_rate = 3; -} - -message ClaimCreatorFeeIxAccounts { - string creator = 1; - string fee_vault_authority = 2; - string creator_fee_vault = 3; - string recipient_token_account = 4; - string quote_mint = 5; - string token_program = 6; - string system_program = 7; - string associated_token_program = 8; -} - - -message ClaimPlatformFeeIxAccounts { - string platform_fee_wallet = 1; - string authority = 2; - string pool_state = 3; - string platform_config = 4; - string quote_vault = 5; - string recipient_token_account = 6; - string quote_mint = 7; - string token_program = 8; - string system_program = 9; - string associated_token_program = 10; -} - - -message ClaimPlatformFeeFromVaultIxAccounts { - string platform_fee_wallet = 1; - string fee_vault_authority = 2; - string platform_config = 3; - string platform_fee_vault = 4; - string recipient_token_account = 5; - string quote_mint = 6; - string token_program = 7; - string system_program = 8; - string associated_token_program = 9; -} - - -message ClaimVestedTokenIxAccounts { - string beneficiary = 1; - string authority = 2; - string pool_state = 3; - string vesting_record = 4; - string base_vault = 5; - string user_base_token = 6; - string base_token_mint = 7; - string base_token_program = 8; - string system_program = 9; - string associated_token_program = 10; -} - - -message CollectFeeIxAccounts { - string owner = 1; - string authority = 2; - string pool_state = 3; - string global_config = 4; - string quote_vault = 5; - string quote_mint = 6; - string recipient_token_account = 7; - string token_program = 8; -} - - -message CollectMigrateFeeIxAccounts { - string owner = 1; - string authority = 2; - string pool_state = 3; - string global_config = 4; - string quote_vault = 5; - string quote_mint = 6; - string recipient_token_account = 7; - string token_program = 8; -} - - -message CreateConfigIxAccounts { - string owner = 1; - string global_config = 2; - string quote_token_mint = 3; - string protocol_fee_owner = 4; - string migrate_fee_owner = 5; - string migrate_to_amm_wallet = 6; - string migrate_to_cpswap_wallet = 7; - string system_program = 8; -} - -message CreateConfigIxData { - uint32 curve_type = 1; - uint32 index = 2; - uint64 migrate_fee = 3; - uint64 trade_fee_rate = 4; -} - -message CreatePlatformConfigIxAccounts { - string platform_admin = 1; - string platform_fee_wallet = 2; - string platform_nft_wallet = 3; - string platform_config = 4; - string cpswap_config = 5; - string system_program = 6; - string transfer_fee_extension_authority = 7; -} - -message CreatePlatformConfigIxData { - MigrateNftInfo migrate_nft_info = 1; - uint64 fee_rate = 2; - string name = 3; - string web = 4; - string img = 5; - uint64 creator_fee_rate = 6; -} - -message CreateVestingAccountIxAccounts { - string creator = 1; - string beneficiary = 2; - string pool_state = 3; - string vesting_record = 4; - string system_program = 5; -} - -message CreateVestingAccountIxData { - uint64 share_amount = 1; -} - -message InitializeIxAccounts { - string payer = 1; - string creator = 2; - string global_config = 3; - string platform_config = 4; - string authority = 5; - string pool_state = 6; - string base_mint = 7; - string quote_mint = 8; - string base_vault = 9; - string quote_vault = 10; - string metadata_account = 11; - string base_token_program = 12; - string quote_token_program = 13; - string metadata_program = 14; - string system_program = 15; - string rent_program = 16; - string event_authority = 17; - string program = 18; -} - -message InitializeIxData { - MintParams base_mint_param = 1; - CurveParams curve_param = 2; - VestingParams vesting_param = 3; -} - -message InitializeV2IxAccounts { - string payer = 1; - string creator = 2; - string global_config = 3; - string platform_config = 4; - string authority = 5; - string pool_state = 6; - string base_mint = 7; - string quote_mint = 8; - string base_vault = 9; - string quote_vault = 10; - string metadata_account = 11; - string base_token_program = 12; - string quote_token_program = 13; - string metadata_program = 14; - string system_program = 15; - string rent_program = 16; - string event_authority = 17; - string program = 18; -} - -message InitializeV2IxData { - MintParams base_mint_param = 1; - CurveParams curve_param = 2; - VestingParams vesting_param = 3; - AmmCreatorFeeOn amm_fee_on = 4; -} - -message InitializeWithToken2022IxAccounts { - string payer = 1; - string creator = 2; - string global_config = 3; - string platform_config = 4; - string authority = 5; - string pool_state = 6; - string base_mint = 7; - string quote_mint = 8; - string base_vault = 9; - string quote_vault = 10; - string base_token_program = 11; - string quote_token_program = 12; - string system_program = 13; - string event_authority = 14; - string program = 15; -} - -message InitializeWithToken2022IxData { - MintParams base_mint_param = 1; - CurveParams curve_param = 2; - VestingParams vesting_param = 3; - AmmCreatorFeeOn amm_fee_on = 4; - optional TransferFeeExtensionParams transfer_fee_extension_param = 5; -} - -message MigrateToAmmIxAccounts { - string payer = 1; - string base_mint = 2; - string quote_mint = 3; - string openbook_program = 4; - string market = 5; - string request_queue = 6; - string event_queue = 7; - string bids = 8; - string asks = 9; - string market_vault_signer = 10; - string market_base_vault = 11; - string market_quote_vault = 12; - string amm_program = 13; - string amm_pool = 14; - string amm_authority = 15; - string amm_open_orders = 16; - string amm_lp_mint = 17; - string amm_base_vault = 18; - string amm_quote_vault = 19; - string amm_target_orders = 20; - string amm_config = 21; - string amm_create_fee_destination = 22; - string authority = 23; - string pool_state = 24; - string global_config = 25; - string base_vault = 26; - string quote_vault = 27; - string pool_lp_token = 28; - string spl_token_program = 29; - string associated_token_program = 30; - string system_program = 31; - string rent_program = 32; -} - -message MigrateToAmmIxData { - uint64 base_lot_size = 1; - uint64 quote_lot_size = 2; - uint32 market_vault_signer_nonce = 3; -} - -message MigrateToCpswapIxAccounts { - string payer = 1; - string base_mint = 2; - string quote_mint = 3; - string platform_config = 4; - string cpswap_program = 5; - string cpswap_pool = 6; - string cpswap_authority = 7; - string cpswap_lp_mint = 8; - string cpswap_base_vault = 9; - string cpswap_quote_vault = 10; - string cpswap_config = 11; - string cpswap_create_pool_fee = 12; - string cpswap_observation = 13; - string lock_program = 14; - string lock_authority = 15; - string lock_lp_vault = 16; - string authority = 17; - string pool_state = 18; - string global_config = 19; - string base_vault = 20; - string quote_vault = 21; - string pool_lp_token = 22; - string base_token_program = 23; - string quote_token_program = 24; - string associated_token_program = 25; - string system_program = 26; - string rent_program = 27; - string metadata_program = 28; -} - - -message RemovePlatformCurveParamIxAccounts { - string platform_admin = 1; - string platform_config = 2; -} - -message RemovePlatformCurveParamIxData { - uint32 index = 1; -} - -message SellExactInIxAccounts { - string payer = 1; - string authority = 2; - string global_config = 3; - string platform_config = 4; - string pool_state = 5; - string user_base_token = 6; - string user_quote_token = 7; - string base_vault = 8; - string quote_vault = 9; - string base_token_mint = 10; - string quote_token_mint = 11; - string base_token_program = 12; - string quote_token_program = 13; - string event_authority = 14; - string program = 15; -} - -message SellExactInIxData { - uint64 amount_in = 1; - uint64 minimum_amount_out = 2; - uint64 share_fee_rate = 3; -} - -message SellExactOutIxAccounts { - string payer = 1; - string authority = 2; - string global_config = 3; - string platform_config = 4; - string pool_state = 5; - string user_base_token = 6; - string user_quote_token = 7; - string base_vault = 8; - string quote_vault = 9; - string base_token_mint = 10; - string quote_token_mint = 11; - string base_token_program = 12; - string quote_token_program = 13; - string event_authority = 14; - string program = 15; -} - -message SellExactOutIxData { - uint64 amount_out = 1; - uint64 maximum_amount_in = 2; - uint64 share_fee_rate = 3; -} - -message UpdateConfigIxAccounts { - string owner = 1; - string global_config = 2; -} - -message UpdateConfigIxData { - uint32 param = 1; - uint64 value = 2; -} - -message UpdatePlatformConfigIxAccounts { - string platform_admin = 1; - string platform_config = 2; -} - -message UpdatePlatformConfigIxData { - PlatformConfigParam param = 1; -} - -message UpdatePlatformCurveParamIxAccounts { - string platform_admin = 1; - string platform_config = 2; - string global_config = 3; - string system_program = 4; -} - -message UpdatePlatformCurveParamIxData { - uint32 index = 1; - BondingCurveParam bonding_curve_param = 2; -} - - -message ProgramState { - oneof state_oneof { - GlobalConfig global_config = 1; - PlatformConfig platform_config = 2; - PoolState pool_state = 3; - VestingRecord vesting_record = 4; - } -} - -message ProgramIxs { - oneof ix_oneof { - BuyExactInIx buy_exact_in = 1; - BuyExactOutIx buy_exact_out = 2; - ClaimCreatorFeeIx claim_creator_fee = 3; - ClaimPlatformFeeIx claim_platform_fee = 4; - ClaimPlatformFeeFromVaultIx claim_platform_fee_from_vault = 5; - ClaimVestedTokenIx claim_vested_token = 6; - CollectFeeIx collect_fee = 7; - CollectMigrateFeeIx collect_migrate_fee = 8; - CreateConfigIx create_config = 9; - CreatePlatformConfigIx create_platform_config = 10; - CreateVestingAccountIx create_vesting_account = 11; - InitializeIx initialize = 12; - InitializeV2Ix initialize_v2 = 13; - InitializeWithToken2022Ix initialize_with_token2022 = 14; - MigrateToAmmIx migrate_to_amm = 15; - MigrateToCpswapIx migrate_to_cpswap = 16; - RemovePlatformCurveParamIx remove_platform_curve_param = 17; - SellExactInIx sell_exact_in = 18; - SellExactOutIx sell_exact_out = 19; - UpdateConfigIx update_config = 20; - UpdatePlatformConfigIx update_platform_config = 21; - UpdatePlatformCurveParamIx update_platform_curve_param = 22; - } -} - diff --git a/crates/raydium-launchpad-parser/src/generated_parser/accounts_parser.rs b/crates/raydium-launchpad-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index e595937d..00000000 --- a/crates/raydium-launchpad-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,256 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{ - accounts::{GlobalConfig, PlatformConfig, PoolState, VestingRecord}, - deserialize_checked, ID, -}; - -/// RaydiumLaunchpad Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum RaydiumLaunchpadProgramState { - GlobalConfig(GlobalConfig), - PlatformConfig(PlatformConfig), - PoolState(PoolState), - VestingRecord(VestingRecord), -} - -impl RaydiumLaunchpadProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [149, 8, 156, 202, 160, 252, 176, 217] => { - Ok(RaydiumLaunchpadProgramState::GlobalConfig( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [160, 78, 128, 0, 248, 83, 230, 160] => { - Ok(RaydiumLaunchpadProgramState::PlatformConfig( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - [247, 237, 227, 245, 215, 195, 222, 70] => Ok(RaydiumLaunchpadProgramState::PoolState( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - [106, 243, 221, 205, 230, 126, 85, 83] => { - Ok(RaydiumLaunchpadProgramState::VestingRecord( - deserialize_checked(data_bytes, &acc_discriminator)?, - )) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = RaydiumLaunchpadProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "raydium_launchpad::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = RaydiumLaunchpadProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, GlobalConfig, RaydiumLaunchpadProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for GlobalConfig { - fn into_proto(self) -> proto_def::GlobalConfig { - proto_def::GlobalConfig { - epoch: self.epoch, - curve_type: self.curve_type.into(), - index: self.index.into(), - migrate_fee: self.migrate_fee, - trade_fee_rate: self.trade_fee_rate, - max_share_fee_rate: self.max_share_fee_rate, - min_base_supply: self.min_base_supply, - max_lock_rate: self.max_lock_rate, - min_base_sell_rate: self.min_base_sell_rate, - min_base_migrate_rate: self.min_base_migrate_rate, - min_quote_fund_raising: self.min_quote_fund_raising, - quote_mint: self.quote_mint.to_string(), - protocol_fee_owner: self.protocol_fee_owner.to_string(), - migrate_fee_owner: self.migrate_fee_owner.to_string(), - migrate_to_amm_wallet: self.migrate_to_amm_wallet.to_string(), - migrate_to_cpswap_wallet: self.migrate_to_cpswap_wallet.to_string(), - padding: self.padding.to_vec(), - } - } - } - use super::PlatformConfig; - impl IntoProto for PlatformConfig { - fn into_proto(self) -> proto_def::PlatformConfig { - proto_def::PlatformConfig { - epoch: self.epoch, - platform_fee_wallet: self.platform_fee_wallet.to_string(), - platform_nft_wallet: self.platform_nft_wallet.to_string(), - platform_scale: self.platform_scale, - creator_scale: self.creator_scale, - burn_scale: self.burn_scale, - fee_rate: self.fee_rate, - name: self.name.into_iter().map(|x| x.into()).collect(), - web: self.web.into_iter().map(|x| x.into()).collect(), - img: self.img.into_iter().map(|x| x.into()).collect(), - cpswap_config: self.cpswap_config.to_string(), - creator_fee_rate: self.creator_fee_rate, - transfer_fee_extension_auth: self.transfer_fee_extension_auth.to_string(), - padding: self.padding.into_iter().map(|x| x.into()).collect(), - curve_params: self - .curve_params - .into_iter() - .map(|x| x.into_proto()) - .collect(), - } - } - } - use super::PoolState; - impl IntoProto for PoolState { - fn into_proto(self) -> proto_def::PoolState { - proto_def::PoolState { - epoch: self.epoch, - auth_bump: self.auth_bump.into(), - status: self.status.into(), - base_decimals: self.base_decimals.into(), - quote_decimals: self.quote_decimals.into(), - migrate_type: self.migrate_type.into(), - supply: self.supply, - total_base_sell: self.total_base_sell, - virtual_base: self.virtual_base, - virtual_quote: self.virtual_quote, - real_base: self.real_base, - real_quote: self.real_quote, - total_quote_fund_raising: self.total_quote_fund_raising, - quote_protocol_fee: self.quote_protocol_fee, - platform_fee: self.platform_fee, - migrate_fee: self.migrate_fee, - vesting_schedule: Some(self.vesting_schedule.into_proto()), - global_config: self.global_config.to_string(), - platform_config: self.platform_config.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - creator: self.creator.to_string(), - token_program_flag: self.token_program_flag.into(), - amm_creator_fee_on: self.amm_creator_fee_on as i32, - padding: self.padding.into_iter().map(|x| x.into()).collect(), - } - } - } - use super::VestingRecord; - impl IntoProto for VestingRecord { - fn into_proto(self) -> proto_def::VestingRecord { - proto_def::VestingRecord { - epoch: self.epoch, - pool: self.pool.to_string(), - beneficiary: self.beneficiary.to_string(), - claimed_amount: self.claimed_amount, - token_share_amount: self.token_share_amount, - padding: self.padding.to_vec(), - } - } - } - - impl IntoProto for RaydiumLaunchpadProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - RaydiumLaunchpadProgramState::GlobalConfig(data) => { - proto_def::program_state::StateOneof::GlobalConfig(data.into_proto()) - }, - RaydiumLaunchpadProgramState::PlatformConfig(data) => { - proto_def::program_state::StateOneof::PlatformConfig(data.into_proto()) - }, - RaydiumLaunchpadProgramState::PoolState(data) => { - proto_def::program_state::StateOneof::PoolState(data.into_proto()) - }, - RaydiumLaunchpadProgramState::VestingRecord(data) => { - proto_def::program_state::StateOneof::VestingRecord(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/raydium-launchpad-parser/src/generated_parser/instructions_parser.rs b/crates/raydium-launchpad-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index 88ef9740..00000000 --- a/crates/raydium-launchpad-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,1499 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - BuyExactIn as BuyExactInIxAccounts, BuyExactInInstructionArgs as BuyExactInIxData, - BuyExactOut as BuyExactOutIxAccounts, BuyExactOutInstructionArgs as BuyExactOutIxData, - ClaimCreatorFee as ClaimCreatorFeeIxAccounts, - ClaimPlatformFee as ClaimPlatformFeeIxAccounts, - ClaimPlatformFeeFromVault as ClaimPlatformFeeFromVaultIxAccounts, - ClaimVestedToken as ClaimVestedTokenIxAccounts, CollectFee as CollectFeeIxAccounts, - CollectMigrateFee as CollectMigrateFeeIxAccounts, CreateConfig as CreateConfigIxAccounts, - CreateConfigInstructionArgs as CreateConfigIxData, - CreatePlatformConfig as CreatePlatformConfigIxAccounts, - CreatePlatformConfigInstructionArgs as CreatePlatformConfigIxData, - CreateVestingAccount as CreateVestingAccountIxAccounts, - CreateVestingAccountInstructionArgs as CreateVestingAccountIxData, - Initialize as InitializeIxAccounts, InitializeInstructionArgs as InitializeIxData, - InitializeV2 as InitializeV2IxAccounts, InitializeV2InstructionArgs as InitializeV2IxData, - InitializeWithToken2022 as InitializeWithToken2022IxAccounts, - InitializeWithToken2022InstructionArgs as InitializeWithToken2022IxData, - MigrateToAmm as MigrateToAmmIxAccounts, MigrateToAmmInstructionArgs as MigrateToAmmIxData, - MigrateToCpswap as MigrateToCpswapIxAccounts, - RemovePlatformCurveParam as RemovePlatformCurveParamIxAccounts, - RemovePlatformCurveParamInstructionArgs as RemovePlatformCurveParamIxData, - SellExactIn as SellExactInIxAccounts, SellExactInInstructionArgs as SellExactInIxData, - SellExactOut as SellExactOutIxAccounts, SellExactOutInstructionArgs as SellExactOutIxData, - UpdateConfig as UpdateConfigIxAccounts, UpdateConfigInstructionArgs as UpdateConfigIxData, - UpdatePlatformConfig as UpdatePlatformConfigIxAccounts, - UpdatePlatformConfigInstructionArgs as UpdatePlatformConfigIxData, - UpdatePlatformCurveParam as UpdatePlatformCurveParamIxAccounts, - UpdatePlatformCurveParamInstructionArgs as UpdatePlatformCurveParamIxData, - }, - ID, -}; - -/// RaydiumLaunchpad Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum RaydiumLaunchpadProgramIx { - BuyExactIn(BuyExactInIxAccounts, BuyExactInIxData), - BuyExactOut(BuyExactOutIxAccounts, BuyExactOutIxData), - ClaimCreatorFee(ClaimCreatorFeeIxAccounts), - ClaimPlatformFee(ClaimPlatformFeeIxAccounts), - ClaimPlatformFeeFromVault(ClaimPlatformFeeFromVaultIxAccounts), - ClaimVestedToken(ClaimVestedTokenIxAccounts), - CollectFee(CollectFeeIxAccounts), - CollectMigrateFee(CollectMigrateFeeIxAccounts), - CreateConfig(CreateConfigIxAccounts, CreateConfigIxData), - CreatePlatformConfig(CreatePlatformConfigIxAccounts, CreatePlatformConfigIxData), - CreateVestingAccount(CreateVestingAccountIxAccounts, CreateVestingAccountIxData), - Initialize(InitializeIxAccounts, InitializeIxData), - InitializeV2(InitializeV2IxAccounts, InitializeV2IxData), - InitializeWithToken2022( - InitializeWithToken2022IxAccounts, - InitializeWithToken2022IxData, - ), - MigrateToAmm(MigrateToAmmIxAccounts, MigrateToAmmIxData), - MigrateToCpswap(MigrateToCpswapIxAccounts), - RemovePlatformCurveParam( - RemovePlatformCurveParamIxAccounts, - RemovePlatformCurveParamIxData, - ), - SellExactIn(SellExactInIxAccounts, SellExactInIxData), - SellExactOut(SellExactOutIxAccounts, SellExactOutIxData), - UpdateConfig(UpdateConfigIxAccounts, UpdateConfigIxData), - UpdatePlatformConfig(UpdatePlatformConfigIxAccounts, UpdatePlatformConfigIxData), - UpdatePlatformCurveParam( - UpdatePlatformCurveParamIxAccounts, - UpdatePlatformCurveParamIxData, - ), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = RaydiumLaunchpadProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "RaydiumLaunchpad::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [250, 234, 13, 123, 213, 156, 19, 236] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = BuyExactInIxAccounts { - payer: next_account(accounts)?, - authority: next_account(accounts)?, - global_config: next_account(accounts)?, - platform_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - user_base_token: next_account(accounts)?, - user_quote_token: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - base_token_mint: next_account(accounts)?, - quote_token_mint: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: BuyExactInIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::BuyExactIn( - ix_accounts, - de_ix_data, - )) - }, - [24, 211, 116, 40, 105, 3, 153, 56] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = BuyExactOutIxAccounts { - payer: next_account(accounts)?, - authority: next_account(accounts)?, - global_config: next_account(accounts)?, - platform_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - user_base_token: next_account(accounts)?, - user_quote_token: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - base_token_mint: next_account(accounts)?, - quote_token_mint: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: BuyExactOutIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::BuyExactOut( - ix_accounts, - de_ix_data, - )) - }, - [26, 97, 138, 203, 132, 171, 141, 252] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimCreatorFeeIxAccounts { - creator: next_account(accounts)?, - fee_vault_authority: next_account(accounts)?, - creator_fee_vault: next_account(accounts)?, - recipient_token_account: next_account(accounts)?, - quote_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - Ok(RaydiumLaunchpadProgramIx::ClaimCreatorFee(ix_accounts)) - }, - [156, 39, 208, 135, 76, 237, 61, 72] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimPlatformFeeIxAccounts { - platform_fee_wallet: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - platform_config: next_account(accounts)?, - quote_vault: next_account(accounts)?, - recipient_token_account: next_account(accounts)?, - quote_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - Ok(RaydiumLaunchpadProgramIx::ClaimPlatformFee(ix_accounts)) - }, - [117, 241, 198, 168, 248, 218, 80, 29] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimPlatformFeeFromVaultIxAccounts { - platform_fee_wallet: next_account(accounts)?, - fee_vault_authority: next_account(accounts)?, - platform_config: next_account(accounts)?, - platform_fee_vault: next_account(accounts)?, - recipient_token_account: next_account(accounts)?, - quote_mint: next_account(accounts)?, - token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - Ok(RaydiumLaunchpadProgramIx::ClaimPlatformFeeFromVault( - ix_accounts, - )) - }, - [49, 33, 104, 30, 189, 157, 79, 35] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimVestedTokenIxAccounts { - beneficiary: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - vesting_record: next_account(accounts)?, - base_vault: next_account(accounts)?, - user_base_token: next_account(accounts)?, - base_token_mint: next_account(accounts)?, - base_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - }; - Ok(RaydiumLaunchpadProgramIx::ClaimVestedToken(ix_accounts)) - }, - [60, 173, 247, 103, 4, 93, 130, 48] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectFeeIxAccounts { - owner: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - global_config: next_account(accounts)?, - quote_vault: next_account(accounts)?, - quote_mint: next_account(accounts)?, - recipient_token_account: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(RaydiumLaunchpadProgramIx::CollectFee(ix_accounts)) - }, - [255, 186, 150, 223, 235, 118, 201, 186] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CollectMigrateFeeIxAccounts { - owner: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - global_config: next_account(accounts)?, - quote_vault: next_account(accounts)?, - quote_mint: next_account(accounts)?, - recipient_token_account: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - Ok(RaydiumLaunchpadProgramIx::CollectMigrateFee(ix_accounts)) - }, - [201, 207, 243, 114, 75, 111, 47, 189] => { - let expected_accounts_len = 8; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateConfigIxAccounts { - owner: next_account(accounts)?, - global_config: next_account(accounts)?, - quote_token_mint: next_account(accounts)?, - protocol_fee_owner: next_account(accounts)?, - migrate_fee_owner: next_account(accounts)?, - migrate_to_amm_wallet: next_account(accounts)?, - migrate_to_cpswap_wallet: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: CreateConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::CreateConfig( - ix_accounts, - de_ix_data, - )) - }, - [176, 90, 196, 175, 253, 113, 220, 20] => { - let expected_accounts_len = 7; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreatePlatformConfigIxAccounts { - platform_admin: next_account(accounts)?, - platform_fee_wallet: next_account(accounts)?, - platform_nft_wallet: next_account(accounts)?, - platform_config: next_account(accounts)?, - cpswap_config: next_account(accounts)?, - system_program: next_account(accounts)?, - transfer_fee_extension_authority: next_account(accounts)?, - }; - let de_ix_data: CreatePlatformConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::CreatePlatformConfig( - ix_accounts, - de_ix_data, - )) - }, - [129, 178, 2, 13, 217, 172, 230, 218] => { - let expected_accounts_len = 5; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateVestingAccountIxAccounts { - creator: next_account(accounts)?, - beneficiary: next_account(accounts)?, - pool_state: next_account(accounts)?, - vesting_record: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: CreateVestingAccountIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::CreateVestingAccount( - ix_accounts, - de_ix_data, - )) - }, - [175, 175, 109, 31, 13, 152, 155, 237] => { - let expected_accounts_len = 18; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeIxAccounts { - payer: next_account(accounts)?, - creator: next_account(accounts)?, - global_config: next_account(accounts)?, - platform_config: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - metadata_account: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - metadata_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::Initialize( - ix_accounts, - de_ix_data, - )) - }, - [67, 153, 175, 39, 218, 16, 38, 32] => { - let expected_accounts_len = 18; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeV2IxAccounts { - payer: next_account(accounts)?, - creator: next_account(accounts)?, - global_config: next_account(accounts)?, - platform_config: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - metadata_account: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - metadata_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeV2IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::InitializeV2( - ix_accounts, - de_ix_data, - )) - }, - [37, 190, 126, 222, 44, 154, 171, 17] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeWithToken2022IxAccounts { - payer: next_account(accounts)?, - creator: next_account(accounts)?, - global_config: next_account(accounts)?, - platform_config: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: InitializeWithToken2022IxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::InitializeWithToken2022( - ix_accounts, - de_ix_data, - )) - }, - [207, 82, 192, 145, 254, 207, 145, 223] => { - let expected_accounts_len = 32; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrateToAmmIxAccounts { - payer: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - openbook_program: next_account(accounts)?, - market: next_account(accounts)?, - request_queue: next_account(accounts)?, - event_queue: next_account(accounts)?, - bids: next_account(accounts)?, - asks: next_account(accounts)?, - market_vault_signer: next_account(accounts)?, - market_base_vault: next_account(accounts)?, - market_quote_vault: next_account(accounts)?, - amm_program: next_account(accounts)?, - amm_pool: next_account(accounts)?, - amm_authority: next_account(accounts)?, - amm_open_orders: next_account(accounts)?, - amm_lp_mint: next_account(accounts)?, - amm_base_vault: next_account(accounts)?, - amm_quote_vault: next_account(accounts)?, - amm_target_orders: next_account(accounts)?, - amm_config: next_account(accounts)?, - amm_create_fee_destination: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - global_config: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - pool_lp_token: next_account(accounts)?, - spl_token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent_program: next_account(accounts)?, - }; - let de_ix_data: MigrateToAmmIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::MigrateToAmm( - ix_accounts, - de_ix_data, - )) - }, - [136, 92, 200, 103, 28, 218, 144, 140] => { - let expected_accounts_len = 28; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = MigrateToCpswapIxAccounts { - payer: next_account(accounts)?, - base_mint: next_account(accounts)?, - quote_mint: next_account(accounts)?, - platform_config: next_account(accounts)?, - cpswap_program: next_account(accounts)?, - cpswap_pool: next_account(accounts)?, - cpswap_authority: next_account(accounts)?, - cpswap_lp_mint: next_account(accounts)?, - cpswap_base_vault: next_account(accounts)?, - cpswap_quote_vault: next_account(accounts)?, - cpswap_config: next_account(accounts)?, - cpswap_create_pool_fee: next_account(accounts)?, - cpswap_observation: next_account(accounts)?, - lock_program: next_account(accounts)?, - lock_authority: next_account(accounts)?, - lock_lp_vault: next_account(accounts)?, - authority: next_account(accounts)?, - pool_state: next_account(accounts)?, - global_config: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - pool_lp_token: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent_program: next_account(accounts)?, - metadata_program: next_account(accounts)?, - }; - Ok(RaydiumLaunchpadProgramIx::MigrateToCpswap(ix_accounts)) - }, - [27, 30, 62, 169, 93, 224, 24, 145] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = RemovePlatformCurveParamIxAccounts { - platform_admin: next_account(accounts)?, - platform_config: next_account(accounts)?, - }; - let de_ix_data: RemovePlatformCurveParamIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::RemovePlatformCurveParam( - ix_accounts, - de_ix_data, - )) - }, - [149, 39, 222, 155, 211, 124, 152, 26] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SellExactInIxAccounts { - payer: next_account(accounts)?, - authority: next_account(accounts)?, - global_config: next_account(accounts)?, - platform_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - user_base_token: next_account(accounts)?, - user_quote_token: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - base_token_mint: next_account(accounts)?, - quote_token_mint: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SellExactInIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::SellExactIn( - ix_accounts, - de_ix_data, - )) - }, - [95, 200, 71, 34, 8, 9, 11, 166] => { - let expected_accounts_len = 15; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SellExactOutIxAccounts { - payer: next_account(accounts)?, - authority: next_account(accounts)?, - global_config: next_account(accounts)?, - platform_config: next_account(accounts)?, - pool_state: next_account(accounts)?, - user_base_token: next_account(accounts)?, - user_quote_token: next_account(accounts)?, - base_vault: next_account(accounts)?, - quote_vault: next_account(accounts)?, - base_token_mint: next_account(accounts)?, - quote_token_mint: next_account(accounts)?, - base_token_program: next_account(accounts)?, - quote_token_program: next_account(accounts)?, - event_authority: next_account(accounts)?, - program: next_account(accounts)?, - }; - let de_ix_data: SellExactOutIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::SellExactOut( - ix_accounts, - de_ix_data, - )) - }, - [29, 158, 252, 191, 10, 83, 219, 99] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdateConfigIxAccounts { - owner: next_account(accounts)?, - global_config: next_account(accounts)?, - }; - let de_ix_data: UpdateConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::UpdateConfig( - ix_accounts, - de_ix_data, - )) - }, - [195, 60, 76, 129, 146, 45, 67, 143] => { - let expected_accounts_len = 2; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdatePlatformConfigIxAccounts { - platform_admin: next_account(accounts)?, - platform_config: next_account(accounts)?, - }; - let de_ix_data: UpdatePlatformConfigIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::UpdatePlatformConfig( - ix_accounts, - de_ix_data, - )) - }, - [138, 144, 138, 250, 220, 128, 4, 57] => { - let expected_accounts_len = 4; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdatePlatformCurveParamIxAccounts { - platform_admin: next_account(accounts)?, - platform_config: next_account(accounts)?, - global_config: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - let de_ix_data: UpdatePlatformCurveParamIxData = - deserialize_checked(ix_data, &ix_discriminator)?; - Ok(RaydiumLaunchpadProgramIx::UpdatePlatformCurveParam( - ix_accounts, - de_ix_data, - )) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{BuyExactInIxAccounts, InstructionParser, RaydiumLaunchpadProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for BuyExactInIxAccounts { - fn into_proto(self) -> proto_def::BuyExactInIxAccounts { - proto_def::BuyExactInIxAccounts { - payer: self.payer.to_string(), - authority: self.authority.to_string(), - global_config: self.global_config.to_string(), - platform_config: self.platform_config.to_string(), - pool_state: self.pool_state.to_string(), - user_base_token: self.user_base_token.to_string(), - user_quote_token: self.user_quote_token.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - base_token_mint: self.base_token_mint.to_string(), - quote_token_mint: self.quote_token_mint.to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::BuyExactInIxData; - impl IntoProto for BuyExactInIxData { - fn into_proto(self) -> proto_def::BuyExactInIxData { - proto_def::BuyExactInIxData { - amount_in: self.amount_in, - minimum_amount_out: self.minimum_amount_out, - share_fee_rate: self.share_fee_rate, - } - } - } - use super::BuyExactOutIxAccounts; - impl IntoProto for BuyExactOutIxAccounts { - fn into_proto(self) -> proto_def::BuyExactOutIxAccounts { - proto_def::BuyExactOutIxAccounts { - payer: self.payer.to_string(), - authority: self.authority.to_string(), - global_config: self.global_config.to_string(), - platform_config: self.platform_config.to_string(), - pool_state: self.pool_state.to_string(), - user_base_token: self.user_base_token.to_string(), - user_quote_token: self.user_quote_token.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - base_token_mint: self.base_token_mint.to_string(), - quote_token_mint: self.quote_token_mint.to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::BuyExactOutIxData; - impl IntoProto for BuyExactOutIxData { - fn into_proto(self) -> proto_def::BuyExactOutIxData { - proto_def::BuyExactOutIxData { - amount_out: self.amount_out, - maximum_amount_in: self.maximum_amount_in, - share_fee_rate: self.share_fee_rate, - } - } - } - use super::ClaimCreatorFeeIxAccounts; - impl IntoProto for ClaimCreatorFeeIxAccounts { - fn into_proto(self) -> proto_def::ClaimCreatorFeeIxAccounts { - proto_def::ClaimCreatorFeeIxAccounts { - creator: self.creator.to_string(), - fee_vault_authority: self.fee_vault_authority.to_string(), - creator_fee_vault: self.creator_fee_vault.to_string(), - recipient_token_account: self.recipient_token_account.to_string(), - quote_mint: self.quote_mint.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::ClaimPlatformFeeIxAccounts; - impl IntoProto for ClaimPlatformFeeIxAccounts { - fn into_proto(self) -> proto_def::ClaimPlatformFeeIxAccounts { - proto_def::ClaimPlatformFeeIxAccounts { - platform_fee_wallet: self.platform_fee_wallet.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - platform_config: self.platform_config.to_string(), - quote_vault: self.quote_vault.to_string(), - recipient_token_account: self.recipient_token_account.to_string(), - quote_mint: self.quote_mint.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::ClaimPlatformFeeFromVaultIxAccounts; - impl IntoProto - for ClaimPlatformFeeFromVaultIxAccounts - { - fn into_proto(self) -> proto_def::ClaimPlatformFeeFromVaultIxAccounts { - proto_def::ClaimPlatformFeeFromVaultIxAccounts { - platform_fee_wallet: self.platform_fee_wallet.to_string(), - fee_vault_authority: self.fee_vault_authority.to_string(), - platform_config: self.platform_config.to_string(), - platform_fee_vault: self.platform_fee_vault.to_string(), - recipient_token_account: self.recipient_token_account.to_string(), - quote_mint: self.quote_mint.to_string(), - token_program: self.token_program.to_string(), - system_program: self.system_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::ClaimVestedTokenIxAccounts; - impl IntoProto for ClaimVestedTokenIxAccounts { - fn into_proto(self) -> proto_def::ClaimVestedTokenIxAccounts { - proto_def::ClaimVestedTokenIxAccounts { - beneficiary: self.beneficiary.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - vesting_record: self.vesting_record.to_string(), - base_vault: self.base_vault.to_string(), - user_base_token: self.user_base_token.to_string(), - base_token_mint: self.base_token_mint.to_string(), - base_token_program: self.base_token_program.to_string(), - system_program: self.system_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - } - } - } - use super::CollectFeeIxAccounts; - impl IntoProto for CollectFeeIxAccounts { - fn into_proto(self) -> proto_def::CollectFeeIxAccounts { - proto_def::CollectFeeIxAccounts { - owner: self.owner.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - global_config: self.global_config.to_string(), - quote_vault: self.quote_vault.to_string(), - quote_mint: self.quote_mint.to_string(), - recipient_token_account: self.recipient_token_account.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::CollectMigrateFeeIxAccounts; - impl IntoProto for CollectMigrateFeeIxAccounts { - fn into_proto(self) -> proto_def::CollectMigrateFeeIxAccounts { - proto_def::CollectMigrateFeeIxAccounts { - owner: self.owner.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - global_config: self.global_config.to_string(), - quote_vault: self.quote_vault.to_string(), - quote_mint: self.quote_mint.to_string(), - recipient_token_account: self.recipient_token_account.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::CreateConfigIxAccounts; - impl IntoProto for CreateConfigIxAccounts { - fn into_proto(self) -> proto_def::CreateConfigIxAccounts { - proto_def::CreateConfigIxAccounts { - owner: self.owner.to_string(), - global_config: self.global_config.to_string(), - quote_token_mint: self.quote_token_mint.to_string(), - protocol_fee_owner: self.protocol_fee_owner.to_string(), - migrate_fee_owner: self.migrate_fee_owner.to_string(), - migrate_to_amm_wallet: self.migrate_to_amm_wallet.to_string(), - migrate_to_cpswap_wallet: self.migrate_to_cpswap_wallet.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreateConfigIxData; - impl IntoProto for CreateConfigIxData { - fn into_proto(self) -> proto_def::CreateConfigIxData { - proto_def::CreateConfigIxData { - curve_type: self.curve_type.into(), - index: self.index.into(), - migrate_fee: self.migrate_fee, - trade_fee_rate: self.trade_fee_rate, - } - } - } - use super::CreatePlatformConfigIxAccounts; - impl IntoProto for CreatePlatformConfigIxAccounts { - fn into_proto(self) -> proto_def::CreatePlatformConfigIxAccounts { - proto_def::CreatePlatformConfigIxAccounts { - platform_admin: self.platform_admin.to_string(), - platform_fee_wallet: self.platform_fee_wallet.to_string(), - platform_nft_wallet: self.platform_nft_wallet.to_string(), - platform_config: self.platform_config.to_string(), - cpswap_config: self.cpswap_config.to_string(), - system_program: self.system_program.to_string(), - transfer_fee_extension_authority: self.transfer_fee_extension_authority.to_string(), - } - } - } - use super::CreatePlatformConfigIxData; - impl IntoProto for CreatePlatformConfigIxData { - fn into_proto(self) -> proto_def::CreatePlatformConfigIxData { - proto_def::CreatePlatformConfigIxData { - migrate_nft_info: Some(self.migrate_nft_info.into_proto()), - fee_rate: self.fee_rate, - name: self.name, - web: self.web, - img: self.img, - creator_fee_rate: self.creator_fee_rate, - } - } - } - use super::CreateVestingAccountIxAccounts; - impl IntoProto for CreateVestingAccountIxAccounts { - fn into_proto(self) -> proto_def::CreateVestingAccountIxAccounts { - proto_def::CreateVestingAccountIxAccounts { - creator: self.creator.to_string(), - beneficiary: self.beneficiary.to_string(), - pool_state: self.pool_state.to_string(), - vesting_record: self.vesting_record.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::CreateVestingAccountIxData; - impl IntoProto for CreateVestingAccountIxData { - fn into_proto(self) -> proto_def::CreateVestingAccountIxData { - proto_def::CreateVestingAccountIxData { - share_amount: self.share_amount, - } - } - } - use super::InitializeIxAccounts; - impl IntoProto for InitializeIxAccounts { - fn into_proto(self) -> proto_def::InitializeIxAccounts { - proto_def::InitializeIxAccounts { - payer: self.payer.to_string(), - creator: self.creator.to_string(), - global_config: self.global_config.to_string(), - platform_config: self.platform_config.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - metadata_account: self.metadata_account.to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - metadata_program: self.metadata_program.to_string(), - system_program: self.system_program.to_string(), - rent_program: self.rent_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeIxData; - impl IntoProto for InitializeIxData { - fn into_proto(self) -> proto_def::InitializeIxData { - proto_def::InitializeIxData { - base_mint_param: Some(self.base_mint_param.into_proto()), - curve_param: Some(self.curve_param.into_proto()), - vesting_param: Some(self.vesting_param.into_proto()), - } - } - } - use super::InitializeV2IxAccounts; - impl IntoProto for InitializeV2IxAccounts { - fn into_proto(self) -> proto_def::InitializeV2IxAccounts { - proto_def::InitializeV2IxAccounts { - payer: self.payer.to_string(), - creator: self.creator.to_string(), - global_config: self.global_config.to_string(), - platform_config: self.platform_config.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - metadata_account: self.metadata_account.to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - metadata_program: self.metadata_program.to_string(), - system_program: self.system_program.to_string(), - rent_program: self.rent_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeV2IxData; - impl IntoProto for InitializeV2IxData { - fn into_proto(self) -> proto_def::InitializeV2IxData { - proto_def::InitializeV2IxData { - base_mint_param: Some(self.base_mint_param.into_proto()), - curve_param: Some(self.curve_param.into_proto()), - vesting_param: Some(self.vesting_param.into_proto()), - amm_fee_on: self.amm_fee_on as i32, - } - } - } - use super::InitializeWithToken2022IxAccounts; - impl IntoProto for InitializeWithToken2022IxAccounts { - fn into_proto(self) -> proto_def::InitializeWithToken2022IxAccounts { - proto_def::InitializeWithToken2022IxAccounts { - payer: self.payer.to_string(), - creator: self.creator.to_string(), - global_config: self.global_config.to_string(), - platform_config: self.platform_config.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - system_program: self.system_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::InitializeWithToken2022IxData; - impl IntoProto for InitializeWithToken2022IxData { - fn into_proto(self) -> proto_def::InitializeWithToken2022IxData { - proto_def::InitializeWithToken2022IxData { - base_mint_param: Some(self.base_mint_param.into_proto()), - curve_param: Some(self.curve_param.into_proto()), - vesting_param: Some(self.vesting_param.into_proto()), - amm_fee_on: self.amm_fee_on as i32, - transfer_fee_extension_param: self - .transfer_fee_extension_param - .map(|x| x.into_proto()), - } - } - } - use super::MigrateToAmmIxAccounts; - impl IntoProto for MigrateToAmmIxAccounts { - fn into_proto(self) -> proto_def::MigrateToAmmIxAccounts { - proto_def::MigrateToAmmIxAccounts { - payer: self.payer.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - openbook_program: self.openbook_program.to_string(), - market: self.market.to_string(), - request_queue: self.request_queue.to_string(), - event_queue: self.event_queue.to_string(), - bids: self.bids.to_string(), - asks: self.asks.to_string(), - market_vault_signer: self.market_vault_signer.to_string(), - market_base_vault: self.market_base_vault.to_string(), - market_quote_vault: self.market_quote_vault.to_string(), - amm_program: self.amm_program.to_string(), - amm_pool: self.amm_pool.to_string(), - amm_authority: self.amm_authority.to_string(), - amm_open_orders: self.amm_open_orders.to_string(), - amm_lp_mint: self.amm_lp_mint.to_string(), - amm_base_vault: self.amm_base_vault.to_string(), - amm_quote_vault: self.amm_quote_vault.to_string(), - amm_target_orders: self.amm_target_orders.to_string(), - amm_config: self.amm_config.to_string(), - amm_create_fee_destination: self.amm_create_fee_destination.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - global_config: self.global_config.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - pool_lp_token: self.pool_lp_token.to_string(), - spl_token_program: self.spl_token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - rent_program: self.rent_program.to_string(), - } - } - } - use super::MigrateToAmmIxData; - impl IntoProto for MigrateToAmmIxData { - fn into_proto(self) -> proto_def::MigrateToAmmIxData { - proto_def::MigrateToAmmIxData { - base_lot_size: self.base_lot_size, - quote_lot_size: self.quote_lot_size, - market_vault_signer_nonce: self.market_vault_signer_nonce.into(), - } - } - } - use super::MigrateToCpswapIxAccounts; - impl IntoProto for MigrateToCpswapIxAccounts { - fn into_proto(self) -> proto_def::MigrateToCpswapIxAccounts { - proto_def::MigrateToCpswapIxAccounts { - payer: self.payer.to_string(), - base_mint: self.base_mint.to_string(), - quote_mint: self.quote_mint.to_string(), - platform_config: self.platform_config.to_string(), - cpswap_program: self.cpswap_program.to_string(), - cpswap_pool: self.cpswap_pool.to_string(), - cpswap_authority: self.cpswap_authority.to_string(), - cpswap_lp_mint: self.cpswap_lp_mint.to_string(), - cpswap_base_vault: self.cpswap_base_vault.to_string(), - cpswap_quote_vault: self.cpswap_quote_vault.to_string(), - cpswap_config: self.cpswap_config.to_string(), - cpswap_create_pool_fee: self.cpswap_create_pool_fee.to_string(), - cpswap_observation: self.cpswap_observation.to_string(), - lock_program: self.lock_program.to_string(), - lock_authority: self.lock_authority.to_string(), - lock_lp_vault: self.lock_lp_vault.to_string(), - authority: self.authority.to_string(), - pool_state: self.pool_state.to_string(), - global_config: self.global_config.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - pool_lp_token: self.pool_lp_token.to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - rent_program: self.rent_program.to_string(), - metadata_program: self.metadata_program.to_string(), - } - } - } - use super::RemovePlatformCurveParamIxAccounts; - impl IntoProto - for RemovePlatformCurveParamIxAccounts - { - fn into_proto(self) -> proto_def::RemovePlatformCurveParamIxAccounts { - proto_def::RemovePlatformCurveParamIxAccounts { - platform_admin: self.platform_admin.to_string(), - platform_config: self.platform_config.to_string(), - } - } - } - use super::RemovePlatformCurveParamIxData; - impl IntoProto for RemovePlatformCurveParamIxData { - fn into_proto(self) -> proto_def::RemovePlatformCurveParamIxData { - proto_def::RemovePlatformCurveParamIxData { - index: self.index.into(), - } - } - } - use super::SellExactInIxAccounts; - impl IntoProto for SellExactInIxAccounts { - fn into_proto(self) -> proto_def::SellExactInIxAccounts { - proto_def::SellExactInIxAccounts { - payer: self.payer.to_string(), - authority: self.authority.to_string(), - global_config: self.global_config.to_string(), - platform_config: self.platform_config.to_string(), - pool_state: self.pool_state.to_string(), - user_base_token: self.user_base_token.to_string(), - user_quote_token: self.user_quote_token.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - base_token_mint: self.base_token_mint.to_string(), - quote_token_mint: self.quote_token_mint.to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SellExactInIxData; - impl IntoProto for SellExactInIxData { - fn into_proto(self) -> proto_def::SellExactInIxData { - proto_def::SellExactInIxData { - amount_in: self.amount_in, - minimum_amount_out: self.minimum_amount_out, - share_fee_rate: self.share_fee_rate, - } - } - } - use super::SellExactOutIxAccounts; - impl IntoProto for SellExactOutIxAccounts { - fn into_proto(self) -> proto_def::SellExactOutIxAccounts { - proto_def::SellExactOutIxAccounts { - payer: self.payer.to_string(), - authority: self.authority.to_string(), - global_config: self.global_config.to_string(), - platform_config: self.platform_config.to_string(), - pool_state: self.pool_state.to_string(), - user_base_token: self.user_base_token.to_string(), - user_quote_token: self.user_quote_token.to_string(), - base_vault: self.base_vault.to_string(), - quote_vault: self.quote_vault.to_string(), - base_token_mint: self.base_token_mint.to_string(), - quote_token_mint: self.quote_token_mint.to_string(), - base_token_program: self.base_token_program.to_string(), - quote_token_program: self.quote_token_program.to_string(), - event_authority: self.event_authority.to_string(), - program: self.program.to_string(), - } - } - } - use super::SellExactOutIxData; - impl IntoProto for SellExactOutIxData { - fn into_proto(self) -> proto_def::SellExactOutIxData { - proto_def::SellExactOutIxData { - amount_out: self.amount_out, - maximum_amount_in: self.maximum_amount_in, - share_fee_rate: self.share_fee_rate, - } - } - } - use super::UpdateConfigIxAccounts; - impl IntoProto for UpdateConfigIxAccounts { - fn into_proto(self) -> proto_def::UpdateConfigIxAccounts { - proto_def::UpdateConfigIxAccounts { - owner: self.owner.to_string(), - global_config: self.global_config.to_string(), - } - } - } - use super::UpdateConfigIxData; - impl IntoProto for UpdateConfigIxData { - fn into_proto(self) -> proto_def::UpdateConfigIxData { - proto_def::UpdateConfigIxData { - param: self.param.into(), - value: self.value, - } - } - } - use super::UpdatePlatformConfigIxAccounts; - impl IntoProto for UpdatePlatformConfigIxAccounts { - fn into_proto(self) -> proto_def::UpdatePlatformConfigIxAccounts { - proto_def::UpdatePlatformConfigIxAccounts { - platform_admin: self.platform_admin.to_string(), - platform_config: self.platform_config.to_string(), - } - } - } - use super::UpdatePlatformConfigIxData; - impl IntoProto for UpdatePlatformConfigIxData { - fn into_proto(self) -> proto_def::UpdatePlatformConfigIxData { - proto_def::UpdatePlatformConfigIxData { - param: Some(self.param.into_proto()), - } - } - } - use super::UpdatePlatformCurveParamIxAccounts; - impl IntoProto - for UpdatePlatformCurveParamIxAccounts - { - fn into_proto(self) -> proto_def::UpdatePlatformCurveParamIxAccounts { - proto_def::UpdatePlatformCurveParamIxAccounts { - platform_admin: self.platform_admin.to_string(), - platform_config: self.platform_config.to_string(), - global_config: self.global_config.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::UpdatePlatformCurveParamIxData; - impl IntoProto for UpdatePlatformCurveParamIxData { - fn into_proto(self) -> proto_def::UpdatePlatformCurveParamIxData { - proto_def::UpdatePlatformCurveParamIxData { - index: self.index.into(), - bonding_curve_param: Some(self.bonding_curve_param.into_proto()), - } - } - } - - impl IntoProto for RaydiumLaunchpadProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - RaydiumLaunchpadProgramIx::BuyExactIn(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::BuyExactIn( - proto_def::BuyExactInIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::BuyExactOut(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::BuyExactOut( - proto_def::BuyExactOutIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::ClaimCreatorFee(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimCreatorFee( - proto_def::ClaimCreatorFeeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::ClaimPlatformFee(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimPlatformFee( - proto_def::ClaimPlatformFeeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::ClaimPlatformFeeFromVault(acc) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimPlatformFeeFromVault( - proto_def::ClaimPlatformFeeFromVaultIx { - accounts: Some(acc.into_proto()), - }, - )), - } - }, - RaydiumLaunchpadProgramIx::ClaimVestedToken(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimVestedToken( - proto_def::ClaimVestedTokenIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::CollectFee(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectFee( - proto_def::CollectFeeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::CollectMigrateFee(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CollectMigrateFee( - proto_def::CollectMigrateFeeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::CreateConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateConfig( - proto_def::CreateConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::CreatePlatformConfig(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreatePlatformConfig( - proto_def::CreatePlatformConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - RaydiumLaunchpadProgramIx::CreateVestingAccount(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateVestingAccount( - proto_def::CreateVestingAccountIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - RaydiumLaunchpadProgramIx::Initialize(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Initialize( - proto_def::InitializeIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::InitializeV2(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeV2( - proto_def::InitializeV2Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::InitializeWithToken2022(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeWithToken2022( - proto_def::InitializeWithToken2022Ix { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - RaydiumLaunchpadProgramIx::MigrateToAmm(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::MigrateToAmm( - proto_def::MigrateToAmmIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::MigrateToCpswap(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::MigrateToCpswap( - proto_def::MigrateToCpswapIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::RemovePlatformCurveParam(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::RemovePlatformCurveParam( - proto_def::RemovePlatformCurveParamIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - RaydiumLaunchpadProgramIx::SellExactIn(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SellExactIn( - proto_def::SellExactInIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::SellExactOut(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::SellExactOut( - proto_def::SellExactOutIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::UpdateConfig(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdateConfig( - proto_def::UpdateConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - RaydiumLaunchpadProgramIx::UpdatePlatformConfig(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdatePlatformConfig( - proto_def::UpdatePlatformConfigIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - RaydiumLaunchpadProgramIx::UpdatePlatformCurveParam(acc, data) => { - proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdatePlatformCurveParam( - proto_def::UpdatePlatformCurveParamIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - } - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/raydium-launchpad-parser/src/generated_parser/mod.rs b/crates/raydium-launchpad-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/raydium-launchpad-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/raydium-launchpad-parser/src/generated_parser/proto_helpers.rs b/crates/raydium-launchpad-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index fa322da7..00000000 --- a/crates/raydium-launchpad-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,287 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::BondingCurveParam}; - impl IntoProto for BondingCurveParam { - fn into_proto(self) -> proto_def::BondingCurveParam { - proto_def::BondingCurveParam { - migrate_type: self.migrate_type.into(), - migrate_cpmm_fee_on: self.migrate_cpmm_fee_on.into(), - supply: self.supply, - total_base_sell: self.total_base_sell, - total_quote_fund_raising: self.total_quote_fund_raising, - total_locked_amount: self.total_locked_amount, - cliff_period: self.cliff_period, - unlock_period: self.unlock_period, - } - } - } - use crate::types::ClaimVestedEvent; - impl IntoProto for ClaimVestedEvent { - fn into_proto(self) -> proto_def::ClaimVestedEvent { - proto_def::ClaimVestedEvent { - pool_state: self.pool_state.to_string(), - beneficiary: self.beneficiary.to_string(), - claim_amount: self.claim_amount, - } - } - } - use crate::types::ConstantCurve; - impl IntoProto for ConstantCurve { - fn into_proto(self) -> proto_def::ConstantCurve { - proto_def::ConstantCurve { - supply: self.supply, - total_base_sell: self.total_base_sell, - total_quote_fund_raising: self.total_quote_fund_raising, - migrate_type: self.migrate_type.into(), - } - } - } - use crate::types::CreateVestingEvent; - impl IntoProto for CreateVestingEvent { - fn into_proto(self) -> proto_def::CreateVestingEvent { - proto_def::CreateVestingEvent { - pool_state: self.pool_state.to_string(), - beneficiary: self.beneficiary.to_string(), - share_amount: self.share_amount, - } - } - } - use crate::types::FixedCurve; - impl IntoProto for FixedCurve { - fn into_proto(self) -> proto_def::FixedCurve { - proto_def::FixedCurve { - supply: self.supply, - total_quote_fund_raising: self.total_quote_fund_raising, - migrate_type: self.migrate_type.into(), - } - } - } - use crate::types::LinearCurve; - impl IntoProto for LinearCurve { - fn into_proto(self) -> proto_def::LinearCurve { - proto_def::LinearCurve { - supply: self.supply, - total_quote_fund_raising: self.total_quote_fund_raising, - migrate_type: self.migrate_type.into(), - } - } - } - use crate::types::MigrateNftInfo; - impl IntoProto for MigrateNftInfo { - fn into_proto(self) -> proto_def::MigrateNftInfo { - proto_def::MigrateNftInfo { - platform_scale: self.platform_scale, - creator_scale: self.creator_scale, - burn_scale: self.burn_scale, - } - } - } - use crate::types::MintParams; - impl IntoProto for MintParams { - fn into_proto(self) -> proto_def::MintParams { - proto_def::MintParams { - decimals: self.decimals.into(), - name: self.name, - symbol: self.symbol, - uri: self.uri, - } - } - } - use crate::types::PlatformConfigInfo; - impl IntoProto for PlatformConfigInfo { - fn into_proto(self) -> proto_def::PlatformConfigInfo { - proto_def::PlatformConfigInfo { - fee_wallet: self.fee_wallet.to_string(), - nft_wallet: self.nft_wallet.to_string(), - migrate_nft_info: Some(self.migrate_nft_info.into_proto()), - fee_rate: self.fee_rate, - name: self.name, - web: self.web, - img: self.img, - transfer_fee_extension_auth: self.transfer_fee_extension_auth.to_string(), - creator_fee_rate: self.creator_fee_rate, - } - } - } - use crate::types::PlatformCurveParam; - impl IntoProto for PlatformCurveParam { - fn into_proto(self) -> proto_def::PlatformCurveParam { - proto_def::PlatformCurveParam { - epoch: self.epoch, - index: self.index.into(), - global_config: self.global_config.to_string(), - bonding_curve_param: Some(self.bonding_curve_param.into_proto()), - padding: self.padding.to_vec(), - } - } - } - use crate::types::PoolCreateEvent; - impl IntoProto for PoolCreateEvent { - fn into_proto(self) -> proto_def::PoolCreateEvent { - proto_def::PoolCreateEvent { - pool_state: self.pool_state.to_string(), - creator: self.creator.to_string(), - config: self.config.to_string(), - base_mint_param: Some(self.base_mint_param.into_proto()), - curve_param: Some(self.curve_param.into_proto()), - vesting_param: Some(self.vesting_param.into_proto()), - amm_fee_on: self.amm_fee_on as i32, - } - } - } - use crate::types::TradeEvent; - impl IntoProto for TradeEvent { - fn into_proto(self) -> proto_def::TradeEvent { - proto_def::TradeEvent { - pool_state: self.pool_state.to_string(), - total_base_sell: self.total_base_sell, - virtual_base: self.virtual_base, - virtual_quote: self.virtual_quote, - real_base_before: self.real_base_before, - real_quote_before: self.real_quote_before, - real_base_after: self.real_base_after, - real_quote_after: self.real_quote_after, - amount_in: self.amount_in, - amount_out: self.amount_out, - protocol_fee: self.protocol_fee, - platform_fee: self.platform_fee, - creator_fee: self.creator_fee, - share_fee: self.share_fee, - trade_direction: self.trade_direction as i32, - pool_status: self.pool_status as i32, - exact_in: self.exact_in, - } - } - } - use crate::types::TransferFeeExtensionParams; - impl IntoProto for TransferFeeExtensionParams { - fn into_proto(self) -> proto_def::TransferFeeExtensionParams { - proto_def::TransferFeeExtensionParams { - transfer_fee_basis_points: self.transfer_fee_basis_points.into(), - maximum_fee: self.maximum_fee, - } - } - } - use crate::types::VestingParams; - impl IntoProto for VestingParams { - fn into_proto(self) -> proto_def::VestingParams { - proto_def::VestingParams { - total_locked_amount: self.total_locked_amount, - cliff_period: self.cliff_period, - unlock_period: self.unlock_period, - } - } - } - use crate::types::VestingSchedule; - impl IntoProto for VestingSchedule { - fn into_proto(self) -> proto_def::VestingSchedule { - proto_def::VestingSchedule { - total_locked_amount: self.total_locked_amount, - cliff_period: self.cliff_period, - unlock_period: self.unlock_period, - start_time: self.start_time, - allocated_share_amount: self.allocated_share_amount, - } - } - } - - use proto_def::curve_params; - - use crate::types::CurveParams; - impl IntoProto for CurveParams { - fn into_proto(self) -> proto_def::CurveParams { - let variant = match self { - CurveParams::Constant { data } => { - curve_params::Variant::Constant(proto_def::CurveParamsConstant { - data: Some(data.into_proto()), - }) - }, - CurveParams::Fixed { data } => { - curve_params::Variant::Fixed(proto_def::CurveParamsFixed { - data: Some(data.into_proto()), - }) - }, - CurveParams::Linear { data } => { - curve_params::Variant::Linear(proto_def::CurveParamsLinear { - data: Some(data.into_proto()), - }) - }, - }; - - proto_def::CurveParams { - variant: Some(variant), - } - } - } - use proto_def::platform_config_param; - - use crate::types::PlatformConfigParam; - impl IntoProto for PlatformConfigParam { - fn into_proto(self) -> proto_def::PlatformConfigParam { - let variant = match self { - PlatformConfigParam::FeeWallet(field_0) => { - platform_config_param::Variant::FeeWallet( - proto_def::PlatformConfigParamFeeWallet { - field_0: field_0.to_string(), - }, - ) - }, - PlatformConfigParam::NFTWallet(field_0) => { - platform_config_param::Variant::NFTWallet( - proto_def::PlatformConfigParamNftWallet { - field_0: field_0.to_string(), - }, - ) - }, - PlatformConfigParam::MigrateNftInfo(field_0) => { - platform_config_param::Variant::MigrateNftInfo( - proto_def::PlatformConfigParamMigrateNftInfo { - field_0: Some(field_0.into_proto()), - }, - ) - }, - PlatformConfigParam::FeeRate(field_0) => { - platform_config_param::Variant::FeeRate(proto_def::PlatformConfigParamFeeRate { - field_0, - }) - }, - PlatformConfigParam::Name(field_0) => { - platform_config_param::Variant::Name(proto_def::PlatformConfigParamName { - field_0, - }) - }, - PlatformConfigParam::Web(field_0) => { - platform_config_param::Variant::Web(proto_def::PlatformConfigParamWeb { - field_0, - }) - }, - PlatformConfigParam::Img(field_0) => { - platform_config_param::Variant::Img(proto_def::PlatformConfigParamImg { - field_0, - }) - }, - PlatformConfigParam::CpSwapConfig => platform_config_param::Variant::CpSwapConfig( - proto_def::PlatformConfigParamCpSwapConfig {}, - ), - PlatformConfigParam::AllInfo(field_0) => { - platform_config_param::Variant::AllInfo(proto_def::PlatformConfigParamAllInfo { - field_0: Some(field_0.into_proto()), - }) - }, - }; - - proto_def::PlatformConfigParam { - variant: Some(variant), - } - } - } -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/accounts/global_config.rs b/crates/raydium-launchpad-parser/src/generated_sdk/accounts/global_config.rs deleted file mode 100644 index 5dda1a9e..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/accounts/global_config.rs +++ /dev/null @@ -1,185 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct GlobalConfig { - pub discriminator: [u8; 8], - /// Account update epoch - pub epoch: u64, - /// 0: Constant Product Curve - /// 1: Fixed Price Curve - /// 2: Linear Price Curve - pub curve_type: u8, - /// Config index - pub index: u16, - /// The fee of migrate to amm - pub migrate_fee: u64, - /// The trade fee rate, denominated in hundredths of a bip (10^-6) - pub trade_fee_rate: u64, - /// The maximum share fee rate, denominated in hundredths of a bip (10^-6) - pub max_share_fee_rate: u64, - /// The minimum base supply, the value without decimals - pub min_base_supply: u64, - /// The maximum lock rate, denominated in hundredths of a bip (10^-6) - pub max_lock_rate: u64, - /// The minimum base sell rate, denominated in hundredths of a bip (10^-6) - pub min_base_sell_rate: u64, - /// The minimum base migrate rate, denominated in hundredths of a bip (10^-6) - pub min_base_migrate_rate: u64, - /// The minimum quote fund raising, the value with decimals - pub min_quote_fund_raising: u64, - /// Mint information for quote token - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub quote_mint: Pubkey, - /// Protocol Fee owner - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub protocol_fee_owner: Pubkey, - /// Migrate Fee owner - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub migrate_fee_owner: Pubkey, - /// Migrate to amm control wallet - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub migrate_to_amm_wallet: Pubkey, - /// Migrate to cpswap wallet - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub migrate_to_cpswap_wallet: Pubkey, - /// padding for future updates - pub padding: [u64; 16], -} - -pub const GLOBAL_CONFIG_DISCRIMINATOR: [u8; 8] = [149, 8, 156, 202, 160, 252, 176, 217]; - -impl GlobalConfig { - pub const LEN: usize = 371; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for GlobalConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_global_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_global_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_global_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = GlobalConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_global_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_global_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_global_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = GlobalConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for GlobalConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for GlobalConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for GlobalConfig { - fn owner() -> Pubkey { crate::RAYDIUM_LAUNCHPAD_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for GlobalConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for GlobalConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/accounts/mod.rs b/crates/raydium-launchpad-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index f12bfe77..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#global_config; -pub(crate) mod r#platform_config; -pub(crate) mod r#pool_state; -pub(crate) mod r#vesting_record; - -pub use self::{r#global_config::*, r#platform_config::*, r#pool_state::*, r#vesting_record::*}; diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/accounts/platform_config.rs b/crates/raydium-launchpad-parser/src/generated_sdk/accounts/platform_config.rs deleted file mode 100644 index fdf6de80..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/accounts/platform_config.rs +++ /dev/null @@ -1,181 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::PlatformCurveParam; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PlatformConfig { - pub discriminator: [u8; 8], - /// The epoch for update interval - pub epoch: u64, - /// The platform fee wallet - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub platform_fee_wallet: Pubkey, - /// The platform nft wallet to receive the platform NFT after migration if platform_scale is not 0(Only support MigrateType::CPSWAP) - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub platform_nft_wallet: Pubkey, - /// Scale of the platform liquidity quantity rights will be converted into NFT(Only support MigrateType::CPSWAP) - pub platform_scale: u64, - /// Scale of the token creator liquidity quantity rights will be converted into NFT(Only support MigrateType::CPSWAP) - pub creator_scale: u64, - /// Scale of liquidity directly to burn - pub burn_scale: u64, - /// The platform fee rate - pub fee_rate: u64, - /// The platform name - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub name: [u8; 64], - /// The platform website - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub web: [u8; 256], - /// The platform img link - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub img: [u8; 256], - /// The platform specifies the trade fee rate after migration to cp swap - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub cpswap_config: Pubkey, - /// Creator fee rate - pub creator_fee_rate: u64, - /// If the base token belongs to token2022, then you can choose to support the transferfeeConfig extension, which includes permissions such as `transfer_fee_config_authority`` and `withdraw_withheld_authority`. - /// When initializing mint, `withdraw_withheld_authority` and `transfer_fee_config_authority` both belongs to the contract. - /// Once the token is migrated to AMM, the authorities will be reset to this value - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub transfer_fee_extension_auth: Pubkey, - /// padding for future updates - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 180], - /// The parameters for launching the pool - pub curve_params: Vec, -} - -pub const PLATFORM_CONFIG_DISCRIMINATOR: [u8; 8] = [160, 78, 128, 0, 248, 83, 230, 160]; - -impl PlatformConfig { - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PlatformConfig { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_platform_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_platform_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_platform_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PlatformConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_platform_config( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_platform_config(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_platform_config( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PlatformConfig::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PlatformConfig { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PlatformConfig {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PlatformConfig { - fn owner() -> Pubkey { crate::RAYDIUM_LAUNCHPAD_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PlatformConfig {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PlatformConfig { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/accounts/pool_state.rs b/crates/raydium-launchpad-parser/src/generated_sdk/accounts/pool_state.rs deleted file mode 100644 index a98a7179..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/accounts/pool_state.rs +++ /dev/null @@ -1,234 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{AmmCreatorFeeOn, VestingSchedule}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolState { - pub discriminator: [u8; 8], - /// Account update epoch - pub epoch: u64, - /// Bump seed used for PDA address derivation - pub auth_bump: u8, - /// Current status of the pool - /// * 0: Pool is funding - /// * 1: Pool funding is end, waiting for migration - /// * 2: Pool migration is done - pub status: u8, - /// Decimals of the pool base token - pub base_decimals: u8, - /// Decimals of the pool quote token - pub quote_decimals: u8, - /// Migrate to AMM or CpSwap, 0: amm, 1: cpswap - pub migrate_type: u8, - /// Supply of the pool base token - pub supply: u64, - /// Total sell amount of the base token - pub total_base_sell: u64, - /// For different curves, virtual_base and virtual_quote have different meanings - /// For constant product curve, virtual_base and virtual_quote are virtual liquidity, virtual_quote/virtual_base is the initial price - /// For linear price curve, virtual_base is the price slope parameter a, virtual_quote has no effect - /// For fixed price curve, virtual_quote/virtual_base is the initial price - pub virtual_base: u64, - pub virtual_quote: u64, - /// Actual base token amount in the pool - /// Represents the real tokens available for trading - pub real_base: u64, - /// Actual quote token amount in the pool - /// Represents the real tokens available for trading - pub real_quote: u64, - /// The total quote fund raising of the pool - pub total_quote_fund_raising: u64, - /// Accumulated trading fees in quote tokens - /// Can be collected by the protocol fee owner - pub quote_protocol_fee: u64, - /// Accumulated platform fees in quote tokens - /// Can be collected by the platform wallet stored in platform config - pub platform_fee: u64, - /// The fee of migrate to amm - pub migrate_fee: u64, - /// Vesting schedule for the base token - pub vesting_schedule: VestingSchedule, - /// Public key of the global configuration account - /// Contains protocol-wide settings this pool adheres to - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub global_config: Pubkey, - /// Public key of the platform configuration account - /// Contains platform-wide settings this pool adheres to - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub platform_config: Pubkey, - /// Public key of the base mint address - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base_mint: Pubkey, - /// Public key of the quote mint address - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub quote_mint: Pubkey, - /// Public key of the base token vault - /// Holds the actual base tokens owned by the pool - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub base_vault: Pubkey, - /// Public key of the quote token vault - /// Holds the actual quote tokens owned by the pool - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub quote_vault: Pubkey, - /// The creator of base token - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - /// token program bits - /// bit0: base token program flag - /// 0: spl_token_program - /// 1: token_program_2022 - /// - /// bit1: quote token program flag - /// 0: spl_token_program - /// 1: token_program_2022 - pub token_program_flag: u8, - /// migrate to cpmm, creator fee on quote token or both token - pub amm_creator_fee_on: AmmCreatorFeeOn, - /// padding for future updates - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub padding: [u8; 62], -} - -pub const POOL_STATE_DISCRIMINATOR: [u8; 8] = [247, 237, 227, 245, 215, 195, 222, 70]; - -impl PoolState { - pub const LEN: usize = 429; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for PoolState { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_pool_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = PoolState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_pool_state(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_pool_state( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = PoolState::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for PoolState { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for PoolState {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for PoolState { - fn owner() -> Pubkey { crate::RAYDIUM_LAUNCHPAD_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for PoolState {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for PoolState { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/accounts/vesting_record.rs b/crates/raydium-launchpad-parser/src/generated_sdk/accounts/vesting_record.rs deleted file mode 100644 index fcdd2333..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/accounts/vesting_record.rs +++ /dev/null @@ -1,149 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct VestingRecord { - pub discriminator: [u8; 8], - /// Account update epoch - pub epoch: u64, - /// The pool state account - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool: Pubkey, - /// The beneficiary of the vesting account - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub beneficiary: Pubkey, - /// The amount of tokens claimed - pub claimed_amount: u64, - /// The share amount of the token to be vested - pub token_share_amount: u64, - /// padding for future updates - pub padding: [u64; 8], -} - -pub const VESTING_RECORD_DISCRIMINATOR: [u8; 8] = [106, 243, 221, 205, 230, 126, 85, 83]; - -impl VestingRecord { - pub const LEN: usize = 160; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for VestingRecord { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_vesting_record( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_vesting_record(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_vesting_record( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = VestingRecord::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_vesting_record( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_vesting_record(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_vesting_record( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = VestingRecord::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for VestingRecord { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for VestingRecord {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for VestingRecord { - fn owner() -> Pubkey { crate::RAYDIUM_LAUNCHPAD_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for VestingRecord {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for VestingRecord { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/errors/mod.rs b/crates/raydium-launchpad-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 60a45b0b..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod raydium_launchpad; - -pub use self::raydium_launchpad::RaydiumLaunchpadError; diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/errors/raydium_launchpad.rs b/crates/raydium-launchpad-parser/src/generated_sdk/errors/raydium_launchpad.rs deleted file mode 100644 index c7ac37bd..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/errors/raydium_launchpad.rs +++ /dev/null @@ -1,88 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum RaydiumLaunchpadError { - /// 6000 - Not approved - #[error("Not approved")] - NotApproved = 0x1770, - /// 6001 - Input account owner is not the program address - #[error("Input account owner is not the program address")] - InvalidOwner = 0x1771, - /// 6002 - InvalidInput - #[error("InvalidInput")] - InvalidInput = 0x1772, - /// 6003 - The input params are not match with curve type in config - #[error("The input params are not match with curve type in config")] - InputNotMatchCurveConfig = 0x1773, - /// 6004 - Exceeds desired slippage limit - #[error("Exceeds desired slippage limit")] - ExceededSlippage = 0x1774, - /// 6005 - Pool funding - #[error("Pool funding")] - PoolFunding = 0x1775, - /// 6006 - Pool migrated - #[error("Pool migrated")] - PoolMigrated = 0x1776, - /// 6007 - Migrate type not match - #[error("Migrate type not match")] - MigrateTypeNotMatch = 0x1777, - /// 6008 - Math overflow - #[error("Math overflow")] - MathOverflow = 0x1778, - /// 6009 - No assets to collect - #[error("No assets to collect")] - NoAssetsToCollect = 0x1779, - /// 6010 - Vesting ratio too high - #[error("Vesting ratio too high")] - VestingRatioTooHigh = 0x177a, - /// 6011 - Vesting setting ended - #[error("Vesting setting ended")] - VestingSettingEnded = 0x177b, - /// 6012 - Vesting not started - #[error("Vesting not started")] - VestingNotStarted = 0x177c, - /// 6013 - No vesting schedule - #[error("No vesting schedule")] - NoVestingSchedule = 0x177d, - /// 6014 - The platform info input is invalid - #[error("The platform info input is invalid")] - InvalidPlatformInfo = 0x177e, - /// 6015 - Pool not migrated - #[error("Pool not migrated")] - PoolNotMigrated = 0x177f, - /// 6016 - The input cp swap config account is invalid - #[error("The input cp swap config account is invalid")] - InvalidCpSwapConfig = 0x1780, - /// 6017 - No support extension - #[error("No support extension")] - NoSupportExtension = 0x1781, - /// 6018 - Not enough remaining accounts - #[error("Not enough remaining accounts")] - NotEnoughRemainingAccounts = 0x1782, - /// 6019 - TransferFee calculate not match - #[error("TransferFee calculate not match")] - TransferFeeCalculateNotMatch = 0x1783, - /// 6020 - Curve param is not exist - #[error("Curve param is not exist")] - CurveParamIsNotExist = 0x1784, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for RaydiumLaunchpadError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for RaydiumLaunchpadError { - fn type_of() -> &'static str { "RaydiumLaunchpadError" } -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/buy_exact_in.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/buy_exact_in.rs deleted file mode 100644 index f4640cea..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/buy_exact_in.rs +++ /dev/null @@ -1,1016 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const BUY_EXACT_IN_DISCRIMINATOR: [u8; 8] = [250, 234, 13, 123, 213, 156, 19, 236]; - -/// Accounts. -#[derive(Debug)] -pub struct BuyExactIn { - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: solana_pubkey::Pubkey, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: solana_pubkey::Pubkey, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: solana_pubkey::Pubkey, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: solana_pubkey::Pubkey, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: solana_pubkey::Pubkey, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: solana_pubkey::Pubkey, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: solana_pubkey::Pubkey, - /// The mint of the quote token - pub quote_token_mint: solana_pubkey::Pubkey, - /// SPL Token program for base token transfers - pub base_token_program: solana_pubkey::Pubkey, - /// SPL Token program for quote token transfers - pub quote_token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl BuyExactIn { - pub fn instruction(&self, args: BuyExactInInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: BuyExactInInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_base_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_quote_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&BuyExactInInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyExactInInstructionData { - discriminator: [u8; 8], -} - -impl BuyExactInInstructionData { - pub fn new() -> Self { - Self { - discriminator: [250, 234, 13, 123, 213, 156, 19, 236], - } - } -} - -impl Default for BuyExactInInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyExactInInstructionArgs { - pub amount_in: u64, - pub minimum_amount_out: u64, - pub share_fee_rate: u64, -} - -/// Instruction builder for `BuyExactIn`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[writable]` pool_state -/// 5. `[writable]` user_base_token -/// 6. `[writable]` user_quote_token -/// 7. `[writable]` base_vault -/// 8. `[writable]` quote_vault -/// 9. `[]` base_token_mint -/// 10. `[]` quote_token_mint -/// 11. `[]` base_token_program -/// 12. `[optional]` quote_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct BuyExactInBuilder { - payer: Option, - authority: Option, - global_config: Option, - platform_config: Option, - pool_state: Option, - user_base_token: Option, - user_quote_token: Option, - base_vault: Option, - quote_vault: Option, - base_token_mint: Option, - quote_token_mint: Option, - base_token_program: Option, - quote_token_program: Option, - event_authority: Option, - program: Option, - amount_in: Option, - minimum_amount_out: Option, - share_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl BuyExactInBuilder { - pub fn new() -> Self { Self::default() } - - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - #[inline(always)] - pub fn user_base_token(&mut self, user_base_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_base_token = Some(user_base_token); - self - } - - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - #[inline(always)] - pub fn user_quote_token(&mut self, user_quote_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_quote_token = Some(user_quote_token); - self - } - - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of the base token - /// Used for transfer fee calculations if applicable - #[inline(always)] - pub fn base_token_mint(&mut self, base_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_mint = Some(base_token_mint); - self - } - - /// The mint of the quote token - #[inline(always)] - pub fn quote_token_mint(&mut self, quote_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_mint = Some(quote_token_mint); - self - } - - /// SPL Token program for base token transfers - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for quote token transfers - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.minimum_amount_out = Some(minimum_amount_out); - self - } - - #[inline(always)] - pub fn share_fee_rate(&mut self, share_fee_rate: u64) -> &mut Self { - self.share_fee_rate = Some(share_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = BuyExactIn { - payer: self.payer.expect("payer is not set"), - authority: self.authority.expect("authority is not set"), - global_config: self.global_config.expect("global_config is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - user_base_token: self.user_base_token.expect("user_base_token is not set"), - user_quote_token: self.user_quote_token.expect("user_quote_token is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - base_token_mint: self.base_token_mint.expect("base_token_mint is not set"), - quote_token_mint: self.quote_token_mint.expect("quote_token_mint is not set"), - base_token_program: self - .base_token_program - .expect("base_token_program is not set"), - quote_token_program: self.quote_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = BuyExactInInstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - minimum_amount_out: self - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - share_fee_rate: self - .share_fee_rate - .clone() - .expect("share_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `buy_exact_in` CPI accounts. -pub struct BuyExactInCpiAccounts<'a, 'b> { - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the quote token - pub quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for base token transfers - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for quote token transfers - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `buy_exact_in` CPI instruction. -pub struct BuyExactInCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the quote token - pub quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for base token transfers - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for quote token transfers - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: BuyExactInInstructionArgs, -} - -impl<'a, 'b> BuyExactInCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: BuyExactInCpiAccounts<'a, 'b>, - args: BuyExactInInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - authority: accounts.authority, - global_config: accounts.global_config, - platform_config: accounts.platform_config, - pool_state: accounts.pool_state, - user_base_token: accounts.user_base_token, - user_quote_token: accounts.user_quote_token, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - base_token_mint: accounts.base_token_mint, - quote_token_mint: accounts.quote_token_mint, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_base_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_quote_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&BuyExactInInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.user_base_token.clone()); - account_infos.push(self.user_quote_token.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.base_token_mint.clone()); - account_infos.push(self.quote_token_mint.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `BuyExactIn` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[writable]` pool_state -/// 5. `[writable]` user_base_token -/// 6. `[writable]` user_quote_token -/// 7. `[writable]` base_vault -/// 8. `[writable]` quote_vault -/// 9. `[]` base_token_mint -/// 10. `[]` quote_token_mint -/// 11. `[]` base_token_program -/// 12. `[]` quote_token_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct BuyExactInCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> BuyExactInCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(BuyExactInCpiBuilderInstruction { - __program: program, - payer: None, - authority: None, - global_config: None, - platform_config: None, - pool_state: None, - user_base_token: None, - user_quote_token: None, - base_vault: None, - quote_vault: None, - base_token_mint: None, - quote_token_mint: None, - base_token_program: None, - quote_token_program: None, - event_authority: None, - program: None, - amount_in: None, - minimum_amount_out: None, - share_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - #[inline(always)] - pub fn user_base_token( - &mut self, - user_base_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_base_token = Some(user_base_token); - self - } - - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - #[inline(always)] - pub fn user_quote_token( - &mut self, - user_quote_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_quote_token = Some(user_quote_token); - self - } - - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of the base token - /// Used for transfer fee calculations if applicable - #[inline(always)] - pub fn base_token_mint( - &mut self, - base_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_mint = Some(base_token_mint); - self - } - - /// The mint of the quote token - #[inline(always)] - pub fn quote_token_mint( - &mut self, - quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_mint = Some(quote_token_mint); - self - } - - /// SPL Token program for base token transfers - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - /// SPL Token program for quote token transfers - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.instruction.minimum_amount_out = Some(minimum_amount_out); - self - } - - #[inline(always)] - pub fn share_fee_rate(&mut self, share_fee_rate: u64) -> &mut Self { - self.instruction.share_fee_rate = Some(share_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = BuyExactInInstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - minimum_amount_out: self - .instruction - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - share_fee_rate: self - .instruction - .share_fee_rate - .clone() - .expect("share_fee_rate is not set"), - }; - let instruction = BuyExactInCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - user_base_token: self - .instruction - .user_base_token - .expect("user_base_token is not set"), - - user_quote_token: self - .instruction - .user_quote_token - .expect("user_quote_token is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - base_token_mint: self - .instruction - .base_token_mint - .expect("base_token_mint is not set"), - - quote_token_mint: self - .instruction - .quote_token_mint - .expect("quote_token_mint is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct BuyExactInCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - user_base_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_quote_token: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - minimum_amount_out: Option, - share_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/buy_exact_out.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/buy_exact_out.rs deleted file mode 100644 index ed498ab9..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/buy_exact_out.rs +++ /dev/null @@ -1,1016 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const BUY_EXACT_OUT_DISCRIMINATOR: [u8; 8] = [24, 211, 116, 40, 105, 3, 153, 56]; - -/// Accounts. -#[derive(Debug)] -pub struct BuyExactOut { - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: solana_pubkey::Pubkey, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: solana_pubkey::Pubkey, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: solana_pubkey::Pubkey, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: solana_pubkey::Pubkey, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: solana_pubkey::Pubkey, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: solana_pubkey::Pubkey, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: solana_pubkey::Pubkey, - /// The mint of the quote token - pub quote_token_mint: solana_pubkey::Pubkey, - /// SPL Token program for base token transfers - pub base_token_program: solana_pubkey::Pubkey, - /// SPL Token program for quote token transfers - pub quote_token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl BuyExactOut { - pub fn instruction(&self, args: BuyExactOutInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: BuyExactOutInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_base_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_quote_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&BuyExactOutInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyExactOutInstructionData { - discriminator: [u8; 8], -} - -impl BuyExactOutInstructionData { - pub fn new() -> Self { - Self { - discriminator: [24, 211, 116, 40, 105, 3, 153, 56], - } - } -} - -impl Default for BuyExactOutInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyExactOutInstructionArgs { - pub amount_out: u64, - pub maximum_amount_in: u64, - pub share_fee_rate: u64, -} - -/// Instruction builder for `BuyExactOut`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[writable]` pool_state -/// 5. `[writable]` user_base_token -/// 6. `[writable]` user_quote_token -/// 7. `[writable]` base_vault -/// 8. `[writable]` quote_vault -/// 9. `[]` base_token_mint -/// 10. `[]` quote_token_mint -/// 11. `[]` base_token_program -/// 12. `[optional]` quote_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct BuyExactOutBuilder { - payer: Option, - authority: Option, - global_config: Option, - platform_config: Option, - pool_state: Option, - user_base_token: Option, - user_quote_token: Option, - base_vault: Option, - quote_vault: Option, - base_token_mint: Option, - quote_token_mint: Option, - base_token_program: Option, - quote_token_program: Option, - event_authority: Option, - program: Option, - amount_out: Option, - maximum_amount_in: Option, - share_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl BuyExactOutBuilder { - pub fn new() -> Self { Self::default() } - - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - #[inline(always)] - pub fn user_base_token(&mut self, user_base_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_base_token = Some(user_base_token); - self - } - - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - #[inline(always)] - pub fn user_quote_token(&mut self, user_quote_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_quote_token = Some(user_quote_token); - self - } - - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of the base token - /// Used for transfer fee calculations if applicable - #[inline(always)] - pub fn base_token_mint(&mut self, base_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_mint = Some(base_token_mint); - self - } - - /// The mint of the quote token - #[inline(always)] - pub fn quote_token_mint(&mut self, quote_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_mint = Some(quote_token_mint); - self - } - - /// SPL Token program for base token transfers - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for quote token transfers - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_out(&mut self, amount_out: u64) -> &mut Self { - self.amount_out = Some(amount_out); - self - } - - #[inline(always)] - pub fn maximum_amount_in(&mut self, maximum_amount_in: u64) -> &mut Self { - self.maximum_amount_in = Some(maximum_amount_in); - self - } - - #[inline(always)] - pub fn share_fee_rate(&mut self, share_fee_rate: u64) -> &mut Self { - self.share_fee_rate = Some(share_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = BuyExactOut { - payer: self.payer.expect("payer is not set"), - authority: self.authority.expect("authority is not set"), - global_config: self.global_config.expect("global_config is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - user_base_token: self.user_base_token.expect("user_base_token is not set"), - user_quote_token: self.user_quote_token.expect("user_quote_token is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - base_token_mint: self.base_token_mint.expect("base_token_mint is not set"), - quote_token_mint: self.quote_token_mint.expect("quote_token_mint is not set"), - base_token_program: self - .base_token_program - .expect("base_token_program is not set"), - quote_token_program: self.quote_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = BuyExactOutInstructionArgs { - amount_out: self.amount_out.clone().expect("amount_out is not set"), - maximum_amount_in: self - .maximum_amount_in - .clone() - .expect("maximum_amount_in is not set"), - share_fee_rate: self - .share_fee_rate - .clone() - .expect("share_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `buy_exact_out` CPI accounts. -pub struct BuyExactOutCpiAccounts<'a, 'b> { - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the quote token - pub quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for base token transfers - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for quote token transfers - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `buy_exact_out` CPI instruction. -pub struct BuyExactOutCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the quote token - pub quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for base token transfers - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for quote token transfers - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: BuyExactOutInstructionArgs, -} - -impl<'a, 'b> BuyExactOutCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: BuyExactOutCpiAccounts<'a, 'b>, - args: BuyExactOutInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - authority: accounts.authority, - global_config: accounts.global_config, - platform_config: accounts.platform_config, - pool_state: accounts.pool_state, - user_base_token: accounts.user_base_token, - user_quote_token: accounts.user_quote_token, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - base_token_mint: accounts.base_token_mint, - quote_token_mint: accounts.quote_token_mint, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_base_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_quote_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&BuyExactOutInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.user_base_token.clone()); - account_infos.push(self.user_quote_token.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.base_token_mint.clone()); - account_infos.push(self.quote_token_mint.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `BuyExactOut` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[writable]` pool_state -/// 5. `[writable]` user_base_token -/// 6. `[writable]` user_quote_token -/// 7. `[writable]` base_vault -/// 8. `[writable]` quote_vault -/// 9. `[]` base_token_mint -/// 10. `[]` quote_token_mint -/// 11. `[]` base_token_program -/// 12. `[]` quote_token_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct BuyExactOutCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> BuyExactOutCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(BuyExactOutCpiBuilderInstruction { - __program: program, - payer: None, - authority: None, - global_config: None, - platform_config: None, - pool_state: None, - user_base_token: None, - user_quote_token: None, - base_vault: None, - quote_vault: None, - base_token_mint: None, - quote_token_mint: None, - base_token_program: None, - quote_token_program: None, - event_authority: None, - program: None, - amount_out: None, - maximum_amount_in: None, - share_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - #[inline(always)] - pub fn user_base_token( - &mut self, - user_base_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_base_token = Some(user_base_token); - self - } - - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - #[inline(always)] - pub fn user_quote_token( - &mut self, - user_quote_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_quote_token = Some(user_quote_token); - self - } - - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of the base token - /// Used for transfer fee calculations if applicable - #[inline(always)] - pub fn base_token_mint( - &mut self, - base_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_mint = Some(base_token_mint); - self - } - - /// The mint of the quote token - #[inline(always)] - pub fn quote_token_mint( - &mut self, - quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_mint = Some(quote_token_mint); - self - } - - /// SPL Token program for base token transfers - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - /// SPL Token program for quote token transfers - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_out(&mut self, amount_out: u64) -> &mut Self { - self.instruction.amount_out = Some(amount_out); - self - } - - #[inline(always)] - pub fn maximum_amount_in(&mut self, maximum_amount_in: u64) -> &mut Self { - self.instruction.maximum_amount_in = Some(maximum_amount_in); - self - } - - #[inline(always)] - pub fn share_fee_rate(&mut self, share_fee_rate: u64) -> &mut Self { - self.instruction.share_fee_rate = Some(share_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = BuyExactOutInstructionArgs { - amount_out: self - .instruction - .amount_out - .clone() - .expect("amount_out is not set"), - maximum_amount_in: self - .instruction - .maximum_amount_in - .clone() - .expect("maximum_amount_in is not set"), - share_fee_rate: self - .instruction - .share_fee_rate - .clone() - .expect("share_fee_rate is not set"), - }; - let instruction = BuyExactOutCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - user_base_token: self - .instruction - .user_base_token - .expect("user_base_token is not set"), - - user_quote_token: self - .instruction - .user_quote_token - .expect("user_quote_token is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - base_token_mint: self - .instruction - .base_token_mint - .expect("base_token_mint is not set"), - - quote_token_mint: self - .instruction - .quote_token_mint - .expect("quote_token_mint is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct BuyExactOutCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - user_base_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_quote_token: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_out: Option, - maximum_amount_in: Option, - share_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_creator_fee.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_creator_fee.rs deleted file mode 100644 index 8eccaa46..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_creator_fee.rs +++ /dev/null @@ -1,602 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLAIM_CREATOR_FEE_DISCRIMINATOR: [u8; 8] = [26, 97, 138, 203, 132, 171, 141, 252]; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimCreatorFee { - /// The pool creator - pub creator: solana_pubkey::Pubkey, - - pub fee_vault_authority: solana_pubkey::Pubkey, - /// The creator fee vault - pub creator_fee_vault: solana_pubkey::Pubkey, - - pub recipient_token_account: solana_pubkey::Pubkey, - /// The mint for the quote token - pub quote_mint: solana_pubkey::Pubkey, - /// SPL Token program for the quote token - pub token_program: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, - /// Required for associated token program - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl ClaimCreatorFee { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.creator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_fee_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClaimCreatorFeeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimCreatorFeeInstructionData { - discriminator: [u8; 8], -} - -impl ClaimCreatorFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [26, 97, 138, 203, 132, 171, 141, 252], - } - } -} - -impl Default for ClaimCreatorFeeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClaimCreatorFee`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[]` fee_vault_authority -/// 2. `[writable]` creator_fee_vault -/// 3. `[writable]` recipient_token_account -/// 4. `[]` quote_mint -/// 5. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 6. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 7. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -#[derive(Clone, Debug, Default)] -pub struct ClaimCreatorFeeBuilder { - creator: Option, - fee_vault_authority: Option, - creator_fee_vault: Option, - recipient_token_account: Option, - quote_mint: Option, - token_program: Option, - system_program: Option, - associated_token_program: Option, - __remaining_accounts: Vec, -} - -impl ClaimCreatorFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// The pool creator - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn fee_vault_authority(&mut self, fee_vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_vault_authority = Some(fee_vault_authority); - self - } - - /// The creator fee vault - #[inline(always)] - pub fn creator_fee_vault(&mut self, creator_fee_vault: solana_pubkey::Pubkey) -> &mut Self { - self.creator_fee_vault = Some(creator_fee_vault); - self - } - - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account = Some(recipient_token_account); - self - } - - /// The mint for the quote token - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for the quote token - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Required for associated token program - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimCreatorFee { - creator: self.creator.expect("creator is not set"), - fee_vault_authority: self - .fee_vault_authority - .expect("fee_vault_authority is not set"), - creator_fee_vault: self - .creator_fee_vault - .expect("creator_fee_vault is not set"), - recipient_token_account: self - .recipient_token_account - .expect("recipient_token_account is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `claim_creator_fee` CPI accounts. -pub struct ClaimCreatorFeeCpiAccounts<'a, 'b> { - /// The pool creator - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub fee_vault_authority: &'b solana_account_info::AccountInfo<'a>, - /// The creator fee vault - pub creator_fee_vault: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the quote token - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for associated token program - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_creator_fee` CPI instruction. -pub struct ClaimCreatorFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The pool creator - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub fee_vault_authority: &'b solana_account_info::AccountInfo<'a>, - /// The creator fee vault - pub creator_fee_vault: &'b solana_account_info::AccountInfo<'a>, - - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the quote token - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for associated token program - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClaimCreatorFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimCreatorFeeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - creator: accounts.creator, - fee_vault_authority: accounts.fee_vault_authority, - creator_fee_vault: accounts.creator_fee_vault, - recipient_token_account: accounts.recipient_token_account, - quote_mint: accounts.quote_mint, - token_program: accounts.token_program, - system_program: accounts.system_program, - associated_token_program: accounts.associated_token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_fee_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClaimCreatorFeeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.fee_vault_authority.clone()); - account_infos.push(self.creator_fee_vault.clone()); - account_infos.push(self.recipient_token_account.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimCreatorFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[]` fee_vault_authority -/// 2. `[writable]` creator_fee_vault -/// 3. `[writable]` recipient_token_account -/// 4. `[]` quote_mint -/// 5. `[]` token_program -/// 6. `[]` system_program -/// 7. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct ClaimCreatorFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimCreatorFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimCreatorFeeCpiBuilderInstruction { - __program: program, - creator: None, - fee_vault_authority: None, - creator_fee_vault: None, - recipient_token_account: None, - quote_mint: None, - token_program: None, - system_program: None, - associated_token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The pool creator - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn fee_vault_authority( - &mut self, - fee_vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_vault_authority = Some(fee_vault_authority); - self - } - - /// The creator fee vault - #[inline(always)] - pub fn creator_fee_vault( - &mut self, - creator_fee_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_fee_vault = Some(creator_fee_vault); - self - } - - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account = Some(recipient_token_account); - self - } - - /// The mint for the quote token - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// SPL Token program for the quote token - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Required for associated token program - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClaimCreatorFeeCpi { - __program: self.instruction.__program, - - creator: self.instruction.creator.expect("creator is not set"), - - fee_vault_authority: self - .instruction - .fee_vault_authority - .expect("fee_vault_authority is not set"), - - creator_fee_vault: self - .instruction - .creator_fee_vault - .expect("creator_fee_vault is not set"), - - recipient_token_account: self - .instruction - .recipient_token_account - .expect("recipient_token_account is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimCreatorFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_fee_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_platform_fee.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_platform_fee.rs deleted file mode 100644 index 805cc9a1..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_platform_fee.rs +++ /dev/null @@ -1,697 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLAIM_PLATFORM_FEE_DISCRIMINATOR: [u8; 8] = [156, 39, 208, 135, 76, 237, 61, 72]; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimPlatformFee { - /// Only the wallet stored in platform_config can collect platform fees - pub platform_fee_wallet: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: solana_pubkey::Pubkey, - /// The platform config account - pub platform_config: solana_pubkey::Pubkey, - - pub quote_vault: solana_pubkey::Pubkey, - /// The address that receives the collected quote token fees - pub recipient_token_account: solana_pubkey::Pubkey, - /// The mint of quote token vault - pub quote_mint: solana_pubkey::Pubkey, - /// SPL program for input token transfers - pub token_program: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, - /// Required for associated token program - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl ClaimPlatformFee { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_fee_wallet, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClaimPlatformFeeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimPlatformFeeInstructionData { - discriminator: [u8; 8], -} - -impl ClaimPlatformFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [156, 39, 208, 135, 76, 237, 61, 72], - } - } -} - -impl Default for ClaimPlatformFeeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClaimPlatformFee`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` platform_fee_wallet -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` platform_config -/// 4. `[writable]` quote_vault -/// 5. `[writable]` recipient_token_account -/// 6. `[]` quote_mint -/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -#[derive(Clone, Debug, Default)] -pub struct ClaimPlatformFeeBuilder { - platform_fee_wallet: Option, - authority: Option, - pool_state: Option, - platform_config: Option, - quote_vault: Option, - recipient_token_account: Option, - quote_mint: Option, - token_program: Option, - system_program: Option, - associated_token_program: Option, - __remaining_accounts: Vec, -} - -impl ClaimPlatformFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// Only the wallet stored in platform_config can collect platform fees - #[inline(always)] - pub fn platform_fee_wallet(&mut self, platform_fee_wallet: solana_pubkey::Pubkey) -> &mut Self { - self.platform_fee_wallet = Some(platform_fee_wallet); - self - } - - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The platform config account - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The address that receives the collected quote token fees - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account = Some(recipient_token_account); - self - } - - /// The mint of quote token vault - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL program for input token transfers - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Required for associated token program - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimPlatformFee { - platform_fee_wallet: self - .platform_fee_wallet - .expect("platform_fee_wallet is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - recipient_token_account: self - .recipient_token_account - .expect("recipient_token_account is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `claim_platform_fee` CPI accounts. -pub struct ClaimPlatformFeeCpiAccounts<'a, 'b> { - /// Only the wallet stored in platform_config can collect platform fees - pub platform_fee_wallet: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The platform config account - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected quote token fees - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token vault - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for associated token program - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_platform_fee` CPI instruction. -pub struct ClaimPlatformFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Only the wallet stored in platform_config can collect platform fees - pub platform_fee_wallet: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The platform config account - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected quote token fees - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token vault - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for associated token program - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClaimPlatformFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimPlatformFeeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - platform_fee_wallet: accounts.platform_fee_wallet, - authority: accounts.authority, - pool_state: accounts.pool_state, - platform_config: accounts.platform_config, - quote_vault: accounts.quote_vault, - recipient_token_account: accounts.recipient_token_account, - quote_mint: accounts.quote_mint, - token_program: accounts.token_program, - system_program: accounts.system_program, - associated_token_program: accounts.associated_token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_fee_wallet.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClaimPlatformFeeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.platform_fee_wallet.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.recipient_token_account.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimPlatformFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` platform_fee_wallet -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` platform_config -/// 4. `[writable]` quote_vault -/// 5. `[writable]` recipient_token_account -/// 6. `[]` quote_mint -/// 7. `[]` token_program -/// 8. `[]` system_program -/// 9. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct ClaimPlatformFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimPlatformFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimPlatformFeeCpiBuilderInstruction { - __program: program, - platform_fee_wallet: None, - authority: None, - pool_state: None, - platform_config: None, - quote_vault: None, - recipient_token_account: None, - quote_mint: None, - token_program: None, - system_program: None, - associated_token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Only the wallet stored in platform_config can collect platform fees - #[inline(always)] - pub fn platform_fee_wallet( - &mut self, - platform_fee_wallet: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_fee_wallet = Some(platform_fee_wallet); - self - } - - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The platform config account - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The address that receives the collected quote token fees - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account = Some(recipient_token_account); - self - } - - /// The mint of quote token vault - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// SPL program for input token transfers - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Required for associated token program - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClaimPlatformFeeCpi { - __program: self.instruction.__program, - - platform_fee_wallet: self - .instruction - .platform_fee_wallet - .expect("platform_fee_wallet is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - recipient_token_account: self - .instruction - .recipient_token_account - .expect("recipient_token_account is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimPlatformFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - platform_fee_wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_platform_fee_from_vault.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_platform_fee_from_vault.rs deleted file mode 100644 index 5cafb6b0..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_platform_fee_from_vault.rs +++ /dev/null @@ -1,660 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLAIM_PLATFORM_FEE_FROM_VAULT_DISCRIMINATOR: [u8; 8] = - [117, 241, 198, 168, 248, 218, 80, 29]; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimPlatformFeeFromVault { - /// Only the wallet stored in platform_config can collect platform fees - pub platform_fee_wallet: solana_pubkey::Pubkey, - - pub fee_vault_authority: solana_pubkey::Pubkey, - /// The platform config account - pub platform_config: solana_pubkey::Pubkey, - /// The platform fee vault - pub platform_fee_vault: solana_pubkey::Pubkey, - /// The address that receives the collected quote token fees - pub recipient_token_account: solana_pubkey::Pubkey, - /// The mint of quote token vault - pub quote_mint: solana_pubkey::Pubkey, - /// SPL program for input token transfers - pub token_program: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, - /// Required for associated token program - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl ClaimPlatformFeeFromVault { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_fee_wallet, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.fee_vault_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_fee_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClaimPlatformFeeFromVaultInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimPlatformFeeFromVaultInstructionData { - discriminator: [u8; 8], -} - -impl ClaimPlatformFeeFromVaultInstructionData { - pub fn new() -> Self { - Self { - discriminator: [117, 241, 198, 168, 248, 218, 80, 29], - } - } -} - -impl Default for ClaimPlatformFeeFromVaultInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClaimPlatformFeeFromVault`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` platform_fee_wallet -/// 1. `[]` fee_vault_authority -/// 2. `[]` platform_config -/// 3. `[writable]` platform_fee_vault -/// 4. `[writable]` recipient_token_account -/// 5. `[]` quote_mint -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 8. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -#[derive(Clone, Debug, Default)] -pub struct ClaimPlatformFeeFromVaultBuilder { - platform_fee_wallet: Option, - fee_vault_authority: Option, - platform_config: Option, - platform_fee_vault: Option, - recipient_token_account: Option, - quote_mint: Option, - token_program: Option, - system_program: Option, - associated_token_program: Option, - __remaining_accounts: Vec, -} - -impl ClaimPlatformFeeFromVaultBuilder { - pub fn new() -> Self { Self::default() } - - /// Only the wallet stored in platform_config can collect platform fees - #[inline(always)] - pub fn platform_fee_wallet(&mut self, platform_fee_wallet: solana_pubkey::Pubkey) -> &mut Self { - self.platform_fee_wallet = Some(platform_fee_wallet); - self - } - - #[inline(always)] - pub fn fee_vault_authority(&mut self, fee_vault_authority: solana_pubkey::Pubkey) -> &mut Self { - self.fee_vault_authority = Some(fee_vault_authority); - self - } - - /// The platform config account - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - /// The platform fee vault - #[inline(always)] - pub fn platform_fee_vault(&mut self, platform_fee_vault: solana_pubkey::Pubkey) -> &mut Self { - self.platform_fee_vault = Some(platform_fee_vault); - self - } - - /// The address that receives the collected quote token fees - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account = Some(recipient_token_account); - self - } - - /// The mint of quote token vault - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL program for input token transfers - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Required for associated token program - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimPlatformFeeFromVault { - platform_fee_wallet: self - .platform_fee_wallet - .expect("platform_fee_wallet is not set"), - fee_vault_authority: self - .fee_vault_authority - .expect("fee_vault_authority is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - platform_fee_vault: self - .platform_fee_vault - .expect("platform_fee_vault is not set"), - recipient_token_account: self - .recipient_token_account - .expect("recipient_token_account is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `claim_platform_fee_from_vault` CPI accounts. -pub struct ClaimPlatformFeeFromVaultCpiAccounts<'a, 'b> { - /// Only the wallet stored in platform_config can collect platform fees - pub platform_fee_wallet: &'b solana_account_info::AccountInfo<'a>, - - pub fee_vault_authority: &'b solana_account_info::AccountInfo<'a>, - /// The platform config account - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The platform fee vault - pub platform_fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected quote token fees - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token vault - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for associated token program - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_platform_fee_from_vault` CPI instruction. -pub struct ClaimPlatformFeeFromVaultCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Only the wallet stored in platform_config can collect platform fees - pub platform_fee_wallet: &'b solana_account_info::AccountInfo<'a>, - - pub fee_vault_authority: &'b solana_account_info::AccountInfo<'a>, - /// The platform config account - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The platform fee vault - pub platform_fee_vault: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected quote token fees - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token vault - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for associated token program - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClaimPlatformFeeFromVaultCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimPlatformFeeFromVaultCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - platform_fee_wallet: accounts.platform_fee_wallet, - fee_vault_authority: accounts.fee_vault_authority, - platform_config: accounts.platform_config, - platform_fee_vault: accounts.platform_fee_vault, - recipient_token_account: accounts.recipient_token_account, - quote_mint: accounts.quote_mint, - token_program: accounts.token_program, - system_program: accounts.system_program, - associated_token_program: accounts.associated_token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_fee_wallet.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.fee_vault_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_fee_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClaimPlatformFeeFromVaultInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.platform_fee_wallet.clone()); - account_infos.push(self.fee_vault_authority.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.platform_fee_vault.clone()); - account_infos.push(self.recipient_token_account.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimPlatformFeeFromVault` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` platform_fee_wallet -/// 1. `[]` fee_vault_authority -/// 2. `[]` platform_config -/// 3. `[writable]` platform_fee_vault -/// 4. `[writable]` recipient_token_account -/// 5. `[]` quote_mint -/// 6. `[]` token_program -/// 7. `[]` system_program -/// 8. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct ClaimPlatformFeeFromVaultCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimPlatformFeeFromVaultCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimPlatformFeeFromVaultCpiBuilderInstruction { - __program: program, - platform_fee_wallet: None, - fee_vault_authority: None, - platform_config: None, - platform_fee_vault: None, - recipient_token_account: None, - quote_mint: None, - token_program: None, - system_program: None, - associated_token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Only the wallet stored in platform_config can collect platform fees - #[inline(always)] - pub fn platform_fee_wallet( - &mut self, - platform_fee_wallet: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_fee_wallet = Some(platform_fee_wallet); - self - } - - #[inline(always)] - pub fn fee_vault_authority( - &mut self, - fee_vault_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.fee_vault_authority = Some(fee_vault_authority); - self - } - - /// The platform config account - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - /// The platform fee vault - #[inline(always)] - pub fn platform_fee_vault( - &mut self, - platform_fee_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_fee_vault = Some(platform_fee_vault); - self - } - - /// The address that receives the collected quote token fees - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account = Some(recipient_token_account); - self - } - - /// The mint of quote token vault - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// SPL program for input token transfers - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Required for associated token program - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClaimPlatformFeeFromVaultCpi { - __program: self.instruction.__program, - - platform_fee_wallet: self - .instruction - .platform_fee_wallet - .expect("platform_fee_wallet is not set"), - - fee_vault_authority: self - .instruction - .fee_vault_authority - .expect("fee_vault_authority is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - platform_fee_vault: self - .instruction - .platform_fee_vault - .expect("platform_fee_vault is not set"), - - recipient_token_account: self - .instruction - .recipient_token_account - .expect("recipient_token_account is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimPlatformFeeFromVaultCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - platform_fee_wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - fee_vault_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_fee_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_vested_token.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_vested_token.rs deleted file mode 100644 index d7e7e4a5..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/claim_vested_token.rs +++ /dev/null @@ -1,699 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CLAIM_VESTED_TOKEN_DISCRIMINATOR: [u8; 8] = [49, 33, 104, 30, 189, 157, 79, 35]; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimVestedToken { - /// The beneficiary of the vesting account - pub beneficiary: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: solana_pubkey::Pubkey, - /// The vesting record account - pub vesting_record: solana_pubkey::Pubkey, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: solana_pubkey::Pubkey, - - pub user_base_token: solana_pubkey::Pubkey, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_token_mint: solana_pubkey::Pubkey, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, - /// Required for associated token program - pub associated_token_program: solana_pubkey::Pubkey, -} - -impl ClaimVestedToken { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.beneficiary, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.vesting_record, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_base_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClaimVestedTokenInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimVestedTokenInstructionData { - discriminator: [u8; 8], -} - -impl ClaimVestedTokenInstructionData { - pub fn new() -> Self { - Self { - discriminator: [49, 33, 104, 30, 189, 157, 79, 35], - } - } -} - -impl Default for ClaimVestedTokenInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClaimVestedToken`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` beneficiary -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[writable]` vesting_record -/// 4. `[writable]` base_vault -/// 5. `[writable]` user_base_token -/// 6. `[]` base_token_mint -/// 7. `[optional]` base_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 9. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -#[derive(Clone, Debug, Default)] -pub struct ClaimVestedTokenBuilder { - beneficiary: Option, - authority: Option, - pool_state: Option, - vesting_record: Option, - base_vault: Option, - user_base_token: Option, - base_token_mint: Option, - base_token_program: Option, - system_program: Option, - associated_token_program: Option, - __remaining_accounts: Vec, -} - -impl ClaimVestedTokenBuilder { - pub fn new() -> Self { Self::default() } - - /// The beneficiary of the vesting account - #[inline(always)] - pub fn beneficiary(&mut self, beneficiary: solana_pubkey::Pubkey) -> &mut Self { - self.beneficiary = Some(beneficiary); - self - } - - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The vesting record account - #[inline(always)] - pub fn vesting_record(&mut self, vesting_record: solana_pubkey::Pubkey) -> &mut Self { - self.vesting_record = Some(vesting_record); - self - } - - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - #[inline(always)] - pub fn user_base_token(&mut self, user_base_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_base_token = Some(user_base_token); - self - } - - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - #[inline(always)] - pub fn base_token_mint(&mut self, base_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_mint = Some(base_token_mint); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for the base token - /// Must be the standard Token program - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Required for associated token program - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimVestedToken { - beneficiary: self.beneficiary.expect("beneficiary is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - vesting_record: self.vesting_record.expect("vesting_record is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - user_base_token: self.user_base_token.expect("user_base_token is not set"), - base_token_mint: self.base_token_mint.expect("base_token_mint is not set"), - base_token_program: self.base_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `claim_vested_token` CPI accounts. -pub struct ClaimVestedTokenCpiAccounts<'a, 'b> { - /// The beneficiary of the vesting account - pub beneficiary: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The vesting record account - pub vesting_record: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for associated token program - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_vested_token` CPI instruction. -pub struct ClaimVestedTokenCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The beneficiary of the vesting account - pub beneficiary: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The vesting record account - pub vesting_record: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub user_base_token: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for associated token program - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClaimVestedTokenCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimVestedTokenCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - beneficiary: accounts.beneficiary, - authority: accounts.authority, - pool_state: accounts.pool_state, - vesting_record: accounts.vesting_record, - base_vault: accounts.base_vault, - user_base_token: accounts.user_base_token, - base_token_mint: accounts.base_token_mint, - base_token_program: accounts.base_token_program, - system_program: accounts.system_program, - associated_token_program: accounts.associated_token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.beneficiary.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vesting_record.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_base_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClaimVestedTokenInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.beneficiary.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.vesting_record.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.user_base_token.clone()); - account_infos.push(self.base_token_mint.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.associated_token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimVestedToken` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` beneficiary -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[writable]` vesting_record -/// 4. `[writable]` base_vault -/// 5. `[writable]` user_base_token -/// 6. `[]` base_token_mint -/// 7. `[]` base_token_program -/// 8. `[]` system_program -/// 9. `[]` associated_token_program -#[derive(Clone, Debug)] -pub struct ClaimVestedTokenCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimVestedTokenCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimVestedTokenCpiBuilderInstruction { - __program: program, - beneficiary: None, - authority: None, - pool_state: None, - vesting_record: None, - base_vault: None, - user_base_token: None, - base_token_mint: None, - base_token_program: None, - system_program: None, - associated_token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The beneficiary of the vesting account - #[inline(always)] - pub fn beneficiary( - &mut self, - beneficiary: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.beneficiary = Some(beneficiary); - self - } - - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The vesting record account - #[inline(always)] - pub fn vesting_record( - &mut self, - vesting_record: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vesting_record = Some(vesting_record); - self - } - - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - #[inline(always)] - pub fn user_base_token( - &mut self, - user_base_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_base_token = Some(user_base_token); - self - } - - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - #[inline(always)] - pub fn base_token_mint( - &mut self, - base_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_mint = Some(base_token_mint); - self - } - - /// SPL Token program for the base token - /// Must be the standard Token program - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Required for associated token program - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClaimVestedTokenCpi { - __program: self.instruction.__program, - - beneficiary: self - .instruction - .beneficiary - .expect("beneficiary is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - vesting_record: self - .instruction - .vesting_record - .expect("vesting_record is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - user_base_token: self - .instruction - .user_base_token - .expect("user_base_token is not set"), - - base_token_mint: self - .instruction - .base_token_mint - .expect("base_token_mint is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimVestedTokenCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - beneficiary: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - vesting_record: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - user_base_token: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/collect_fee.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/collect_fee.rs deleted file mode 100644 index 9a37c418..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/collect_fee.rs +++ /dev/null @@ -1,581 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const COLLECT_FEE_DISCRIMINATOR: [u8; 8] = [60, 173, 247, 103, 4, 93, 130, 48]; - -/// Accounts. -#[derive(Debug)] -pub struct CollectFee { - /// Only protocol_fee_owner saved in global_config can collect protocol fee now - pub owner: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - /// Pool state stores accumulated protocol fee amount - pub pool_state: solana_pubkey::Pubkey, - /// Global config account stores owner - pub global_config: solana_pubkey::Pubkey, - /// The address that holds pool tokens for quote token - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of quote token vault - pub quote_mint: solana_pubkey::Pubkey, - /// The address that receives the collected quote token fees - pub recipient_token_account: solana_pubkey::Pubkey, - /// SPL program for input token transfers - pub token_program: solana_pubkey::Pubkey, -} - -impl CollectFee { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CollectFeeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectFeeInstructionData { - discriminator: [u8; 8], -} - -impl CollectFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [60, 173, 247, 103, 4, 93, 130, 48], - } - } -} - -impl Default for CollectFeeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CollectFee`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` global_config -/// 4. `[writable]` quote_vault -/// 5. `[]` quote_mint -/// 6. `[writable]` recipient_token_account -/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct CollectFeeBuilder { - owner: Option, - authority: Option, - pool_state: Option, - global_config: Option, - quote_vault: Option, - quote_mint: Option, - recipient_token_account: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl CollectFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// Only protocol_fee_owner saved in global_config can collect protocol fee now - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Pool state stores accumulated protocol fee amount - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Global config account stores owner - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// The address that holds pool tokens for quote token - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of quote token vault - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// The address that receives the collected quote token fees - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account = Some(recipient_token_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL program for input token transfers - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectFee { - owner: self.owner.expect("owner is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - global_config: self.global_config.expect("global_config is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - recipient_token_account: self - .recipient_token_account - .expect("recipient_token_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `collect_fee` CPI accounts. -pub struct CollectFeeCpiAccounts<'a, 'b> { - /// Only protocol_fee_owner saved in global_config can collect protocol fee now - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state stores accumulated protocol fee amount - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Global config account stores owner - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for quote token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token vault - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected quote token fees - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_fee` CPI instruction. -pub struct CollectFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Only protocol_fee_owner saved in global_config can collect protocol fee now - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state stores accumulated protocol fee amount - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Global config account stores owner - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for quote token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token vault - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected quote token fees - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CollectFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectFeeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - authority: accounts.authority, - pool_state: accounts.pool_state, - global_config: accounts.global_config, - quote_vault: accounts.quote_vault, - quote_mint: accounts.quote_mint, - recipient_token_account: accounts.recipient_token_account, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CollectFeeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.recipient_token_account.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` global_config -/// 4. `[writable]` quote_vault -/// 5. `[]` quote_mint -/// 6. `[writable]` recipient_token_account -/// 7. `[]` token_program -#[derive(Clone, Debug)] -pub struct CollectFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectFeeCpiBuilderInstruction { - __program: program, - owner: None, - authority: None, - pool_state: None, - global_config: None, - quote_vault: None, - quote_mint: None, - recipient_token_account: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Only protocol_fee_owner saved in global_config can collect protocol fee now - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Pool state stores accumulated protocol fee amount - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Global config account stores owner - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// The address that holds pool tokens for quote token - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of quote token vault - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// The address that receives the collected quote token fees - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account = Some(recipient_token_account); - self - } - - /// SPL program for input token transfers - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CollectFeeCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - recipient_token_account: self - .instruction - .recipient_token_account - .expect("recipient_token_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/collect_migrate_fee.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/collect_migrate_fee.rs deleted file mode 100644 index 1ea512c8..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/collect_migrate_fee.rs +++ /dev/null @@ -1,581 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const COLLECT_MIGRATE_FEE_DISCRIMINATOR: [u8; 8] = [255, 186, 150, 223, 235, 118, 201, 186]; - -/// Accounts. -#[derive(Debug)] -pub struct CollectMigrateFee { - /// Only migrate_fee_owner saved in global_config can collect migrate fee now - pub owner: solana_pubkey::Pubkey, - - pub authority: solana_pubkey::Pubkey, - /// Pool state stores accumulated protocol fee amount - pub pool_state: solana_pubkey::Pubkey, - /// Global config account stores owner - pub global_config: solana_pubkey::Pubkey, - /// The address that holds pool tokens for quote token - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of quote token vault - pub quote_mint: solana_pubkey::Pubkey, - /// The address that receives the collected quote token fees - pub recipient_token_account: solana_pubkey::Pubkey, - /// SPL program for input token transfers - pub token_program: solana_pubkey::Pubkey, -} - -impl CollectMigrateFee { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.recipient_token_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CollectMigrateFeeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectMigrateFeeInstructionData { - discriminator: [u8; 8], -} - -impl CollectMigrateFeeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [255, 186, 150, 223, 235, 118, 201, 186], - } - } -} - -impl Default for CollectMigrateFeeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CollectMigrateFee`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` global_config -/// 4. `[writable]` quote_vault -/// 5. `[]` quote_mint -/// 6. `[writable]` recipient_token_account -/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct CollectMigrateFeeBuilder { - owner: Option, - authority: Option, - pool_state: Option, - global_config: Option, - quote_vault: Option, - quote_mint: Option, - recipient_token_account: Option, - token_program: Option, - __remaining_accounts: Vec, -} - -impl CollectMigrateFeeBuilder { - pub fn new() -> Self { Self::default() } - - /// Only migrate_fee_owner saved in global_config can collect migrate fee now - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Pool state stores accumulated protocol fee amount - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Global config account stores owner - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// The address that holds pool tokens for quote token - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of quote token vault - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// The address that receives the collected quote token fees - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: solana_pubkey::Pubkey, - ) -> &mut Self { - self.recipient_token_account = Some(recipient_token_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL program for input token transfers - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CollectMigrateFee { - owner: self.owner.expect("owner is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - global_config: self.global_config.expect("global_config is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - recipient_token_account: self - .recipient_token_account - .expect("recipient_token_account is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `collect_migrate_fee` CPI accounts. -pub struct CollectMigrateFeeCpiAccounts<'a, 'b> { - /// Only migrate_fee_owner saved in global_config can collect migrate fee now - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state stores accumulated protocol fee amount - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Global config account stores owner - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for quote token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token vault - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected quote token fees - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `collect_migrate_fee` CPI instruction. -pub struct CollectMigrateFeeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Only migrate_fee_owner saved in global_config can collect migrate fee now - pub owner: &'b solana_account_info::AccountInfo<'a>, - - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Pool state stores accumulated protocol fee amount - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Global config account stores owner - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The address that holds pool tokens for quote token - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of quote token vault - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// The address that receives the collected quote token fees - pub recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - /// SPL program for input token transfers - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CollectMigrateFeeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CollectMigrateFeeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - authority: accounts.authority, - pool_state: accounts.pool_state, - global_config: accounts.global_config, - quote_vault: accounts.quote_vault, - quote_mint: accounts.quote_mint, - recipient_token_account: accounts.recipient_token_account, - token_program: accounts.token_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.recipient_token_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CollectMigrateFeeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.recipient_token_account.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CollectMigrateFee` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[]` authority -/// 2. `[writable]` pool_state -/// 3. `[]` global_config -/// 4. `[writable]` quote_vault -/// 5. `[]` quote_mint -/// 6. `[writable]` recipient_token_account -/// 7. `[]` token_program -#[derive(Clone, Debug)] -pub struct CollectMigrateFeeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CollectMigrateFeeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CollectMigrateFeeCpiBuilderInstruction { - __program: program, - owner: None, - authority: None, - pool_state: None, - global_config: None, - quote_vault: None, - quote_mint: None, - recipient_token_account: None, - token_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Only migrate_fee_owner saved in global_config can collect migrate fee now - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Pool state stores accumulated protocol fee amount - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Global config account stores owner - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// The address that holds pool tokens for quote token - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of quote token vault - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// The address that receives the collected quote token fees - #[inline(always)] - pub fn recipient_token_account( - &mut self, - recipient_token_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.recipient_token_account = Some(recipient_token_account); - self - } - - /// SPL program for input token transfers - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CollectMigrateFeeCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - recipient_token_account: self - .instruction - .recipient_token_account - .expect("recipient_token_account is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CollectMigrateFeeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - recipient_token_account: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/create_config.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/create_config.rs deleted file mode 100644 index 918b1ea9..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/create_config.rs +++ /dev/null @@ -1,739 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CREATE_CONFIG_DISCRIMINATOR: [u8; 8] = [201, 207, 243, 114, 75, 111, 47, 189]; - -/// Accounts. -#[derive(Debug)] -pub struct CreateConfig { - /// The protocol owner/admin account - /// Must match the predefined admin address - /// Has authority to create and modify protocol configurations - pub owner: solana_pubkey::Pubkey, - /// Global configuration account that stores protocol-wide settings - /// PDA generated using GLOBAL_CONFIG_SEED, quote token mint, and curve type - /// Stores fee rates and protocol parameters - pub global_config: solana_pubkey::Pubkey, - /// The mint address of the quote token (token used for buying) - /// This will be the standard token used for all pools with this config - pub quote_token_mint: solana_pubkey::Pubkey, - /// Account that will receive protocol fees - pub protocol_fee_owner: solana_pubkey::Pubkey, - /// Account that will receive migrate fees - pub migrate_fee_owner: solana_pubkey::Pubkey, - /// The control wallet address for migrating to amm - pub migrate_to_amm_wallet: solana_pubkey::Pubkey, - /// The control wallet address for migrating to cpswap - pub migrate_to_cpswap_wallet: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateConfig { - pub fn instruction( - &self, - args: CreateConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.owner, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.protocol_fee_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.migrate_fee_owner, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.migrate_to_amm_wallet, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.migrate_to_cpswap_wallet, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigInstructionData { - discriminator: [u8; 8], -} - -impl CreateConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [201, 207, 243, 114, 75, 111, 47, 189], - } - } -} - -impl Default for CreateConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateConfigInstructionArgs { - pub curve_type: u8, - pub index: u16, - pub migrate_fee: u64, - pub trade_fee_rate: u64, -} - -/// Instruction builder for `CreateConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer, optional]` owner (default to `GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ`) -/// 1. `[writable]` global_config -/// 2. `[]` quote_token_mint -/// 3. `[]` protocol_fee_owner -/// 4. `[]` migrate_fee_owner -/// 5. `[]` migrate_to_amm_wallet -/// 6. `[]` migrate_to_cpswap_wallet -/// 7. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateConfigBuilder { - owner: Option, - global_config: Option, - quote_token_mint: Option, - protocol_fee_owner: Option, - migrate_fee_owner: Option, - migrate_to_amm_wallet: Option, - migrate_to_cpswap_wallet: Option, - system_program: Option, - curve_type: Option, - index: Option, - migrate_fee: Option, - trade_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl CreateConfigBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ']` - /// The protocol owner/admin account - /// Must match the predefined admin address - /// Has authority to create and modify protocol configurations - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Global configuration account that stores protocol-wide settings - /// PDA generated using GLOBAL_CONFIG_SEED, quote token mint, and curve type - /// Stores fee rates and protocol parameters - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// The mint address of the quote token (token used for buying) - /// This will be the standard token used for all pools with this config - #[inline(always)] - pub fn quote_token_mint(&mut self, quote_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_mint = Some(quote_token_mint); - self - } - - /// Account that will receive protocol fees - #[inline(always)] - pub fn protocol_fee_owner(&mut self, protocol_fee_owner: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_fee_owner = Some(protocol_fee_owner); - self - } - - /// Account that will receive migrate fees - #[inline(always)] - pub fn migrate_fee_owner(&mut self, migrate_fee_owner: solana_pubkey::Pubkey) -> &mut Self { - self.migrate_fee_owner = Some(migrate_fee_owner); - self - } - - /// The control wallet address for migrating to amm - #[inline(always)] - pub fn migrate_to_amm_wallet( - &mut self, - migrate_to_amm_wallet: solana_pubkey::Pubkey, - ) -> &mut Self { - self.migrate_to_amm_wallet = Some(migrate_to_amm_wallet); - self - } - - /// The control wallet address for migrating to cpswap - #[inline(always)] - pub fn migrate_to_cpswap_wallet( - &mut self, - migrate_to_cpswap_wallet: solana_pubkey::Pubkey, - ) -> &mut Self { - self.migrate_to_cpswap_wallet = Some(migrate_to_cpswap_wallet); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: u8) -> &mut Self { - self.curve_type = Some(curve_type); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u16) -> &mut Self { - self.index = Some(index); - self - } - - #[inline(always)] - pub fn migrate_fee(&mut self, migrate_fee: u64) -> &mut Self { - self.migrate_fee = Some(migrate_fee); - self - } - - #[inline(always)] - pub fn trade_fee_rate(&mut self, trade_fee_rate: u64) -> &mut Self { - self.trade_fee_rate = Some(trade_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateConfig { - owner: self.owner.unwrap_or(solana_pubkey::pubkey!( - "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - )), - global_config: self.global_config.expect("global_config is not set"), - quote_token_mint: self.quote_token_mint.expect("quote_token_mint is not set"), - protocol_fee_owner: self - .protocol_fee_owner - .expect("protocol_fee_owner is not set"), - migrate_fee_owner: self - .migrate_fee_owner - .expect("migrate_fee_owner is not set"), - migrate_to_amm_wallet: self - .migrate_to_amm_wallet - .expect("migrate_to_amm_wallet is not set"), - migrate_to_cpswap_wallet: self - .migrate_to_cpswap_wallet - .expect("migrate_to_cpswap_wallet is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = CreateConfigInstructionArgs { - curve_type: self.curve_type.clone().expect("curve_type is not set"), - index: self.index.clone().expect("index is not set"), - migrate_fee: self.migrate_fee.clone().expect("migrate_fee is not set"), - trade_fee_rate: self - .trade_fee_rate - .clone() - .expect("trade_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_config` CPI accounts. -pub struct CreateConfigCpiAccounts<'a, 'b> { - /// The protocol owner/admin account - /// Must match the predefined admin address - /// Has authority to create and modify protocol configurations - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account that stores protocol-wide settings - /// PDA generated using GLOBAL_CONFIG_SEED, quote token mint, and curve type - /// Stores fee rates and protocol parameters - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The mint address of the quote token (token used for buying) - /// This will be the standard token used for all pools with this config - pub quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// Account that will receive protocol fees - pub protocol_fee_owner: &'b solana_account_info::AccountInfo<'a>, - /// Account that will receive migrate fees - pub migrate_fee_owner: &'b solana_account_info::AccountInfo<'a>, - /// The control wallet address for migrating to amm - pub migrate_to_amm_wallet: &'b solana_account_info::AccountInfo<'a>, - /// The control wallet address for migrating to cpswap - pub migrate_to_cpswap_wallet: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_config` CPI instruction. -pub struct CreateConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The protocol owner/admin account - /// Must match the predefined admin address - /// Has authority to create and modify protocol configurations - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account that stores protocol-wide settings - /// PDA generated using GLOBAL_CONFIG_SEED, quote token mint, and curve type - /// Stores fee rates and protocol parameters - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The mint address of the quote token (token used for buying) - /// This will be the standard token used for all pools with this config - pub quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// Account that will receive protocol fees - pub protocol_fee_owner: &'b solana_account_info::AccountInfo<'a>, - /// Account that will receive migrate fees - pub migrate_fee_owner: &'b solana_account_info::AccountInfo<'a>, - /// The control wallet address for migrating to amm - pub migrate_to_amm_wallet: &'b solana_account_info::AccountInfo<'a>, - /// The control wallet address for migrating to cpswap - pub migrate_to_cpswap_wallet: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateConfigInstructionArgs, -} - -impl<'a, 'b> CreateConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateConfigCpiAccounts<'a, 'b>, - args: CreateConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - global_config: accounts.global_config, - quote_token_mint: accounts.quote_token_mint, - protocol_fee_owner: accounts.protocol_fee_owner, - migrate_fee_owner: accounts.migrate_fee_owner, - migrate_to_amm_wallet: accounts.migrate_to_amm_wallet, - migrate_to_cpswap_wallet: accounts.migrate_to_cpswap_wallet, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.owner.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.protocol_fee_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.migrate_fee_owner.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.migrate_to_amm_wallet.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.migrate_to_cpswap_wallet.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.quote_token_mint.clone()); - account_infos.push(self.protocol_fee_owner.clone()); - account_infos.push(self.migrate_fee_owner.clone()); - account_infos.push(self.migrate_to_amm_wallet.clone()); - account_infos.push(self.migrate_to_cpswap_wallet.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` owner -/// 1. `[writable]` global_config -/// 2. `[]` quote_token_mint -/// 3. `[]` protocol_fee_owner -/// 4. `[]` migrate_fee_owner -/// 5. `[]` migrate_to_amm_wallet -/// 6. `[]` migrate_to_cpswap_wallet -/// 7. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateConfigCpiBuilderInstruction { - __program: program, - owner: None, - global_config: None, - quote_token_mint: None, - protocol_fee_owner: None, - migrate_fee_owner: None, - migrate_to_amm_wallet: None, - migrate_to_cpswap_wallet: None, - system_program: None, - curve_type: None, - index: None, - migrate_fee: None, - trade_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The protocol owner/admin account - /// Must match the predefined admin address - /// Has authority to create and modify protocol configurations - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Global configuration account that stores protocol-wide settings - /// PDA generated using GLOBAL_CONFIG_SEED, quote token mint, and curve type - /// Stores fee rates and protocol parameters - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// The mint address of the quote token (token used for buying) - /// This will be the standard token used for all pools with this config - #[inline(always)] - pub fn quote_token_mint( - &mut self, - quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_mint = Some(quote_token_mint); - self - } - - /// Account that will receive protocol fees - #[inline(always)] - pub fn protocol_fee_owner( - &mut self, - protocol_fee_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_fee_owner = Some(protocol_fee_owner); - self - } - - /// Account that will receive migrate fees - #[inline(always)] - pub fn migrate_fee_owner( - &mut self, - migrate_fee_owner: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migrate_fee_owner = Some(migrate_fee_owner); - self - } - - /// The control wallet address for migrating to amm - #[inline(always)] - pub fn migrate_to_amm_wallet( - &mut self, - migrate_to_amm_wallet: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migrate_to_amm_wallet = Some(migrate_to_amm_wallet); - self - } - - /// The control wallet address for migrating to cpswap - #[inline(always)] - pub fn migrate_to_cpswap_wallet( - &mut self, - migrate_to_cpswap_wallet: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.migrate_to_cpswap_wallet = Some(migrate_to_cpswap_wallet); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn curve_type(&mut self, curve_type: u8) -> &mut Self { - self.instruction.curve_type = Some(curve_type); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u16) -> &mut Self { - self.instruction.index = Some(index); - self - } - - #[inline(always)] - pub fn migrate_fee(&mut self, migrate_fee: u64) -> &mut Self { - self.instruction.migrate_fee = Some(migrate_fee); - self - } - - #[inline(always)] - pub fn trade_fee_rate(&mut self, trade_fee_rate: u64) -> &mut Self { - self.instruction.trade_fee_rate = Some(trade_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateConfigInstructionArgs { - curve_type: self - .instruction - .curve_type - .clone() - .expect("curve_type is not set"), - index: self.instruction.index.clone().expect("index is not set"), - migrate_fee: self - .instruction - .migrate_fee - .clone() - .expect("migrate_fee is not set"), - trade_fee_rate: self - .instruction - .trade_fee_rate - .clone() - .expect("trade_fee_rate is not set"), - }; - let instruction = CreateConfigCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - quote_token_mint: self - .instruction - .quote_token_mint - .expect("quote_token_mint is not set"), - - protocol_fee_owner: self - .instruction - .protocol_fee_owner - .expect("protocol_fee_owner is not set"), - - migrate_fee_owner: self - .instruction - .migrate_fee_owner - .expect("migrate_fee_owner is not set"), - - migrate_to_amm_wallet: self - .instruction - .migrate_to_amm_wallet - .expect("migrate_to_amm_wallet is not set"), - - migrate_to_cpswap_wallet: self - .instruction - .migrate_to_cpswap_wallet - .expect("migrate_to_cpswap_wallet is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_fee_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - migrate_fee_owner: Option<&'b solana_account_info::AccountInfo<'a>>, - migrate_to_amm_wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - migrate_to_cpswap_wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - curve_type: Option, - index: Option, - migrate_fee: Option, - trade_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/create_platform_config.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/create_platform_config.rs deleted file mode 100644 index 9bc6b9a5..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/create_platform_config.rs +++ /dev/null @@ -1,707 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::MigrateNftInfo; - -pub const CREATE_PLATFORM_CONFIG_DISCRIMINATOR: [u8; 8] = [176, 90, 196, 175, 253, 113, 220, 20]; - -/// Accounts. -#[derive(Debug)] -pub struct CreatePlatformConfig { - /// The account paying for the initialization costs - pub platform_admin: solana_pubkey::Pubkey, - - pub platform_fee_wallet: solana_pubkey::Pubkey, - - pub platform_nft_wallet: solana_pubkey::Pubkey, - /// The platform config account - pub platform_config: solana_pubkey::Pubkey, - - pub cpswap_config: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, - - pub transfer_fee_extension_authority: solana_pubkey::Pubkey, -} - -impl CreatePlatformConfig { - pub fn instruction( - &self, - args: CreatePlatformConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreatePlatformConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_admin, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_fee_wallet, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_nft_wallet, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cpswap_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.transfer_fee_extension_authority, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreatePlatformConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePlatformConfigInstructionData { - discriminator: [u8; 8], -} - -impl CreatePlatformConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [176, 90, 196, 175, 253, 113, 220, 20], - } - } -} - -impl Default for CreatePlatformConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreatePlatformConfigInstructionArgs { - pub migrate_nft_info: MigrateNftInfo, - pub fee_rate: u64, - pub name: String, - pub web: String, - pub img: String, - pub creator_fee_rate: u64, -} - -/// Instruction builder for `CreatePlatformConfig`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` platform_admin -/// 1. `[]` platform_fee_wallet -/// 2. `[]` platform_nft_wallet -/// 3. `[writable]` platform_config -/// 4. `[]` cpswap_config -/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 6. `[]` transfer_fee_extension_authority -#[derive(Clone, Debug, Default)] -pub struct CreatePlatformConfigBuilder { - platform_admin: Option, - platform_fee_wallet: Option, - platform_nft_wallet: Option, - platform_config: Option, - cpswap_config: Option, - system_program: Option, - transfer_fee_extension_authority: Option, - migrate_nft_info: Option, - fee_rate: Option, - name: Option, - web: Option, - img: Option, - creator_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl CreatePlatformConfigBuilder { - pub fn new() -> Self { Self::default() } - - /// The account paying for the initialization costs - #[inline(always)] - pub fn platform_admin(&mut self, platform_admin: solana_pubkey::Pubkey) -> &mut Self { - self.platform_admin = Some(platform_admin); - self - } - - #[inline(always)] - pub fn platform_fee_wallet(&mut self, platform_fee_wallet: solana_pubkey::Pubkey) -> &mut Self { - self.platform_fee_wallet = Some(platform_fee_wallet); - self - } - - #[inline(always)] - pub fn platform_nft_wallet(&mut self, platform_nft_wallet: solana_pubkey::Pubkey) -> &mut Self { - self.platform_nft_wallet = Some(platform_nft_wallet); - self - } - - /// The platform config account - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - #[inline(always)] - pub fn cpswap_config(&mut self, cpswap_config: solana_pubkey::Pubkey) -> &mut Self { - self.cpswap_config = Some(cpswap_config); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn transfer_fee_extension_authority( - &mut self, - transfer_fee_extension_authority: solana_pubkey::Pubkey, - ) -> &mut Self { - self.transfer_fee_extension_authority = Some(transfer_fee_extension_authority); - self - } - - #[inline(always)] - pub fn migrate_nft_info(&mut self, migrate_nft_info: MigrateNftInfo) -> &mut Self { - self.migrate_nft_info = Some(migrate_nft_info); - self - } - - #[inline(always)] - pub fn fee_rate(&mut self, fee_rate: u64) -> &mut Self { - self.fee_rate = Some(fee_rate); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.name = Some(name); - self - } - - #[inline(always)] - pub fn web(&mut self, web: String) -> &mut Self { - self.web = Some(web); - self - } - - #[inline(always)] - pub fn img(&mut self, img: String) -> &mut Self { - self.img = Some(img); - self - } - - #[inline(always)] - pub fn creator_fee_rate(&mut self, creator_fee_rate: u64) -> &mut Self { - self.creator_fee_rate = Some(creator_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreatePlatformConfig { - platform_admin: self.platform_admin.expect("platform_admin is not set"), - platform_fee_wallet: self - .platform_fee_wallet - .expect("platform_fee_wallet is not set"), - platform_nft_wallet: self - .platform_nft_wallet - .expect("platform_nft_wallet is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - cpswap_config: self.cpswap_config.expect("cpswap_config is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - transfer_fee_extension_authority: self - .transfer_fee_extension_authority - .expect("transfer_fee_extension_authority is not set"), - }; - let args = CreatePlatformConfigInstructionArgs { - migrate_nft_info: self - .migrate_nft_info - .clone() - .expect("migrate_nft_info is not set"), - fee_rate: self.fee_rate.clone().expect("fee_rate is not set"), - name: self.name.clone().expect("name is not set"), - web: self.web.clone().expect("web is not set"), - img: self.img.clone().expect("img is not set"), - creator_fee_rate: self - .creator_fee_rate - .clone() - .expect("creator_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_platform_config` CPI accounts. -pub struct CreatePlatformConfigCpiAccounts<'a, 'b> { - /// The account paying for the initialization costs - pub platform_admin: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_wallet: &'b solana_account_info::AccountInfo<'a>, - - pub platform_nft_wallet: &'b solana_account_info::AccountInfo<'a>, - /// The platform config account - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_config: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub transfer_fee_extension_authority: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_platform_config` CPI instruction. -pub struct CreatePlatformConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The account paying for the initialization costs - pub platform_admin: &'b solana_account_info::AccountInfo<'a>, - - pub platform_fee_wallet: &'b solana_account_info::AccountInfo<'a>, - - pub platform_nft_wallet: &'b solana_account_info::AccountInfo<'a>, - /// The platform config account - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_config: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub transfer_fee_extension_authority: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreatePlatformConfigInstructionArgs, -} - -impl<'a, 'b> CreatePlatformConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreatePlatformConfigCpiAccounts<'a, 'b>, - args: CreatePlatformConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - platform_admin: accounts.platform_admin, - platform_fee_wallet: accounts.platform_fee_wallet, - platform_nft_wallet: accounts.platform_nft_wallet, - platform_config: accounts.platform_config, - cpswap_config: accounts.cpswap_config, - system_program: accounts.system_program, - transfer_fee_extension_authority: accounts.transfer_fee_extension_authority, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_fee_wallet.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_nft_wallet.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cpswap_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.transfer_fee_extension_authority.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreatePlatformConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.platform_admin.clone()); - account_infos.push(self.platform_fee_wallet.clone()); - account_infos.push(self.platform_nft_wallet.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.cpswap_config.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.transfer_fee_extension_authority.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreatePlatformConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` platform_admin -/// 1. `[]` platform_fee_wallet -/// 2. `[]` platform_nft_wallet -/// 3. `[writable]` platform_config -/// 4. `[]` cpswap_config -/// 5. `[]` system_program -/// 6. `[]` transfer_fee_extension_authority -#[derive(Clone, Debug)] -pub struct CreatePlatformConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreatePlatformConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreatePlatformConfigCpiBuilderInstruction { - __program: program, - platform_admin: None, - platform_fee_wallet: None, - platform_nft_wallet: None, - platform_config: None, - cpswap_config: None, - system_program: None, - transfer_fee_extension_authority: None, - migrate_nft_info: None, - fee_rate: None, - name: None, - web: None, - img: None, - creator_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The account paying for the initialization costs - #[inline(always)] - pub fn platform_admin( - &mut self, - platform_admin: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_admin = Some(platform_admin); - self - } - - #[inline(always)] - pub fn platform_fee_wallet( - &mut self, - platform_fee_wallet: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_fee_wallet = Some(platform_fee_wallet); - self - } - - #[inline(always)] - pub fn platform_nft_wallet( - &mut self, - platform_nft_wallet: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_nft_wallet = Some(platform_nft_wallet); - self - } - - /// The platform config account - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - #[inline(always)] - pub fn cpswap_config( - &mut self, - cpswap_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpswap_config = Some(cpswap_config); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn transfer_fee_extension_authority( - &mut self, - transfer_fee_extension_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.transfer_fee_extension_authority = Some(transfer_fee_extension_authority); - self - } - - #[inline(always)] - pub fn migrate_nft_info(&mut self, migrate_nft_info: MigrateNftInfo) -> &mut Self { - self.instruction.migrate_nft_info = Some(migrate_nft_info); - self - } - - #[inline(always)] - pub fn fee_rate(&mut self, fee_rate: u64) -> &mut Self { - self.instruction.fee_rate = Some(fee_rate); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.instruction.name = Some(name); - self - } - - #[inline(always)] - pub fn web(&mut self, web: String) -> &mut Self { - self.instruction.web = Some(web); - self - } - - #[inline(always)] - pub fn img(&mut self, img: String) -> &mut Self { - self.instruction.img = Some(img); - self - } - - #[inline(always)] - pub fn creator_fee_rate(&mut self, creator_fee_rate: u64) -> &mut Self { - self.instruction.creator_fee_rate = Some(creator_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreatePlatformConfigInstructionArgs { - migrate_nft_info: self - .instruction - .migrate_nft_info - .clone() - .expect("migrate_nft_info is not set"), - fee_rate: self - .instruction - .fee_rate - .clone() - .expect("fee_rate is not set"), - name: self.instruction.name.clone().expect("name is not set"), - web: self.instruction.web.clone().expect("web is not set"), - img: self.instruction.img.clone().expect("img is not set"), - creator_fee_rate: self - .instruction - .creator_fee_rate - .clone() - .expect("creator_fee_rate is not set"), - }; - let instruction = CreatePlatformConfigCpi { - __program: self.instruction.__program, - - platform_admin: self - .instruction - .platform_admin - .expect("platform_admin is not set"), - - platform_fee_wallet: self - .instruction - .platform_fee_wallet - .expect("platform_fee_wallet is not set"), - - platform_nft_wallet: self - .instruction - .platform_nft_wallet - .expect("platform_nft_wallet is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - cpswap_config: self - .instruction - .cpswap_config - .expect("cpswap_config is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - transfer_fee_extension_authority: self - .instruction - .transfer_fee_extension_authority - .expect("transfer_fee_extension_authority is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreatePlatformConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - platform_admin: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_fee_wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_nft_wallet: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - cpswap_config: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - transfer_fee_extension_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - migrate_nft_info: Option, - fee_rate: Option, - name: Option, - web: Option, - img: Option, - creator_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/create_vesting_account.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/create_vesting_account.rs deleted file mode 100644 index d01119bb..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/create_vesting_account.rs +++ /dev/null @@ -1,512 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const CREATE_VESTING_ACCOUNT_DISCRIMINATOR: [u8; 8] = [129, 178, 2, 13, 217, 172, 230, 218]; - -/// Accounts. -#[derive(Debug)] -pub struct CreateVestingAccount { - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub creator: solana_pubkey::Pubkey, - /// The beneficiary is used to receive the allocated linear release of tokens. - /// Once this account is set, it cannot be modified, so please ensure the validity of this account, - /// otherwise, the unlocked tokens will not be claimable. - pub beneficiary: solana_pubkey::Pubkey, - /// The pool state account - pub pool_state: solana_pubkey::Pubkey, - /// The vesting record account - pub vesting_record: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, -} - -impl CreateVestingAccount { - pub fn instruction( - &self, - args: CreateVestingAccountInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: CreateVestingAccountInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.creator, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.beneficiary, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.vesting_record, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateVestingAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateVestingAccountInstructionData { - discriminator: [u8; 8], -} - -impl CreateVestingAccountInstructionData { - pub fn new() -> Self { - Self { - discriminator: [129, 178, 2, 13, 217, 172, 230, 218], - } - } -} - -impl Default for CreateVestingAccountInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateVestingAccountInstructionArgs { - pub share_amount: u64, -} - -/// Instruction builder for `CreateVestingAccount`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[writable]` beneficiary -/// 2. `[writable]` pool_state -/// 3. `[writable]` vesting_record -/// 4. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct CreateVestingAccountBuilder { - creator: Option, - beneficiary: Option, - pool_state: Option, - vesting_record: Option, - system_program: Option, - share_amount: Option, - __remaining_accounts: Vec, -} - -impl CreateVestingAccountBuilder { - pub fn new() -> Self { Self::default() } - - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// The beneficiary is used to receive the allocated linear release of tokens. - /// Once this account is set, it cannot be modified, so please ensure the validity of this account, - /// otherwise, the unlocked tokens will not be claimable. - #[inline(always)] - pub fn beneficiary(&mut self, beneficiary: solana_pubkey::Pubkey) -> &mut Self { - self.beneficiary = Some(beneficiary); - self - } - - /// The pool state account - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The vesting record account - #[inline(always)] - pub fn vesting_record(&mut self, vesting_record: solana_pubkey::Pubkey) -> &mut Self { - self.vesting_record = Some(vesting_record); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn share_amount(&mut self, share_amount: u64) -> &mut Self { - self.share_amount = Some(share_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateVestingAccount { - creator: self.creator.expect("creator is not set"), - beneficiary: self.beneficiary.expect("beneficiary is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - vesting_record: self.vesting_record.expect("vesting_record is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = CreateVestingAccountInstructionArgs { - share_amount: self.share_amount.clone().expect("share_amount is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `create_vesting_account` CPI accounts. -pub struct CreateVestingAccountCpiAccounts<'a, 'b> { - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// The beneficiary is used to receive the allocated linear release of tokens. - /// Once this account is set, it cannot be modified, so please ensure the validity of this account, - /// otherwise, the unlocked tokens will not be claimable. - pub beneficiary: &'b solana_account_info::AccountInfo<'a>, - /// The pool state account - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The vesting record account - pub vesting_record: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_vesting_account` CPI instruction. -pub struct CreateVestingAccountCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// The beneficiary is used to receive the allocated linear release of tokens. - /// Once this account is set, it cannot be modified, so please ensure the validity of this account, - /// otherwise, the unlocked tokens will not be claimable. - pub beneficiary: &'b solana_account_info::AccountInfo<'a>, - /// The pool state account - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The vesting record account - pub vesting_record: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: CreateVestingAccountInstructionArgs, -} - -impl<'a, 'b> CreateVestingAccountCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateVestingAccountCpiAccounts<'a, 'b>, - args: CreateVestingAccountInstructionArgs, - ) -> Self { - Self { - __program: program, - creator: accounts.creator, - beneficiary: accounts.beneficiary, - pool_state: accounts.pool_state, - vesting_record: accounts.vesting_record, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.beneficiary.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vesting_record.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&CreateVestingAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.beneficiary.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.vesting_record.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateVestingAccount` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[writable]` beneficiary -/// 2. `[writable]` pool_state -/// 3. `[writable]` vesting_record -/// 4. `[]` system_program -#[derive(Clone, Debug)] -pub struct CreateVestingAccountCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateVestingAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateVestingAccountCpiBuilderInstruction { - __program: program, - creator: None, - beneficiary: None, - pool_state: None, - vesting_record: None, - system_program: None, - share_amount: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// The beneficiary is used to receive the allocated linear release of tokens. - /// Once this account is set, it cannot be modified, so please ensure the validity of this account, - /// otherwise, the unlocked tokens will not be claimable. - #[inline(always)] - pub fn beneficiary( - &mut self, - beneficiary: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.beneficiary = Some(beneficiary); - self - } - - /// The pool state account - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The vesting record account - #[inline(always)] - pub fn vesting_record( - &mut self, - vesting_record: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vesting_record = Some(vesting_record); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn share_amount(&mut self, share_amount: u64) -> &mut Self { - self.instruction.share_amount = Some(share_amount); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = CreateVestingAccountInstructionArgs { - share_amount: self - .instruction - .share_amount - .clone() - .expect("share_amount is not set"), - }; - let instruction = CreateVestingAccountCpi { - __program: self.instruction.__program, - - creator: self.instruction.creator.expect("creator is not set"), - - beneficiary: self - .instruction - .beneficiary - .expect("beneficiary is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - vesting_record: self - .instruction - .vesting_record - .expect("vesting_record is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateVestingAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - beneficiary: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - vesting_record: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - share_amount: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/initialize.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/initialize.rs deleted file mode 100644 index 861cd0a0..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/initialize.rs +++ /dev/null @@ -1,1145 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{CurveParams, MintParams, VestingParams}; - -pub const INITIALIZE_DISCRIMINATOR: [u8; 8] = [175, 175, 109, 31, 13, 152, 155, 237]; - -/// Accounts. -#[derive(Debug)] -pub struct Initialize { - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub payer: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: solana_pubkey::Pubkey, - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - pub platform_config: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: solana_pubkey::Pubkey, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_mint: solana_pubkey::Pubkey, - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - pub quote_mint: solana_pubkey::Pubkey, - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - pub base_vault: solana_pubkey::Pubkey, - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - pub quote_vault: solana_pubkey::Pubkey, - /// Account to store the base token's metadata - /// Created using Metaplex metadata program - pub metadata_account: solana_pubkey::Pubkey, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: solana_pubkey::Pubkey, - /// SPL Token program for the quote token - pub quote_token_program: solana_pubkey::Pubkey, - /// Metaplex Token Metadata program - /// Used to create metadata for the base token - pub metadata_program: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, - /// Required for rent exempt calculations - pub rent_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl Initialize { - pub fn instruction(&self, args: InitializeInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new(self.base_mint, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.metadata_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionData { - discriminator: [u8; 8], -} - -impl InitializeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [175, 175, 109, 31, 13, 152, 155, 237], - } - } -} - -impl Default for InitializeInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionArgs { - pub base_mint_param: MintParams, - pub curve_param: CurveParams, - pub vesting_param: VestingParams, -} - -/// Instruction builder for `Initialize`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` creator -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[]` authority -/// 5. `[writable]` pool_state -/// 6. `[writable, signer]` base_mint -/// 7. `[]` quote_mint -/// 8. `[writable]` base_vault -/// 9. `[writable]` quote_vault -/// 10. `[writable]` metadata_account -/// 11. `[optional]` base_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 12. `[optional]` quote_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 13. `[optional]` metadata_program (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -/// 14. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 15. `[optional]` rent_program (default to `SysvarRent111111111111111111111111111111111`) -/// 16. `[]` event_authority -/// 17. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeBuilder { - payer: Option, - creator: Option, - global_config: Option, - platform_config: Option, - authority: Option, - pool_state: Option, - base_mint: Option, - quote_mint: Option, - base_vault: Option, - quote_vault: Option, - metadata_account: Option, - base_token_program: Option, - quote_token_program: Option, - metadata_program: Option, - system_program: Option, - rent_program: Option, - event_authority: Option, - program: Option, - base_mint_param: Option, - curve_param: Option, - vesting_param: Option, - __remaining_accounts: Vec, -} - -impl InitializeBuilder { - pub fn new() -> Self { Self::default() } - - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// Account to store the base token's metadata - /// Created using Metaplex metadata program - #[inline(always)] - pub fn metadata_account(&mut self, metadata_account: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_account = Some(metadata_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for the base token - /// Must be the standard Token program - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for the quote token - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - /// Metaplex Token Metadata program - /// Used to create metadata for the base token - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Required for rent exempt calculations - #[inline(always)] - pub fn rent_program(&mut self, rent_program: solana_pubkey::Pubkey) -> &mut Self { - self.rent_program = Some(rent_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn base_mint_param(&mut self, base_mint_param: MintParams) -> &mut Self { - self.base_mint_param = Some(base_mint_param); - self - } - - #[inline(always)] - pub fn curve_param(&mut self, curve_param: CurveParams) -> &mut Self { - self.curve_param = Some(curve_param); - self - } - - #[inline(always)] - pub fn vesting_param(&mut self, vesting_param: VestingParams) -> &mut Self { - self.vesting_param = Some(vesting_param); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Initialize { - payer: self.payer.expect("payer is not set"), - creator: self.creator.expect("creator is not set"), - global_config: self.global_config.expect("global_config is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - metadata_account: self.metadata_account.expect("metadata_account is not set"), - base_token_program: self.base_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - quote_token_program: self.quote_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - metadata_program: self.metadata_program.unwrap_or(solana_pubkey::pubkey!( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent_program: self.rent_program.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeInstructionArgs { - base_mint_param: self - .base_mint_param - .clone() - .expect("base_mint_param is not set"), - curve_param: self.curve_param.clone().expect("curve_param is not set"), - vesting_param: self - .vesting_param - .clone() - .expect("vesting_param is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize` CPI accounts. -pub struct InitializeCpiAccounts<'a, 'b> { - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// Account to store the base token's metadata - /// Created using Metaplex metadata program - pub metadata_account: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the quote token - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Metaplex Token Metadata program - /// Used to create metadata for the base token - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for rent exempt calculations - pub rent_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize` CPI instruction. -pub struct InitializeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// Account to store the base token's metadata - /// Created using Metaplex metadata program - pub metadata_account: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the quote token - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Metaplex Token Metadata program - /// Used to create metadata for the base token - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for rent exempt calculations - pub rent_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeInstructionArgs, -} - -impl<'a, 'b> InitializeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCpiAccounts<'a, 'b>, - args: InitializeInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - creator: accounts.creator, - global_config: accounts.global_config, - platform_config: accounts.platform_config, - authority: accounts.authority, - pool_state: accounts.pool_state, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - metadata_account: accounts.metadata_account, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - metadata_program: accounts.metadata_program, - system_program: accounts.system_program, - rent_program: accounts.rent_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.metadata_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(19 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.metadata_account.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Initialize` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` creator -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[]` authority -/// 5. `[writable]` pool_state -/// 6. `[writable, signer]` base_mint -/// 7. `[]` quote_mint -/// 8. `[writable]` base_vault -/// 9. `[writable]` quote_vault -/// 10. `[writable]` metadata_account -/// 11. `[]` base_token_program -/// 12. `[]` quote_token_program -/// 13. `[]` metadata_program -/// 14. `[]` system_program -/// 15. `[]` rent_program -/// 16. `[]` event_authority -/// 17. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCpiBuilderInstruction { - __program: program, - payer: None, - creator: None, - global_config: None, - platform_config: None, - authority: None, - pool_state: None, - base_mint: None, - quote_mint: None, - base_vault: None, - quote_vault: None, - metadata_account: None, - base_token_program: None, - quote_token_program: None, - metadata_program: None, - system_program: None, - rent_program: None, - event_authority: None, - program: None, - base_mint_param: None, - curve_param: None, - vesting_param: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// Account to store the base token's metadata - /// Created using Metaplex metadata program - #[inline(always)] - pub fn metadata_account( - &mut self, - metadata_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_account = Some(metadata_account); - self - } - - /// SPL Token program for the base token - /// Must be the standard Token program - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - /// SPL Token program for the quote token - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - /// Metaplex Token Metadata program - /// Used to create metadata for the base token - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Required for rent exempt calculations - #[inline(always)] - pub fn rent_program( - &mut self, - rent_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_program = Some(rent_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn base_mint_param(&mut self, base_mint_param: MintParams) -> &mut Self { - self.instruction.base_mint_param = Some(base_mint_param); - self - } - - #[inline(always)] - pub fn curve_param(&mut self, curve_param: CurveParams) -> &mut Self { - self.instruction.curve_param = Some(curve_param); - self - } - - #[inline(always)] - pub fn vesting_param(&mut self, vesting_param: VestingParams) -> &mut Self { - self.instruction.vesting_param = Some(vesting_param); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeInstructionArgs { - base_mint_param: self - .instruction - .base_mint_param - .clone() - .expect("base_mint_param is not set"), - curve_param: self - .instruction - .curve_param - .clone() - .expect("curve_param is not set"), - vesting_param: self - .instruction - .vesting_param - .clone() - .expect("vesting_param is not set"), - }; - let instruction = InitializeCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - metadata_account: self - .instruction - .metadata_account - .expect("metadata_account is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent_program: self - .instruction - .rent_program - .expect("rent_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_account: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint_param: Option, - curve_param: Option, - vesting_param: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/initialize_v2.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/initialize_v2.rs deleted file mode 100644 index 61554f18..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/initialize_v2.rs +++ /dev/null @@ -1,1170 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{AmmCreatorFeeOn, CurveParams, MintParams, VestingParams}; - -pub const INITIALIZE_V2_DISCRIMINATOR: [u8; 8] = [67, 153, 175, 39, 218, 16, 38, 32]; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeV2 { - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub payer: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: solana_pubkey::Pubkey, - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - pub platform_config: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: solana_pubkey::Pubkey, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_mint: solana_pubkey::Pubkey, - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - pub quote_mint: solana_pubkey::Pubkey, - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - pub base_vault: solana_pubkey::Pubkey, - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - pub quote_vault: solana_pubkey::Pubkey, - /// Account to store the base token's metadata - /// Created using Metaplex metadata program - pub metadata_account: solana_pubkey::Pubkey, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: solana_pubkey::Pubkey, - /// SPL Token program for the quote token - pub quote_token_program: solana_pubkey::Pubkey, - /// Metaplex Token Metadata program - /// Used to create metadata for the base token - pub metadata_program: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, - /// Required for rent exempt calculations - pub rent_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeV2 { - pub fn instruction( - &self, - args: InitializeV2InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeV2InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new(self.base_mint, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.metadata_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeV2InstructionData { - discriminator: [u8; 8], -} - -impl InitializeV2InstructionData { - pub fn new() -> Self { - Self { - discriminator: [67, 153, 175, 39, 218, 16, 38, 32], - } - } -} - -impl Default for InitializeV2InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeV2InstructionArgs { - pub base_mint_param: MintParams, - pub curve_param: CurveParams, - pub vesting_param: VestingParams, - pub amm_fee_on: AmmCreatorFeeOn, -} - -/// Instruction builder for `InitializeV2`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` creator -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[]` authority -/// 5. `[writable]` pool_state -/// 6. `[writable, signer]` base_mint -/// 7. `[]` quote_mint -/// 8. `[writable]` base_vault -/// 9. `[writable]` quote_vault -/// 10. `[writable]` metadata_account -/// 11. `[optional]` base_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 12. `[optional]` quote_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 13. `[optional]` metadata_program (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -/// 14. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 15. `[optional]` rent_program (default to `SysvarRent111111111111111111111111111111111`) -/// 16. `[]` event_authority -/// 17. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeV2Builder { - payer: Option, - creator: Option, - global_config: Option, - platform_config: Option, - authority: Option, - pool_state: Option, - base_mint: Option, - quote_mint: Option, - base_vault: Option, - quote_vault: Option, - metadata_account: Option, - base_token_program: Option, - quote_token_program: Option, - metadata_program: Option, - system_program: Option, - rent_program: Option, - event_authority: Option, - program: Option, - base_mint_param: Option, - curve_param: Option, - vesting_param: Option, - amm_fee_on: Option, - __remaining_accounts: Vec, -} - -impl InitializeV2Builder { - pub fn new() -> Self { Self::default() } - - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// Account to store the base token's metadata - /// Created using Metaplex metadata program - #[inline(always)] - pub fn metadata_account(&mut self, metadata_account: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_account = Some(metadata_account); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for the base token - /// Must be the standard Token program - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for the quote token - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - /// Metaplex Token Metadata program - /// Used to create metadata for the base token - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Required for rent exempt calculations - #[inline(always)] - pub fn rent_program(&mut self, rent_program: solana_pubkey::Pubkey) -> &mut Self { - self.rent_program = Some(rent_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn base_mint_param(&mut self, base_mint_param: MintParams) -> &mut Self { - self.base_mint_param = Some(base_mint_param); - self - } - - #[inline(always)] - pub fn curve_param(&mut self, curve_param: CurveParams) -> &mut Self { - self.curve_param = Some(curve_param); - self - } - - #[inline(always)] - pub fn vesting_param(&mut self, vesting_param: VestingParams) -> &mut Self { - self.vesting_param = Some(vesting_param); - self - } - - #[inline(always)] - pub fn amm_fee_on(&mut self, amm_fee_on: AmmCreatorFeeOn) -> &mut Self { - self.amm_fee_on = Some(amm_fee_on); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeV2 { - payer: self.payer.expect("payer is not set"), - creator: self.creator.expect("creator is not set"), - global_config: self.global_config.expect("global_config is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - metadata_account: self.metadata_account.expect("metadata_account is not set"), - base_token_program: self.base_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - quote_token_program: self.quote_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - metadata_program: self.metadata_program.unwrap_or(solana_pubkey::pubkey!( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent_program: self.rent_program.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeV2InstructionArgs { - base_mint_param: self - .base_mint_param - .clone() - .expect("base_mint_param is not set"), - curve_param: self.curve_param.clone().expect("curve_param is not set"), - vesting_param: self - .vesting_param - .clone() - .expect("vesting_param is not set"), - amm_fee_on: self.amm_fee_on.clone().expect("amm_fee_on is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_v2` CPI accounts. -pub struct InitializeV2CpiAccounts<'a, 'b> { - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// Account to store the base token's metadata - /// Created using Metaplex metadata program - pub metadata_account: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the quote token - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Metaplex Token Metadata program - /// Used to create metadata for the base token - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for rent exempt calculations - pub rent_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_v2` CPI instruction. -pub struct InitializeV2Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// Account to store the base token's metadata - /// Created using Metaplex metadata program - pub metadata_account: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the quote token - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Metaplex Token Metadata program - /// Used to create metadata for the base token - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for rent exempt calculations - pub rent_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeV2InstructionArgs, -} - -impl<'a, 'b> InitializeV2Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeV2CpiAccounts<'a, 'b>, - args: InitializeV2InstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - creator: accounts.creator, - global_config: accounts.global_config, - platform_config: accounts.platform_config, - authority: accounts.authority, - pool_state: accounts.pool_state, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - metadata_account: accounts.metadata_account, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - metadata_program: accounts.metadata_program, - system_program: accounts.system_program, - rent_program: accounts.rent_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.metadata_account.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeV2InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(19 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.metadata_account.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeV2` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` creator -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[]` authority -/// 5. `[writable]` pool_state -/// 6. `[writable, signer]` base_mint -/// 7. `[]` quote_mint -/// 8. `[writable]` base_vault -/// 9. `[writable]` quote_vault -/// 10. `[writable]` metadata_account -/// 11. `[]` base_token_program -/// 12. `[]` quote_token_program -/// 13. `[]` metadata_program -/// 14. `[]` system_program -/// 15. `[]` rent_program -/// 16. `[]` event_authority -/// 17. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeV2CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeV2CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeV2CpiBuilderInstruction { - __program: program, - payer: None, - creator: None, - global_config: None, - platform_config: None, - authority: None, - pool_state: None, - base_mint: None, - quote_mint: None, - base_vault: None, - quote_vault: None, - metadata_account: None, - base_token_program: None, - quote_token_program: None, - metadata_program: None, - system_program: None, - rent_program: None, - event_authority: None, - program: None, - base_mint_param: None, - curve_param: None, - vesting_param: None, - amm_fee_on: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// Account to store the base token's metadata - /// Created using Metaplex metadata program - #[inline(always)] - pub fn metadata_account( - &mut self, - metadata_account: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_account = Some(metadata_account); - self - } - - /// SPL Token program for the base token - /// Must be the standard Token program - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - /// SPL Token program for the quote token - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - /// Metaplex Token Metadata program - /// Used to create metadata for the base token - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Required for rent exempt calculations - #[inline(always)] - pub fn rent_program( - &mut self, - rent_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_program = Some(rent_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn base_mint_param(&mut self, base_mint_param: MintParams) -> &mut Self { - self.instruction.base_mint_param = Some(base_mint_param); - self - } - - #[inline(always)] - pub fn curve_param(&mut self, curve_param: CurveParams) -> &mut Self { - self.instruction.curve_param = Some(curve_param); - self - } - - #[inline(always)] - pub fn vesting_param(&mut self, vesting_param: VestingParams) -> &mut Self { - self.instruction.vesting_param = Some(vesting_param); - self - } - - #[inline(always)] - pub fn amm_fee_on(&mut self, amm_fee_on: AmmCreatorFeeOn) -> &mut Self { - self.instruction.amm_fee_on = Some(amm_fee_on); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeV2InstructionArgs { - base_mint_param: self - .instruction - .base_mint_param - .clone() - .expect("base_mint_param is not set"), - curve_param: self - .instruction - .curve_param - .clone() - .expect("curve_param is not set"), - vesting_param: self - .instruction - .vesting_param - .clone() - .expect("vesting_param is not set"), - amm_fee_on: self - .instruction - .amm_fee_on - .clone() - .expect("amm_fee_on is not set"), - }; - let instruction = InitializeV2Cpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - metadata_account: self - .instruction - .metadata_account - .expect("metadata_account is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent_program: self - .instruction - .rent_program - .expect("rent_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeV2CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_account: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint_param: Option, - curve_param: Option, - vesting_param: Option, - amm_fee_on: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/initialize_with_token2022.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/initialize_with_token2022.rs deleted file mode 100644 index e64e54c3..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/initialize_with_token2022.rs +++ /dev/null @@ -1,1045 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{ - AmmCreatorFeeOn, CurveParams, MintParams, TransferFeeExtensionParams, VestingParams, -}; - -pub const INITIALIZE_WITH_TOKEN2022_DISCRIMINATOR: [u8; 8] = [37, 190, 126, 222, 44, 154, 171, 17]; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeWithToken2022 { - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub payer: solana_pubkey::Pubkey, - - pub creator: solana_pubkey::Pubkey, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: solana_pubkey::Pubkey, - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - pub platform_config: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: solana_pubkey::Pubkey, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_mint: solana_pubkey::Pubkey, - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - pub quote_mint: solana_pubkey::Pubkey, - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - pub base_vault: solana_pubkey::Pubkey, - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - pub quote_vault: solana_pubkey::Pubkey, - /// SPL Token program for the base token - pub base_token_program: solana_pubkey::Pubkey, - /// SPL Token program for the quote token - pub quote_token_program: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl InitializeWithToken2022 { - pub fn instruction( - &self, - args: InitializeWithToken2022InstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: InitializeWithToken2022InstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.creator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new(self.base_mint, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeWithToken2022InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeWithToken2022InstructionData { - discriminator: [u8; 8], -} - -impl InitializeWithToken2022InstructionData { - pub fn new() -> Self { - Self { - discriminator: [37, 190, 126, 222, 44, 154, 171, 17], - } - } -} - -impl Default for InitializeWithToken2022InstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeWithToken2022InstructionArgs { - pub base_mint_param: MintParams, - pub curve_param: CurveParams, - pub vesting_param: VestingParams, - pub amm_fee_on: AmmCreatorFeeOn, - pub transfer_fee_extension_param: Option, -} - -/// Instruction builder for `InitializeWithToken2022`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` creator -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[]` authority -/// 5. `[writable]` pool_state -/// 6. `[writable, signer]` base_mint -/// 7. `[]` quote_mint -/// 8. `[writable]` base_vault -/// 9. `[writable]` quote_vault -/// 10. `[optional]` base_token_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) -/// 11. `[optional]` quote_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 12. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct InitializeWithToken2022Builder { - payer: Option, - creator: Option, - global_config: Option, - platform_config: Option, - authority: Option, - pool_state: Option, - base_mint: Option, - quote_mint: Option, - base_vault: Option, - quote_vault: Option, - base_token_program: Option, - quote_token_program: Option, - system_program: Option, - event_authority: Option, - program: Option, - base_mint_param: Option, - curve_param: Option, - vesting_param: Option, - amm_fee_on: Option, - transfer_fee_extension_param: Option, - __remaining_accounts: Vec, -} - -impl InitializeWithToken2022Builder { - pub fn new() -> Self { Self::default() } - - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']` - /// SPL Token program for the base token - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for the quote token - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn base_mint_param(&mut self, base_mint_param: MintParams) -> &mut Self { - self.base_mint_param = Some(base_mint_param); - self - } - - #[inline(always)] - pub fn curve_param(&mut self, curve_param: CurveParams) -> &mut Self { - self.curve_param = Some(curve_param); - self - } - - #[inline(always)] - pub fn vesting_param(&mut self, vesting_param: VestingParams) -> &mut Self { - self.vesting_param = Some(vesting_param); - self - } - - #[inline(always)] - pub fn amm_fee_on(&mut self, amm_fee_on: AmmCreatorFeeOn) -> &mut Self { - self.amm_fee_on = Some(amm_fee_on); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn transfer_fee_extension_param( - &mut self, - transfer_fee_extension_param: TransferFeeExtensionParams, - ) -> &mut Self { - self.transfer_fee_extension_param = Some(transfer_fee_extension_param); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeWithToken2022 { - payer: self.payer.expect("payer is not set"), - creator: self.creator.expect("creator is not set"), - global_config: self.global_config.expect("global_config is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - base_token_program: self.base_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - )), - quote_token_program: self.quote_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = InitializeWithToken2022InstructionArgs { - base_mint_param: self - .base_mint_param - .clone() - .expect("base_mint_param is not set"), - curve_param: self.curve_param.clone().expect("curve_param is not set"), - vesting_param: self - .vesting_param - .clone() - .expect("vesting_param is not set"), - amm_fee_on: self.amm_fee_on.clone().expect("amm_fee_on is not set"), - transfer_fee_extension_param: self.transfer_fee_extension_param.clone(), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `initialize_with_token2022` CPI accounts. -pub struct InitializeWithToken2022CpiAccounts<'a, 'b> { - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the quote token - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_with_token2022` CPI instruction. -pub struct InitializeWithToken2022Cpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the quote token - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: InitializeWithToken2022InstructionArgs, -} - -impl<'a, 'b> InitializeWithToken2022Cpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeWithToken2022CpiAccounts<'a, 'b>, - args: InitializeWithToken2022InstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - creator: accounts.creator, - global_config: accounts.global_config, - platform_config: accounts.platform_config, - authority: accounts.authority, - pool_state: accounts.pool_state, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - system_program: accounts.system_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.creator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_mint.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&InitializeWithToken2022InstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeWithToken2022` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` creator -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[]` authority -/// 5. `[writable]` pool_state -/// 6. `[writable, signer]` base_mint -/// 7. `[]` quote_mint -/// 8. `[writable]` base_vault -/// 9. `[writable]` quote_vault -/// 10. `[]` base_token_program -/// 11. `[]` quote_token_program -/// 12. `[]` system_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct InitializeWithToken2022CpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeWithToken2022CpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeWithToken2022CpiBuilderInstruction { - __program: program, - payer: None, - creator: None, - global_config: None, - platform_config: None, - authority: None, - pool_state: None, - base_mint: None, - quote_mint: None, - base_vault: None, - quote_vault: None, - base_token_program: None, - quote_token_program: None, - system_program: None, - event_authority: None, - program: None, - base_mint_param: None, - curve_param: None, - vesting_param: None, - amm_fee_on: None, - transfer_fee_extension_param: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The account paying for the initialization costs - /// This can be any account with sufficient SOL to cover the transaction - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform info - /// Includes settings like the fee_rate, name, web, img of the platform - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - /// PDA that acts as the authority for pool vault and mint operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The mint for the base token (token being sold) - /// Created in this instruction with specified decimals - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - /// The mint for the quote token (token used to buy) - /// Must match the quote_mint specified in global config - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// Token account that holds the pool's base tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// Token account that holds the pool's quote tokens - /// PDA generated using POOL_VAULT_SEED - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// SPL Token program for the base token - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - /// SPL Token program for the quote token - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn base_mint_param(&mut self, base_mint_param: MintParams) -> &mut Self { - self.instruction.base_mint_param = Some(base_mint_param); - self - } - - #[inline(always)] - pub fn curve_param(&mut self, curve_param: CurveParams) -> &mut Self { - self.instruction.curve_param = Some(curve_param); - self - } - - #[inline(always)] - pub fn vesting_param(&mut self, vesting_param: VestingParams) -> &mut Self { - self.instruction.vesting_param = Some(vesting_param); - self - } - - #[inline(always)] - pub fn amm_fee_on(&mut self, amm_fee_on: AmmCreatorFeeOn) -> &mut Self { - self.instruction.amm_fee_on = Some(amm_fee_on); - self - } - - /// `[optional argument]` - #[inline(always)] - pub fn transfer_fee_extension_param( - &mut self, - transfer_fee_extension_param: TransferFeeExtensionParams, - ) -> &mut Self { - self.instruction.transfer_fee_extension_param = Some(transfer_fee_extension_param); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = InitializeWithToken2022InstructionArgs { - base_mint_param: self - .instruction - .base_mint_param - .clone() - .expect("base_mint_param is not set"), - curve_param: self - .instruction - .curve_param - .clone() - .expect("curve_param is not set"), - vesting_param: self - .instruction - .vesting_param - .clone() - .expect("vesting_param is not set"), - amm_fee_on: self - .instruction - .amm_fee_on - .clone() - .expect("amm_fee_on is not set"), - transfer_fee_extension_param: self.instruction.transfer_fee_extension_param.clone(), - }; - let instruction = InitializeWithToken2022Cpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - creator: self.instruction.creator.expect("creator is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeWithToken2022CpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint_param: Option, - curve_param: Option, - vesting_param: Option, - amm_fee_on: Option, - transfer_fee_extension_param: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/migrate_to_amm.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/migrate_to_amm.rs deleted file mode 100644 index cec4dc0d..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/migrate_to_amm.rs +++ /dev/null @@ -1,1701 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const MIGRATE_TO_AMM_DISCRIMINATOR: [u8; 8] = [207, 82, 192, 145, 254, 207, 145, 223]; - -/// Accounts. -#[derive(Debug)] -pub struct MigrateToAmm { - /// Only migrate_to_amm_wallet can migrate to cpswap pool - /// This signer must match the migrate_to_amm_wallet saved in global_config - pub payer: solana_pubkey::Pubkey, - /// The mint for the base token (token being sold) - pub base_mint: solana_pubkey::Pubkey, - /// The mint for the quote token (token used to buy) - pub quote_mint: solana_pubkey::Pubkey, - - pub openbook_program: solana_pubkey::Pubkey, - /// Account created and asigned to openbook_program but not been initialized - pub market: solana_pubkey::Pubkey, - /// Account created and asigned to openbook_program but not been initialized - pub request_queue: solana_pubkey::Pubkey, - /// Account created and asigned to openbook_program but not been initialized - pub event_queue: solana_pubkey::Pubkey, - /// Account created and asigned to openbook_program but not been initialized - pub bids: solana_pubkey::Pubkey, - /// Account created and asigned to openbook_program but not been initialized - pub asks: solana_pubkey::Pubkey, - - pub market_vault_signer: solana_pubkey::Pubkey, - /// Token account that holds the market's base tokens - pub market_base_vault: solana_pubkey::Pubkey, - /// Token account that holds the market's quote tokens - pub market_quote_vault: solana_pubkey::Pubkey, - - pub amm_program: solana_pubkey::Pubkey, - - pub amm_pool: solana_pubkey::Pubkey, - - pub amm_authority: solana_pubkey::Pubkey, - - pub amm_open_orders: solana_pubkey::Pubkey, - - pub amm_lp_mint: solana_pubkey::Pubkey, - - pub amm_base_vault: solana_pubkey::Pubkey, - - pub amm_quote_vault: solana_pubkey::Pubkey, - - pub amm_target_orders: solana_pubkey::Pubkey, - - pub amm_config: solana_pubkey::Pubkey, - - pub amm_create_fee_destination: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: solana_pubkey::Pubkey, - /// Global config account stores owner - pub global_config: solana_pubkey::Pubkey, - /// The pool's vault for base tokens - /// Will be fully drained during migration - pub base_vault: solana_pubkey::Pubkey, - /// The pool's vault for quote tokens - /// Will be fully drained during migration - pub quote_vault: solana_pubkey::Pubkey, - - pub pool_lp_token: solana_pubkey::Pubkey, - /// SPL Token program for the base token - /// Must be the standard Token program - pub spl_token_program: solana_pubkey::Pubkey, - /// Program to create an ATA for receiving fee NFT - pub associated_token_program: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, - /// Required for rent exempt calculations - pub rent_program: solana_pubkey::Pubkey, -} - -impl MigrateToAmm { - pub fn instruction( - &self, - args: MigrateToAmmInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: MigrateToAmmInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(32 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.openbook_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.market, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.request_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.event_queue, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.bids, false)); - accounts.push(solana_instruction::AccountMeta::new(self.asks, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.market_vault_signer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.market_base_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.market_quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.amm_pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_open_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_base_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_target_orders, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.amm_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.amm_create_fee_destination, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.authority, false)); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_lp_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.spl_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&MigrateToAmmInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateToAmmInstructionData { - discriminator: [u8; 8], -} - -impl MigrateToAmmInstructionData { - pub fn new() -> Self { - Self { - discriminator: [207, 82, 192, 145, 254, 207, 145, 223], - } - } -} - -impl Default for MigrateToAmmInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateToAmmInstructionArgs { - pub base_lot_size: u64, - pub quote_lot_size: u64, - pub market_vault_signer_nonce: u8, -} - -/// Instruction builder for `MigrateToAmm`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` base_mint -/// 2. `[]` quote_mint -/// 3. `[optional]` openbook_program (default to `srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX`) -/// 4. `[writable]` market -/// 5. `[writable]` request_queue -/// 6. `[writable]` event_queue -/// 7. `[writable]` bids -/// 8. `[writable]` asks -/// 9. `[]` market_vault_signer -/// 10. `[writable]` market_base_vault -/// 11. `[writable]` market_quote_vault -/// 12. `[optional]` amm_program (default to `675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8`) -/// 13. `[writable]` amm_pool -/// 14. `[]` amm_authority -/// 15. `[writable]` amm_open_orders -/// 16. `[writable]` amm_lp_mint -/// 17. `[writable]` amm_base_vault -/// 18. `[writable]` amm_quote_vault -/// 19. `[writable]` amm_target_orders -/// 20. `[]` amm_config -/// 21. `[writable]` amm_create_fee_destination -/// 22. `[writable]` authority -/// 23. `[writable]` pool_state -/// 24. `[]` global_config -/// 25. `[writable]` base_vault -/// 26. `[writable]` quote_vault -/// 27. `[writable]` pool_lp_token -/// 28. `[optional]` spl_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 29. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 30. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 31. `[optional]` rent_program (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct MigrateToAmmBuilder { - payer: Option, - base_mint: Option, - quote_mint: Option, - openbook_program: Option, - market: Option, - request_queue: Option, - event_queue: Option, - bids: Option, - asks: Option, - market_vault_signer: Option, - market_base_vault: Option, - market_quote_vault: Option, - amm_program: Option, - amm_pool: Option, - amm_authority: Option, - amm_open_orders: Option, - amm_lp_mint: Option, - amm_base_vault: Option, - amm_quote_vault: Option, - amm_target_orders: Option, - amm_config: Option, - amm_create_fee_destination: Option, - authority: Option, - pool_state: Option, - global_config: Option, - base_vault: Option, - quote_vault: Option, - pool_lp_token: Option, - spl_token_program: Option, - associated_token_program: Option, - system_program: Option, - rent_program: Option, - base_lot_size: Option, - quote_lot_size: Option, - market_vault_signer_nonce: Option, - __remaining_accounts: Vec, -} - -impl MigrateToAmmBuilder { - pub fn new() -> Self { Self::default() } - - /// Only migrate_to_amm_wallet can migrate to cpswap pool - /// This signer must match the migrate_to_amm_wallet saved in global_config - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// The mint for the base token (token being sold) - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - /// The mint for the quote token (token used to buy) - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// `[optional account, default to 'srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX']` - #[inline(always)] - pub fn openbook_program(&mut self, openbook_program: solana_pubkey::Pubkey) -> &mut Self { - self.openbook_program = Some(openbook_program); - self - } - - /// Account created and asigned to openbook_program but not been initialized - #[inline(always)] - pub fn market(&mut self, market: solana_pubkey::Pubkey) -> &mut Self { - self.market = Some(market); - self - } - - /// Account created and asigned to openbook_program but not been initialized - #[inline(always)] - pub fn request_queue(&mut self, request_queue: solana_pubkey::Pubkey) -> &mut Self { - self.request_queue = Some(request_queue); - self - } - - /// Account created and asigned to openbook_program but not been initialized - #[inline(always)] - pub fn event_queue(&mut self, event_queue: solana_pubkey::Pubkey) -> &mut Self { - self.event_queue = Some(event_queue); - self - } - - /// Account created and asigned to openbook_program but not been initialized - #[inline(always)] - pub fn bids(&mut self, bids: solana_pubkey::Pubkey) -> &mut Self { - self.bids = Some(bids); - self - } - - /// Account created and asigned to openbook_program but not been initialized - #[inline(always)] - pub fn asks(&mut self, asks: solana_pubkey::Pubkey) -> &mut Self { - self.asks = Some(asks); - self - } - - #[inline(always)] - pub fn market_vault_signer(&mut self, market_vault_signer: solana_pubkey::Pubkey) -> &mut Self { - self.market_vault_signer = Some(market_vault_signer); - self - } - - /// Token account that holds the market's base tokens - #[inline(always)] - pub fn market_base_vault(&mut self, market_base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.market_base_vault = Some(market_base_vault); - self - } - - /// Token account that holds the market's quote tokens - #[inline(always)] - pub fn market_quote_vault(&mut self, market_quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.market_quote_vault = Some(market_quote_vault); - self - } - - /// `[optional account, default to '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8']` - #[inline(always)] - pub fn amm_program(&mut self, amm_program: solana_pubkey::Pubkey) -> &mut Self { - self.amm_program = Some(amm_program); - self - } - - #[inline(always)] - pub fn amm_pool(&mut self, amm_pool: solana_pubkey::Pubkey) -> &mut Self { - self.amm_pool = Some(amm_pool); - self - } - - #[inline(always)] - pub fn amm_authority(&mut self, amm_authority: solana_pubkey::Pubkey) -> &mut Self { - self.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders(&mut self, amm_open_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_lp_mint(&mut self, amm_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.amm_lp_mint = Some(amm_lp_mint); - self - } - - #[inline(always)] - pub fn amm_base_vault(&mut self, amm_base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.amm_base_vault = Some(amm_base_vault); - self - } - - #[inline(always)] - pub fn amm_quote_vault(&mut self, amm_quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.amm_quote_vault = Some(amm_quote_vault); - self - } - - #[inline(always)] - pub fn amm_target_orders(&mut self, amm_target_orders: solana_pubkey::Pubkey) -> &mut Self { - self.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self { - self.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn amm_create_fee_destination( - &mut self, - amm_create_fee_destination: solana_pubkey::Pubkey, - ) -> &mut Self { - self.amm_create_fee_destination = Some(amm_create_fee_destination); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Global config account stores owner - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// The pool's vault for base tokens - /// Will be fully drained during migration - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will be fully drained during migration - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - #[inline(always)] - pub fn pool_lp_token(&mut self, pool_lp_token: solana_pubkey::Pubkey) -> &mut Self { - self.pool_lp_token = Some(pool_lp_token); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for the base token - /// Must be the standard Token program - #[inline(always)] - pub fn spl_token_program(&mut self, spl_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.spl_token_program = Some(spl_token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Program to create an ATA for receiving fee NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Required for rent exempt calculations - #[inline(always)] - pub fn rent_program(&mut self, rent_program: solana_pubkey::Pubkey) -> &mut Self { - self.rent_program = Some(rent_program); - self - } - - #[inline(always)] - pub fn base_lot_size(&mut self, base_lot_size: u64) -> &mut Self { - self.base_lot_size = Some(base_lot_size); - self - } - - #[inline(always)] - pub fn quote_lot_size(&mut self, quote_lot_size: u64) -> &mut Self { - self.quote_lot_size = Some(quote_lot_size); - self - } - - #[inline(always)] - pub fn market_vault_signer_nonce(&mut self, market_vault_signer_nonce: u8) -> &mut Self { - self.market_vault_signer_nonce = Some(market_vault_signer_nonce); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrateToAmm { - payer: self.payer.expect("payer is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - openbook_program: self.openbook_program.unwrap_or(solana_pubkey::pubkey!( - "srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX" - )), - market: self.market.expect("market is not set"), - request_queue: self.request_queue.expect("request_queue is not set"), - event_queue: self.event_queue.expect("event_queue is not set"), - bids: self.bids.expect("bids is not set"), - asks: self.asks.expect("asks is not set"), - market_vault_signer: self - .market_vault_signer - .expect("market_vault_signer is not set"), - market_base_vault: self - .market_base_vault - .expect("market_base_vault is not set"), - market_quote_vault: self - .market_quote_vault - .expect("market_quote_vault is not set"), - amm_program: self.amm_program.unwrap_or(solana_pubkey::pubkey!( - "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" - )), - amm_pool: self.amm_pool.expect("amm_pool is not set"), - amm_authority: self.amm_authority.expect("amm_authority is not set"), - amm_open_orders: self.amm_open_orders.expect("amm_open_orders is not set"), - amm_lp_mint: self.amm_lp_mint.expect("amm_lp_mint is not set"), - amm_base_vault: self.amm_base_vault.expect("amm_base_vault is not set"), - amm_quote_vault: self.amm_quote_vault.expect("amm_quote_vault is not set"), - amm_target_orders: self - .amm_target_orders - .expect("amm_target_orders is not set"), - amm_config: self.amm_config.expect("amm_config is not set"), - amm_create_fee_destination: self - .amm_create_fee_destination - .expect("amm_create_fee_destination is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - global_config: self.global_config.expect("global_config is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - pool_lp_token: self.pool_lp_token.expect("pool_lp_token is not set"), - spl_token_program: self.spl_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent_program: self.rent_program.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = MigrateToAmmInstructionArgs { - base_lot_size: self - .base_lot_size - .clone() - .expect("base_lot_size is not set"), - quote_lot_size: self - .quote_lot_size - .clone() - .expect("quote_lot_size is not set"), - market_vault_signer_nonce: self - .market_vault_signer_nonce - .clone() - .expect("market_vault_signer_nonce is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `migrate_to_amm` CPI accounts. -pub struct MigrateToAmmCpiAccounts<'a, 'b> { - /// Only migrate_to_amm_wallet can migrate to cpswap pool - /// This signer must match the migrate_to_amm_wallet saved in global_config - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token (token used to buy) - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub openbook_program: &'b solana_account_info::AccountInfo<'a>, - /// Account created and asigned to openbook_program but not been initialized - pub market: &'b solana_account_info::AccountInfo<'a>, - /// Account created and asigned to openbook_program but not been initialized - pub request_queue: &'b solana_account_info::AccountInfo<'a>, - /// Account created and asigned to openbook_program but not been initialized - pub event_queue: &'b solana_account_info::AccountInfo<'a>, - /// Account created and asigned to openbook_program but not been initialized - pub bids: &'b solana_account_info::AccountInfo<'a>, - /// Account created and asigned to openbook_program but not been initialized - pub asks: &'b solana_account_info::AccountInfo<'a>, - - pub market_vault_signer: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the market's base tokens - pub market_base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the market's quote tokens - pub market_quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub amm_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm_pool: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub amm_base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub amm_quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub amm_create_fee_destination: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Global config account stores owner - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be fully drained during migration - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will be fully drained during migration - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub pool_lp_token: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - /// Must be the standard Token program - pub spl_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving fee NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for rent exempt calculations - pub rent_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migrate_to_amm` CPI instruction. -pub struct MigrateToAmmCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Only migrate_to_amm_wallet can migrate to cpswap pool - /// This signer must match the migrate_to_amm_wallet saved in global_config - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token (token used to buy) - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - - pub openbook_program: &'b solana_account_info::AccountInfo<'a>, - /// Account created and asigned to openbook_program but not been initialized - pub market: &'b solana_account_info::AccountInfo<'a>, - /// Account created and asigned to openbook_program but not been initialized - pub request_queue: &'b solana_account_info::AccountInfo<'a>, - /// Account created and asigned to openbook_program but not been initialized - pub event_queue: &'b solana_account_info::AccountInfo<'a>, - /// Account created and asigned to openbook_program but not been initialized - pub bids: &'b solana_account_info::AccountInfo<'a>, - /// Account created and asigned to openbook_program but not been initialized - pub asks: &'b solana_account_info::AccountInfo<'a>, - - pub market_vault_signer: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the market's base tokens - pub market_base_vault: &'b solana_account_info::AccountInfo<'a>, - /// Token account that holds the market's quote tokens - pub market_quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub amm_program: &'b solana_account_info::AccountInfo<'a>, - - pub amm_pool: &'b solana_account_info::AccountInfo<'a>, - - pub amm_authority: &'b solana_account_info::AccountInfo<'a>, - - pub amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub amm_base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub amm_quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - - pub amm_config: &'b solana_account_info::AccountInfo<'a>, - - pub amm_create_fee_destination: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Global config account stores owner - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be fully drained during migration - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will be fully drained during migration - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub pool_lp_token: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - /// Must be the standard Token program - pub spl_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving fee NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for rent exempt calculations - pub rent_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: MigrateToAmmInstructionArgs, -} - -impl<'a, 'b> MigrateToAmmCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrateToAmmCpiAccounts<'a, 'b>, - args: MigrateToAmmInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - openbook_program: accounts.openbook_program, - market: accounts.market, - request_queue: accounts.request_queue, - event_queue: accounts.event_queue, - bids: accounts.bids, - asks: accounts.asks, - market_vault_signer: accounts.market_vault_signer, - market_base_vault: accounts.market_base_vault, - market_quote_vault: accounts.market_quote_vault, - amm_program: accounts.amm_program, - amm_pool: accounts.amm_pool, - amm_authority: accounts.amm_authority, - amm_open_orders: accounts.amm_open_orders, - amm_lp_mint: accounts.amm_lp_mint, - amm_base_vault: accounts.amm_base_vault, - amm_quote_vault: accounts.amm_quote_vault, - amm_target_orders: accounts.amm_target_orders, - amm_config: accounts.amm_config, - amm_create_fee_destination: accounts.amm_create_fee_destination, - authority: accounts.authority, - pool_state: accounts.pool_state, - global_config: accounts.global_config, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - pool_lp_token: accounts.pool_lp_token, - spl_token_program: accounts.spl_token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - rent_program: accounts.rent_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(32 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.openbook_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.market.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.request_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.event_queue.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.bids.key, false)); - accounts.push(solana_instruction::AccountMeta::new(*self.asks.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.market_vault_signer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.market_base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.market_quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_open_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_target_orders.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.amm_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.amm_create_fee_destination.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_lp_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.spl_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&MigrateToAmmInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(33 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.openbook_program.clone()); - account_infos.push(self.market.clone()); - account_infos.push(self.request_queue.clone()); - account_infos.push(self.event_queue.clone()); - account_infos.push(self.bids.clone()); - account_infos.push(self.asks.clone()); - account_infos.push(self.market_vault_signer.clone()); - account_infos.push(self.market_base_vault.clone()); - account_infos.push(self.market_quote_vault.clone()); - account_infos.push(self.amm_program.clone()); - account_infos.push(self.amm_pool.clone()); - account_infos.push(self.amm_authority.clone()); - account_infos.push(self.amm_open_orders.clone()); - account_infos.push(self.amm_lp_mint.clone()); - account_infos.push(self.amm_base_vault.clone()); - account_infos.push(self.amm_quote_vault.clone()); - account_infos.push(self.amm_target_orders.clone()); - account_infos.push(self.amm_config.clone()); - account_infos.push(self.amm_create_fee_destination.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.pool_lp_token.clone()); - account_infos.push(self.spl_token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrateToAmm` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` base_mint -/// 2. `[]` quote_mint -/// 3. `[]` openbook_program -/// 4. `[writable]` market -/// 5. `[writable]` request_queue -/// 6. `[writable]` event_queue -/// 7. `[writable]` bids -/// 8. `[writable]` asks -/// 9. `[]` market_vault_signer -/// 10. `[writable]` market_base_vault -/// 11. `[writable]` market_quote_vault -/// 12. `[]` amm_program -/// 13. `[writable]` amm_pool -/// 14. `[]` amm_authority -/// 15. `[writable]` amm_open_orders -/// 16. `[writable]` amm_lp_mint -/// 17. `[writable]` amm_base_vault -/// 18. `[writable]` amm_quote_vault -/// 19. `[writable]` amm_target_orders -/// 20. `[]` amm_config -/// 21. `[writable]` amm_create_fee_destination -/// 22. `[writable]` authority -/// 23. `[writable]` pool_state -/// 24. `[]` global_config -/// 25. `[writable]` base_vault -/// 26. `[writable]` quote_vault -/// 27. `[writable]` pool_lp_token -/// 28. `[]` spl_token_program -/// 29. `[]` associated_token_program -/// 30. `[]` system_program -/// 31. `[]` rent_program -#[derive(Clone, Debug)] -pub struct MigrateToAmmCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrateToAmmCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrateToAmmCpiBuilderInstruction { - __program: program, - payer: None, - base_mint: None, - quote_mint: None, - openbook_program: None, - market: None, - request_queue: None, - event_queue: None, - bids: None, - asks: None, - market_vault_signer: None, - market_base_vault: None, - market_quote_vault: None, - amm_program: None, - amm_pool: None, - amm_authority: None, - amm_open_orders: None, - amm_lp_mint: None, - amm_base_vault: None, - amm_quote_vault: None, - amm_target_orders: None, - amm_config: None, - amm_create_fee_destination: None, - authority: None, - pool_state: None, - global_config: None, - base_vault: None, - quote_vault: None, - pool_lp_token: None, - spl_token_program: None, - associated_token_program: None, - system_program: None, - rent_program: None, - base_lot_size: None, - quote_lot_size: None, - market_vault_signer_nonce: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Only migrate_to_amm_wallet can migrate to cpswap pool - /// This signer must match the migrate_to_amm_wallet saved in global_config - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// The mint for the base token (token being sold) - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - /// The mint for the quote token (token used to buy) - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - #[inline(always)] - pub fn openbook_program( - &mut self, - openbook_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.openbook_program = Some(openbook_program); - self - } - - /// Account created and asigned to openbook_program but not been initialized - #[inline(always)] - pub fn market(&mut self, market: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.market = Some(market); - self - } - - /// Account created and asigned to openbook_program but not been initialized - #[inline(always)] - pub fn request_queue( - &mut self, - request_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.request_queue = Some(request_queue); - self - } - - /// Account created and asigned to openbook_program but not been initialized - #[inline(always)] - pub fn event_queue( - &mut self, - event_queue: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_queue = Some(event_queue); - self - } - - /// Account created and asigned to openbook_program but not been initialized - #[inline(always)] - pub fn bids(&mut self, bids: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.bids = Some(bids); - self - } - - /// Account created and asigned to openbook_program but not been initialized - #[inline(always)] - pub fn asks(&mut self, asks: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.asks = Some(asks); - self - } - - #[inline(always)] - pub fn market_vault_signer( - &mut self, - market_vault_signer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.market_vault_signer = Some(market_vault_signer); - self - } - - /// Token account that holds the market's base tokens - #[inline(always)] - pub fn market_base_vault( - &mut self, - market_base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.market_base_vault = Some(market_base_vault); - self - } - - /// Token account that holds the market's quote tokens - #[inline(always)] - pub fn market_quote_vault( - &mut self, - market_quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.market_quote_vault = Some(market_quote_vault); - self - } - - #[inline(always)] - pub fn amm_program( - &mut self, - amm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_program = Some(amm_program); - self - } - - #[inline(always)] - pub fn amm_pool(&mut self, amm_pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.amm_pool = Some(amm_pool); - self - } - - #[inline(always)] - pub fn amm_authority( - &mut self, - amm_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_authority = Some(amm_authority); - self - } - - #[inline(always)] - pub fn amm_open_orders( - &mut self, - amm_open_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_open_orders = Some(amm_open_orders); - self - } - - #[inline(always)] - pub fn amm_lp_mint( - &mut self, - amm_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_lp_mint = Some(amm_lp_mint); - self - } - - #[inline(always)] - pub fn amm_base_vault( - &mut self, - amm_base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_base_vault = Some(amm_base_vault); - self - } - - #[inline(always)] - pub fn amm_quote_vault( - &mut self, - amm_quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_quote_vault = Some(amm_quote_vault); - self - } - - #[inline(always)] - pub fn amm_target_orders( - &mut self, - amm_target_orders: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_target_orders = Some(amm_target_orders); - self - } - - #[inline(always)] - pub fn amm_config( - &mut self, - amm_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_config = Some(amm_config); - self - } - - #[inline(always)] - pub fn amm_create_fee_destination( - &mut self, - amm_create_fee_destination: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.amm_create_fee_destination = Some(amm_create_fee_destination); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Global config account stores owner - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// The pool's vault for base tokens - /// Will be fully drained during migration - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will be fully drained during migration - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - #[inline(always)] - pub fn pool_lp_token( - &mut self, - pool_lp_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_lp_token = Some(pool_lp_token); - self - } - - /// SPL Token program for the base token - /// Must be the standard Token program - #[inline(always)] - pub fn spl_token_program( - &mut self, - spl_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); - self - } - - /// Program to create an ATA for receiving fee NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Required for rent exempt calculations - #[inline(always)] - pub fn rent_program( - &mut self, - rent_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_program = Some(rent_program); - self - } - - #[inline(always)] - pub fn base_lot_size(&mut self, base_lot_size: u64) -> &mut Self { - self.instruction.base_lot_size = Some(base_lot_size); - self - } - - #[inline(always)] - pub fn quote_lot_size(&mut self, quote_lot_size: u64) -> &mut Self { - self.instruction.quote_lot_size = Some(quote_lot_size); - self - } - - #[inline(always)] - pub fn market_vault_signer_nonce(&mut self, market_vault_signer_nonce: u8) -> &mut Self { - self.instruction.market_vault_signer_nonce = Some(market_vault_signer_nonce); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = MigrateToAmmInstructionArgs { - base_lot_size: self - .instruction - .base_lot_size - .clone() - .expect("base_lot_size is not set"), - quote_lot_size: self - .instruction - .quote_lot_size - .clone() - .expect("quote_lot_size is not set"), - market_vault_signer_nonce: self - .instruction - .market_vault_signer_nonce - .clone() - .expect("market_vault_signer_nonce is not set"), - }; - let instruction = MigrateToAmmCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - openbook_program: self - .instruction - .openbook_program - .expect("openbook_program is not set"), - - market: self.instruction.market.expect("market is not set"), - - request_queue: self - .instruction - .request_queue - .expect("request_queue is not set"), - - event_queue: self - .instruction - .event_queue - .expect("event_queue is not set"), - - bids: self.instruction.bids.expect("bids is not set"), - - asks: self.instruction.asks.expect("asks is not set"), - - market_vault_signer: self - .instruction - .market_vault_signer - .expect("market_vault_signer is not set"), - - market_base_vault: self - .instruction - .market_base_vault - .expect("market_base_vault is not set"), - - market_quote_vault: self - .instruction - .market_quote_vault - .expect("market_quote_vault is not set"), - - amm_program: self - .instruction - .amm_program - .expect("amm_program is not set"), - - amm_pool: self.instruction.amm_pool.expect("amm_pool is not set"), - - amm_authority: self - .instruction - .amm_authority - .expect("amm_authority is not set"), - - amm_open_orders: self - .instruction - .amm_open_orders - .expect("amm_open_orders is not set"), - - amm_lp_mint: self - .instruction - .amm_lp_mint - .expect("amm_lp_mint is not set"), - - amm_base_vault: self - .instruction - .amm_base_vault - .expect("amm_base_vault is not set"), - - amm_quote_vault: self - .instruction - .amm_quote_vault - .expect("amm_quote_vault is not set"), - - amm_target_orders: self - .instruction - .amm_target_orders - .expect("amm_target_orders is not set"), - - amm_config: self.instruction.amm_config.expect("amm_config is not set"), - - amm_create_fee_destination: self - .instruction - .amm_create_fee_destination - .expect("amm_create_fee_destination is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - pool_lp_token: self - .instruction - .pool_lp_token - .expect("pool_lp_token is not set"), - - spl_token_program: self - .instruction - .spl_token_program - .expect("spl_token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent_program: self - .instruction - .rent_program - .expect("rent_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrateToAmmCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - openbook_program: Option<&'b solana_account_info::AccountInfo<'a>>, - market: Option<&'b solana_account_info::AccountInfo<'a>>, - request_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - event_queue: Option<&'b solana_account_info::AccountInfo<'a>>, - bids: Option<&'b solana_account_info::AccountInfo<'a>>, - asks: Option<&'b solana_account_info::AccountInfo<'a>>, - market_vault_signer: Option<&'b solana_account_info::AccountInfo<'a>>, - market_base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - market_quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_open_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_target_orders: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_config: Option<&'b solana_account_info::AccountInfo<'a>>, - amm_create_fee_destination: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_lp_token: Option<&'b solana_account_info::AccountInfo<'a>>, - spl_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_program: Option<&'b solana_account_info::AccountInfo<'a>>, - base_lot_size: Option, - quote_lot_size: Option, - market_vault_signer_nonce: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/migrate_to_cpswap.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/migrate_to_cpswap.rs deleted file mode 100644 index 5bd87d19..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/migrate_to_cpswap.rs +++ /dev/null @@ -1,1525 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const MIGRATE_TO_CPSWAP_DISCRIMINATOR: [u8; 8] = [136, 92, 200, 103, 28, 218, 144, 140]; - -/// Accounts. -#[derive(Debug)] -pub struct MigrateToCpswap { - /// Only migrate_to_cpswap_wallet can migrate to cpswap pool - /// This signer must match the migrate_to_cpswap_wallet saved in global_config - pub payer: solana_pubkey::Pubkey, - /// The mint for the base token (token being sold) - pub base_mint: solana_pubkey::Pubkey, - /// The mint for the quote token (token used to buy) - pub quote_mint: solana_pubkey::Pubkey, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: solana_pubkey::Pubkey, - - pub cpswap_program: solana_pubkey::Pubkey, - /// PDA account: - /// seeds = [ - /// b"pool", - /// cpswap_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// seeds::program = cpswap_program, - /// - /// Or random account: must be signed by cli - pub cpswap_pool: solana_pubkey::Pubkey, - - pub cpswap_authority: solana_pubkey::Pubkey, - - pub cpswap_lp_mint: solana_pubkey::Pubkey, - - pub cpswap_base_vault: solana_pubkey::Pubkey, - - pub cpswap_quote_vault: solana_pubkey::Pubkey, - - pub cpswap_config: solana_pubkey::Pubkey, - - pub cpswap_create_pool_fee: solana_pubkey::Pubkey, - - pub cpswap_observation: solana_pubkey::Pubkey, - - pub lock_program: solana_pubkey::Pubkey, - - pub lock_authority: solana_pubkey::Pubkey, - - pub lock_lp_vault: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: solana_pubkey::Pubkey, - /// Global config account stores owner - pub global_config: solana_pubkey::Pubkey, - /// The pool's vault for base tokens - /// Will be fully drained during migration - pub base_vault: solana_pubkey::Pubkey, - /// The pool's vault for quote tokens - /// Will be fully drained during migration - pub quote_vault: solana_pubkey::Pubkey, - - pub pool_lp_token: solana_pubkey::Pubkey, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: solana_pubkey::Pubkey, - /// SPL Token program for the quote token - pub quote_token_program: solana_pubkey::Pubkey, - /// Program to create an ATA for receiving fee NFT - pub associated_token_program: solana_pubkey::Pubkey, - /// Required for account creation - pub system_program: solana_pubkey::Pubkey, - /// Required for rent exempt calculations - pub rent_program: solana_pubkey::Pubkey, - /// Program to create NFT metadata accunt - pub metadata_program: solana_pubkey::Pubkey, -} - -impl MigrateToCpswap { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(28 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new(self.base_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cpswap_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.cpswap_pool, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cpswap_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.cpswap_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.cpswap_base_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.cpswap_quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.cpswap_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.cpswap_create_pool_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.cpswap_observation, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lock_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.lock_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lock_lp_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.authority, false)); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_lp_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&MigrateToCpswapInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateToCpswapInstructionData { - discriminator: [u8; 8], -} - -impl MigrateToCpswapInstructionData { - pub fn new() -> Self { - Self { - discriminator: [136, 92, 200, 103, 28, 218, 144, 140], - } - } -} - -impl Default for MigrateToCpswapInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `MigrateToCpswap`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[writable]` base_mint -/// 2. `[]` quote_mint -/// 3. `[]` platform_config -/// 4. `[optional]` cpswap_program (default to `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C`) -/// 5. `[writable]` cpswap_pool -/// 6. `[]` cpswap_authority -/// 7. `[writable]` cpswap_lp_mint -/// 8. `[writable]` cpswap_base_vault -/// 9. `[writable]` cpswap_quote_vault -/// 10. `[]` cpswap_config -/// 11. `[writable]` cpswap_create_pool_fee -/// 12. `[writable]` cpswap_observation -/// 13. `[optional]` lock_program (default to `LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE`) -/// 14. `[]` lock_authority -/// 15. `[writable]` lock_lp_vault -/// 16. `[writable]` authority -/// 17. `[writable]` pool_state -/// 18. `[]` global_config -/// 19. `[writable]` base_vault -/// 20. `[writable]` quote_vault -/// 21. `[writable]` pool_lp_token -/// 22. `[]` base_token_program -/// 23. `[optional]` quote_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 24. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 25. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 26. `[optional]` rent_program (default to `SysvarRent111111111111111111111111111111111`) -/// 27. `[optional]` metadata_program (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -#[derive(Clone, Debug, Default)] -pub struct MigrateToCpswapBuilder { - payer: Option, - base_mint: Option, - quote_mint: Option, - platform_config: Option, - cpswap_program: Option, - cpswap_pool: Option, - cpswap_authority: Option, - cpswap_lp_mint: Option, - cpswap_base_vault: Option, - cpswap_quote_vault: Option, - cpswap_config: Option, - cpswap_create_pool_fee: Option, - cpswap_observation: Option, - lock_program: Option, - lock_authority: Option, - lock_lp_vault: Option, - authority: Option, - pool_state: Option, - global_config: Option, - base_vault: Option, - quote_vault: Option, - pool_lp_token: Option, - base_token_program: Option, - quote_token_program: Option, - associated_token_program: Option, - system_program: Option, - rent_program: Option, - metadata_program: Option, - __remaining_accounts: Vec, -} - -impl MigrateToCpswapBuilder { - pub fn new() -> Self { Self::default() } - - /// Only migrate_to_cpswap_wallet can migrate to cpswap pool - /// This signer must match the migrate_to_cpswap_wallet saved in global_config - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// The mint for the base token (token being sold) - #[inline(always)] - pub fn base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_mint = Some(base_mint); - self - } - - /// The mint for the quote token (token used to buy) - #[inline(always)] - pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_mint = Some(quote_mint); - self - } - - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - /// `[optional account, default to 'CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C']` - #[inline(always)] - pub fn cpswap_program(&mut self, cpswap_program: solana_pubkey::Pubkey) -> &mut Self { - self.cpswap_program = Some(cpswap_program); - self - } - - /// PDA account: - /// seeds = [ - /// b"pool", - /// cpswap_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// seeds::program = cpswap_program, - /// - /// Or random account: must be signed by cli - #[inline(always)] - pub fn cpswap_pool(&mut self, cpswap_pool: solana_pubkey::Pubkey) -> &mut Self { - self.cpswap_pool = Some(cpswap_pool); - self - } - - #[inline(always)] - pub fn cpswap_authority(&mut self, cpswap_authority: solana_pubkey::Pubkey) -> &mut Self { - self.cpswap_authority = Some(cpswap_authority); - self - } - - #[inline(always)] - pub fn cpswap_lp_mint(&mut self, cpswap_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.cpswap_lp_mint = Some(cpswap_lp_mint); - self - } - - #[inline(always)] - pub fn cpswap_base_vault(&mut self, cpswap_base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.cpswap_base_vault = Some(cpswap_base_vault); - self - } - - #[inline(always)] - pub fn cpswap_quote_vault(&mut self, cpswap_quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.cpswap_quote_vault = Some(cpswap_quote_vault); - self - } - - #[inline(always)] - pub fn cpswap_config(&mut self, cpswap_config: solana_pubkey::Pubkey) -> &mut Self { - self.cpswap_config = Some(cpswap_config); - self - } - - #[inline(always)] - pub fn cpswap_create_pool_fee( - &mut self, - cpswap_create_pool_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.cpswap_create_pool_fee = Some(cpswap_create_pool_fee); - self - } - - #[inline(always)] - pub fn cpswap_observation(&mut self, cpswap_observation: solana_pubkey::Pubkey) -> &mut Self { - self.cpswap_observation = Some(cpswap_observation); - self - } - - /// `[optional account, default to 'LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE']` - #[inline(always)] - pub fn lock_program(&mut self, lock_program: solana_pubkey::Pubkey) -> &mut Self { - self.lock_program = Some(lock_program); - self - } - - #[inline(always)] - pub fn lock_authority(&mut self, lock_authority: solana_pubkey::Pubkey) -> &mut Self { - self.lock_authority = Some(lock_authority); - self - } - - #[inline(always)] - pub fn lock_lp_vault(&mut self, lock_lp_vault: solana_pubkey::Pubkey) -> &mut Self { - self.lock_lp_vault = Some(lock_lp_vault); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// Global config account stores owner - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// The pool's vault for base tokens - /// Will be fully drained during migration - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will be fully drained during migration - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - #[inline(always)] - pub fn pool_lp_token(&mut self, pool_lp_token: solana_pubkey::Pubkey) -> &mut Self { - self.pool_lp_token = Some(pool_lp_token); - self - } - - /// SPL Token program for the base token - /// Must be the standard Token program - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for the quote token - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Program to create an ATA for receiving fee NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// Required for account creation - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Required for rent exempt calculations - #[inline(always)] - pub fn rent_program(&mut self, rent_program: solana_pubkey::Pubkey) -> &mut Self { - self.rent_program = Some(rent_program); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - /// Program to create NFT metadata accunt - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = MigrateToCpswap { - payer: self.payer.expect("payer is not set"), - base_mint: self.base_mint.expect("base_mint is not set"), - quote_mint: self.quote_mint.expect("quote_mint is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - cpswap_program: self.cpswap_program.unwrap_or(solana_pubkey::pubkey!( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C" - )), - cpswap_pool: self.cpswap_pool.expect("cpswap_pool is not set"), - cpswap_authority: self.cpswap_authority.expect("cpswap_authority is not set"), - cpswap_lp_mint: self.cpswap_lp_mint.expect("cpswap_lp_mint is not set"), - cpswap_base_vault: self - .cpswap_base_vault - .expect("cpswap_base_vault is not set"), - cpswap_quote_vault: self - .cpswap_quote_vault - .expect("cpswap_quote_vault is not set"), - cpswap_config: self.cpswap_config.expect("cpswap_config is not set"), - cpswap_create_pool_fee: self - .cpswap_create_pool_fee - .expect("cpswap_create_pool_fee is not set"), - cpswap_observation: self - .cpswap_observation - .expect("cpswap_observation is not set"), - lock_program: self.lock_program.unwrap_or(solana_pubkey::pubkey!( - "LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE" - )), - lock_authority: self.lock_authority.expect("lock_authority is not set"), - lock_lp_vault: self.lock_lp_vault.expect("lock_lp_vault is not set"), - authority: self.authority.expect("authority is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - global_config: self.global_config.expect("global_config is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - pool_lp_token: self.pool_lp_token.expect("pool_lp_token is not set"), - base_token_program: self - .base_token_program - .expect("base_token_program is not set"), - quote_token_program: self.quote_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent_program: self.rent_program.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - metadata_program: self.metadata_program.unwrap_or(solana_pubkey::pubkey!( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `migrate_to_cpswap` CPI accounts. -pub struct MigrateToCpswapCpiAccounts<'a, 'b> { - /// Only migrate_to_cpswap_wallet can migrate to cpswap pool - /// This signer must match the migrate_to_cpswap_wallet saved in global_config - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token (token used to buy) - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_program: &'b solana_account_info::AccountInfo<'a>, - /// PDA account: - /// seeds = [ - /// b"pool", - /// cpswap_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// seeds::program = cpswap_program, - /// - /// Or random account: must be signed by cli - pub cpswap_pool: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_authority: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_config: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_observation: &'b solana_account_info::AccountInfo<'a>, - - pub lock_program: &'b solana_account_info::AccountInfo<'a>, - - pub lock_authority: &'b solana_account_info::AccountInfo<'a>, - - pub lock_lp_vault: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Global config account stores owner - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be fully drained during migration - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will be fully drained during migration - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub pool_lp_token: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the quote token - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving fee NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for rent exempt calculations - pub rent_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT metadata accunt - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `migrate_to_cpswap` CPI instruction. -pub struct MigrateToCpswapCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// Only migrate_to_cpswap_wallet can migrate to cpswap pool - /// This signer must match the migrate_to_cpswap_wallet saved in global_config - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the base token (token being sold) - pub base_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint for the quote token (token used to buy) - pub quote_mint: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_program: &'b solana_account_info::AccountInfo<'a>, - /// PDA account: - /// seeds = [ - /// b"pool", - /// cpswap_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// seeds::program = cpswap_program, - /// - /// Or random account: must be signed by cli - pub cpswap_pool: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_authority: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_base_vault: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_config: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - - pub cpswap_observation: &'b solana_account_info::AccountInfo<'a>, - - pub lock_program: &'b solana_account_info::AccountInfo<'a>, - - pub lock_authority: &'b solana_account_info::AccountInfo<'a>, - - pub lock_lp_vault: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// Global config account stores owner - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be fully drained during migration - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will be fully drained during migration - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - - pub pool_lp_token: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the base token - /// Must be the standard Token program - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for the quote token - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create an ATA for receiving fee NFT - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for account creation - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// Required for rent exempt calculations - pub rent_program: &'b solana_account_info::AccountInfo<'a>, - /// Program to create NFT metadata accunt - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> MigrateToCpswapCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: MigrateToCpswapCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - base_mint: accounts.base_mint, - quote_mint: accounts.quote_mint, - platform_config: accounts.platform_config, - cpswap_program: accounts.cpswap_program, - cpswap_pool: accounts.cpswap_pool, - cpswap_authority: accounts.cpswap_authority, - cpswap_lp_mint: accounts.cpswap_lp_mint, - cpswap_base_vault: accounts.cpswap_base_vault, - cpswap_quote_vault: accounts.cpswap_quote_vault, - cpswap_config: accounts.cpswap_config, - cpswap_create_pool_fee: accounts.cpswap_create_pool_fee, - cpswap_observation: accounts.cpswap_observation, - lock_program: accounts.lock_program, - lock_authority: accounts.lock_authority, - lock_lp_vault: accounts.lock_lp_vault, - authority: accounts.authority, - pool_state: accounts.pool_state, - global_config: accounts.global_config, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - pool_lp_token: accounts.pool_lp_token, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - rent_program: accounts.rent_program, - metadata_program: accounts.metadata_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(28 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cpswap_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.cpswap_pool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cpswap_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.cpswap_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.cpswap_base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.cpswap_quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.cpswap_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.cpswap_create_pool_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.cpswap_observation.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lock_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.lock_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lock_lp_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_lp_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&MigrateToCpswapInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(29 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.base_mint.clone()); - account_infos.push(self.quote_mint.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.cpswap_program.clone()); - account_infos.push(self.cpswap_pool.clone()); - account_infos.push(self.cpswap_authority.clone()); - account_infos.push(self.cpswap_lp_mint.clone()); - account_infos.push(self.cpswap_base_vault.clone()); - account_infos.push(self.cpswap_quote_vault.clone()); - account_infos.push(self.cpswap_config.clone()); - account_infos.push(self.cpswap_create_pool_fee.clone()); - account_infos.push(self.cpswap_observation.clone()); - account_infos.push(self.lock_program.clone()); - account_infos.push(self.lock_authority.clone()); - account_infos.push(self.lock_lp_vault.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.pool_lp_token.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent_program.clone()); - account_infos.push(self.metadata_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `MigrateToCpswap` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[writable]` base_mint -/// 2. `[]` quote_mint -/// 3. `[]` platform_config -/// 4. `[]` cpswap_program -/// 5. `[writable]` cpswap_pool -/// 6. `[]` cpswap_authority -/// 7. `[writable]` cpswap_lp_mint -/// 8. `[writable]` cpswap_base_vault -/// 9. `[writable]` cpswap_quote_vault -/// 10. `[]` cpswap_config -/// 11. `[writable]` cpswap_create_pool_fee -/// 12. `[writable]` cpswap_observation -/// 13. `[]` lock_program -/// 14. `[]` lock_authority -/// 15. `[writable]` lock_lp_vault -/// 16. `[writable]` authority -/// 17. `[writable]` pool_state -/// 18. `[]` global_config -/// 19. `[writable]` base_vault -/// 20. `[writable]` quote_vault -/// 21. `[writable]` pool_lp_token -/// 22. `[]` base_token_program -/// 23. `[]` quote_token_program -/// 24. `[]` associated_token_program -/// 25. `[]` system_program -/// 26. `[]` rent_program -/// 27. `[]` metadata_program -#[derive(Clone, Debug)] -pub struct MigrateToCpswapCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> MigrateToCpswapCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(MigrateToCpswapCpiBuilderInstruction { - __program: program, - payer: None, - base_mint: None, - quote_mint: None, - platform_config: None, - cpswap_program: None, - cpswap_pool: None, - cpswap_authority: None, - cpswap_lp_mint: None, - cpswap_base_vault: None, - cpswap_quote_vault: None, - cpswap_config: None, - cpswap_create_pool_fee: None, - cpswap_observation: None, - lock_program: None, - lock_authority: None, - lock_lp_vault: None, - authority: None, - pool_state: None, - global_config: None, - base_vault: None, - quote_vault: None, - pool_lp_token: None, - base_token_program: None, - quote_token_program: None, - associated_token_program: None, - system_program: None, - rent_program: None, - metadata_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// Only migrate_to_cpswap_wallet can migrate to cpswap pool - /// This signer must match the migrate_to_cpswap_wallet saved in global_config - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// The mint for the base token (token being sold) - #[inline(always)] - pub fn base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.base_mint = Some(base_mint); - self - } - - /// The mint for the quote token (token used to buy) - #[inline(always)] - pub fn quote_mint( - &mut self, - quote_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_mint = Some(quote_mint); - self - } - - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - #[inline(always)] - pub fn cpswap_program( - &mut self, - cpswap_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpswap_program = Some(cpswap_program); - self - } - - /// PDA account: - /// seeds = [ - /// b"pool", - /// cpswap_config.key().as_ref(), - /// token_0_mint.key().as_ref(), - /// token_1_mint.key().as_ref(), - /// ], - /// seeds::program = cpswap_program, - /// - /// Or random account: must be signed by cli - #[inline(always)] - pub fn cpswap_pool( - &mut self, - cpswap_pool: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpswap_pool = Some(cpswap_pool); - self - } - - #[inline(always)] - pub fn cpswap_authority( - &mut self, - cpswap_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpswap_authority = Some(cpswap_authority); - self - } - - #[inline(always)] - pub fn cpswap_lp_mint( - &mut self, - cpswap_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpswap_lp_mint = Some(cpswap_lp_mint); - self - } - - #[inline(always)] - pub fn cpswap_base_vault( - &mut self, - cpswap_base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpswap_base_vault = Some(cpswap_base_vault); - self - } - - #[inline(always)] - pub fn cpswap_quote_vault( - &mut self, - cpswap_quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpswap_quote_vault = Some(cpswap_quote_vault); - self - } - - #[inline(always)] - pub fn cpswap_config( - &mut self, - cpswap_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpswap_config = Some(cpswap_config); - self - } - - #[inline(always)] - pub fn cpswap_create_pool_fee( - &mut self, - cpswap_create_pool_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpswap_create_pool_fee = Some(cpswap_create_pool_fee); - self - } - - #[inline(always)] - pub fn cpswap_observation( - &mut self, - cpswap_observation: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.cpswap_observation = Some(cpswap_observation); - self - } - - #[inline(always)] - pub fn lock_program( - &mut self, - lock_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_program = Some(lock_program); - self - } - - #[inline(always)] - pub fn lock_authority( - &mut self, - lock_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_authority = Some(lock_authority); - self - } - - #[inline(always)] - pub fn lock_lp_vault( - &mut self, - lock_lp_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_lp_vault = Some(lock_lp_vault); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Account that stores the pool's state and parameters - /// PDA generated using POOL_SEED and both token mints - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// Global config account stores owner - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// The pool's vault for base tokens - /// Will be fully drained during migration - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will be fully drained during migration - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - #[inline(always)] - pub fn pool_lp_token( - &mut self, - pool_lp_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_lp_token = Some(pool_lp_token); - self - } - - /// SPL Token program for the base token - /// Must be the standard Token program - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - /// SPL Token program for the quote token - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - /// Program to create an ATA for receiving fee NFT - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// Required for account creation - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Required for rent exempt calculations - #[inline(always)] - pub fn rent_program( - &mut self, - rent_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.rent_program = Some(rent_program); - self - } - - /// Program to create NFT metadata accunt - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = MigrateToCpswapCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - base_mint: self.instruction.base_mint.expect("base_mint is not set"), - - quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - cpswap_program: self - .instruction - .cpswap_program - .expect("cpswap_program is not set"), - - cpswap_pool: self - .instruction - .cpswap_pool - .expect("cpswap_pool is not set"), - - cpswap_authority: self - .instruction - .cpswap_authority - .expect("cpswap_authority is not set"), - - cpswap_lp_mint: self - .instruction - .cpswap_lp_mint - .expect("cpswap_lp_mint is not set"), - - cpswap_base_vault: self - .instruction - .cpswap_base_vault - .expect("cpswap_base_vault is not set"), - - cpswap_quote_vault: self - .instruction - .cpswap_quote_vault - .expect("cpswap_quote_vault is not set"), - - cpswap_config: self - .instruction - .cpswap_config - .expect("cpswap_config is not set"), - - cpswap_create_pool_fee: self - .instruction - .cpswap_create_pool_fee - .expect("cpswap_create_pool_fee is not set"), - - cpswap_observation: self - .instruction - .cpswap_observation - .expect("cpswap_observation is not set"), - - lock_program: self - .instruction - .lock_program - .expect("lock_program is not set"), - - lock_authority: self - .instruction - .lock_authority - .expect("lock_authority is not set"), - - lock_lp_vault: self - .instruction - .lock_lp_vault - .expect("lock_lp_vault is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - pool_lp_token: self - .instruction - .pool_lp_token - .expect("pool_lp_token is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent_program: self - .instruction - .rent_program - .expect("rent_program is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct MigrateToCpswapCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - base_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - cpswap_program: Option<&'b solana_account_info::AccountInfo<'a>>, - cpswap_pool: Option<&'b solana_account_info::AccountInfo<'a>>, - cpswap_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - cpswap_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - cpswap_base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - cpswap_quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - cpswap_config: Option<&'b solana_account_info::AccountInfo<'a>>, - cpswap_create_pool_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - cpswap_observation: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_program: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_lp_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_lp_token: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent_program: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/mod.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index ba5a647f..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#buy_exact_in; -pub(crate) mod r#buy_exact_out; -pub(crate) mod r#claim_creator_fee; -pub(crate) mod r#claim_platform_fee; -pub(crate) mod r#claim_platform_fee_from_vault; -pub(crate) mod r#claim_vested_token; -pub(crate) mod r#collect_fee; -pub(crate) mod r#collect_migrate_fee; -pub(crate) mod r#create_config; -pub(crate) mod r#create_platform_config; -pub(crate) mod r#create_vesting_account; -pub(crate) mod r#initialize; -pub(crate) mod r#initialize_v2; -pub(crate) mod r#initialize_with_token2022; -pub(crate) mod r#migrate_to_amm; -pub(crate) mod r#migrate_to_cpswap; -pub(crate) mod r#remove_platform_curve_param; -pub(crate) mod r#sell_exact_in; -pub(crate) mod r#sell_exact_out; -pub(crate) mod r#update_config; -pub(crate) mod r#update_platform_config; -pub(crate) mod r#update_platform_curve_param; - -pub use self::{ - r#buy_exact_in::*, r#buy_exact_out::*, r#claim_creator_fee::*, r#claim_platform_fee::*, - r#claim_platform_fee_from_vault::*, r#claim_vested_token::*, r#collect_fee::*, - r#collect_migrate_fee::*, r#create_config::*, r#create_platform_config::*, - r#create_vesting_account::*, r#initialize::*, r#initialize_v2::*, - r#initialize_with_token2022::*, r#migrate_to_amm::*, r#migrate_to_cpswap::*, - r#remove_platform_curve_param::*, r#sell_exact_in::*, r#sell_exact_out::*, r#update_config::*, - r#update_platform_config::*, r#update_platform_curve_param::*, -}; diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/remove_platform_curve_param.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/remove_platform_curve_param.rs deleted file mode 100644 index e308921f..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/remove_platform_curve_param.rs +++ /dev/null @@ -1,373 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const REMOVE_PLATFORM_CURVE_PARAM_DISCRIMINATOR: [u8; 8] = [27, 30, 62, 169, 93, 224, 24, 145]; - -/// Accounts. -#[derive(Debug)] -pub struct RemovePlatformCurveParam { - /// The account paying for the initialization costs - pub platform_admin: solana_pubkey::Pubkey, - /// Platform config account to be changed - pub platform_config: solana_pubkey::Pubkey, -} - -impl RemovePlatformCurveParam { - pub fn instruction( - &self, - args: RemovePlatformCurveParamInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: RemovePlatformCurveParamInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_admin, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_config, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&RemovePlatformCurveParamInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemovePlatformCurveParamInstructionData { - discriminator: [u8; 8], -} - -impl RemovePlatformCurveParamInstructionData { - pub fn new() -> Self { - Self { - discriminator: [27, 30, 62, 169, 93, 224, 24, 145], - } - } -} - -impl Default for RemovePlatformCurveParamInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct RemovePlatformCurveParamInstructionArgs { - pub index: u8, -} - -/// Instruction builder for `RemovePlatformCurveParam`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` platform_admin -/// 1. `[writable]` platform_config -#[derive(Clone, Debug, Default)] -pub struct RemovePlatformCurveParamBuilder { - platform_admin: Option, - platform_config: Option, - index: Option, - __remaining_accounts: Vec, -} - -impl RemovePlatformCurveParamBuilder { - pub fn new() -> Self { Self::default() } - - /// The account paying for the initialization costs - #[inline(always)] - pub fn platform_admin(&mut self, platform_admin: solana_pubkey::Pubkey) -> &mut Self { - self.platform_admin = Some(platform_admin); - self - } - - /// Platform config account to be changed - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u8) -> &mut Self { - self.index = Some(index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = RemovePlatformCurveParam { - platform_admin: self.platform_admin.expect("platform_admin is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - }; - let args = RemovePlatformCurveParamInstructionArgs { - index: self.index.clone().expect("index is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `remove_platform_curve_param` CPI accounts. -pub struct RemovePlatformCurveParamCpiAccounts<'a, 'b> { - /// The account paying for the initialization costs - pub platform_admin: &'b solana_account_info::AccountInfo<'a>, - /// Platform config account to be changed - pub platform_config: &'b solana_account_info::AccountInfo<'a>, -} - -/// `remove_platform_curve_param` CPI instruction. -pub struct RemovePlatformCurveParamCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The account paying for the initialization costs - pub platform_admin: &'b solana_account_info::AccountInfo<'a>, - /// Platform config account to be changed - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: RemovePlatformCurveParamInstructionArgs, -} - -impl<'a, 'b> RemovePlatformCurveParamCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: RemovePlatformCurveParamCpiAccounts<'a, 'b>, - args: RemovePlatformCurveParamInstructionArgs, - ) -> Self { - Self { - __program: program, - platform_admin: accounts.platform_admin, - platform_config: accounts.platform_config, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_config.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&RemovePlatformCurveParamInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.platform_admin.clone()); - account_infos.push(self.platform_config.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `RemovePlatformCurveParam` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` platform_admin -/// 1. `[writable]` platform_config -#[derive(Clone, Debug)] -pub struct RemovePlatformCurveParamCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> RemovePlatformCurveParamCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(RemovePlatformCurveParamCpiBuilderInstruction { - __program: program, - platform_admin: None, - platform_config: None, - index: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The account paying for the initialization costs - #[inline(always)] - pub fn platform_admin( - &mut self, - platform_admin: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_admin = Some(platform_admin); - self - } - - /// Platform config account to be changed - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u8) -> &mut Self { - self.instruction.index = Some(index); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = RemovePlatformCurveParamInstructionArgs { - index: self.instruction.index.clone().expect("index is not set"), - }; - let instruction = RemovePlatformCurveParamCpi { - __program: self.instruction.__program, - - platform_admin: self - .instruction - .platform_admin - .expect("platform_admin is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct RemovePlatformCurveParamCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - platform_admin: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - index: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/sell_exact_in.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/sell_exact_in.rs deleted file mode 100644 index 616cfe8a..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/sell_exact_in.rs +++ /dev/null @@ -1,1016 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const SELL_EXACT_IN_DISCRIMINATOR: [u8; 8] = [149, 39, 222, 155, 211, 124, 152, 26]; - -/// Accounts. -#[derive(Debug)] -pub struct SellExactIn { - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: solana_pubkey::Pubkey, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: solana_pubkey::Pubkey, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: solana_pubkey::Pubkey, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: solana_pubkey::Pubkey, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: solana_pubkey::Pubkey, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: solana_pubkey::Pubkey, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: solana_pubkey::Pubkey, - /// The mint of the quote token - pub quote_token_mint: solana_pubkey::Pubkey, - /// SPL Token program for base token transfers - pub base_token_program: solana_pubkey::Pubkey, - /// SPL Token program for quote token transfers - pub quote_token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SellExactIn { - pub fn instruction(&self, args: SellExactInInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SellExactInInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_base_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_quote_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SellExactInInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellExactInInstructionData { - discriminator: [u8; 8], -} - -impl SellExactInInstructionData { - pub fn new() -> Self { - Self { - discriminator: [149, 39, 222, 155, 211, 124, 152, 26], - } - } -} - -impl Default for SellExactInInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellExactInInstructionArgs { - pub amount_in: u64, - pub minimum_amount_out: u64, - pub share_fee_rate: u64, -} - -/// Instruction builder for `SellExactIn`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[writable]` pool_state -/// 5. `[writable]` user_base_token -/// 6. `[writable]` user_quote_token -/// 7. `[writable]` base_vault -/// 8. `[writable]` quote_vault -/// 9. `[]` base_token_mint -/// 10. `[]` quote_token_mint -/// 11. `[]` base_token_program -/// 12. `[optional]` quote_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SellExactInBuilder { - payer: Option, - authority: Option, - global_config: Option, - platform_config: Option, - pool_state: Option, - user_base_token: Option, - user_quote_token: Option, - base_vault: Option, - quote_vault: Option, - base_token_mint: Option, - quote_token_mint: Option, - base_token_program: Option, - quote_token_program: Option, - event_authority: Option, - program: Option, - amount_in: Option, - minimum_amount_out: Option, - share_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl SellExactInBuilder { - pub fn new() -> Self { Self::default() } - - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - #[inline(always)] - pub fn user_base_token(&mut self, user_base_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_base_token = Some(user_base_token); - self - } - - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - #[inline(always)] - pub fn user_quote_token(&mut self, user_quote_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_quote_token = Some(user_quote_token); - self - } - - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of the base token - /// Used for transfer fee calculations if applicable - #[inline(always)] - pub fn base_token_mint(&mut self, base_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_mint = Some(base_token_mint); - self - } - - /// The mint of the quote token - #[inline(always)] - pub fn quote_token_mint(&mut self, quote_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_mint = Some(quote_token_mint); - self - } - - /// SPL Token program for base token transfers - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for quote token transfers - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.minimum_amount_out = Some(minimum_amount_out); - self - } - - #[inline(always)] - pub fn share_fee_rate(&mut self, share_fee_rate: u64) -> &mut Self { - self.share_fee_rate = Some(share_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SellExactIn { - payer: self.payer.expect("payer is not set"), - authority: self.authority.expect("authority is not set"), - global_config: self.global_config.expect("global_config is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - user_base_token: self.user_base_token.expect("user_base_token is not set"), - user_quote_token: self.user_quote_token.expect("user_quote_token is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - base_token_mint: self.base_token_mint.expect("base_token_mint is not set"), - quote_token_mint: self.quote_token_mint.expect("quote_token_mint is not set"), - base_token_program: self - .base_token_program - .expect("base_token_program is not set"), - quote_token_program: self.quote_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SellExactInInstructionArgs { - amount_in: self.amount_in.clone().expect("amount_in is not set"), - minimum_amount_out: self - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - share_fee_rate: self - .share_fee_rate - .clone() - .expect("share_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `sell_exact_in` CPI accounts. -pub struct SellExactInCpiAccounts<'a, 'b> { - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the quote token - pub quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for base token transfers - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for quote token transfers - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `sell_exact_in` CPI instruction. -pub struct SellExactInCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the quote token - pub quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for base token transfers - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for quote token transfers - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SellExactInInstructionArgs, -} - -impl<'a, 'b> SellExactInCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SellExactInCpiAccounts<'a, 'b>, - args: SellExactInInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - authority: accounts.authority, - global_config: accounts.global_config, - platform_config: accounts.platform_config, - pool_state: accounts.pool_state, - user_base_token: accounts.user_base_token, - user_quote_token: accounts.user_quote_token, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - base_token_mint: accounts.base_token_mint, - quote_token_mint: accounts.quote_token_mint, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_base_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_quote_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SellExactInInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.user_base_token.clone()); - account_infos.push(self.user_quote_token.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.base_token_mint.clone()); - account_infos.push(self.quote_token_mint.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SellExactIn` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[writable]` pool_state -/// 5. `[writable]` user_base_token -/// 6. `[writable]` user_quote_token -/// 7. `[writable]` base_vault -/// 8. `[writable]` quote_vault -/// 9. `[]` base_token_mint -/// 10. `[]` quote_token_mint -/// 11. `[]` base_token_program -/// 12. `[]` quote_token_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct SellExactInCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SellExactInCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SellExactInCpiBuilderInstruction { - __program: program, - payer: None, - authority: None, - global_config: None, - platform_config: None, - pool_state: None, - user_base_token: None, - user_quote_token: None, - base_vault: None, - quote_vault: None, - base_token_mint: None, - quote_token_mint: None, - base_token_program: None, - quote_token_program: None, - event_authority: None, - program: None, - amount_in: None, - minimum_amount_out: None, - share_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - #[inline(always)] - pub fn user_base_token( - &mut self, - user_base_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_base_token = Some(user_base_token); - self - } - - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - #[inline(always)] - pub fn user_quote_token( - &mut self, - user_quote_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_quote_token = Some(user_quote_token); - self - } - - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of the base token - /// Used for transfer fee calculations if applicable - #[inline(always)] - pub fn base_token_mint( - &mut self, - base_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_mint = Some(base_token_mint); - self - } - - /// The mint of the quote token - #[inline(always)] - pub fn quote_token_mint( - &mut self, - quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_mint = Some(quote_token_mint); - self - } - - /// SPL Token program for base token transfers - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - /// SPL Token program for quote token transfers - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_in(&mut self, amount_in: u64) -> &mut Self { - self.instruction.amount_in = Some(amount_in); - self - } - - #[inline(always)] - pub fn minimum_amount_out(&mut self, minimum_amount_out: u64) -> &mut Self { - self.instruction.minimum_amount_out = Some(minimum_amount_out); - self - } - - #[inline(always)] - pub fn share_fee_rate(&mut self, share_fee_rate: u64) -> &mut Self { - self.instruction.share_fee_rate = Some(share_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SellExactInInstructionArgs { - amount_in: self - .instruction - .amount_in - .clone() - .expect("amount_in is not set"), - minimum_amount_out: self - .instruction - .minimum_amount_out - .clone() - .expect("minimum_amount_out is not set"), - share_fee_rate: self - .instruction - .share_fee_rate - .clone() - .expect("share_fee_rate is not set"), - }; - let instruction = SellExactInCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - user_base_token: self - .instruction - .user_base_token - .expect("user_base_token is not set"), - - user_quote_token: self - .instruction - .user_quote_token - .expect("user_quote_token is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - base_token_mint: self - .instruction - .base_token_mint - .expect("base_token_mint is not set"), - - quote_token_mint: self - .instruction - .quote_token_mint - .expect("quote_token_mint is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SellExactInCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - user_base_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_quote_token: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_in: Option, - minimum_amount_out: Option, - share_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/sell_exact_out.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/sell_exact_out.rs deleted file mode 100644 index f58ab005..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/sell_exact_out.rs +++ /dev/null @@ -1,1019 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const SELL_EXACT_OUT_DISCRIMINATOR: [u8; 8] = [95, 200, 71, 34, 8, 9, 11, 166]; - -/// Accounts. -#[derive(Debug)] -pub struct SellExactOut { - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: solana_pubkey::Pubkey, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: solana_pubkey::Pubkey, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: solana_pubkey::Pubkey, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: solana_pubkey::Pubkey, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: solana_pubkey::Pubkey, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: solana_pubkey::Pubkey, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: solana_pubkey::Pubkey, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: solana_pubkey::Pubkey, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: solana_pubkey::Pubkey, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: solana_pubkey::Pubkey, - /// The mint of the quote token - pub quote_token_mint: solana_pubkey::Pubkey, - /// SPL Token program for base token transfers - pub base_token_program: solana_pubkey::Pubkey, - /// SPL Token program for quote token transfers - pub quote_token_program: solana_pubkey::Pubkey, - - pub event_authority: solana_pubkey::Pubkey, - - pub program: solana_pubkey::Pubkey, -} - -impl SellExactOut { - pub fn instruction( - &self, - args: SellExactOutInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SellExactOutInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.payer, true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.user_base_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_quote_token, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.base_vault, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.quote_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.base_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.quote_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.event_authority, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SellExactOutInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellExactOutInstructionData { - discriminator: [u8; 8], -} - -impl SellExactOutInstructionData { - pub fn new() -> Self { - Self { - discriminator: [95, 200, 71, 34, 8, 9, 11, 166], - } - } -} - -impl Default for SellExactOutInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellExactOutInstructionArgs { - pub amount_out: u64, - pub maximum_amount_in: u64, - pub share_fee_rate: u64, -} - -/// Instruction builder for `SellExactOut`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[writable]` pool_state -/// 5. `[writable]` user_base_token -/// 6. `[writable]` user_quote_token -/// 7. `[writable]` base_vault -/// 8. `[writable]` quote_vault -/// 9. `[]` base_token_mint -/// 10. `[]` quote_token_mint -/// 11. `[]` base_token_program -/// 12. `[optional]` quote_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug, Default)] -pub struct SellExactOutBuilder { - payer: Option, - authority: Option, - global_config: Option, - platform_config: Option, - pool_state: Option, - user_base_token: Option, - user_quote_token: Option, - base_vault: Option, - quote_vault: Option, - base_token_mint: Option, - quote_token_mint: Option, - base_token_program: Option, - quote_token_program: Option, - event_authority: Option, - program: Option, - amount_out: Option, - maximum_amount_in: Option, - share_fee_rate: Option, - __remaining_accounts: Vec, -} - -impl SellExactOutBuilder { - pub fn new() -> Self { Self::default() } - - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); - self - } - - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - #[inline(always)] - pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self { - self.pool_state = Some(pool_state); - self - } - - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - #[inline(always)] - pub fn user_base_token(&mut self, user_base_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_base_token = Some(user_base_token); - self - } - - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - #[inline(always)] - pub fn user_quote_token(&mut self, user_quote_token: solana_pubkey::Pubkey) -> &mut Self { - self.user_quote_token = Some(user_quote_token); - self - } - - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - #[inline(always)] - pub fn base_vault(&mut self, base_vault: solana_pubkey::Pubkey) -> &mut Self { - self.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - #[inline(always)] - pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self { - self.quote_vault = Some(quote_vault); - self - } - - /// The mint of the base token - /// Used for transfer fee calculations if applicable - #[inline(always)] - pub fn base_token_mint(&mut self, base_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_mint = Some(base_token_mint); - self - } - - /// The mint of the quote token - #[inline(always)] - pub fn quote_token_mint(&mut self, quote_token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_mint = Some(quote_token_mint); - self - } - - /// SPL Token program for base token transfers - #[inline(always)] - pub fn base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.base_token_program = Some(base_token_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// SPL Token program for quote token transfers - #[inline(always)] - pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self { - self.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self { - self.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self { - self.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_out(&mut self, amount_out: u64) -> &mut Self { - self.amount_out = Some(amount_out); - self - } - - #[inline(always)] - pub fn maximum_amount_in(&mut self, maximum_amount_in: u64) -> &mut Self { - self.maximum_amount_in = Some(maximum_amount_in); - self - } - - #[inline(always)] - pub fn share_fee_rate(&mut self, share_fee_rate: u64) -> &mut Self { - self.share_fee_rate = Some(share_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = SellExactOut { - payer: self.payer.expect("payer is not set"), - authority: self.authority.expect("authority is not set"), - global_config: self.global_config.expect("global_config is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - pool_state: self.pool_state.expect("pool_state is not set"), - user_base_token: self.user_base_token.expect("user_base_token is not set"), - user_quote_token: self.user_quote_token.expect("user_quote_token is not set"), - base_vault: self.base_vault.expect("base_vault is not set"), - quote_vault: self.quote_vault.expect("quote_vault is not set"), - base_token_mint: self.base_token_mint.expect("base_token_mint is not set"), - quote_token_mint: self.quote_token_mint.expect("quote_token_mint is not set"), - base_token_program: self - .base_token_program - .expect("base_token_program is not set"), - quote_token_program: self.quote_token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - event_authority: self.event_authority.expect("event_authority is not set"), - program: self.program.expect("program is not set"), - }; - let args = SellExactOutInstructionArgs { - amount_out: self.amount_out.clone().expect("amount_out is not set"), - maximum_amount_in: self - .maximum_amount_in - .clone() - .expect("maximum_amount_in is not set"), - share_fee_rate: self - .share_fee_rate - .clone() - .expect("share_fee_rate is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `sell_exact_out` CPI accounts. -pub struct SellExactOutCpiAccounts<'a, 'b> { - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the quote token - pub quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for base token transfers - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for quote token transfers - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `sell_exact_out` CPI instruction. -pub struct SellExactOutCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - pub payer: &'b solana_account_info::AccountInfo<'a>, - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - pub authority: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - pub pool_state: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - pub user_base_token: &'b solana_account_info::AccountInfo<'a>, - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - pub user_quote_token: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - pub base_vault: &'b solana_account_info::AccountInfo<'a>, - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - pub quote_vault: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the base token - /// Used for transfer fee calculations if applicable - pub base_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// The mint of the quote token - pub quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for base token transfers - pub base_token_program: &'b solana_account_info::AccountInfo<'a>, - /// SPL Token program for quote token transfers - pub quote_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub event_authority: &'b solana_account_info::AccountInfo<'a>, - - pub program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SellExactOutInstructionArgs, -} - -impl<'a, 'b> SellExactOutCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SellExactOutCpiAccounts<'a, 'b>, - args: SellExactOutInstructionArgs, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - authority: accounts.authority, - global_config: accounts.global_config, - platform_config: accounts.platform_config, - pool_state: accounts.pool_state, - user_base_token: accounts.user_base_token, - user_quote_token: accounts.user_quote_token, - base_vault: accounts.base_vault, - quote_vault: accounts.quote_vault, - base_token_mint: accounts.base_token_mint, - quote_token_mint: accounts.quote_token_mint, - base_token_program: accounts.base_token_program, - quote_token_program: accounts.quote_token_program, - event_authority: accounts.event_authority, - program: accounts.program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.payer.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_state.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_base_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_quote_token.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.base_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.quote_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.base_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.quote_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.event_authority.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SellExactOutInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(16 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.authority.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.pool_state.clone()); - account_infos.push(self.user_base_token.clone()); - account_infos.push(self.user_quote_token.clone()); - account_infos.push(self.base_vault.clone()); - account_infos.push(self.quote_vault.clone()); - account_infos.push(self.base_token_mint.clone()); - account_infos.push(self.quote_token_mint.clone()); - account_infos.push(self.base_token_program.clone()); - account_infos.push(self.quote_token_program.clone()); - account_infos.push(self.event_authority.clone()); - account_infos.push(self.program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `SellExactOut` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` payer -/// 1. `[]` authority -/// 2. `[]` global_config -/// 3. `[]` platform_config -/// 4. `[writable]` pool_state -/// 5. `[writable]` user_base_token -/// 6. `[writable]` user_quote_token -/// 7. `[writable]` base_vault -/// 8. `[writable]` quote_vault -/// 9. `[]` base_token_mint -/// 10. `[]` quote_token_mint -/// 11. `[]` base_token_program -/// 12. `[]` quote_token_program -/// 13. `[]` event_authority -/// 14. `[]` program -#[derive(Clone, Debug)] -pub struct SellExactOutCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SellExactOutCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SellExactOutCpiBuilderInstruction { - __program: program, - payer: None, - authority: None, - global_config: None, - platform_config: None, - pool_state: None, - user_base_token: None, - user_quote_token: None, - base_vault: None, - quote_vault: None, - base_token_mint: None, - quote_token_mint: None, - base_token_program: None, - quote_token_program: None, - event_authority: None, - program: None, - amount_out: None, - maximum_amount_in: None, - share_fee_rate: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The user performing the swap operation - /// Must sign the transaction and pay for fees - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - /// PDA that acts as the authority for pool vault operations - /// Generated using AUTH_SEED - #[inline(always)] - pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.authority = Some(authority); - self - } - - /// Global configuration account containing protocol-wide settings - /// Used to read protocol fee rates and curve type - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// Platform configuration account containing platform-wide settings - /// Used to read platform fee rate - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - /// The pool state account where the swap will be performed - /// Contains current pool parameters and balances - #[inline(always)] - pub fn pool_state( - &mut self, - pool_state: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_state = Some(pool_state); - self - } - - /// The user's token account for base tokens (tokens being bought) - /// Will receive the output tokens after the swap - #[inline(always)] - pub fn user_base_token( - &mut self, - user_base_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_base_token = Some(user_base_token); - self - } - - /// The user's token account for quote tokens (tokens being sold) - /// Will be debited for the input amount - #[inline(always)] - pub fn user_quote_token( - &mut self, - user_quote_token: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_quote_token = Some(user_quote_token); - self - } - - /// The pool's vault for base tokens - /// Will be debited to send tokens to the user - #[inline(always)] - pub fn base_vault( - &mut self, - base_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_vault = Some(base_vault); - self - } - - /// The pool's vault for quote tokens - /// Will receive the input tokens from the user - #[inline(always)] - pub fn quote_vault( - &mut self, - quote_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_vault = Some(quote_vault); - self - } - - /// The mint of the base token - /// Used for transfer fee calculations if applicable - #[inline(always)] - pub fn base_token_mint( - &mut self, - base_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_mint = Some(base_token_mint); - self - } - - /// The mint of the quote token - #[inline(always)] - pub fn quote_token_mint( - &mut self, - quote_token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_mint = Some(quote_token_mint); - self - } - - /// SPL Token program for base token transfers - #[inline(always)] - pub fn base_token_program( - &mut self, - base_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.base_token_program = Some(base_token_program); - self - } - - /// SPL Token program for quote token transfers - #[inline(always)] - pub fn quote_token_program( - &mut self, - quote_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.quote_token_program = Some(quote_token_program); - self - } - - #[inline(always)] - pub fn event_authority( - &mut self, - event_authority: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.event_authority = Some(event_authority); - self - } - - #[inline(always)] - pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.program = Some(program); - self - } - - #[inline(always)] - pub fn amount_out(&mut self, amount_out: u64) -> &mut Self { - self.instruction.amount_out = Some(amount_out); - self - } - - #[inline(always)] - pub fn maximum_amount_in(&mut self, maximum_amount_in: u64) -> &mut Self { - self.instruction.maximum_amount_in = Some(maximum_amount_in); - self - } - - #[inline(always)] - pub fn share_fee_rate(&mut self, share_fee_rate: u64) -> &mut Self { - self.instruction.share_fee_rate = Some(share_fee_rate); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SellExactOutInstructionArgs { - amount_out: self - .instruction - .amount_out - .clone() - .expect("amount_out is not set"), - maximum_amount_in: self - .instruction - .maximum_amount_in - .clone() - .expect("maximum_amount_in is not set"), - share_fee_rate: self - .instruction - .share_fee_rate - .clone() - .expect("share_fee_rate is not set"), - }; - let instruction = SellExactOutCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - authority: self.instruction.authority.expect("authority is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - pool_state: self.instruction.pool_state.expect("pool_state is not set"), - - user_base_token: self - .instruction - .user_base_token - .expect("user_base_token is not set"), - - user_quote_token: self - .instruction - .user_quote_token - .expect("user_quote_token is not set"), - - base_vault: self.instruction.base_vault.expect("base_vault is not set"), - - quote_vault: self - .instruction - .quote_vault - .expect("quote_vault is not set"), - - base_token_mint: self - .instruction - .base_token_mint - .expect("base_token_mint is not set"), - - quote_token_mint: self - .instruction - .quote_token_mint - .expect("quote_token_mint is not set"), - - base_token_program: self - .instruction - .base_token_program - .expect("base_token_program is not set"), - - quote_token_program: self - .instruction - .quote_token_program - .expect("quote_token_program is not set"), - - event_authority: self - .instruction - .event_authority - .expect("event_authority is not set"), - - program: self.instruction.program.expect("program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SellExactOutCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - authority: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_state: Option<&'b solana_account_info::AccountInfo<'a>>, - user_base_token: Option<&'b solana_account_info::AccountInfo<'a>>, - user_quote_token: Option<&'b solana_account_info::AccountInfo<'a>>, - base_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - event_authority: Option<&'b solana_account_info::AccountInfo<'a>>, - program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount_out: Option, - maximum_amount_in: Option, - share_fee_rate: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/update_config.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/update_config.rs deleted file mode 100644 index 61c79157..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/update_config.rs +++ /dev/null @@ -1,387 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -pub const UPDATE_CONFIG_DISCRIMINATOR: [u8; 8] = [29, 158, 252, 191, 10, 83, 219, 99]; - -/// Accounts. -#[derive(Debug)] -pub struct UpdateConfig { - /// The global config owner or admin - pub owner: solana_pubkey::Pubkey, - /// Global config account to be changed - pub global_config: solana_pubkey::Pubkey, -} - -impl UpdateConfig { - pub fn instruction( - &self, - args: UpdateConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdateConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.owner, true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.global_config, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateConfigInstructionData { - discriminator: [u8; 8], -} - -impl UpdateConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [29, 158, 252, 191, 10, 83, 219, 99], - } - } -} - -impl Default for UpdateConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdateConfigInstructionArgs { - pub param: u8, - pub value: u64, -} - -/// Instruction builder for `UpdateConfig`. -/// -/// ### Accounts: -/// -/// 0. `[signer, optional]` owner (default to `GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ`) -/// 1. `[writable]` global_config -#[derive(Clone, Debug, Default)] -pub struct UpdateConfigBuilder { - owner: Option, - global_config: Option, - param: Option, - value: Option, - __remaining_accounts: Vec, -} - -impl UpdateConfigBuilder { - pub fn new() -> Self { Self::default() } - - /// `[optional account, default to 'GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ']` - /// The global config owner or admin - #[inline(always)] - pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self { - self.owner = Some(owner); - self - } - - /// Global config account to be changed - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.param = Some(param); - self - } - - #[inline(always)] - pub fn value(&mut self, value: u64) -> &mut Self { - self.value = Some(value); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdateConfig { - owner: self.owner.unwrap_or(solana_pubkey::pubkey!( - "GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ" - )), - global_config: self.global_config.expect("global_config is not set"), - }; - let args = UpdateConfigInstructionArgs { - param: self.param.clone().expect("param is not set"), - value: self.value.clone().expect("value is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_config` CPI accounts. -pub struct UpdateConfigCpiAccounts<'a, 'b> { - /// The global config owner or admin - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Global config account to be changed - pub global_config: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_config` CPI instruction. -pub struct UpdateConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The global config owner or admin - pub owner: &'b solana_account_info::AccountInfo<'a>, - /// Global config account to be changed - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdateConfigInstructionArgs, -} - -impl<'a, 'b> UpdateConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdateConfigCpiAccounts<'a, 'b>, - args: UpdateConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - owner: accounts.owner, - global_config: accounts.global_config, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.owner.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.global_config.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdateConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.owner.clone()); - account_infos.push(self.global_config.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdateConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` owner -/// 1. `[writable]` global_config -#[derive(Clone, Debug)] -pub struct UpdateConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdateConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdateConfigCpiBuilderInstruction { - __program: program, - owner: None, - global_config: None, - param: None, - value: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The global config owner or admin - #[inline(always)] - pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.owner = Some(owner); - self - } - - /// Global config account to be changed - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - #[inline(always)] - pub fn param(&mut self, param: u8) -> &mut Self { - self.instruction.param = Some(param); - self - } - - #[inline(always)] - pub fn value(&mut self, value: u64) -> &mut Self { - self.instruction.value = Some(value); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdateConfigInstructionArgs { - param: self.instruction.param.clone().expect("param is not set"), - value: self.instruction.value.clone().expect("value is not set"), - }; - let instruction = UpdateConfigCpi { - __program: self.instruction.__program, - - owner: self.instruction.owner.expect("owner is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdateConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - owner: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - param: Option, - value: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/update_platform_config.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/update_platform_config.rs deleted file mode 100644 index 3a1c481b..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/update_platform_config.rs +++ /dev/null @@ -1,375 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::PlatformConfigParam; - -pub const UPDATE_PLATFORM_CONFIG_DISCRIMINATOR: [u8; 8] = [195, 60, 76, 129, 146, 45, 67, 143]; - -/// Accounts. -#[derive(Debug)] -pub struct UpdatePlatformConfig { - /// The account paying for the initialization costs - pub platform_admin: solana_pubkey::Pubkey, - /// Platform config account to be changed - pub platform_config: solana_pubkey::Pubkey, -} - -impl UpdatePlatformConfig { - pub fn instruction( - &self, - args: UpdatePlatformConfigInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdatePlatformConfigInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.platform_admin, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_config, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdatePlatformConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePlatformConfigInstructionData { - discriminator: [u8; 8], -} - -impl UpdatePlatformConfigInstructionData { - pub fn new() -> Self { - Self { - discriminator: [195, 60, 76, 129, 146, 45, 67, 143], - } - } -} - -impl Default for UpdatePlatformConfigInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePlatformConfigInstructionArgs { - pub param: PlatformConfigParam, -} - -/// Instruction builder for `UpdatePlatformConfig`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` platform_admin -/// 1. `[writable]` platform_config -#[derive(Clone, Debug, Default)] -pub struct UpdatePlatformConfigBuilder { - platform_admin: Option, - platform_config: Option, - param: Option, - __remaining_accounts: Vec, -} - -impl UpdatePlatformConfigBuilder { - pub fn new() -> Self { Self::default() } - - /// The account paying for the initialization costs - #[inline(always)] - pub fn platform_admin(&mut self, platform_admin: solana_pubkey::Pubkey) -> &mut Self { - self.platform_admin = Some(platform_admin); - self - } - - /// Platform config account to be changed - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - #[inline(always)] - pub fn param(&mut self, param: PlatformConfigParam) -> &mut Self { - self.param = Some(param); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdatePlatformConfig { - platform_admin: self.platform_admin.expect("platform_admin is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - }; - let args = UpdatePlatformConfigInstructionArgs { - param: self.param.clone().expect("param is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_platform_config` CPI accounts. -pub struct UpdatePlatformConfigCpiAccounts<'a, 'b> { - /// The account paying for the initialization costs - pub platform_admin: &'b solana_account_info::AccountInfo<'a>, - /// Platform config account to be changed - pub platform_config: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_platform_config` CPI instruction. -pub struct UpdatePlatformConfigCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The account paying for the initialization costs - pub platform_admin: &'b solana_account_info::AccountInfo<'a>, - /// Platform config account to be changed - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdatePlatformConfigInstructionArgs, -} - -impl<'a, 'b> UpdatePlatformConfigCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdatePlatformConfigCpiAccounts<'a, 'b>, - args: UpdatePlatformConfigInstructionArgs, - ) -> Self { - Self { - __program: program, - platform_admin: accounts.platform_admin, - platform_config: accounts.platform_config, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.platform_admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_config.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdatePlatformConfigInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.platform_admin.clone()); - account_infos.push(self.platform_config.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdatePlatformConfig` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` platform_admin -/// 1. `[writable]` platform_config -#[derive(Clone, Debug)] -pub struct UpdatePlatformConfigCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdatePlatformConfigCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdatePlatformConfigCpiBuilderInstruction { - __program: program, - platform_admin: None, - platform_config: None, - param: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The account paying for the initialization costs - #[inline(always)] - pub fn platform_admin( - &mut self, - platform_admin: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_admin = Some(platform_admin); - self - } - - /// Platform config account to be changed - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - #[inline(always)] - pub fn param(&mut self, param: PlatformConfigParam) -> &mut Self { - self.instruction.param = Some(param); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdatePlatformConfigInstructionArgs { - param: self.instruction.param.clone().expect("param is not set"), - }; - let instruction = UpdatePlatformConfigCpi { - __program: self.instruction.__program, - - platform_admin: self - .instruction - .platform_admin - .expect("platform_admin is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdatePlatformConfigCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - platform_admin: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - param: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/update_platform_curve_param.rs b/crates/raydium-launchpad-parser/src/generated_sdk/instructions/update_platform_curve_param.rs deleted file mode 100644 index 37b4f941..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/instructions/update_platform_curve_param.rs +++ /dev/null @@ -1,497 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::BondingCurveParam; - -pub const UPDATE_PLATFORM_CURVE_PARAM_DISCRIMINATOR: [u8; 8] = - [138, 144, 138, 250, 220, 128, 4, 57]; - -/// Accounts. -#[derive(Debug)] -pub struct UpdatePlatformCurveParam { - /// The account paying for the initialization costs - pub platform_admin: solana_pubkey::Pubkey, - /// Platform config account to be changed - pub platform_config: solana_pubkey::Pubkey, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: solana_pubkey::Pubkey, - /// System program for lamport transfers - pub system_program: solana_pubkey::Pubkey, -} - -impl UpdatePlatformCurveParam { - pub fn instruction( - &self, - args: UpdatePlatformCurveParamInstructionArgs, - ) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: UpdatePlatformCurveParamInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_admin, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.global_config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&UpdatePlatformCurveParamInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePlatformCurveParamInstructionData { - discriminator: [u8; 8], -} - -impl UpdatePlatformCurveParamInstructionData { - pub fn new() -> Self { - Self { - discriminator: [138, 144, 138, 250, 220, 128, 4, 57], - } - } -} - -impl Default for UpdatePlatformCurveParamInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePlatformCurveParamInstructionArgs { - pub index: u8, - pub bonding_curve_param: BondingCurveParam, -} - -/// Instruction builder for `UpdatePlatformCurveParam`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` platform_admin -/// 1. `[writable]` platform_config -/// 2. `[]` global_config -/// 3. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct UpdatePlatformCurveParamBuilder { - platform_admin: Option, - platform_config: Option, - global_config: Option, - system_program: Option, - index: Option, - bonding_curve_param: Option, - __remaining_accounts: Vec, -} - -impl UpdatePlatformCurveParamBuilder { - pub fn new() -> Self { Self::default() } - - /// The account paying for the initialization costs - #[inline(always)] - pub fn platform_admin(&mut self, platform_admin: solana_pubkey::Pubkey) -> &mut Self { - self.platform_admin = Some(platform_admin); - self - } - - /// Platform config account to be changed - #[inline(always)] - pub fn platform_config(&mut self, platform_config: solana_pubkey::Pubkey) -> &mut Self { - self.platform_config = Some(platform_config); - self - } - - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - #[inline(always)] - pub fn global_config(&mut self, global_config: solana_pubkey::Pubkey) -> &mut Self { - self.global_config = Some(global_config); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program for lamport transfers - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u8) -> &mut Self { - self.index = Some(index); - self - } - - #[inline(always)] - pub fn bonding_curve_param(&mut self, bonding_curve_param: BondingCurveParam) -> &mut Self { - self.bonding_curve_param = Some(bonding_curve_param); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdatePlatformCurveParam { - platform_admin: self.platform_admin.expect("platform_admin is not set"), - platform_config: self.platform_config.expect("platform_config is not set"), - global_config: self.global_config.expect("global_config is not set"), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - let args = UpdatePlatformCurveParamInstructionArgs { - index: self.index.clone().expect("index is not set"), - bonding_curve_param: self - .bonding_curve_param - .clone() - .expect("bonding_curve_param is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `update_platform_curve_param` CPI accounts. -pub struct UpdatePlatformCurveParamCpiAccounts<'a, 'b> { - /// The account paying for the initialization costs - pub platform_admin: &'b solana_account_info::AccountInfo<'a>, - /// Platform config account to be changed - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// System program for lamport transfers - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_platform_curve_param` CPI instruction. -pub struct UpdatePlatformCurveParamCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - /// The account paying for the initialization costs - pub platform_admin: &'b solana_account_info::AccountInfo<'a>, - /// Platform config account to be changed - pub platform_config: &'b solana_account_info::AccountInfo<'a>, - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - pub global_config: &'b solana_account_info::AccountInfo<'a>, - /// System program for lamport transfers - pub system_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: UpdatePlatformCurveParamInstructionArgs, -} - -impl<'a, 'b> UpdatePlatformCurveParamCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdatePlatformCurveParamCpiAccounts<'a, 'b>, - args: UpdatePlatformCurveParamInstructionArgs, - ) -> Self { - Self { - __program: program, - platform_admin: accounts.platform_admin, - platform_config: accounts.platform_config, - global_config: accounts.global_config, - system_program: accounts.system_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_admin.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.global_config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&UpdatePlatformCurveParamInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::RAYDIUM_LAUNCHPAD_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.platform_admin.clone()); - account_infos.push(self.platform_config.clone()); - account_infos.push(self.global_config.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdatePlatformCurveParam` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` platform_admin -/// 1. `[writable]` platform_config -/// 2. `[]` global_config -/// 3. `[]` system_program -#[derive(Clone, Debug)] -pub struct UpdatePlatformCurveParamCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdatePlatformCurveParamCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdatePlatformCurveParamCpiBuilderInstruction { - __program: program, - platform_admin: None, - platform_config: None, - global_config: None, - system_program: None, - index: None, - bonding_curve_param: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - /// The account paying for the initialization costs - #[inline(always)] - pub fn platform_admin( - &mut self, - platform_admin: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_admin = Some(platform_admin); - self - } - - /// Platform config account to be changed - #[inline(always)] - pub fn platform_config( - &mut self, - platform_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_config = Some(platform_config); - self - } - - /// Global configuration account containing protocol-wide settings - /// Includes settings like quote token mint and fee parameters - #[inline(always)] - pub fn global_config( - &mut self, - global_config: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.global_config = Some(global_config); - self - } - - /// System program for lamport transfers - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn index(&mut self, index: u8) -> &mut Self { - self.instruction.index = Some(index); - self - } - - #[inline(always)] - pub fn bonding_curve_param(&mut self, bonding_curve_param: BondingCurveParam) -> &mut Self { - self.instruction.bonding_curve_param = Some(bonding_curve_param); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = UpdatePlatformCurveParamInstructionArgs { - index: self.instruction.index.clone().expect("index is not set"), - bonding_curve_param: self - .instruction - .bonding_curve_param - .clone() - .expect("bonding_curve_param is not set"), - }; - let instruction = UpdatePlatformCurveParamCpi { - __program: self.instruction.__program, - - platform_admin: self - .instruction - .platform_admin - .expect("platform_admin is not set"), - - platform_config: self - .instruction - .platform_config - .expect("platform_config is not set"), - - global_config: self - .instruction - .global_config - .expect("global_config is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdatePlatformCurveParamCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - platform_admin: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_config: Option<&'b solana_account_info::AccountInfo<'a>>, - global_config: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - index: Option, - bonding_curve_param: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/mod.rs b/crates/raydium-launchpad-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/programs.rs b/crates/raydium-launchpad-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 707c3647..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `raydium_launchpad` program ID. -pub const RAYDIUM_LAUNCHPAD_ID: Pubkey = pubkey!("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"); diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/shared.rs b/crates/raydium-launchpad-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/amm_creator_fee_on.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/amm_creator_fee_on.rs deleted file mode 100644 index bfc226ba..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/amm_creator_fee_on.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// migrate to cpmm, creator fee on quote token or both token -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum AmmCreatorFeeOn { - QuoteToken, - BothToken, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/bonding_curve_param.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/bonding_curve_param.rs deleted file mode 100644 index f6917bfa..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/bonding_curve_param.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BondingCurveParam { - /// Migrate to AMM or CpSwap, 0: amm, 1: cpswap, - /// Neither 0 nor 1: invalid - pub migrate_type: u8, - /// The migrate fee on, 0 means fee on the quote token, 1 means fee on both token - /// Neither 0 nor 1: invalid - pub migrate_cpmm_fee_on: u8, - /// The supply of the token, - /// 0: invalid - pub supply: u64, - /// The total base sell of the token - /// 0: invalid - pub total_base_sell: u64, - /// The total quote fund raising of the token - /// 0: invalid - pub total_quote_fund_raising: u64, - /// total amount of tokens to be unlocked - /// u64::MAX: invalid - pub total_locked_amount: u64, - /// Waiting time in seconds before unlocking after fundraising ends - /// u64::MAX: invalid - pub cliff_period: u64, - /// Unlocking period in seconds - /// u64::MAX: invalid - pub unlock_period: u64, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/claim_vested_event.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/claim_vested_event.rs deleted file mode 100644 index 23cd18e7..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/claim_vested_event.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Emitted when vesting token claimed by beneficiary -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimVestedEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_state: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub beneficiary: Pubkey, - pub claim_amount: u64, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/constant_curve.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/constant_curve.rs deleted file mode 100644 index 57fdd2b9..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/constant_curve.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ConstantCurve { - pub supply: u64, - pub total_base_sell: u64, - pub total_quote_fund_raising: u64, - pub migrate_type: u8, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/create_vesting_event.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/create_vesting_event.rs deleted file mode 100644 index 599a8df8..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/create_vesting_event.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -/// Emitted when vest_account created -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateVestingEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_state: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub beneficiary: Pubkey, - pub share_amount: u64, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/curve_params.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/curve_params.rs deleted file mode 100644 index 14ec5e75..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/curve_params.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -use crate::generated::types::{ConstantCurve, FixedCurve, LinearCurve}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum CurveParams { - Constant { data: ConstantCurve }, - Fixed { data: FixedCurve }, - Linear { data: LinearCurve }, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/fixed_curve.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/fixed_curve.rs deleted file mode 100644 index 7db5b434..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/fixed_curve.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct FixedCurve { - pub supply: u64, - pub total_quote_fund_raising: u64, - pub migrate_type: u8, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/linear_curve.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/linear_curve.rs deleted file mode 100644 index 7323830a..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/linear_curve.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LinearCurve { - pub supply: u64, - pub total_quote_fund_raising: u64, - pub migrate_type: u8, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/migrate_nft_info.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/migrate_nft_info.rs deleted file mode 100644 index f587e38e..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/migrate_nft_info.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Represents the parameters for initializing a platform config account(Only support MigrateType::CPSWAP) -/// # Fields -/// * `platform_scale` - Scale of the platform liquidity quantity rights will be converted into NFT -/// * `creator_scale` - Scale of the token creator liquidity quantity rights will be converted into NFT -/// * `burn_scale` - Scale of liquidity directly to burn -/// -/// * platform_scale + creator_scale + burn_scale = RATE_DENOMINATOR_VALUE -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MigrateNftInfo { - pub platform_scale: u64, - pub creator_scale: u64, - pub burn_scale: u64, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/mint_params.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/mint_params.rs deleted file mode 100644 index 847936e9..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/mint_params.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Represents the parameters for initializing a new token mint -/// # Fields -/// * `decimals` - Number of decimal places for the token -/// * `name` - Name of the token -/// * `symbol` - Symbol/ticker of the token -/// * `uri` - URI pointing to token metadata -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct MintParams { - pub decimals: u8, - pub name: String, - pub symbol: String, - pub uri: String, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/mod.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index 7d9f2528..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#amm_creator_fee_on; -pub(crate) mod r#bonding_curve_param; -pub(crate) mod r#claim_vested_event; -pub(crate) mod r#constant_curve; -pub(crate) mod r#create_vesting_event; -pub(crate) mod r#curve_params; -pub(crate) mod r#fixed_curve; -pub(crate) mod r#linear_curve; -pub(crate) mod r#migrate_nft_info; -pub(crate) mod r#mint_params; -pub(crate) mod r#platform_config_info; -pub(crate) mod r#platform_config_param; -pub(crate) mod r#platform_curve_param; -pub(crate) mod r#pool_create_event; -pub(crate) mod r#pool_status; -pub(crate) mod r#trade_direction; -pub(crate) mod r#trade_event; -pub(crate) mod r#transfer_fee_extension_params; -pub(crate) mod r#vesting_params; -pub(crate) mod r#vesting_schedule; - -pub use self::{ - r#amm_creator_fee_on::*, r#bonding_curve_param::*, r#claim_vested_event::*, - r#constant_curve::*, r#create_vesting_event::*, r#curve_params::*, r#fixed_curve::*, - r#linear_curve::*, r#migrate_nft_info::*, r#mint_params::*, r#platform_config_info::*, - r#platform_config_param::*, r#platform_curve_param::*, r#pool_create_event::*, - r#pool_status::*, r#trade_direction::*, r#trade_event::*, r#transfer_fee_extension_params::*, - r#vesting_params::*, r#vesting_schedule::*, -}; diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/platform_config_info.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/platform_config_info.rs deleted file mode 100644 index c4a642cd..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/platform_config_info.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::MigrateNftInfo; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PlatformConfigInfo { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub fee_wallet: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub nft_wallet: Pubkey, - pub migrate_nft_info: MigrateNftInfo, - pub fee_rate: u64, - pub name: String, - pub web: String, - pub img: String, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub transfer_fee_extension_auth: Pubkey, - pub creator_fee_rate: u64, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/platform_config_param.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/platform_config_param.rs deleted file mode 100644 index f8cbeaba..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/platform_config_param.rs +++ /dev/null @@ -1,33 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{MigrateNftInfo, PlatformConfigInfo}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum PlatformConfigParam { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - FeeWallet(Pubkey), - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - NFTWallet(Pubkey), - MigrateNftInfo(MigrateNftInfo), - FeeRate(u64), - Name(String), - Web(String), - Img(String), - CpSwapConfig, - AllInfo(PlatformConfigInfo), -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/platform_curve_param.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/platform_curve_param.rs deleted file mode 100644 index e8429c94..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/platform_curve_param.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::BondingCurveParam; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PlatformCurveParam { - /// The epoch for update interval, 0 means not update - pub epoch: u64, - /// The curve params index - pub index: u8, - /// The global config address - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub global_config: Pubkey, - /// bonding curve param - pub bonding_curve_param: BondingCurveParam, - /// padding for future updates - #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))] - pub padding: [u64; 50], -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/pool_create_event.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/pool_create_event.rs deleted file mode 100644 index 0a5f448d..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/pool_create_event.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{AmmCreatorFeeOn, CurveParams, MintParams, VestingParams}; - -/// Emitted when pool created -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct PoolCreateEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_state: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub config: Pubkey, - pub base_mint_param: MintParams, - pub curve_param: CurveParams, - pub vesting_param: VestingParams, - pub amm_fee_on: AmmCreatorFeeOn, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/pool_status.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/pool_status.rs deleted file mode 100644 index 43d8750e..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/pool_status.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Represents the different states a pool can be in -/// * Fund - Initial state where pool is accepting funds -/// * Migrate - Pool funding has ended and waiting for migration -/// * Trade - Pool migration is complete and amm trading is enabled -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum PoolStatus { - Fund, - Migrate, - Trade, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/trade_direction.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/trade_direction.rs deleted file mode 100644 index b0995141..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/trade_direction.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -/// Specifies the direction of a trade in the bonding curve -/// This is important because curves can treat tokens differently through weights or offsets -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TradeDirection { - Buy, - Sell, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/trade_event.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/trade_event.rs deleted file mode 100644 index d9e62760..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/trade_event.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::{PoolStatus, TradeDirection}; - -/// Emitted when trade process -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TradeEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub pool_state: Pubkey, - pub total_base_sell: u64, - pub virtual_base: u64, - pub virtual_quote: u64, - pub real_base_before: u64, - pub real_quote_before: u64, - pub real_base_after: u64, - pub real_quote_after: u64, - pub amount_in: u64, - pub amount_out: u64, - pub protocol_fee: u64, - pub platform_fee: u64, - pub creator_fee: u64, - pub share_fee: u64, - pub trade_direction: TradeDirection, - pub pool_status: PoolStatus, - pub exact_in: bool, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/transfer_fee_extension_params.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/transfer_fee_extension_params.rs deleted file mode 100644 index 48276a23..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/transfer_fee_extension_params.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TransferFeeExtensionParams { - /// denominator is 10000, currently, this value cannot exceed 5%, which is 500. - pub transfer_fee_basis_points: u16, - /// Maximum fee on each transfers, the value must exceed supply * transfer_fee_basis_points / 10000 - pub maximum_fee: u64, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/vesting_params.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/vesting_params.rs deleted file mode 100644 index a7ee7b6a..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/vesting_params.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct VestingParams { - pub total_locked_amount: u64, - pub cliff_period: u64, - pub unlock_period: u64, -} diff --git a/crates/raydium-launchpad-parser/src/generated_sdk/types/vesting_schedule.rs b/crates/raydium-launchpad-parser/src/generated_sdk/types/vesting_schedule.rs deleted file mode 100644 index 6233179b..00000000 --- a/crates/raydium-launchpad-parser/src/generated_sdk/types/vesting_schedule.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct VestingSchedule { - pub total_locked_amount: u64, - pub cliff_period: u64, - pub unlock_period: u64, - pub start_time: u64, - /// Total allocated share amount of the base token, not greater than total_locked_amount - pub allocated_share_amount: u64, -} diff --git a/crates/raydium-launchpad-parser/src/lib.rs b/crates/raydium-launchpad-parser/src/lib.rs deleted file mode 100644 index 73e91463..00000000 --- a/crates/raydium-launchpad-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = RAYDIUM_LAUNCHPAD_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.raydium_launchpad"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/crates/runtime/Cargo.toml b/crates/runtime/Cargo.toml index daf793fe..af53da2f 100644 --- a/crates/runtime/Cargo.toml +++ b/crates/runtime/Cargo.toml @@ -11,11 +11,7 @@ readme = "./../../README.md" [dependencies] async-trait = { workspace = true } -clap = { workspace = true, features = [ - "env", - "derive", - "std", -] } +clap = { workspace = true, features = ["env", "derive", "std"] } futures-channel = { workspace = true, features = ["sink"] } futures-util = { workspace = true, features = ["sink"] } opentelemetry = { workspace = true, features = ["metrics"], optional = true } @@ -29,7 +25,6 @@ tracing = { workspace = true } yellowstone-grpc-client = { workspace = true } yellowstone-grpc-proto = { workspace = true } yellowstone-vixen-core = { workspace = true } -rustls = { workspace = true, features = ["aws-lc-rs"] } [features] default = [] diff --git a/crates/runtime/src/lib.rs b/crates/runtime/src/lib.rs index f4860694..bd4b9ef7 100644 --- a/crates/runtime/src/lib.rs +++ b/crates/runtime/src/lib.rs @@ -104,24 +104,14 @@ impl Runtime { /// /// ```ignore /// use yellowstone_vixen::Pipeline; - /// use yellowstone_vixen_parser::{ - /// token_extension_program::{ - /// AccountParser as TokenExtensionProgramAccParser, - /// InstructionParser as TokenExtensionProgramIxParser, - /// }, - /// token_program::{ - /// AccountParser as TokenProgramAccParser, InstructionParser as TokenProgramIxParser, - /// }, - /// }; + /// use yellowstone_vixen_spl_token_parser::{AccountParser, InstructionParser}; /// /// // MyHandler is a handler that implements the Handler trait /// // NOTE: The main function is not async /// fn main() { /// Runtime::builder::() - /// .account(Pipeline::new(TokenProgramAccParser, [MyHandler])) - /// .account(Pipeline::new(TokenExtensionProgramAccParser, [MyHandler])) - /// .instruction(Pipeline::new(TokenExtensionProgramIxParser, [MyHandler])) - /// .instruction(Pipeline::new(TokenProgramIxParser, [MyHandler])) + /// .account(Pipeline::new(AccountParser, [MyHandler])) + /// .instruction(Pipeline::new(InstructionParser, [MyHandler])) /// .build(config) /// .run(); // Process will exit if an error occurs /// } diff --git a/crates/slot-parser/Cargo.toml b/crates/slot-parser/Cargo.toml new file mode 100644 index 00000000..c4253d3e --- /dev/null +++ b/crates/slot-parser/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "yellowstone-vixen-slot-parser" +description = "Vixen slot parser." +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +authors.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +yellowstone-vixen-core = { workspace = true } + +[dev-dependencies] +yellowstone-vixen-mock = { workspace = true } +tokio.workspace = true + +[features] +default = [] diff --git a/crates/slot-parser/src/lib.rs b/crates/slot-parser/src/lib.rs new file mode 100644 index 00000000..defded93 --- /dev/null +++ b/crates/slot-parser/src/lib.rs @@ -0,0 +1,3 @@ +mod slot; + +pub use slot::*; diff --git a/crates/parser/src/slot.rs b/crates/slot-parser/src/slot.rs similarity index 100% rename from crates/parser/src/slot.rs rename to crates/slot-parser/src/slot.rs diff --git a/crates/solana-snapshot-source/Cargo.toml b/crates/solana-snapshot-source/Cargo.toml index d7d55207..bbba83ca 100644 --- a/crates/solana-snapshot-source/Cargo.toml +++ b/crates/solana-snapshot-source/Cargo.toml @@ -9,6 +9,7 @@ authors.workspace = true readme = "./../../README.md" [dependencies] +agave-snapshots = { workspace = true } async-trait = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread", "signal"] } tracing = { workspace = true } @@ -21,10 +22,11 @@ toml = { workspace = true } serde = { workspace = true, features = ["derive"] } solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } solana-accounts-db = { workspace = true } +solana-genesis-utils = { workspace = true, features = ["agave-unstable-api"] } +solana-ledger = { workspace = true, features = ["agave-unstable-api"] } tempfile = { workspace = true } zstd = { workspace = true } tar = { workspace = true } solana-account = { workspace = true } clap = { workspace = true, features = ["derive", "cargo", "wrap_help"] } -solana-ledger = { workspace = true } solana-runtime = { workspace = true } diff --git a/crates/solana-snapshot-source/src/lib.rs b/crates/solana-snapshot-source/src/lib.rs index 7c032e4e..89533b37 100644 --- a/crates/solana-snapshot-source/src/lib.rs +++ b/crates/solana-snapshot-source/src/lib.rs @@ -4,16 +4,17 @@ use std::{ sync::{atomic::AtomicBool, Arc}, }; +use agave_snapshots::snapshot_config::{SnapshotConfig, SnapshotUsage}; use async_trait::async_trait; use serde::{Deserialize, Serialize}; use solana_account::ReadableAccount; use solana_accounts_db::{ accounts_db::AccountsDbConfig, accounts_index::{ScanConfig, ScanOrder}, - hardened_unpack::open_genesis_config, is_loadable::IsLoadable, utils::create_all_accounts_run_and_snapshot_dirs, }; +use solana_genesis_utils::open_genesis_config; use solana_ledger::{ bank_forks_utils, blockstore::Blockstore, @@ -21,10 +22,7 @@ use solana_ledger::{ blockstore_processor::ProcessOptions, }; use solana_pubkey::Pubkey as SolanaPubkey; -use solana_runtime::{ - bank::Bank, - snapshot_config::{SnapshotConfig, SnapshotUsage}, -}; +use solana_runtime::bank::Bank; use tokio::sync::mpsc; use yellowstone_grpc_proto::{ geyser::{ @@ -63,7 +61,7 @@ impl SolanaSnapshot { let process_options = ProcessOptions { accounts_db_skip_shrink: true, - accounts_db_config: Some(accounts_db_config), + accounts_db_config, ..Default::default() }; diff --git a/crates/spl-token-extensions-parser/Cargo.toml b/crates/spl-token-extensions-parser/Cargo.toml new file mode 100644 index 00000000..3ea19229 --- /dev/null +++ b/crates/spl-token-extensions-parser/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "yellowstone-vixen-spl-token-extensions-parser" +description = "Vixen program parsers for spl token exetensions parser." +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +authors.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +spl-pod = { workspace = true } +spl-token-2022 = { workspace = true } +spl-type-length-value = { workspace = true } +spl-token-group-interface = { workspace = true } +spl-token-metadata-interface = { workspace = true } +solana-program-pack = { workspace = true } +solana-program-error = { workspace = true } +yellowstone-grpc-proto = { workspace = true } +yellowstone-vixen-core = { workspace = true } +yellowstone-vixen-parser = { workspace = true } +yellowstone-vixen-spl-token-parser = { workspace = true } +thiserror.workspace = true +bs58.workspace = true +bytemuck = { workspace = true } + +[dev-dependencies] +yellowstone-vixen-mock = { workspace = true } +tokio.workspace = true + +[features] +default = [] diff --git a/crates/parser/src/token_extension_program/account_parser.rs b/crates/spl-token-extensions-parser/src/account_parser.rs similarity index 62% rename from crates/parser/src/token_extension_program/account_parser.rs rename to crates/spl-token-extensions-parser/src/account_parser.rs index c4585306..8630362b 100644 --- a/crates/parser/src/token_extension_program/account_parser.rs +++ b/crates/spl-token-extensions-parser/src/account_parser.rs @@ -1,13 +1,14 @@ use std::borrow::Cow; -use spl_pod::solana_program::{program_error::ProgramError, program_pack::Pack}; +use solana_program_error::ProgramError; +use solana_program_pack::Pack; use spl_token_2022::{ extension::{BaseStateWithExtensions, StateWithExtensions}, state::{Account, Mint, Multisig}, }; use yellowstone_vixen_core::{AccountUpdate, ParseResult, Parser, Prefilter, ProgramParser}; -use super::account_helpers::{ +use super::accounts::{ mint_account_extensions_data_bytes, token_account_extensions_data_bytes, ExtensionData, }; @@ -83,7 +84,6 @@ fn extension_account_type(data_bytes: &[u8]) -> Result ParseResult { let account_type = extension_account_type(data_bytes)?; - let acc = match account_type { + match account_type { TokenExtensionAccountType::Mint => Ok(TokenExtensionState::ExtendedMint( ExtendedMint::try_from_data(data_bytes)?, )), @@ -106,30 +106,7 @@ impl TokenExtensionState { TokenExtensionAccountType::Multisig => { Ok(TokenExtensionState::Multisig(Multisig::unpack(data_bytes)?)) }, - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = spl_token_2022::ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = spl_token_2022::ID.to_string(), - account = "error", - error = ?e - ); - }, } - - acc } } @@ -160,66 +137,6 @@ impl ProgramParser for AccountParser { fn program_id(&self) -> yellowstone_vixen_core::Pubkey { spl_token_2022::ID.to_bytes().into() } } -#[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - use yellowstone_vixen_proto::parser::token_extensions::{ - program_state as token_extension_state_proto, ExtendedMintProto, ExtendedTokenAccountProto, - ExtensionDataProto, ProgramState as TokenExtensionStateProto, - }; - - use super::{AccountParser, ExtendedMint, ExtendedTokenAccount, TokenExtensionState}; - use crate::helpers::IntoProto; - - impl IntoProto for ExtendedMint { - fn into_proto(self) -> ExtendedMintProto { - ExtendedMintProto { - base_mint: Some(self.base_account.into_proto()), - extension_data_vec: self - .extension_data_vec - .into_iter() - .map(IntoProto::into_proto) - .collect::>(), - } - } - } - - impl IntoProto for ExtendedTokenAccount { - fn into_proto(self) -> ExtendedTokenAccountProto { - ExtendedTokenAccountProto { - base_account: Some(self.base_account.into_proto()), - extension_data_vec: self - .extension_data_vec - .into_iter() - .map(IntoProto::into_proto) - .collect::>(), - } - } - } - - impl ParseProto for AccountParser { - type Message = TokenExtensionStateProto; - - fn output_into_message(value: Self::Output) -> Self::Message { - let state_oneof = match value { - TokenExtensionState::ExtendedTokenAccount(data) => Some( - token_extension_state_proto::StateOneof::ExtendedTokenAccount( - data.into_proto(), - ), - ), - TokenExtensionState::ExtendedMint(data) => Some( - token_extension_state_proto::StateOneof::ExtendedMintAccount(data.into_proto()), - ), - TokenExtensionState::Multisig(data) => Some( - token_extension_state_proto::StateOneof::Multisig(data.into_proto()), - ), - }; - - Self::Message { state_oneof } - } - } -} - #[cfg(test)] mod tests { use core::panic; diff --git a/crates/spl-token-extensions-parser/src/accounts.rs b/crates/spl-token-extensions-parser/src/accounts.rs new file mode 100644 index 00000000..44959dc5 --- /dev/null +++ b/crates/spl-token-extensions-parser/src/accounts.rs @@ -0,0 +1,203 @@ +use bytemuck::Pod; +use solana_program_error::ProgramError; +use solana_program_pack::Pack; +use spl_pod::bytemuck::pod_from_bytes; +use spl_token_2022::{ + extension::{ + self, BaseState, BaseStateWithExtensions, Extension, ExtensionType, StateWithExtensions, + }, + state::{Account, Mint}, +}; +use spl_token_group_interface::state::{TokenGroup, TokenGroupMember}; +use spl_token_metadata_interface::state::TokenMetadata; +use spl_type_length_value::variable_len_pack::VariableLenPack; + +fn get_extension_data_bytes<'data, T: BaseState + Pack>( + state_with_ex: &'data StateWithExtensions, + extension_type: ExtensionType, +) -> Result<&'data [u8], ProgramError> { + let extension_data = match extension_type { + ExtensionType::ImmutableOwner => state_with_ex.get_extension_bytes::()?, + ExtensionType::TransferFeeAmount => state_with_ex.get_extension_bytes::()?, + ExtensionType::ConfidentialTransferAccount => state_with_ex.get_extension_bytes::()?, + ExtensionType::MemoTransfer => state_with_ex.get_extension_bytes::()?, + ExtensionType::NonTransferableAccount => state_with_ex.get_extension_bytes::()?, + ExtensionType::TransferHookAccount => state_with_ex.get_extension_bytes::()?, + ExtensionType::CpiGuard => state_with_ex.get_extension_bytes::()?, + ExtensionType::ConfidentialTransferFeeAmount => state_with_ex.get_extension_bytes::()?, + ExtensionType::TransferFeeConfig => state_with_ex.get_extension_bytes::()?, + ExtensionType::MintCloseAuthority => state_with_ex.get_extension_bytes::()?, + ExtensionType::ConfidentialTransferMint => state_with_ex.get_extension_bytes::()?, + ExtensionType::DefaultAccountState => state_with_ex.get_extension_bytes::()?, + ExtensionType::NonTransferable => state_with_ex.get_extension_bytes::()?, + ExtensionType::InterestBearingConfig => state_with_ex.get_extension_bytes::()?, + ExtensionType::PermanentDelegate => state_with_ex.get_extension_bytes::()?, + ExtensionType::TransferHook => state_with_ex.get_extension_bytes::()?, + ExtensionType::ConfidentialTransferFeeConfig => state_with_ex.get_extension_bytes::()?, + ExtensionType::MetadataPointer => state_with_ex.get_extension_bytes::()?, + ExtensionType::TokenMetadata => state_with_ex.get_extension_bytes::()?, + ExtensionType::GroupPointer => state_with_ex.get_extension_bytes::()?, + ExtensionType::TokenGroup => state_with_ex.get_extension_bytes::()?, + ExtensionType::GroupMemberPointer => state_with_ex.get_extension_bytes::()?, + ExtensionType::TokenGroupMember => state_with_ex.get_extension_bytes::()?, + ExtensionType::ConfidentialMintBurn => state_with_ex.get_extension_bytes::()?, + ExtensionType::ScaledUiAmount => state_with_ex.get_extension_bytes::()?, + ExtensionType::Pausable => state_with_ex.get_extension_bytes::()?, + ExtensionType::PausableAccount => state_with_ex.get_extension_bytes::()?, + ExtensionType::Uninitialized => &[], + }; + + Ok(extension_data) +} + +pub fn token_account_extensions_data_bytes<'data>( + state_with_ex: &'data StateWithExtensions, + extension_type: ExtensionType, +) -> Result<&'data [u8], ProgramError> { + get_extension_data_bytes(state_with_ex, extension_type) +} + +pub fn mint_account_extensions_data_bytes<'data>( + state_with_ex: &'data StateWithExtensions, + extension_type: ExtensionType, +) -> Result<&'data [u8], ProgramError> { + get_extension_data_bytes(state_with_ex, extension_type) +} + +pub fn parse_extension_data(data_bytes: &[u8]) -> Result { + let extension = pod_from_bytes::(data_bytes)?; + Ok(extension.to_owned()) +} + +pub fn parse_token_metadata_extension(data_bytes: &[u8]) -> Result { + let token_metadata = TokenMetadata::unpack_from_slice(data_bytes)?; + Ok(token_metadata.clone()) +} + +#[derive(Debug, PartialEq)] +pub enum ExtensionData { + ImmutableOwner(extension::immutable_owner::ImmutableOwner), + TransferFeeAmount(extension::transfer_fee::TransferFeeAmount), + ConfidentialTransferAccount(extension::confidential_transfer::ConfidentialTransferAccount), + MemoTransfer(extension::memo_transfer::MemoTransfer), + NonTransferableAccount(extension::non_transferable::NonTransferableAccount), + TransferHookAccount(extension::transfer_hook::TransferHookAccount), + CpiGuard(extension::cpi_guard::CpiGuard), + ConfidentialTransferFeeAmount( + extension::confidential_transfer_fee::ConfidentialTransferFeeAmount, + ), + TransferFeeConfig(extension::transfer_fee::TransferFeeConfig), + MintCloseAuthority(extension::mint_close_authority::MintCloseAuthority), + ConfidentialTransferMint(extension::confidential_transfer::ConfidentialTransferMint), + DefaultAccountState(extension::default_account_state::DefaultAccountState), + NonTransferable(extension::non_transferable::NonTransferable), + InterestBearingConfig(extension::interest_bearing_mint::InterestBearingConfig), + PermanentDelegate(extension::permanent_delegate::PermanentDelegate), + TransferHook(extension::transfer_hook::TransferHook), + ConfidentialTransferFeeConfig( + extension::confidential_transfer_fee::ConfidentialTransferFeeConfig, + ), + MetadataPointer(extension::metadata_pointer::MetadataPointer), + TokenMetadata(TokenMetadata), + GroupPointer(extension::group_pointer::GroupPointer), + TokenGroup(TokenGroup), + GroupMemberPointer(extension::group_member_pointer::GroupMemberPointer), + TokenGroupMember(TokenGroupMember), + ConfidentialMintBurn(extension::confidential_mint_burn::ConfidentialMintBurn), + ScaledUiAmountConfig(extension::scaled_ui_amount::ScaledUiAmountConfig), + PausableConfig(extension::pausable::PausableConfig), + PausableAccount(extension::pausable::PausableAccount), +} + +impl TryFrom<(ExtensionType, &[u8])> for ExtensionData { + type Error = ProgramError; + + fn try_from(value: (ExtensionType, &[u8])) -> Result { + let (extension_type, data_bytes) = value; + match extension_type { + ExtensionType::ImmutableOwner => Ok(ExtensionData::ImmutableOwner( + parse_extension_data(data_bytes)?, + )), + ExtensionType::TransferFeeAmount => Ok(ExtensionData::TransferFeeAmount( + parse_extension_data(data_bytes)?, + )), + ExtensionType::ConfidentialTransferAccount => Ok( + ExtensionData::ConfidentialTransferAccount(parse_extension_data(data_bytes)?), + ), + ExtensionType::MemoTransfer => Ok(ExtensionData::MemoTransfer(parse_extension_data( + data_bytes, + )?)), + ExtensionType::NonTransferableAccount => Ok(ExtensionData::NonTransferableAccount( + parse_extension_data(data_bytes)?, + )), + ExtensionType::TransferHookAccount => Ok(ExtensionData::TransferHookAccount( + parse_extension_data(data_bytes)?, + )), + ExtensionType::CpiGuard => { + Ok(ExtensionData::CpiGuard(parse_extension_data(data_bytes)?)) + }, + ExtensionType::ConfidentialTransferFeeAmount => Ok( + ExtensionData::ConfidentialTransferFeeAmount(parse_extension_data(data_bytes)?), + ), + ExtensionType::TransferFeeConfig => Ok(ExtensionData::TransferFeeConfig( + parse_extension_data(data_bytes)?, + )), + ExtensionType::MintCloseAuthority => Ok(ExtensionData::MintCloseAuthority( + parse_extension_data(data_bytes)?, + )), + ExtensionType::ConfidentialTransferMint => Ok(ExtensionData::ConfidentialTransferMint( + parse_extension_data(data_bytes)?, + )), + ExtensionType::DefaultAccountState => Ok(ExtensionData::DefaultAccountState( + parse_extension_data(data_bytes)?, + )), + ExtensionType::NonTransferable => Ok(ExtensionData::NonTransferable( + parse_extension_data(data_bytes)?, + )), + ExtensionType::InterestBearingConfig => Ok(ExtensionData::InterestBearingConfig( + parse_extension_data(data_bytes)?, + )), + ExtensionType::PermanentDelegate => Ok(ExtensionData::PermanentDelegate( + parse_extension_data(data_bytes)?, + )), + ExtensionType::TransferHook => Ok(ExtensionData::TransferHook(parse_extension_data( + data_bytes, + )?)), + ExtensionType::ConfidentialTransferFeeConfig => Ok( + ExtensionData::ConfidentialTransferFeeConfig(parse_extension_data(data_bytes)?), + ), + ExtensionType::MetadataPointer => Ok(ExtensionData::MetadataPointer( + parse_extension_data(data_bytes)?, + )), + ExtensionType::TokenMetadata => Ok(ExtensionData::TokenMetadata( + parse_token_metadata_extension(data_bytes)?, + )), + ExtensionType::GroupPointer => Ok(ExtensionData::GroupPointer(parse_extension_data( + data_bytes, + )?)), + ExtensionType::TokenGroup => { + Ok(ExtensionData::TokenGroup(parse_extension_data(data_bytes)?)) + }, + ExtensionType::GroupMemberPointer => Ok(ExtensionData::GroupMemberPointer( + parse_extension_data(data_bytes)?, + )), + ExtensionType::TokenGroupMember => Ok(ExtensionData::TokenGroupMember( + parse_extension_data(data_bytes)?, + )), + ExtensionType::ConfidentialMintBurn => Ok(ExtensionData::ConfidentialMintBurn( + parse_extension_data(data_bytes)?, + )), + ExtensionType::ScaledUiAmount => Ok(ExtensionData::ScaledUiAmountConfig( + parse_extension_data(data_bytes)?, + )), + ExtensionType::Pausable => Ok(ExtensionData::PausableConfig(parse_extension_data( + data_bytes, + )?)), + ExtensionType::PausableAccount => Ok(ExtensionData::PausableAccount( + parse_extension_data(data_bytes)?, + )), + + ExtensionType::Uninitialized => Err(ProgramError::InvalidArgument), + } + } +} diff --git a/crates/spl-token-extensions-parser/src/extensions/common_instructions.rs b/crates/spl-token-extensions-parser/src/extensions/common_instructions.rs new file mode 100644 index 00000000..5d5b4ac7 --- /dev/null +++ b/crates/spl-token-extensions-parser/src/extensions/common_instructions.rs @@ -0,0 +1,148 @@ +use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; +use yellowstone_vixen_parser::{check_min_accounts_req, Error, Result}; + +use super::extension::decode_extension_ix_type; + +#[derive(Debug, Clone, Copy)] +pub enum ExtensionWithCommonInstruction { + CpiGuard, + DefaultAccountState, + InterestBearingMint, + MemoTransfer, + GroupMemberPointer, + GroupPointer, + MetadataPointer, + TransferHook, +} + +#[derive(Debug, Clone, Copy)] +pub enum InstructionSupported { + InitAndUpdate, + EnableAndDisable, +} + +impl ExtensionWithCommonInstruction { + #[must_use] + pub fn get_instructions_supported(extension: &Self) -> InstructionSupported { + match extension { + ExtensionWithCommonInstruction::CpiGuard + | ExtensionWithCommonInstruction::MemoTransfer => { + InstructionSupported::EnableAndDisable + }, + ExtensionWithCommonInstruction::DefaultAccountState + | ExtensionWithCommonInstruction::InterestBearingMint + | ExtensionWithCommonInstruction::GroupMemberPointer + | ExtensionWithCommonInstruction::MetadataPointer + | ExtensionWithCommonInstruction::TransferHook + | ExtensionWithCommonInstruction::GroupPointer => InstructionSupported::InitAndUpdate, + } + } +} + +#[derive(Debug, Clone, Copy)] +pub struct ExtInitializeAccounts { + pub mint: Pubkey, +} + +#[derive(Debug)] +pub struct UpdateAccounts { + pub mint: Pubkey, + pub extension_authority: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] +pub struct EnableAccounts { + pub account: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] +pub struct DisableAccounts { + pub account: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] +pub struct CommonExtensionInstructions { + pub extension: ExtensionWithCommonInstruction, + pub instruction: CommonInstruction, +} + +#[derive(Debug)] +pub enum CommonInstruction { + Initialize { accounts: ExtInitializeAccounts }, + Update { accounts: UpdateAccounts }, + Enable { accounts: EnableAccounts }, + Disable { accounts: DisableAccounts }, +} + +impl CommonExtensionInstructions { + pub fn try_parse_extension_instruction( + extension: ExtensionWithCommonInstruction, + ix: &InstructionUpdate, + ) -> Result { + let ix_type: u8 = decode_extension_ix_type(&ix.data[1..])?; + let accounts_len = ix.accounts.len(); + match ExtensionWithCommonInstruction::get_instructions_supported(&extension) { + InstructionSupported::InitAndUpdate => match ix_type { + 0 => { + check_min_accounts_req(accounts_len, 1)?; + Ok(CommonExtensionInstructions { + extension, + instruction: CommonInstruction::Initialize { + accounts: ExtInitializeAccounts { + mint: ix.accounts[0], + }, + }, + }) + }, + 1 => { + check_min_accounts_req(accounts_len, 2)?; + Ok(CommonExtensionInstructions { + extension, + instruction: CommonInstruction::Update { + accounts: UpdateAccounts { + mint: ix.accounts[0], + extension_authority: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }, + }) + }, + _ => Err(Error::new("Invalid instruction")), + }, + InstructionSupported::EnableAndDisable => match ix_type { + 0 => { + check_min_accounts_req(accounts_len, 2)?; + Ok(CommonExtensionInstructions { + extension, + instruction: CommonInstruction::Enable { + accounts: EnableAccounts { + account: ix.accounts[0], + owner: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }, + }) + }, + 1 => { + check_min_accounts_req(accounts_len, 2)?; + Ok(CommonExtensionInstructions { + extension, + instruction: CommonInstruction::Disable { + accounts: DisableAccounts { + account: ix.accounts[0], + owner: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }, + }) + }, + _ => Err(Error::new("Invalid instruction")), + }, + } + } +} diff --git a/crates/spl-token-extensions-parser/src/extensions/confidential_transfer.rs b/crates/spl-token-extensions-parser/src/extensions/confidential_transfer.rs new file mode 100644 index 00000000..633fb911 --- /dev/null +++ b/crates/spl-token-extensions-parser/src/extensions/confidential_transfer.rs @@ -0,0 +1,330 @@ +use spl_token_2022::extension::confidential_transfer::instruction::ConfidentialTransferInstruction as SplConfidentialTransferInstruction; +use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; +use yellowstone_vixen_parser::{check_min_accounts_req, Result}; +use yellowstone_vixen_spl_token_parser::InitializeMintAccounts; + +use crate::{decode_extension_ix_type, ExtensionInstructionParser}; + +#[derive(Debug, Clone, Copy)] +pub struct UpdateMintAccounts { + pub mint: Pubkey, + pub authority: Pubkey, +} + +#[derive(Debug, Clone)] +pub struct ConfigureAccountAccounts { + pub account: Pubkey, + pub mint: Pubkey, + pub sysvar: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct ApproveAccountAccounts { + pub account: Pubkey, + pub mint: Pubkey, + pub authority: Pubkey, +} + +#[derive(Debug)] +pub struct EmptyAccountAccounts { + pub account: Pubkey, + pub sysvar: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] + +pub struct DepositAccounts { + pub account: Pubkey, + pub mint: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] +pub struct WithdrawAccounts { + pub source_account: Pubkey, + pub mint: Pubkey, + pub destination: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] + +pub struct ConfidentialTransferAccounts { + pub source_account: Pubkey, + pub mint: Pubkey, + pub destination: Pubkey, + pub owner: Pubkey, + pub context_account: Pubkey, // Sysvar account or context state account + pub multisig_signers: Vec, +} + +#[derive(Debug)] +pub struct ApplyPendingBalanceAccounts { + pub account: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] + +pub struct CreditsAccounts { + pub account: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] + +pub struct TransferWithFeeAccounts { + pub source_account: Pubkey, + pub mint: Pubkey, + pub destination: Pubkey, +} + +#[derive(Debug, Clone, Copy)] + +pub struct ConfigureAccountWithRegistryAccounts { + pub account: Pubkey, + pub mint: Pubkey, + pub registry: Pubkey, +} + +#[allow(clippy::large_enum_variant)] +#[derive(Debug)] +pub enum ConfidentialTransferInstruction { + InitializeMint { + accounts: InitializeMintAccounts, + }, + UpdateMint { + accounts: UpdateMintAccounts, + }, + ConfigureAccount { + accounts: ConfigureAccountAccounts, + }, + ApproveAccount { + accounts: ApproveAccountAccounts, + }, + EmptyAccount { + accounts: EmptyAccountAccounts, + }, + Deposit { + accounts: DepositAccounts, + }, + Withdraw { + accounts: WithdrawAccounts, + }, + Transfer { + accounts: ConfidentialTransferAccounts, + }, + ApplyPendingBalance { + accounts: ApplyPendingBalanceAccounts, + }, + EnableConfidentialCredits { + accounts: CreditsAccounts, + }, + DisableConfidentialCredits { + accounts: CreditsAccounts, + }, + EnableNonConfidentialCredits { + accounts: CreditsAccounts, + }, + DisableNonConfidentialCredits { + accounts: CreditsAccounts, + }, + TransferWithFee { + accounts: TransferWithFeeAccounts, + }, + ConfigureAccountWithRegistry { + accounts: ConfigureAccountWithRegistryAccounts, + }, +} + +impl ExtensionInstructionParser for ConfidentialTransferInstruction { + #[allow(clippy::too_many_lines)] + fn try_parse(ix: &InstructionUpdate) -> Result { + let accounts_len = ix.accounts.len(); + let ix_type: SplConfidentialTransferInstruction = decode_extension_ix_type(&ix.data[1..])?; + match ix_type { + SplConfidentialTransferInstruction::InitializeMint => { + check_min_accounts_req(accounts_len, 1)?; + Ok(ConfidentialTransferInstruction::InitializeMint { + accounts: InitializeMintAccounts { + mint: ix.accounts[0], + }, + }) + }, + SplConfidentialTransferInstruction::UpdateMint => { + check_min_accounts_req(accounts_len, 2)?; + Ok(ConfidentialTransferInstruction::UpdateMint { + accounts: UpdateMintAccounts { + mint: ix.accounts[0], + authority: ix.accounts[1], + }, + }) + }, + SplConfidentialTransferInstruction::ConfigureAccount => { + check_min_accounts_req(accounts_len, 4)?; + Ok(ConfidentialTransferInstruction::ConfigureAccount { + accounts: ConfigureAccountAccounts { + account: ix.accounts[0], + mint: ix.accounts[1], + sysvar: ix.accounts[2], + owner: ix.accounts[3], + multisig_signers: ix.accounts[4..].to_vec(), + }, + }) + }, + + SplConfidentialTransferInstruction::ApproveAccount => { + check_min_accounts_req(accounts_len, 3)?; + Ok(ConfidentialTransferInstruction::ApproveAccount { + accounts: ApproveAccountAccounts { + account: ix.accounts[0], + mint: ix.accounts[1], + authority: ix.accounts[2], + }, + }) + }, + + SplConfidentialTransferInstruction::EmptyAccount => { + check_min_accounts_req(accounts_len, 3)?; + Ok(ConfidentialTransferInstruction::EmptyAccount { + accounts: EmptyAccountAccounts { + account: ix.accounts[0], + sysvar: ix.accounts[1], + owner: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + }) + }, + + SplConfidentialTransferInstruction::Deposit => { + check_min_accounts_req(accounts_len, 3)?; + Ok(ConfidentialTransferInstruction::Deposit { + accounts: DepositAccounts { + account: ix.accounts[0], + mint: ix.accounts[1], + owner: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + }) + }, + + SplConfidentialTransferInstruction::Withdraw => { + check_min_accounts_req(accounts_len, 4)?; + Ok(ConfidentialTransferInstruction::Withdraw { + accounts: WithdrawAccounts { + source_account: ix.accounts[0], + mint: ix.accounts[1], + destination: ix.accounts[2], + owner: ix.accounts[3], + multisig_signers: ix.accounts[4..].to_vec(), + }, + }) + }, + + SplConfidentialTransferInstruction::Transfer => { + check_min_accounts_req(accounts_len, 5)?; + Ok(ConfidentialTransferInstruction::Transfer { + accounts: ConfidentialTransferAccounts { + source_account: ix.accounts[0], + mint: ix.accounts[1], + destination: ix.accounts[2], + context_account: ix.accounts[3], + owner: ix.accounts[4], + multisig_signers: ix.accounts[5..].to_vec(), + }, + }) + }, + + SplConfidentialTransferInstruction::ApplyPendingBalance => { + check_min_accounts_req(accounts_len, 2)?; + Ok(ConfidentialTransferInstruction::ApplyPendingBalance { + accounts: ApplyPendingBalanceAccounts { + account: ix.accounts[0], + owner: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }) + }, + + SplConfidentialTransferInstruction::EnableConfidentialCredits => { + check_min_accounts_req(accounts_len, 2)?; + Ok(ConfidentialTransferInstruction::EnableConfidentialCredits { + accounts: CreditsAccounts { + account: ix.accounts[0], + owner: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }) + }, + + SplConfidentialTransferInstruction::DisableConfidentialCredits => { + check_min_accounts_req(accounts_len, 2)?; + Ok( + ConfidentialTransferInstruction::DisableConfidentialCredits { + accounts: CreditsAccounts { + account: ix.accounts[0], + owner: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }, + ) + }, + + SplConfidentialTransferInstruction::EnableNonConfidentialCredits => { + check_min_accounts_req(accounts_len, 2)?; + Ok( + ConfidentialTransferInstruction::EnableNonConfidentialCredits { + accounts: CreditsAccounts { + account: ix.accounts[0], + owner: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }, + ) + }, + + SplConfidentialTransferInstruction::DisableNonConfidentialCredits => { + check_min_accounts_req(accounts_len, 2)?; + Ok( + ConfidentialTransferInstruction::DisableNonConfidentialCredits { + accounts: CreditsAccounts { + account: ix.accounts[0], + owner: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }, + ) + }, + SplConfidentialTransferInstruction::TransferWithFee => { + check_min_accounts_req(accounts_len, 5)?; + Ok(ConfidentialTransferInstruction::TransferWithFee { + accounts: TransferWithFeeAccounts { + source_account: ix.accounts[0], + mint: ix.accounts[1], + destination: ix.accounts[2], + }, + }) + }, + SplConfidentialTransferInstruction::ConfigureAccountWithRegistry => { + check_min_accounts_req(accounts_len, 4)?; + Ok( + ConfidentialTransferInstruction::ConfigureAccountWithRegistry { + accounts: ConfigureAccountWithRegistryAccounts { + account: ix.accounts[0], + mint: ix.accounts[1], + registry: ix.accounts[2], + }, + }, + ) + }, + } + } +} diff --git a/crates/spl-token-extensions-parser/src/extensions/confidential_transfer_fee.rs b/crates/spl-token-extensions-parser/src/extensions/confidential_transfer_fee.rs new file mode 100644 index 00000000..056e8cfa --- /dev/null +++ b/crates/spl-token-extensions-parser/src/extensions/confidential_transfer_fee.rs @@ -0,0 +1,156 @@ +use spl_token_2022::extension::confidential_transfer_fee::instruction::ConfidentialTransferFeeInstruction as SplConfidentialTransferFeeInstruction; +use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; +use yellowstone_vixen_parser::{check_min_accounts_req, Result}; + +use super::extension::{decode_extension_ix_type, ExtensionInstructionParser}; + +#[derive(Debug, Clone, Copy)] +pub struct InitializeConfidentialTransferFeeConfigAccounts { + pub mint: Pubkey, +} + +#[derive(Debug)] +pub struct ConfidentialWithdrawWithheldTokensFromMintAccounts { + pub mint: Pubkey, + pub fee_recipient: Pubkey, + pub sysvar: Pubkey, + pub withdraw_withheld_authority: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] +pub struct ConfidentialWithdrawWithheldTokensFromAccounts { + pub mint: Pubkey, + pub fee_recipient: Pubkey, + pub sysvar: Pubkey, + pub withdraw_withheld_authority: Pubkey, + pub multisig_signers: Vec, + pub source_accounts: Vec, +} + +#[derive(Debug)] +pub struct ConfidentialHarvestWithheldTokensToMintAccounts { + pub mint: Pubkey, + pub source_accounts: Vec, +} + +#[derive(Debug)] +pub struct EnableHarvestToMintAccounts { + pub mint: Pubkey, + pub confidential_transfer_fee_authority: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] +pub struct DisableHarvestToMintAccounts { + pub account: Pubkey, + pub confidential_transfer_fee_authority: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] +pub enum ConfidentialTransferFeeInstruction { + InitializeConfidentialTransferFeeConfig { + accounts: InitializeConfidentialTransferFeeConfigAccounts, + }, + WithdrawWithheldTokensFromMint { + accounts: ConfidentialWithdrawWithheldTokensFromMintAccounts, + }, + WithdrawWithheldTokensFromAccounts { + accounts: ConfidentialWithdrawWithheldTokensFromAccounts, + }, + HarvestWithheldTokensToMint { + accounts: ConfidentialHarvestWithheldTokensToMintAccounts, + }, + EnableHarvestToMint { + accounts: EnableHarvestToMintAccounts, + }, + DisableHarvestToMint { + accounts: DisableHarvestToMintAccounts, + }, +} + +impl ExtensionInstructionParser for ConfidentialTransferFeeInstruction { + fn try_parse(ix: &InstructionUpdate) -> Result { + let accounts_len = ix.accounts.len(); + let ix_type = decode_extension_ix_type(&ix.data[1..])?; + + match ix_type { + SplConfidentialTransferFeeInstruction::InitializeConfidentialTransferFeeConfig => { + check_min_accounts_req(accounts_len, 1)?; + Ok( + ConfidentialTransferFeeInstruction::InitializeConfidentialTransferFeeConfig { + accounts: InitializeConfidentialTransferFeeConfigAccounts { + mint: ix.accounts[0], + }, + }, + ) + }, + + SplConfidentialTransferFeeInstruction::WithdrawWithheldTokensFromMint => { + check_min_accounts_req(accounts_len, 4)?; + Ok( + ConfidentialTransferFeeInstruction::WithdrawWithheldTokensFromMint { + accounts: ConfidentialWithdrawWithheldTokensFromMintAccounts { + mint: ix.accounts[0], + fee_recipient: ix.accounts[1], + sysvar: ix.accounts[2], + withdraw_withheld_authority: ix.accounts[3], + multisig_signers: ix.accounts[4..].to_vec(), + }, + }, + ) + }, + + SplConfidentialTransferFeeInstruction::WithdrawWithheldTokensFromAccounts => { + check_min_accounts_req(accounts_len, 5)?; + Ok( + ConfidentialTransferFeeInstruction::WithdrawWithheldTokensFromAccounts { + accounts: ConfidentialWithdrawWithheldTokensFromAccounts { + mint: ix.accounts[0], + fee_recipient: ix.accounts[1], + sysvar: ix.accounts[2], + withdraw_withheld_authority: ix.accounts[3], + source_accounts: ix.accounts[4..].to_vec(), + multisig_signers: Vec::new(), + }, + }, + ) + }, + + SplConfidentialTransferFeeInstruction::HarvestWithheldTokensToMint => { + check_min_accounts_req(accounts_len, 2)?; + Ok( + ConfidentialTransferFeeInstruction::HarvestWithheldTokensToMint { + accounts: ConfidentialHarvestWithheldTokensToMintAccounts { + mint: ix.accounts[0], + source_accounts: ix.accounts[1..].to_vec(), + }, + }, + ) + }, + + SplConfidentialTransferFeeInstruction::EnableHarvestToMint => { + check_min_accounts_req(accounts_len, 2)?; + Ok(ConfidentialTransferFeeInstruction::EnableHarvestToMint { + accounts: EnableHarvestToMintAccounts { + mint: ix.accounts[0], + confidential_transfer_fee_authority: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }) + }, + + SplConfidentialTransferFeeInstruction::DisableHarvestToMint => { + check_min_accounts_req(accounts_len, 2)?; + Ok(ConfidentialTransferFeeInstruction::DisableHarvestToMint { + accounts: DisableHarvestToMintAccounts { + account: ix.accounts[0], + confidential_transfer_fee_authority: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }) + }, + } + } +} diff --git a/crates/parser/src/token_extension_program/extensions/helpers.rs b/crates/spl-token-extensions-parser/src/extensions/extension.rs similarity index 65% rename from crates/parser/src/token_extension_program/extensions/helpers.rs rename to crates/spl-token-extensions-parser/src/extensions/extension.rs index 9e68d5c0..04f222fc 100644 --- a/crates/parser/src/token_extension_program/extensions/helpers.rs +++ b/crates/spl-token-extensions-parser/src/extensions/extension.rs @@ -1,12 +1,11 @@ use yellowstone_vixen_core::instruction::InstructionUpdate; - -use crate::{Result, ResultExt}; +use yellowstone_vixen_parser::{Result, ResultExt}; pub fn decode_extension_ix_type>(ix_data: &[u8]) -> Result where T::Error: std::error::Error + Send + Sync + 'static { T::try_from(ix_data[0]).parse_err("Error decoding instruction data for token extension") } -pub trait ExtensionIxParser: Sized { - fn try_parse_extension_ix(ix: &InstructionUpdate) -> Result; +pub trait ExtensionInstructionParser: Sized { + fn try_parse(ix: &InstructionUpdate) -> Result; } diff --git a/crates/parser/src/token_extension_program/extensions/mod.rs b/crates/spl-token-extensions-parser/src/extensions/mod.rs similarity index 73% rename from crates/parser/src/token_extension_program/extensions/mod.rs rename to crates/spl-token-extensions-parser/src/extensions/mod.rs index 1e37a89d..69b79c8d 100644 --- a/crates/parser/src/token_extension_program/extensions/mod.rs +++ b/crates/spl-token-extensions-parser/src/extensions/mod.rs @@ -1,14 +1,15 @@ -mod common_ix; +mod common_instructions; mod confidential_transfer; mod confidential_transfer_fee; -pub mod helpers; +mod extension; mod token_group; mod token_metadata; mod transfer_fee; -pub use common_ix::*; +pub use common_instructions::*; pub use confidential_transfer::*; pub use confidential_transfer_fee::*; +pub use extension::*; pub use token_group::*; pub use token_metadata::*; pub use transfer_fee::*; diff --git a/crates/spl-token-extensions-parser/src/extensions/token_group.rs b/crates/spl-token-extensions-parser/src/extensions/token_group.rs new file mode 100644 index 00000000..69e366eb --- /dev/null +++ b/crates/spl-token-extensions-parser/src/extensions/token_group.rs @@ -0,0 +1,112 @@ +use spl_token_group_interface::instruction::{ + InitializeGroup, InitializeMember, TokenGroupInstruction as SplTokenGroupInstruction, + UpdateGroupAuthority, UpdateGroupMaxSize, +}; +use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; +use yellowstone_vixen_parser::{check_min_accounts_req, Result, ResultExt}; + +use crate::ExtensionInstructionParser; + +#[derive(Debug, Clone, Copy)] +pub struct InitializeGroupAccounts { + pub group: Pubkey, + pub mint: Pubkey, + pub mint_authority: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct UpdateGroupMaxSizeAccounts { + pub group: Pubkey, + pub update_authority: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct UpdateGroupAuthorityAccounts { + pub group: Pubkey, + pub current_authority: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeMemberAccounts { + pub member: Pubkey, + pub member_mint: Pubkey, + pub member_mint_authority: Pubkey, + pub group: Pubkey, + pub group_update_authority: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub enum TokenGroupInstruction { + InitializeGroup { + accounts: InitializeGroupAccounts, + args: InitializeGroup, + }, + UpdateGroupMaxSize { + accounts: UpdateGroupMaxSizeAccounts, + args: UpdateGroupMaxSize, + }, + UpdateGroupAuthority { + accounts: UpdateGroupAuthorityAccounts, + args: UpdateGroupAuthority, + }, + InitializeMember { + accounts: InitializeMemberAccounts, + args: InitializeMember, + }, +} + +impl ExtensionInstructionParser for TokenGroupInstruction { + fn try_parse(ix: &InstructionUpdate) -> Result { + let accounts_len = ix.accounts.len(); + + let ix_type = SplTokenGroupInstruction::unpack(&ix.data) + .parse_err("Error unpacking token group instruction data")?; + + Ok(match ix_type { + SplTokenGroupInstruction::InitializeGroup(args) => { + check_min_accounts_req(accounts_len, 3)?; + TokenGroupInstruction::InitializeGroup { + accounts: InitializeGroupAccounts { + group: ix.accounts[0], + mint: ix.accounts[1], + mint_authority: ix.accounts[2], + }, + args, + } + }, + SplTokenGroupInstruction::UpdateGroupMaxSize(args) => { + check_min_accounts_req(accounts_len, 2)?; + TokenGroupInstruction::UpdateGroupMaxSize { + accounts: UpdateGroupMaxSizeAccounts { + group: ix.accounts[0], + update_authority: ix.accounts[1], + }, + args, + } + }, + SplTokenGroupInstruction::UpdateGroupAuthority(args) => { + check_min_accounts_req(accounts_len, 2)?; + TokenGroupInstruction::UpdateGroupAuthority { + accounts: UpdateGroupAuthorityAccounts { + group: ix.accounts[0], + current_authority: ix.accounts[1], + }, + args, + } + }, + SplTokenGroupInstruction::InitializeMember(args) => { + check_min_accounts_req(accounts_len, 5)?; + TokenGroupInstruction::InitializeMember { + accounts: InitializeMemberAccounts { + member: ix.accounts[0], + member_mint: ix.accounts[1], + member_mint_authority: ix.accounts[2], + group: ix.accounts[3], + group_update_authority: ix.accounts[4], + }, + args, + } + }, + }) + } +} diff --git a/crates/spl-token-extensions-parser/src/extensions/token_metadata.rs b/crates/spl-token-extensions-parser/src/extensions/token_metadata.rs new file mode 100644 index 00000000..3cafe98e --- /dev/null +++ b/crates/spl-token-extensions-parser/src/extensions/token_metadata.rs @@ -0,0 +1,131 @@ +use spl_token_metadata_interface::instruction::{ + Emit, Initialize, RemoveKey, TokenMetadataInstruction as SplTokenMetadataInstruction, + UpdateAuthority, UpdateField, +}; +use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; +use yellowstone_vixen_parser::{check_min_accounts_req, Result, ResultExt}; + +use super::extension::ExtensionInstructionParser; + +#[derive(Debug, Clone, Copy)] +pub struct InitializeAccounts { + pub metadata: Pubkey, + pub update_authority: Pubkey, + pub mint: Pubkey, + pub mint_authority: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct UpdateFieldAccounts { + pub metadata: Pubkey, + pub update_authority: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct RmoveKeyAccounts { + pub metadata: Pubkey, + pub update_authority: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct UpdateAuthorityAccounts { + pub metadata: Pubkey, + pub current_update_authority: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct EmitAccounts { + pub metadata: Pubkey, +} + +#[derive(Debug)] +pub enum TokenMetadataInstruction { + Initialize { + accounts: InitializeAccounts, + args: Initialize, + }, + UpdateField { + accounts: UpdateFieldAccounts, + args: UpdateField, + }, + RemoveKey { + accounts: RmoveKeyAccounts, + args: RemoveKey, + }, + UpdateAuthority { + accounts: UpdateAuthorityAccounts, + args: UpdateAuthority, + }, + Emit { + accounts: EmitAccounts, + args: Emit, + }, +} + +impl ExtensionInstructionParser for TokenMetadataInstruction { + fn try_parse(ix: &InstructionUpdate) -> Result { + let accounts_len = ix.accounts.len(); + + let ix_type = SplTokenMetadataInstruction::unpack(&ix.data) + .parse_err("Error unpacking token metadata instruction data")?; + + match ix_type { + SplTokenMetadataInstruction::Initialize(args) => { + check_min_accounts_req(accounts_len, 4)?; + + Ok(TokenMetadataInstruction::Initialize { + accounts: InitializeAccounts { + metadata: ix.accounts[0], + update_authority: ix.accounts[1], + mint: ix.accounts[2], + mint_authority: ix.accounts[3], + }, + args, + }) + }, + SplTokenMetadataInstruction::UpdateField(args) => { + check_min_accounts_req(accounts_len, 2)?; + + Ok(TokenMetadataInstruction::UpdateField { + accounts: UpdateFieldAccounts { + metadata: ix.accounts[0], + update_authority: ix.accounts[1], + }, + args, + }) + }, + SplTokenMetadataInstruction::RemoveKey(args) => { + check_min_accounts_req(accounts_len, 2)?; + + Ok(TokenMetadataInstruction::RemoveKey { + accounts: RmoveKeyAccounts { + metadata: ix.accounts[0], + update_authority: ix.accounts[1], + }, + args, + }) + }, + SplTokenMetadataInstruction::UpdateAuthority(args) => { + check_min_accounts_req(accounts_len, 2)?; + + Ok(TokenMetadataInstruction::UpdateAuthority { + accounts: UpdateAuthorityAccounts { + metadata: ix.accounts[0], + current_update_authority: ix.accounts[1], + }, + args, + }) + }, + SplTokenMetadataInstruction::Emit(args) => { + check_min_accounts_req(accounts_len, 1)?; + + Ok(TokenMetadataInstruction::Emit { + accounts: EmitAccounts { + metadata: ix.accounts[0], + }, + args, + }) + }, + } + } +} diff --git a/crates/spl-token-extensions-parser/src/extensions/transfer_fee.rs b/crates/spl-token-extensions-parser/src/extensions/transfer_fee.rs new file mode 100644 index 00000000..aae8226d --- /dev/null +++ b/crates/spl-token-extensions-parser/src/extensions/transfer_fee.rs @@ -0,0 +1,214 @@ +use spl_token_2022::extension::transfer_fee::instruction::TransferFeeInstruction as SplTransferFeeInstruction; +use yellowstone_vixen_core::{instruction::InstructionUpdate, Pubkey}; +use yellowstone_vixen_parser::{check_min_accounts_req, Result, ResultExt}; + +use super::extension::ExtensionInstructionParser; + +#[derive(Debug)] +pub struct TransferCheckedWithFeeAccounts { + pub source: Pubkey, + pub mint: Pubkey, + pub destination: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} +#[derive(Debug, Clone, Copy)] +pub struct TransferCheckedWithFeeArgs { + pub amount: u64, + pub fee_amount: u64, + pub decimals: u8, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeTransferFeeConfigAccounts { + pub mint: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeTransferFeeConfigArgs { + pub transfer_fee_config_authority: Option, + pub withdraw_withheld_authority: Option, + pub transfer_fee_basis_points: u16, + pub maximum_fee: u64, +} + +#[derive(Debug)] +pub struct WithdrawWithheldTokensFromMintAccounts { + pub mint: Pubkey, + pub fee_recipient: Pubkey, + pub withdraw_withheld_authority: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] +pub struct WithdrawWithheldTokensFromAccountsAccounts { + pub mint: Pubkey, + pub fee_recipient: Pubkey, + pub withdraw_withheld_authority: Pubkey, + pub source_accounts: Vec, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct WithdrawWithheldTokensFromAccountsArgs { + pub num_token_accounts: u8, +} + +#[derive(Debug)] + +pub struct SetTransferFeeAccounts { + pub mint: Pubkey, + pub mint_fee_acc_owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] + +pub struct SetTransferFeeArgs { + pub transfer_fee_basis_points: u16, + pub maximum_fee: u64, +} + +#[derive(Debug, Clone, Copy)] +pub struct HarvestWithheldTokensToMintAccounts { + pub mint: Pubkey, + pub mint_fee_acc_owner: Pubkey, +} + +#[derive(Debug)] +pub enum TransferFeeInstruction { + TransferCheckedWithFee { + accounts: TransferCheckedWithFeeAccounts, + args: TransferCheckedWithFeeArgs, + }, + InitializeTransferFeeConfig { + accounts: InitializeTransferFeeConfigAccounts, + args: InitializeTransferFeeConfigArgs, + }, + WithdrawWithheldTokensFromMint { + accounts: WithdrawWithheldTokensFromMintAccounts, + }, + WithdrawWithheldTokensFromAccounts { + accounts: WithdrawWithheldTokensFromAccountsAccounts, + args: WithdrawWithheldTokensFromAccountsArgs, + }, + HarvestWithheldTokensToMint { + accounts: HarvestWithheldTokensToMintAccounts, + }, + SetTransferFee { + accounts: SetTransferFeeAccounts, + args: SetTransferFeeArgs, + }, +} + +impl ExtensionInstructionParser for TransferFeeInstruction { + #[allow(clippy::too_many_lines)] + fn try_parse(ix: &InstructionUpdate) -> Result { + let accounts_len = ix.accounts.len(); + let ix_type = SplTransferFeeInstruction::unpack(&ix.data[1..]) + .parse_err("Error unpacking transfer fee instruction data")?; + match ix_type { + SplTransferFeeInstruction::TransferCheckedWithFee { + amount, + decimals, + fee, + } => { + check_min_accounts_req(accounts_len, 4)?; + Ok(TransferFeeInstruction::TransferCheckedWithFee { + accounts: TransferCheckedWithFeeAccounts { + source: ix.accounts[0], + mint: ix.accounts[1], + destination: ix.accounts[2], + owner: ix.accounts[3], + multisig_signers: ix.accounts[4..].to_vec(), + }, + args: TransferCheckedWithFeeArgs { + amount, + fee_amount: fee, + decimals, + }, + }) + }, + + SplTransferFeeInstruction::InitializeTransferFeeConfig { + transfer_fee_config_authority, + withdraw_withheld_authority, + transfer_fee_basis_points, + maximum_fee, + } => { + check_min_accounts_req(accounts_len, 1)?; + Ok(TransferFeeInstruction::InitializeTransferFeeConfig { + accounts: InitializeTransferFeeConfigAccounts { + mint: ix.accounts[0], + }, + args: InitializeTransferFeeConfigArgs { + transfer_fee_config_authority: transfer_fee_config_authority + .map(|p| p.to_bytes().into()) + .into(), + withdraw_withheld_authority: withdraw_withheld_authority + .map(|p| p.to_bytes().into()) + .into(), + transfer_fee_basis_points, + maximum_fee, + }, + }) + }, + + SplTransferFeeInstruction::WithdrawWithheldTokensFromMint => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TransferFeeInstruction::WithdrawWithheldTokensFromMint { + accounts: WithdrawWithheldTokensFromMintAccounts { + mint: ix.accounts[0], + fee_recipient: ix.accounts[1], + withdraw_withheld_authority: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + }) + }, + + SplTransferFeeInstruction::WithdrawWithheldTokensFromAccounts { + num_token_accounts, + } => { + check_min_accounts_req(accounts_len, 3 + num_token_accounts as usize)?; + Ok(TransferFeeInstruction::WithdrawWithheldTokensFromAccounts { + accounts: WithdrawWithheldTokensFromAccountsAccounts { + mint: ix.accounts[0], + fee_recipient: ix.accounts[1], + withdraw_withheld_authority: ix.accounts[2], + source_accounts: ix.accounts[3..(3 + num_token_accounts) as usize].to_vec(), + multisig_signers: ix.accounts[(3 + num_token_accounts as usize)..].to_vec(), + }, + args: WithdrawWithheldTokensFromAccountsArgs { num_token_accounts }, + }) + }, + + SplTransferFeeInstruction::HarvestWithheldTokensToMint => { + check_min_accounts_req(accounts_len, 2)?; + Ok(TransferFeeInstruction::HarvestWithheldTokensToMint { + accounts: HarvestWithheldTokensToMintAccounts { + mint: ix.accounts[0], + mint_fee_acc_owner: ix.accounts[1], + }, + }) + }, + + SplTransferFeeInstruction::SetTransferFee { + transfer_fee_basis_points, + maximum_fee, + } => { + check_min_accounts_req(accounts_len, 2)?; + Ok(TransferFeeInstruction::SetTransferFee { + accounts: SetTransferFeeAccounts { + mint: ix.accounts[0], + mint_fee_acc_owner: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + args: SetTransferFeeArgs { + transfer_fee_basis_points, + maximum_fee, + }, + }) + }, + } + } +} diff --git a/crates/spl-token-extensions-parser/src/instruction_parser.rs b/crates/spl-token-extensions-parser/src/instruction_parser.rs new file mode 100644 index 00000000..a76d08fa --- /dev/null +++ b/crates/spl-token-extensions-parser/src/instruction_parser.rs @@ -0,0 +1,285 @@ +use spl_token_2022::instruction::TokenInstruction as SplTokenInstruction; +use spl_token_group_interface::instruction::TokenGroupInstruction as SplTokenGroupInstruction; +use spl_token_metadata_interface::instruction::TokenMetadataInstruction as SplTokenMetadataInstruction; +use yellowstone_vixen_core::{ + instruction::InstructionUpdate, ParseError, ParseResult, Parser, Prefilter, ProgramParser, +}; +use yellowstone_vixen_parser::{check_min_accounts_req, Error, Result, ResultExt}; +use yellowstone_vixen_spl_token_parser::{ + InstructionParser as TokenProgramInstructionParser, SetAuthorityAccounts, +}; + +use crate::{ + extensions::{ + CommonExtensionInstructions, ConfidentialTransferFeeInstruction, + ConfidentialTransferInstruction, ExtensionWithCommonInstruction, TokenGroupInstruction, + TokenMetadataInstruction, TransferFeeInstruction, + }, + instructions::{ + CreateNativeMintAccounts, InitializeMintCloseAuthorityAccounts, + InitializeMintCloseAuthorityArgs, InitializeNonTransferableMintAccounts, + InitializePermanentDelegateAccounts, InitializePermanentDelegateArgs, ReallocateAccounts, + ReallocateArgs, WithdrawExcessLamportsAccounts, + }, + ExtensionInstructionParser, SetAuthorityArgs, TokenExtensionProgramInstruction, +}; + +#[derive(Debug, Clone, Copy)] +pub struct InstructionParser; + +impl Parser for InstructionParser { + type Input = InstructionUpdate; + type Output = TokenExtensionProgramInstruction; + + fn id(&self) -> std::borrow::Cow<'static, str> { "token_extensions::InstructionParser".into() } + + fn prefilter(&self) -> Prefilter { + Prefilter::builder() + .transaction_accounts([spl_token_2022::ID]) + .build() + .unwrap() + } + + async fn parse(&self, ix_update: &InstructionUpdate) -> ParseResult { + InstructionParser::parse_impl(ix_update).map_err(|e| ParseError::Other(e.into())) + } +} + +impl ProgramParser for InstructionParser { + fn program_id(&self) -> yellowstone_vixen_core::Pubkey { spl_token_2022::ID.to_bytes().into() } +} + +impl InstructionParser { + #[allow(clippy::too_many_lines)] + fn parse_impl(ix: &InstructionUpdate) -> Result { + let accounts_len = ix.accounts.len(); + match SplTokenInstruction::unpack(&ix.data) { + Ok(token_ix) => match token_ix { + SplTokenInstruction::TransferFeeExtension => { + Ok(TokenExtensionProgramInstruction::TransferFee( + TransferFeeInstruction::try_parse(ix)?, + )) + }, + SplTokenInstruction::ConfidentialTransferExtension => { + Ok(TokenExtensionProgramInstruction::ConfidentialTransfer( + ConfidentialTransferInstruction::try_parse(ix)?, + )) + }, + SplTokenInstruction::ConfidentialTransferFeeExtension => { + Ok(TokenExtensionProgramInstruction::ConfidentialTransferFee( + ConfidentialTransferFeeInstruction::try_parse(ix)?, + )) + }, + SplTokenInstruction::CpiGuardExtension => { + Ok(TokenExtensionProgramInstruction::CpiGuard( + CommonExtensionInstructions::try_parse_extension_instruction( + ExtensionWithCommonInstruction::CpiGuard, + ix, + )?, + )) + }, + + SplTokenInstruction::DefaultAccountStateExtension => { + Ok(TokenExtensionProgramInstruction::DefaultAccountState( + CommonExtensionInstructions::try_parse_extension_instruction( + ExtensionWithCommonInstruction::DefaultAccountState, + ix, + )?, + )) + }, + SplTokenInstruction::InterestBearingMintExtension => { + Ok(TokenExtensionProgramInstruction::InterestBearingMint( + CommonExtensionInstructions::try_parse_extension_instruction( + ExtensionWithCommonInstruction::InterestBearingMint, + ix, + )?, + )) + }, + SplTokenInstruction::MemoTransferExtension => { + Ok(TokenExtensionProgramInstruction::MemoTransfer( + CommonExtensionInstructions::try_parse_extension_instruction( + ExtensionWithCommonInstruction::MemoTransfer, + ix, + )?, + )) + }, + + SplTokenInstruction::GroupMemberPointerExtension => { + Ok(TokenExtensionProgramInstruction::GroupMemberPointer( + CommonExtensionInstructions::try_parse_extension_instruction( + ExtensionWithCommonInstruction::GroupMemberPointer, + ix, + )?, + )) + }, + + SplTokenInstruction::GroupPointerExtension => { + Ok(TokenExtensionProgramInstruction::GroupPointer( + CommonExtensionInstructions::try_parse_extension_instruction( + ExtensionWithCommonInstruction::GroupPointer, + ix, + )?, + )) + }, + + SplTokenInstruction::MetadataPointerExtension => { + Ok(TokenExtensionProgramInstruction::MetadataPointer( + CommonExtensionInstructions::try_parse_extension_instruction( + ExtensionWithCommonInstruction::MetadataPointer, + ix, + )?, + )) + }, + + SplTokenInstruction::TransferHookExtension => { + Ok(TokenExtensionProgramInstruction::TransferHook( + CommonExtensionInstructions::try_parse_extension_instruction( + ExtensionWithCommonInstruction::TransferHook, + ix, + )?, + )) + }, + SplTokenInstruction::SetAuthority { + authority_type, + new_authority, + } => { + check_min_accounts_req(accounts_len, 2)?; + Ok(TokenExtensionProgramInstruction::SetAuthority { + accounts: SetAuthorityAccounts { + account: ix.accounts[0], + current_authority: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + args: SetAuthorityArgs { + authority_type, + new_authority: new_authority.map(|p| p.to_bytes().into()).into(), + }, + }) + }, + SplTokenInstruction::CreateNativeMint => { + check_min_accounts_req(accounts_len, 2)?; + Ok(TokenExtensionProgramInstruction::CreateNativeMint { + accounts: CreateNativeMintAccounts { + funding_account: ix.accounts[0], + mint: ix.accounts[1], + }, + }) + }, + + SplTokenInstruction::InitializeMintCloseAuthority { close_authority } => { + check_min_accounts_req(accounts_len, 1)?; + Ok( + TokenExtensionProgramInstruction::InitializeMintCloseAuthority { + accounts: InitializeMintCloseAuthorityAccounts { + mint: ix.accounts[0], + }, + args: InitializeMintCloseAuthorityArgs { + close_authority: close_authority + .map(|p| p.to_bytes().into()) + .into(), + }, + }, + ) + }, + + SplTokenInstruction::InitializeNonTransferableMint => { + check_min_accounts_req(accounts_len, 1)?; + Ok( + TokenExtensionProgramInstruction::InitializeNonTransferableMint { + accounts: InitializeNonTransferableMintAccounts { + mint: ix.accounts[0], + }, + }, + ) + }, + + SplTokenInstruction::Reallocate { extension_types } => { + check_min_accounts_req(accounts_len, 4)?; + Ok(TokenExtensionProgramInstruction::Reallocate { + accounts: ReallocateAccounts { + account: ix.accounts[0], + payer: ix.accounts[1], + owner: ix.accounts[3], + multisig_signers: ix.accounts[4..].to_vec(), + }, + args: ReallocateArgs { extension_types }, + }) + }, + + SplTokenInstruction::InitializePermanentDelegate { delegate } => { + check_min_accounts_req(accounts_len, 1)?; + Ok( + TokenExtensionProgramInstruction::InitializePermanentDelegate { + accounts: InitializePermanentDelegateAccounts { + account: ix.accounts[0], + }, + args: InitializePermanentDelegateArgs { + delegate: delegate.to_bytes().into(), + }, + }, + ) + }, + + SplTokenInstruction::WithdrawExcessLamports => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenExtensionProgramInstruction::WithdrawExcessLamports { + accounts: WithdrawExcessLamportsAccounts { + source_account: ix.accounts[0], + destination_account: ix.accounts[1], + authority: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + }) + }, + + _ => Ok(TokenExtensionProgramInstruction::TokenProgram( + TokenProgramInstructionParser::parse_impl(ix).parse_err( + "Error parsing token extension instruction as token instruction", + )?, + )), + }, + Err(e) => { + if SplTokenMetadataInstruction::unpack(&ix.data).is_ok() { + return Ok(TokenExtensionProgramInstruction::TokenMetadata( + TokenMetadataInstruction::try_parse(ix)?, + )); + } + + if SplTokenGroupInstruction::unpack(&ix.data).is_ok() { + return Ok(TokenExtensionProgramInstruction::TokenGroup( + TokenGroupInstruction::try_parse(ix)?, + )); + } + + Err(Error::from_inner("Error unpacking instruction data", e)) + }, + } + } +} + +#[cfg(test)] +mod tests { + use std::ops::Mul; + + use yellowstone_vixen_mock::tx_fixture; + use yellowstone_vixen_spl_token_parser::TokenProgramInstruction; + + use super::{InstructionParser, Parser, TokenExtensionProgramInstruction}; + + #[tokio::test] + async fn test_mint_to_checked_ix_parsing() { + let parser = InstructionParser; + + let ixs = tx_fixture!("44gWEyKUkeUabtJr4eT3CQEkFGrD4jMdwUV6Ew5MR5K3RGizs9iwbkb5Q4T3gnAaSgHxn3ERQ8g5YTXuLP1FrWnt",&parser); + + let TokenExtensionProgramInstruction::TokenProgram( + TokenProgramInstruction::MintToChecked { args, .. }, + ) = &ixs[0] + else { + panic!("Invalid Instruction"); + }; + + assert_eq!(args.decimals, 9); + assert_eq!(args.amount, 100.mul(10u64.pow(args.decimals.into()))); + } +} diff --git a/crates/spl-token-extensions-parser/src/instructions.rs b/crates/spl-token-extensions-parser/src/instructions.rs new file mode 100644 index 00000000..17a31084 --- /dev/null +++ b/crates/spl-token-extensions-parser/src/instructions.rs @@ -0,0 +1,111 @@ +use spl_token_2022::{extension::ExtensionType, instruction::AuthorityType}; +use yellowstone_vixen_core::Pubkey; +use yellowstone_vixen_spl_token_parser::{SetAuthorityAccounts, TokenProgramInstruction}; + +use super::{ + CommonExtensionInstructions, ConfidentialTransferFeeInstruction, + ConfidentialTransferInstruction, TokenGroupInstruction, TokenMetadataInstruction, + TransferFeeInstruction, +}; + +#[allow(clippy::large_enum_variant)] +#[derive(Debug)] +pub enum TokenExtensionProgramInstruction { + TokenProgram(TokenProgramInstruction), + SetAuthority { + accounts: SetAuthorityAccounts, + args: SetAuthorityArgs, + }, + CreateNativeMint { + accounts: CreateNativeMintAccounts, + }, + InitializeMintCloseAuthority { + accounts: InitializeMintCloseAuthorityAccounts, + args: InitializeMintCloseAuthorityArgs, + }, + InitializeNonTransferableMint { + accounts: InitializeNonTransferableMintAccounts, + }, + Reallocate { + accounts: ReallocateAccounts, + args: ReallocateArgs, + }, + InitializePermanentDelegate { + accounts: InitializePermanentDelegateAccounts, + args: InitializePermanentDelegateArgs, + }, + WithdrawExcessLamports { + accounts: WithdrawExcessLamportsAccounts, + }, + TransferFee(TransferFeeInstruction), + ConfidentialTransfer(ConfidentialTransferInstruction), + ConfidentialTransferFee(ConfidentialTransferFeeInstruction), + CpiGuard(CommonExtensionInstructions), + DefaultAccountState(CommonExtensionInstructions), + GroupMemberPointer(CommonExtensionInstructions), + GroupPointer(CommonExtensionInstructions), + InterestBearingMint(CommonExtensionInstructions), + MemoTransfer(CommonExtensionInstructions), + MetadataPointer(CommonExtensionInstructions), + TransferHook(CommonExtensionInstructions), + TokenMetadata(TokenMetadataInstruction), + TokenGroup(TokenGroupInstruction), +} + +#[derive(Debug, Clone, Copy)] +pub struct CreateNativeMintAccounts { + pub mint: Pubkey, + pub funding_account: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeMintCloseAuthorityAccounts { + pub mint: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeMintCloseAuthorityArgs { + pub close_authority: Option, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeNonTransferableMintAccounts { + pub mint: Pubkey, +} + +#[derive(Debug)] +pub struct ReallocateAccounts { + pub account: Pubkey, + pub payer: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug)] +pub struct ReallocateArgs { + pub extension_types: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializePermanentDelegateAccounts { + pub account: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializePermanentDelegateArgs { + pub delegate: Pubkey, +} + +#[derive(Debug)] +pub struct WithdrawExcessLamportsAccounts { + pub source_account: Pubkey, + pub destination_account: Pubkey, + pub authority: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone)] +pub struct SetAuthorityArgs { + pub authority_type: AuthorityType, + pub new_authority: Option, +} diff --git a/crates/parser/src/token_extension_program/mod.rs b/crates/spl-token-extensions-parser/src/lib.rs similarity index 57% rename from crates/parser/src/token_extension_program/mod.rs rename to crates/spl-token-extensions-parser/src/lib.rs index 49f27f4f..7a8f6bdf 100644 --- a/crates/parser/src/token_extension_program/mod.rs +++ b/crates/spl-token-extensions-parser/src/lib.rs @@ -1,12 +1,12 @@ -mod account_helpers; mod account_parser; +mod accounts; mod extensions; -mod instruction_helpers; mod instruction_parser; +mod instructions; -pub use account_helpers::*; pub use account_parser::*; +pub use accounts::*; pub use extensions::*; -pub use instruction_helpers::*; pub use instruction_parser::*; +pub use instructions::*; diff --git a/crates/spl-token-parser/Cargo.toml b/crates/spl-token-parser/Cargo.toml new file mode 100644 index 00000000..673a7116 --- /dev/null +++ b/crates/spl-token-parser/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "yellowstone-vixen-spl-token-parser" +description = "Vixen program parsers for spl token program." +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +authors.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +spl-pod = { workspace = true } +spl-token = { workspace = true } +solana-program-error = { workspace = true } +yellowstone-grpc-proto = { workspace = true } +yellowstone-vixen-core = { workspace = true } +yellowstone-vixen-parser = { workspace = true } +yellowstone-vixen-proto = { workspace = true, features = [ + "parser", +], optional = true } +thiserror.workspace = true +bs58.workspace = true +tracing = { workspace = true, optional = true } +strum = { workspace = true, optional = true } +strum_macros = { workspace = true, optional = true } +bytemuck = { workspace = true, optional = true } + +[dev-dependencies] +yellowstone-vixen-mock = { workspace = true } +tokio.workspace = true + +[features] +default = [] +proto = [ + "dep:yellowstone-vixen-proto", + "yellowstone-vixen-core/proto", + "yellowstone-vixen-proto/parser", + "yellowstone-vixen-parser/proto", +] diff --git a/crates/parser/fixtures/3SmPYPvZfEmroktLiJsgaNENuPEud3Z52zSfLQ1zJdkK_account.json b/crates/spl-token-parser/fixtures/3SmPYPvZfEmroktLiJsgaNENuPEud3Z52zSfLQ1zJdkK_account.json similarity index 100% rename from crates/parser/fixtures/3SmPYPvZfEmroktLiJsgaNENuPEud3Z52zSfLQ1zJdkK_account.json rename to crates/spl-token-parser/fixtures/3SmPYPvZfEmroktLiJsgaNENuPEud3Z52zSfLQ1zJdkK_account.json diff --git a/crates/parser/fixtures/55kpnRufcX9Fo44oRBXtrkxPRww4UWJKxCpgBV39kzAAag8oyJbd9Y3YWdQQUi3TBqtrhjgsMGb9Nw8bUxy7j5rt_tx.json b/crates/spl-token-parser/fixtures/55kpnRufcX9Fo44oRBXtrkxPRww4UWJKxCpgBV39kzAAag8oyJbd9Y3YWdQQUi3TBqtrhjgsMGb9Nw8bUxy7j5rt_tx.json similarity index 100% rename from crates/parser/fixtures/55kpnRufcX9Fo44oRBXtrkxPRww4UWJKxCpgBV39kzAAag8oyJbd9Y3YWdQQUi3TBqtrhjgsMGb9Nw8bUxy7j5rt_tx.json rename to crates/spl-token-parser/fixtures/55kpnRufcX9Fo44oRBXtrkxPRww4UWJKxCpgBV39kzAAag8oyJbd9Y3YWdQQUi3TBqtrhjgsMGb9Nw8bUxy7j5rt_tx.json diff --git a/crates/spl-token-parser/src/account_parser.rs b/crates/spl-token-parser/src/account_parser.rs new file mode 100644 index 00000000..df2fb0c5 --- /dev/null +++ b/crates/spl-token-parser/src/account_parser.rs @@ -0,0 +1,81 @@ +use std::borrow::Cow; + +use spl_token::{ + solana_program::{program_error::ProgramError, program_pack::Pack}, + state::{Account, Mint, Multisig}, +}; +use yellowstone_vixen_core::{ + AccountUpdate, ParseError, ParseResult, Parser, Prefilter, ProgramParser, +}; + +#[derive(Debug)] +pub enum TokenProgramState { + TokenAccount(Account), + Mint(Mint), + Multisig(Multisig), +} + +impl TokenProgramState { + pub fn try_unpack(data_bytes: &[u8]) -> ParseResult { + match data_bytes.len() { + Mint::LEN => Mint::unpack_from_slice(data_bytes) + .map(Self::Mint) + .map_err(Into::into), + Account::LEN => Account::unpack_from_slice(data_bytes) + .map(Self::TokenAccount) + .map_err(Into::into), + Multisig::LEN => Multisig::unpack_from_slice(data_bytes) + .map(Self::Multisig) + .map_err(Into::into), + _ => Err(ParseError::Filtered), + } + } +} + +#[derive(Debug, Clone, Copy)] +pub struct AccountParser; + +impl Parser for AccountParser { + type Input = AccountUpdate; + type Output = TokenProgramState; + + fn id(&self) -> Cow<'static, str> { "token_program::AccountParser".into() } + + fn prefilter(&self) -> Prefilter { + Prefilter::builder() + .account_owners([spl_token::ID]) + .build() + .unwrap() + } + + async fn parse(&self, acct: &AccountUpdate) -> ParseResult { + let inner = acct.account.as_ref().ok_or(ProgramError::InvalidArgument)?; + + TokenProgramState::try_unpack(&inner.data) + } +} + +impl ProgramParser for AccountParser { + #[inline] + fn program_id(&self) -> yellowstone_vixen_core::Pubkey { spl_token::ID.to_bytes().into() } +} + +#[cfg(test)] +mod tests { + use yellowstone_vixen_mock::{account_fixture, run_account_parse, FixtureData}; + + use super::{AccountParser, Parser, TokenProgramState}; + + #[tokio::test] + async fn test_mint_account_parsing() { + let parser = AccountParser; + + let account = account_fixture!("3SmPYPvZfEmroktLiJsgaNENuPEud3Z52zSfLQ1zJdkK", &parser); + + let TokenProgramState::Mint(mint) = account else { + panic!("Invalid Account"); + }; + + assert_eq!(mint.decimals, 10); + } +} diff --git a/crates/spl-token-parser/src/instruction_parser.rs b/crates/spl-token-parser/src/instruction_parser.rs new file mode 100644 index 00000000..5a7fcabb --- /dev/null +++ b/crates/spl-token-parser/src/instruction_parser.rs @@ -0,0 +1,362 @@ +use spl_token::instruction::TokenInstruction as SplTokenInstruction; +use yellowstone_vixen_core::{ + instruction::InstructionUpdate, ParseError, ParseResult, Parser, Prefilter, ProgramParser, +}; +use yellowstone_vixen_parser::{check_min_accounts_req, Result, ResultExt}; + +#[allow(clippy::wildcard_imports)] +use crate::instructions::*; + +#[derive(Debug, Clone, Copy)] +pub struct InstructionParser; + +impl Parser for InstructionParser { + type Input = InstructionUpdate; + type Output = TokenProgramInstruction; + + fn id(&self) -> std::borrow::Cow<'static, str> { "token_program::InstructionParser".into() } + + fn prefilter(&self) -> Prefilter { + Prefilter::builder() + .transaction_accounts([spl_token::ID]) + .build() + .unwrap() + } + + async fn parse(&self, ix_update: &InstructionUpdate) -> ParseResult { + if ix_update.program.equals_ref(spl_token::ID) { + InstructionParser::parse_impl(ix_update).map_err(|e| ParseError::Other(e.into())) + } else { + Err(ParseError::Filtered) + } + } +} + +impl ProgramParser for InstructionParser { + #[inline] + fn program_id(&self) -> yellowstone_vixen_core::Pubkey { spl_token::ID.to_bytes().into() } +} + +impl InstructionParser { + #[allow(clippy::too_many_lines)] + pub fn parse_impl(ix: &InstructionUpdate) -> Result { + let ix_type = SplTokenInstruction::unpack(&ix.data) + .parse_err("Error unpacking token instruction data")?; + let accounts_len = ix.accounts.len(); + match ix_type { + SplTokenInstruction::Transfer { amount } => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::Transfer { + accounts: TransferAccounts { + source: ix.accounts[0], + destination: ix.accounts[1], + owner: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + args: TransferArgs { amount }, + }) + }, + SplTokenInstruction::InitializeAccount => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::InitializeAccount { + accounts: InitializeAccountAccounts { + account: ix.accounts[0], + mint: ix.accounts[1], + owner: ix.accounts[2], + }, + }) + }, + SplTokenInstruction::InitializeMint { + decimals, + mint_authority, + freeze_authority, + } => { + check_min_accounts_req(accounts_len, 1)?; + Ok(TokenProgramInstruction::InitializeMint { + accounts: InitializeMintAccounts { + mint: ix.accounts[0], + }, + args: InitializeMintArgs { + decimals, + mint_authority: mint_authority.to_bytes().into(), + freeze_authority: freeze_authority.map(|p| p.to_bytes().into()).into(), + }, + }) + }, + SplTokenInstruction::InitializeMint2 { + decimals, + mint_authority, + freeze_authority, + } => { + check_min_accounts_req(accounts_len, 1)?; + Ok(TokenProgramInstruction::InitializeMint { + accounts: InitializeMintAccounts { + mint: ix.accounts[0], + }, + args: InitializeMintArgs { + decimals, + mint_authority: mint_authority.to_bytes().into(), + freeze_authority: freeze_authority.map(|p| p.to_bytes().into()).into(), + }, + }) + }, + SplTokenInstruction::InitializeAccount2 { owner } => { + check_min_accounts_req(accounts_len, 2)?; + Ok(TokenProgramInstruction::InitializeAccount2 { + accounts: InitializeAccount2Accounts { + account: ix.accounts[0], + mint: ix.accounts[1], + }, + args: InitializeAccount2Args { + owner: owner.to_bytes().into(), + }, + }) + }, + SplTokenInstruction::InitializeAccount3 { owner } => { + check_min_accounts_req(accounts_len, 2)?; + Ok(TokenProgramInstruction::InitializeAccount3 { + accounts: InitializeAccount2Accounts { + account: ix.accounts[0], + mint: ix.accounts[1], + }, + args: InitializeAccount2Args { + owner: owner.to_bytes().into(), + }, + }) + }, + SplTokenInstruction::InitializeMultisig { m } => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::InitializeMultisig { + accounts: InitializeMultisigAccounts { + multisig: ix.accounts[0], + signers: ix.accounts[2..].to_vec(), + }, + args: InitializeMultisigArgs { m }, + }) + }, + SplTokenInstruction::InitializeMultisig2 { m } => { + check_min_accounts_req(accounts_len, 2)?; + Ok(TokenProgramInstruction::InitializeMultisig { + accounts: InitializeMultisigAccounts { + multisig: ix.accounts[0], + signers: ix.accounts[1..].to_vec(), + }, + args: InitializeMultisigArgs { m }, + }) + }, + SplTokenInstruction::Approve { amount } => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::Approve { + accounts: ApproveAccounts { + source: ix.accounts[0], + delegate: ix.accounts[1], + owner: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + args: ApproveArgs { amount }, + }) + }, + SplTokenInstruction::Revoke => { + check_min_accounts_req(accounts_len, 2)?; + Ok(TokenProgramInstruction::Revoke { + accounts: RevokeAccounts { + source: ix.accounts[0], + owner: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + }) + }, + SplTokenInstruction::SetAuthority { + authority_type, + new_authority, + } => { + check_min_accounts_req(accounts_len, 2)?; + Ok(TokenProgramInstruction::SetAuthority { + accounts: SetAuthorityAccounts { + account: ix.accounts[0], + current_authority: ix.accounts[1], + multisig_signers: ix.accounts[2..].to_vec(), + }, + args: SetAuthorityArgs { + authority_type, + new_authority: new_authority.map(|p| p.to_bytes().into()).into(), + }, + }) + }, + SplTokenInstruction::MintTo { amount } => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::MintTo { + accounts: MintToAccounts { + mint: ix.accounts[0], + account: ix.accounts[1], + mint_authority: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + args: MintToArgs { amount }, + }) + }, + SplTokenInstruction::Burn { amount } => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::Burn { + accounts: BurnAccounts { + account: ix.accounts[0], + mint: ix.accounts[1], + owner: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + args: BurnArgs { amount }, + }) + }, + SplTokenInstruction::CloseAccount => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::CloseAccount { + accounts: CloseAccountAccounts { + account: ix.accounts[0], + destination: ix.accounts[1], + owner: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + }) + }, + SplTokenInstruction::FreezeAccount => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::FreezeAccount { + accounts: FreezeAccountAccounts { + account: ix.accounts[0], + mint: ix.accounts[1], + mint_freeze_authority: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + }) + }, + SplTokenInstruction::ThawAccount => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::ThawAccount { + accounts: ThawAccountAccounts { + account: ix.accounts[0], + mint: ix.accounts[1], + mint_freeze_authority: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + }) + }, + SplTokenInstruction::TransferChecked { amount, decimals } => { + check_min_accounts_req(accounts_len, 4)?; + Ok(TokenProgramInstruction::TransferChecked { + accounts: TransferCheckedAccounts { + source: ix.accounts[0], + mint: ix.accounts[1], + destination: ix.accounts[2], + owner: ix.accounts[3], + multisig_signers: ix.accounts[4..].to_vec(), + }, + args: TransferCheckedArgs { amount, decimals }, + }) + }, + SplTokenInstruction::ApproveChecked { amount, decimals } => { + check_min_accounts_req(accounts_len, 4)?; + Ok(TokenProgramInstruction::ApproveChecked { + accounts: ApproveCheckedAccounts { + source: ix.accounts[0], + mint: ix.accounts[1], + delegate: ix.accounts[2], + owner: ix.accounts[3], + multisig_signers: ix.accounts[4..].to_vec(), + }, + args: ApproveCheckedArgs { amount, decimals }, + }) + }, + SplTokenInstruction::MintToChecked { amount, decimals } => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::MintToChecked { + accounts: MintToCheckedAccounts { + mint: ix.accounts[0], + account: ix.accounts[1], + mint_authority: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + args: MintToCheckedArgs { amount, decimals }, + }) + }, + SplTokenInstruction::BurnChecked { amount, decimals } => { + check_min_accounts_req(accounts_len, 3)?; + Ok(TokenProgramInstruction::BurnChecked { + accounts: BurnCheckedAccounts { + account: ix.accounts[0], + mint: ix.accounts[1], + owner: ix.accounts[2], + multisig_signers: ix.accounts[3..].to_vec(), + }, + args: BurnCheckedArgs { amount, decimals }, + }) + }, + SplTokenInstruction::SyncNative => { + check_min_accounts_req(accounts_len, 1)?; + Ok(TokenProgramInstruction::SyncNative { + accounts: SyncNativeAccounts { + account: ix.accounts[0], + }, + }) + }, + SplTokenInstruction::GetAccountDataSize => { + check_min_accounts_req(accounts_len, 1)?; + Ok(TokenProgramInstruction::GetAccountDataSize { + accounts: GetAccountDataSizeAccounts { + mint: ix.accounts[0], + }, + }) + }, + SplTokenInstruction::InitializeImmutableOwner => { + check_min_accounts_req(accounts_len, 1)?; + Ok(TokenProgramInstruction::InitializeImmutableOwner { + accounts: InitializeImmutableOwnerAccounts { + account: ix.accounts[0], + }, + }) + }, + SplTokenInstruction::AmountToUiAmount { amount } => { + check_min_accounts_req(accounts_len, 1)?; + Ok(TokenProgramInstruction::AmountToUiAmount { + accounts: AmountToUiAmountAccounts { + mint: ix.accounts[0], + }, + args: AmountToUiAmountArgs { amount }, + }) + }, + SplTokenInstruction::UiAmountToAmount { ui_amount } => { + check_min_accounts_req(accounts_len, 1)?; + Ok(TokenProgramInstruction::UiAmountToAmount { + accounts: UiAmountToAmountAccounts { + mint: ix.accounts[0], + }, + args: UiAmountToAmountArgs { + ui_amount: ui_amount.into(), + }, + }) + }, + } + } +} + +#[cfg(test)] +mod tests { + use std::ops::Mul; + + use yellowstone_vixen_mock::tx_fixture; + + use super::*; + + #[tokio::test] + async fn test_mint_to_checked_ix_parsing() { + let parser = InstructionParser; + + let ixs = tx_fixture!("55kpnRufcX9Fo44oRBXtrkxPRww4UWJKxCpgBV39kzAAag8oyJbd9Y3YWdQQUi3TBqtrhjgsMGb9Nw8bUxy7j5rt",&parser); + + let TokenProgramInstruction::MintToChecked { args, .. } = &ixs[0] else { + panic!("Invalid Instruction"); + }; + + assert_eq!(args.decimals, 10); + assert_eq!(args.amount, 10.mul(10u64.pow(args.decimals.into()))); + } +} diff --git a/crates/spl-token-parser/src/instructions.rs b/crates/spl-token-parser/src/instructions.rs new file mode 100644 index 00000000..bde04f2a --- /dev/null +++ b/crates/spl-token-parser/src/instructions.rs @@ -0,0 +1,316 @@ +use spl_token::instruction::AuthorityType; +use yellowstone_vixen_core::Pubkey; + +#[derive(Debug, Clone)] +pub struct TransferAccounts { + pub source: Pubkey, + pub destination: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct TransferCheckedArgs { + pub amount: u64, + pub decimals: u8, +} + +#[derive(Debug, Clone, Copy)] +pub struct TransferArgs { + pub amount: u64, +} +#[derive(Debug, Clone, Copy)] +pub struct InitializeMintAccounts { + pub mint: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeMintArgs { + pub decimals: u8, + pub mint_authority: Pubkey, + pub freeze_authority: Option, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeAccountAccounts { + pub account: Pubkey, + pub mint: Pubkey, + pub owner: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeAccount2Accounts { + pub account: Pubkey, + pub mint: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeAccount2Args { + pub owner: Pubkey, +} + +#[derive(Debug, Clone)] +pub struct InitializeMultisigAccounts { + pub multisig: Pubkey, + pub signers: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeMultisigArgs { + pub m: u8, +} + +#[derive(Debug, Clone)] +pub struct ApproveAccounts { + pub source: Pubkey, + pub delegate: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct ApproveArgs { + pub amount: u64, +} + +#[derive(Debug, Clone)] +pub struct RevokeAccounts { + pub source: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone)] +pub struct SetAuthorityAccounts { + pub current_authority: Pubkey, + pub account: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone)] +pub struct SetAuthorityArgs { + pub authority_type: AuthorityType, + pub new_authority: Option, +} + +#[derive(Debug, Clone)] +pub struct MintToAccounts { + pub mint: Pubkey, + pub account: Pubkey, + pub mint_authority: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct MintToArgs { + pub amount: u64, +} + +#[derive(Debug, Clone)] +pub struct BurnAccounts { + pub account: Pubkey, + pub mint: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct BurnArgs { + pub amount: u64, +} + +#[derive(Debug, Clone)] +pub struct CloseAccountAccounts { + pub account: Pubkey, + pub destination: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone)] +pub struct FreezeAccountAccounts { + pub account: Pubkey, + pub mint: Pubkey, + pub mint_freeze_authority: Pubkey, + pub multisig_signers: Vec, +} +#[derive(Debug, Clone)] +pub struct ThawAccountAccounts { + pub account: Pubkey, + pub mint: Pubkey, + pub mint_freeze_authority: Pubkey, + pub multisig_signers: Vec, +} +#[derive(Debug, Clone)] +pub struct TransferCheckedAccounts { + pub source: Pubkey, + pub mint: Pubkey, + pub destination: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone)] +pub struct ApproveCheckedAccounts { + pub source: Pubkey, + pub mint: Pubkey, + pub delegate: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct ApproveCheckedArgs { + pub amount: u64, + pub decimals: u8, +} + +#[derive(Debug, Clone)] +pub struct MintToCheckedAccounts { + pub mint: Pubkey, + pub account: Pubkey, + pub mint_authority: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct MintToCheckedArgs { + pub amount: u64, + pub decimals: u8, +} + +#[derive(Debug, Clone)] +pub struct BurnCheckedAccounts { + pub account: Pubkey, + pub mint: Pubkey, + pub owner: Pubkey, + pub multisig_signers: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct BurnCheckedArgs { + pub amount: u64, + pub decimals: u8, +} + +#[derive(Debug, Clone, Copy)] +pub struct SyncNativeAccounts { + pub account: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct GetAccountDataSizeAccounts { + pub mint: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct InitializeImmutableOwnerAccounts { + pub account: Pubkey, +} +#[derive(Debug, Clone, Copy)] +pub struct AmountToUiAmountAccounts { + pub mint: Pubkey, +} + +#[derive(Debug, Clone, Copy)] +pub struct AmountToUiAmountArgs { + pub amount: u64, +} + +#[derive(Debug, Clone, Copy)] +pub struct UiAmountToAmountAccounts { + pub mint: Pubkey, +} + +#[derive(Debug, Clone)] +pub struct UiAmountToAmountArgs { + pub ui_amount: String, +} + +#[derive(Debug)] +pub enum TokenProgramInstruction { + Transfer { + accounts: TransferAccounts, + args: TransferArgs, + }, + InitializeMint { + accounts: InitializeMintAccounts, + args: InitializeMintArgs, + }, + InitializeAccount { + accounts: InitializeAccountAccounts, + }, + InitializeAccount2 { + accounts: InitializeAccount2Accounts, + args: InitializeAccount2Args, + }, + InitializeAccount3 { + accounts: InitializeAccount2Accounts, + args: InitializeAccount2Args, + }, + InitializeMultisig { + accounts: InitializeMultisigAccounts, + args: InitializeMultisigArgs, + }, + Approve { + accounts: ApproveAccounts, + args: ApproveArgs, + }, + Revoke { + accounts: RevokeAccounts, + }, + SetAuthority { + accounts: SetAuthorityAccounts, + args: SetAuthorityArgs, + }, + MintTo { + accounts: MintToAccounts, + args: MintToArgs, + }, + Burn { + accounts: BurnAccounts, + args: BurnArgs, + }, + CloseAccount { + accounts: CloseAccountAccounts, + }, + FreezeAccount { + accounts: FreezeAccountAccounts, + }, + ThawAccount { + accounts: ThawAccountAccounts, + }, + TransferChecked { + accounts: TransferCheckedAccounts, + args: TransferCheckedArgs, + }, + ApproveChecked { + accounts: ApproveCheckedAccounts, + args: ApproveCheckedArgs, + }, + MintToChecked { + accounts: MintToCheckedAccounts, + args: MintToCheckedArgs, + }, + BurnChecked { + accounts: BurnCheckedAccounts, + args: BurnCheckedArgs, + }, + SyncNative { + accounts: SyncNativeAccounts, + }, + GetAccountDataSize { + accounts: GetAccountDataSizeAccounts, + }, + InitializeImmutableOwner { + accounts: InitializeImmutableOwnerAccounts, + }, + AmountToUiAmount { + accounts: AmountToUiAmountAccounts, + args: AmountToUiAmountArgs, + }, + UiAmountToAmount { + accounts: UiAmountToAmountAccounts, + args: UiAmountToAmountArgs, + }, +} diff --git a/crates/parser/src/token_program/mod.rs b/crates/spl-token-parser/src/lib.rs similarity index 64% rename from crates/parser/src/token_program/mod.rs rename to crates/spl-token-parser/src/lib.rs index ee7876e9..3370f0b3 100644 --- a/crates/parser/src/token_program/mod.rs +++ b/crates/spl-token-parser/src/lib.rs @@ -1,8 +1,8 @@ mod account_parser; -mod instruction_helpers; mod instruction_parser; +mod instructions; pub use account_parser::*; -pub use instruction_helpers::*; pub use instruction_parser::*; +pub use instructions::*; diff --git a/crates/stake-pool-parser/Cargo.toml b/crates/stake-pool-parser/Cargo.toml index c125a5e2..e9a50139 100644 --- a/crates/stake-pool-parser/Cargo.toml +++ b/crates/stake-pool-parser/Cargo.toml @@ -10,13 +10,9 @@ authors.workspace = true [dependencies] spl-pod = { workspace = true } spl-stake-pool = { workspace = true, features = ["no-entrypoint"] } -spl-token = { workspace = true, optional = true } -spl-token-2022 = { workspace = true, optional = true } -spl-type-length-value = { workspace = true, optional = true } -spl-token-group-interface = { workspace = true, optional = true } -spl-token-metadata-interface = { version = "0.4.0", optional = true } yellowstone-grpc-proto = { workspace = true } yellowstone-vixen-core = { workspace = true } +yellowstone-vixen-parser = { workspace = true } yellowstone-vixen-proto = { workspace = true, features = [ "parser", ], optional = true } diff --git a/crates/stake-pool-parser/src/account_parser.rs b/crates/stake-pool-parser/src/account_parser.rs index 31a4c363..ca0fbc7c 100644 --- a/crates/stake-pool-parser/src/account_parser.rs +++ b/crates/stake-pool-parser/src/account_parser.rs @@ -1,5 +1,7 @@ -use spl_pod::solana_program::{self, borsh1::try_from_slice_unchecked}; -use spl_stake_pool::state::{StakePool, ValidatorList}; +use spl_stake_pool::{ + solana_program::{borsh1::try_from_slice_unchecked, program_error}, + state::{StakePool, ValidatorList}, +}; /// SplStakePool Program State #[allow(clippy::large_enum_variant)] @@ -55,7 +57,7 @@ impl yellowstone_vixen_core::Parser for AccountParser { let inner = acct .account .as_ref() - .ok_or(solana_program::program_error::ProgramError::InvalidArgument)?; + .ok_or(program_error::ProgramError::InvalidArgument)?; SplStakePoolProgramState::try_unpack(&inner.data) } } diff --git a/crates/stake-pool-parser/src/instruction_helpers.rs b/crates/stake-pool-parser/src/instruction_helpers.rs index 86751df4..3483b34c 100644 --- a/crates/stake-pool-parser/src/instruction_helpers.rs +++ b/crates/stake-pool-parser/src/instruction_helpers.rs @@ -1,9 +1,9 @@ use borsh::BorshDeserialize; use spl_stake_pool::{ instruction::{FundingType, PreferredValidatorType}, - solana_program::pubkey::Pubkey, state::{Fee, FeeType}, }; +use yellowstone_vixen_parser::Pubkey; /// (Staker only) Adds stake account delegated to validator to the pool's /// list of managed validators. @@ -60,7 +60,7 @@ pub struct AddValidatorToPoolAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct AddValidatorToPoolData { +pub struct AddValidatorToPoolArgs { pub raw_validator_seed: u32, } @@ -104,7 +104,7 @@ pub struct CreateTokenMetadataAccounts { } #[derive(Debug, BorshDeserialize)] -pub struct CreateTokenMetadataData { +pub struct CreateTokenMetadataArgs { pub name: String, pub symbol: String, pub uri: String, @@ -163,7 +163,7 @@ pub struct DecreaseValidatorStakeAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct DecreaseValidatorStakeData { +pub struct DecreaseValidatorStakeArgs { /// amount of lamports to split into the transient stake account pub lamports: u64, @@ -211,7 +211,7 @@ pub struct DepositSolAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct DepositSolData { +pub struct DepositSolArgs { pub arg: u64, } @@ -335,7 +335,7 @@ pub struct IncreaseValidatorStakeAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct IncreaseValidatorStakeData { +pub struct IncreaseValidatorStakeArgs { /// amount of lamports to increase on the given validator pub lamports: u64, @@ -383,7 +383,7 @@ pub struct InitializeAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct InitializeData { +pub struct InitializeArgs { /// Fee assessed as percentage of perceived rewards pub fee: Fee, @@ -444,7 +444,7 @@ pub struct SetFeeAccounts { } #[derive(Debug, BorshDeserialize)] -pub struct SetFeeData { +pub struct SetFeeArgs { /// Type of fee to update and value to update it to pub fee: FeeType, } @@ -464,7 +464,7 @@ pub struct SetFundingAuthorityAccounts { } #[derive(Debug, BorshDeserialize)] -pub struct SetFundingAuthorityData { +pub struct SetFundingAuthorityArgs { pub arg: FundingType, } @@ -506,7 +506,7 @@ pub struct SetPreferredValidatorAccounts { } #[derive(Debug, BorshDeserialize)] -pub struct SetPreferredValidatorData { +pub struct SetPreferredValidatorArgs { /// Affected operation (deposit or withdraw) pub validator_type: PreferredValidatorType, @@ -575,7 +575,7 @@ pub struct UpdateTokenMetadataAccounts { } #[derive(Debug, BorshDeserialize)] -pub struct UpdateTokenMetadataData { +pub struct UpdateTokenMetadataArgs { pub name: String, pub symbol: String, pub uri: String, @@ -614,7 +614,7 @@ pub struct UpdateValidatorListBalanceAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct UpdateValidatorListBalanceData { +pub struct UpdateValidatorListBalanceArgs { /// Index to start updating on the validator list pub start_index: u32, @@ -671,7 +671,7 @@ pub struct WithdrawSolAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct WithdrawSolData { +pub struct WithdrawSolArgs { pub arg: u64, } @@ -740,7 +740,7 @@ pub struct WithdrawStakeAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct WithdrawStakeData { +pub struct WithdrawStakeArgs { /// amount of pool tokens to withdraw pub arg: u64, } @@ -811,7 +811,7 @@ pub struct IncreaseAdditionalValidatorStakeAccounts { /// The rent-exemption of the stake account is withdrawn back to the /// reserve after it is merged. #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct IncreaseAdditionalValidatorStakeData { +pub struct IncreaseAdditionalValidatorStakeArgs { /// amount of lamports to increase on the given validator pub lamports: u64, @@ -878,7 +878,7 @@ pub struct DecreaseAdditionalValidatorStakeAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct DecreaseAdditionalValidatorStakeData { +pub struct DecreaseAdditionalValidatorStakeArgs { /// amount of lamports to increase on the given validator pub lamports: u64, @@ -944,7 +944,7 @@ pub struct DecreaseValidatorStakeWithReserveAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct DecreaseValidatorStakeWithReserveData { +pub struct DecreaseValidatorStakeWithReserveArgs { /// amount of lamports to split into the transient stake account pub lamports: u64, @@ -1028,7 +1028,7 @@ pub struct DepositStakeWithSlippageAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct DepositStakeWithSlippageData { +pub struct DepositStakeWithSlippageArgs { /// Minimum amount of pool tokens that must be received pub minimum_pool_tokens_out: u64, } @@ -1076,7 +1076,7 @@ pub struct WithdrawStakeWithSlippageAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct WithdrawStakeWithSlippageData { +pub struct WithdrawStakeWithSlippageArgs { /// Pool tokens to burn in exchange for lamports pub pool_tokens_in: u64, @@ -1125,7 +1125,7 @@ pub struct DepositSolWithSlippageAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct DepositSolWithSlippageData { +pub struct DepositSolWithSlippageArgs { /// Amount of lamports to deposit into the reserve pub lamports_in: u64, @@ -1180,7 +1180,7 @@ pub struct WithdrawSolWithSlippageAccounts { } #[derive(Clone, Copy, Debug, BorshDeserialize)] -pub struct WithdrawSolWithSlippageData { +pub struct WithdrawSolWithSlippageArgs { /// Pool tokens to burn in exchange for lamports pub pool_tokens_in: u64, @@ -1189,49 +1189,103 @@ pub struct WithdrawSolWithSlippageData { } #[derive(Debug, BorshDeserialize)] -pub enum StakePoolProgramIx { - Initialize(InitializeAccounts, InitializeData), - AddValidatorToPool(AddValidatorToPoolAccounts, AddValidatorToPoolData), - RemoveValidatorFromPool(RemoveValidatorFromPoolAccounts), - DecreaseValidatorStake(DecreaseValidatorStakeAccounts, DecreaseValidatorStakeData), - IncreaseValidatorStake(IncreaseValidatorStakeAccounts, IncreaseValidatorStakeData), - SetPreferredValidator(SetPreferredValidatorAccounts, SetPreferredValidatorData), - UpdateValidatorListBalance( - UpdateValidatorListBalanceAccounts, - UpdateValidatorListBalanceData, - ), - UpdateStakePoolBalance(UpdateStakePoolBalanceAccounts), - CleanupRemovedValidatorEntries(CleanupRemovedValidatorEntriesAccounts), - DepositStake(DepositStakeAccounts), - WithdrawStake(WithdrawStakeAccounts, WithdrawStakeData), - SetManager(SetManagerAccounts), - SetFee(SetFeeAccounts, SetFeeData), - SetStaker(SetStakerAccounts), - DepositSol(DepositSolAccounts, DepositSolData), - SetFundingAuthority(SetFundingAuthorityAccounts, SetFundingAuthorityData), - WithdrawSol(WithdrawSolAccounts, WithdrawSolData), - CreateTokenMetadata(CreateTokenMetadataAccounts, CreateTokenMetadataData), - UpdateTokenMetadata(UpdateTokenMetadataAccounts, UpdateTokenMetadataData), - IncreaseAdditionalValidatorStake( - IncreaseAdditionalValidatorStakeAccounts, - IncreaseAdditionalValidatorStakeData, - ), - DecreaseAdditionalValidatorStake( - DecreaseAdditionalValidatorStakeAccounts, - DecreaseAdditionalValidatorStakeData, - ), - DecreaseValidatorStakeWithReserve( - DecreaseValidatorStakeWithReserveAccounts, - DecreaseValidatorStakeWithReserveData, - ), - DepositStakeWithSlippage( - DepositStakeWithSlippageAccounts, - DepositStakeWithSlippageData, - ), - WithdrawStakeWithSlippage( - WithdrawStakeWithSlippageAccounts, - WithdrawStakeWithSlippageData, - ), - DepositSolWithSlippage(DepositSolWithSlippageAccounts, DepositSolWithSlippageData), - WithdrawSolWithSlippage(WithdrawSolWithSlippageAccounts, WithdrawSolWithSlippageData), +pub enum StakePoolProgramInstruction { + Initialize { + accounts: InitializeAccounts, + args: InitializeArgs, + }, + AddValidatorToPool { + accounts: AddValidatorToPoolAccounts, + args: AddValidatorToPoolArgs, + }, + RemoveValidatorFromPool { + accounts: RemoveValidatorFromPoolAccounts, + }, + DecreaseValidatorStake { + accounts: DecreaseValidatorStakeAccounts, + args: DecreaseValidatorStakeArgs, + }, + IncreaseValidatorStake { + accounts: IncreaseValidatorStakeAccounts, + args: IncreaseValidatorStakeArgs, + }, + SetPreferredValidator { + accounts: SetPreferredValidatorAccounts, + args: SetPreferredValidatorArgs, + }, + UpdateValidatorListBalance { + accounts: UpdateValidatorListBalanceAccounts, + args: UpdateValidatorListBalanceArgs, + }, + UpdateStakePoolBalance { + accounts: UpdateStakePoolBalanceAccounts, + }, + CleanupRemovedValidatorEntries { + accounts: CleanupRemovedValidatorEntriesAccounts, + }, + DepositStake { + accounts: DepositStakeAccounts, + }, + WithdrawStake { + accounts: WithdrawStakeAccounts, + args: WithdrawStakeArgs, + }, + SetManager { + accounts: SetManagerAccounts, + }, + SetFee { + accounts: SetFeeAccounts, + args: SetFeeArgs, + }, + SetStaker { + accounts: SetStakerAccounts, + }, + DepositSol { + accounts: DepositSolAccounts, + args: DepositSolArgs, + }, + SetFundingAuthority { + accounts: SetFundingAuthorityAccounts, + args: SetFundingAuthorityArgs, + }, + WithdrawSol { + accounts: WithdrawSolAccounts, + args: WithdrawSolArgs, + }, + CreateTokenMetadata { + accounts: CreateTokenMetadataAccounts, + args: CreateTokenMetadataArgs, + }, + UpdateTokenMetadata { + accounts: UpdateTokenMetadataAccounts, + args: UpdateTokenMetadataArgs, + }, + IncreaseAdditionalValidatorStake { + accounts: IncreaseAdditionalValidatorStakeAccounts, + args: IncreaseAdditionalValidatorStakeArgs, + }, + DecreaseAdditionalValidatorStake { + accounts: DecreaseAdditionalValidatorStakeAccounts, + args: DecreaseAdditionalValidatorStakeArgs, + }, + DecreaseValidatorStakeWithReserve { + accounts: DecreaseValidatorStakeWithReserveAccounts, + args: DecreaseValidatorStakeWithReserveArgs, + }, + DepositStakeWithSlippage { + accounts: DepositStakeWithSlippageAccounts, + args: DepositStakeWithSlippageArgs, + }, + WithdrawStakeWithSlippage { + accounts: WithdrawStakeWithSlippageAccounts, + args: WithdrawStakeWithSlippageArgs, + }, + DepositSolWithSlippage { + accounts: DepositSolWithSlippageAccounts, + args: DepositSolWithSlippageArgs, + }, + WithdrawSolWithSlippage { + accounts: WithdrawSolWithSlippageAccounts, + args: WithdrawSolWithSlippageArgs, + }, } diff --git a/crates/stake-pool-parser/src/instruction_parser.rs b/crates/stake-pool-parser/src/instruction_parser.rs index 29d3cdf1..e5bbcf29 100644 --- a/crates/stake-pool-parser/src/instruction_parser.rs +++ b/crates/stake-pool-parser/src/instruction_parser.rs @@ -1,24 +1,25 @@ use borsh::BorshDeserialize; use spl_stake_pool::instruction::StakePoolInstruction; - -use super::instruction_helpers::{ - AddValidatorToPoolAccounts, AddValidatorToPoolData, CleanupRemovedValidatorEntriesAccounts, - CreateTokenMetadataAccounts, CreateTokenMetadataData, DecreaseAdditionalValidatorStakeAccounts, - DecreaseAdditionalValidatorStakeData, DecreaseValidatorStakeAccounts, - DecreaseValidatorStakeData, DecreaseValidatorStakeWithReserveAccounts, - DecreaseValidatorStakeWithReserveData, DepositSolAccounts, DepositSolData, - DepositSolWithSlippageAccounts, DepositSolWithSlippageData, DepositStakeAccounts, - DepositStakeWithSlippageAccounts, DepositStakeWithSlippageData, - IncreaseAdditionalValidatorStakeAccounts, IncreaseAdditionalValidatorStakeData, - IncreaseValidatorStakeAccounts, IncreaseValidatorStakeData, InitializeAccounts, InitializeData, - RemoveValidatorFromPoolAccounts, SetFeeAccounts, SetFeeData, SetFundingAuthorityAccounts, - SetFundingAuthorityData, SetManagerAccounts, SetPreferredValidatorAccounts, - SetPreferredValidatorData, SetStakerAccounts, StakePoolProgramIx, - UpdateStakePoolBalanceAccounts, UpdateTokenMetadataAccounts, UpdateTokenMetadataData, - UpdateValidatorListBalanceAccounts, UpdateValidatorListBalanceData, WithdrawSolAccounts, - WithdrawSolData, WithdrawSolWithSlippageAccounts, WithdrawSolWithSlippageData, - WithdrawStakeAccounts, WithdrawStakeData, WithdrawStakeWithSlippageAccounts, - WithdrawStakeWithSlippageData, +use yellowstone_vixen_parser::check_min_accounts_req; + +use crate::instruction_helpers::{ + AddValidatorToPoolAccounts, AddValidatorToPoolArgs, CleanupRemovedValidatorEntriesAccounts, + CreateTokenMetadataAccounts, CreateTokenMetadataArgs, DecreaseAdditionalValidatorStakeAccounts, + DecreaseAdditionalValidatorStakeArgs, DecreaseValidatorStakeAccounts, + DecreaseValidatorStakeArgs, DecreaseValidatorStakeWithReserveAccounts, + DecreaseValidatorStakeWithReserveArgs, DepositSolAccounts, DepositSolArgs, + DepositSolWithSlippageAccounts, DepositSolWithSlippageArgs, DepositStakeAccounts, + DepositStakeWithSlippageAccounts, DepositStakeWithSlippageArgs, + IncreaseAdditionalValidatorStakeAccounts, IncreaseAdditionalValidatorStakeArgs, + IncreaseValidatorStakeAccounts, IncreaseValidatorStakeArgs, InitializeAccounts, InitializeArgs, + RemoveValidatorFromPoolAccounts, SetFeeAccounts, SetFeeArgs, SetFundingAuthorityAccounts, + SetFundingAuthorityArgs, SetManagerAccounts, SetPreferredValidatorAccounts, + SetPreferredValidatorArgs, SetStakerAccounts, StakePoolProgramInstruction, + UpdateStakePoolBalanceAccounts, UpdateTokenMetadataAccounts, UpdateTokenMetadataArgs, + UpdateValidatorListBalanceAccounts, UpdateValidatorListBalanceArgs, WithdrawSolAccounts, + WithdrawSolArgs, WithdrawSolWithSlippageAccounts, WithdrawSolWithSlippageArgs, + WithdrawStakeAccounts, WithdrawStakeArgs, WithdrawStakeWithSlippageAccounts, + WithdrawStakeWithSlippageArgs, }; #[derive(Debug, Copy, Clone)] @@ -26,7 +27,7 @@ pub struct InstructionParser; impl yellowstone_vixen_core::Parser for InstructionParser { type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - type Output = StakePoolProgramIx; + type Output = StakePoolProgramInstruction; fn id(&self) -> std::borrow::Cow<'static, str> { "StakePool::InstructionParser".into() } @@ -59,7 +60,7 @@ impl yellowstone_vixen_core::ProgramParser for InstructionParser { impl InstructionParser { pub(crate) fn parse_impl( ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { + ) -> yellowstone_vixen_core::ParseResult { let ix_type = StakePoolInstruction::try_from_slice(ix.data.as_slice())?; let accounts_len = ix.accounts.len(); @@ -74,23 +75,23 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 9)?; let mut ix_accounts = InitializeAccounts { - stake_pool: ix.accounts[0].0.into(), - manager: ix.accounts[1].0.into(), - staker: ix.accounts[2].0.into(), - stake_pool_withdraw_authority: ix.accounts[3].0.into(), - validator_list: ix.accounts[4].0.into(), - reserve_stake: ix.accounts[5].0.into(), - pool_mint: ix.accounts[6].0.into(), - manager_pool_account: ix.accounts[7].0.into(), - token_program: ix.accounts[8].0.into(), + stake_pool: ix.accounts[0], + manager: ix.accounts[1], + staker: ix.accounts[2], + stake_pool_withdraw_authority: ix.accounts[3], + validator_list: ix.accounts[4], + reserve_stake: ix.accounts[5], + pool_mint: ix.accounts[6], + manager_pool_account: ix.accounts[7], + token_program: ix.accounts[8], deposit_authority: None, }; if let Some(deposit_authority) = ix.accounts.get(9) { - ix_accounts.deposit_authority = Some(deposit_authority.0.into()); + ix_accounts.deposit_authority = Some(deposit_authority.to_owned()); } - let de_ix_data: InitializeData = InitializeData { + let args = InitializeArgs { fee, withdrawal_fee, deposit_fee, @@ -98,50 +99,54 @@ impl InstructionParser { max_validators, }; - Ok(StakePoolProgramIx::Initialize(ix_accounts, de_ix_data)) + Ok(StakePoolProgramInstruction::Initialize { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::AddValidatorToPool(raw_validator_seed) => { check_min_accounts_req(accounts_len, 13)?; let ix_accounts = AddValidatorToPoolAccounts { - stake_pool: ix.accounts[0].0.into(), - staker: ix.accounts[1].0.into(), - funder: ix.accounts[2].0.into(), - stake_pool_withdraw: ix.accounts[3].0.into(), - validator_list: ix.accounts[4].0.into(), - stake: ix.accounts[5].0.into(), - validator: ix.accounts[6].0.into(), - rent: ix.accounts[7].0.into(), - clock: ix.accounts[8].0.into(), - sysvar_stake_history: ix.accounts[9].0.into(), - stake_config: ix.accounts[10].0.into(), - system_program: ix.accounts[11].0.into(), - stake_program: ix.accounts[12].0.into(), - }; - - let de_ix_data: AddValidatorToPoolData = - AddValidatorToPoolData { raw_validator_seed }; - - Ok(StakePoolProgramIx::AddValidatorToPool( - ix_accounts, - de_ix_data, - )) + stake_pool: ix.accounts[0], + staker: ix.accounts[1], + funder: ix.accounts[2], + stake_pool_withdraw: ix.accounts[3], + validator_list: ix.accounts[4], + stake: ix.accounts[5], + validator: ix.accounts[6], + rent: ix.accounts[7], + clock: ix.accounts[8], + sysvar_stake_history: ix.accounts[9], + stake_config: ix.accounts[10], + system_program: ix.accounts[11], + stake_program: ix.accounts[12], + }; + + let args = AddValidatorToPoolArgs { raw_validator_seed }; + + Ok(StakePoolProgramInstruction::AddValidatorToPool { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::RemoveValidatorFromPool => { check_min_accounts_req(accounts_len, 8)?; let ix_accounts = RemoveValidatorFromPoolAccounts { - stake_pool: ix.accounts[0].0.into(), - staker: ix.accounts[1].0.into(), - stake_pool_withdraw: ix.accounts[2].0.into(), - validator_list: ix.accounts[3].0.into(), - stake_account: ix.accounts[4].0.into(), - transient_stake_account: ix.accounts[5].0.into(), - clock: ix.accounts[6].0.into(), - stake_program: ix.accounts[7].0.into(), - }; - - Ok(StakePoolProgramIx::RemoveValidatorFromPool(ix_accounts)) + stake_pool: ix.accounts[0], + staker: ix.accounts[1], + stake_pool_withdraw: ix.accounts[2], + validator_list: ix.accounts[3], + stake_account: ix.accounts[4], + transient_stake_account: ix.accounts[5], + clock: ix.accounts[6], + stake_program: ix.accounts[7], + }; + + Ok(StakePoolProgramInstruction::RemoveValidatorFromPool { + accounts: ix_accounts, + }) }, StakePoolInstruction::DecreaseValidatorStake { lamports, @@ -150,27 +155,27 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 10)?; let ix_accounts = DecreaseValidatorStakeAccounts { - stake_pool: ix.accounts[0].0.into(), - staker: ix.accounts[1].0.into(), - stake_pool_withdraw_authority: ix.accounts[2].0.into(), - validator_list: ix.accounts[3].0.into(), - validator_stake: ix.accounts[4].0.into(), - transient_stake: ix.accounts[5].0.into(), - clock: ix.accounts[6].0.into(), - rent: ix.accounts[7].0.into(), - system_program: ix.accounts[8].0.into(), - stake_program: ix.accounts[9].0.into(), - }; - - let de_ix_data: DecreaseValidatorStakeData = DecreaseValidatorStakeData { + stake_pool: ix.accounts[0], + staker: ix.accounts[1], + stake_pool_withdraw_authority: ix.accounts[2], + validator_list: ix.accounts[3], + validator_stake: ix.accounts[4], + transient_stake: ix.accounts[5], + clock: ix.accounts[6], + rent: ix.accounts[7], + system_program: ix.accounts[8], + stake_program: ix.accounts[9], + }; + + let args = DecreaseValidatorStakeArgs { lamports, transient_stake_seed, }; - Ok(StakePoolProgramIx::DecreaseValidatorStake( - ix_accounts, - de_ix_data, - )) + Ok(StakePoolProgramInstruction::DecreaseValidatorStake { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::IncreaseValidatorStake { lamports, @@ -179,31 +184,31 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 14)?; let ix_accounts = IncreaseValidatorStakeAccounts { - stake_pool: ix.accounts[0].0.into(), - staker: ix.accounts[1].0.into(), - stake_pool_withdraw_authority: ix.accounts[2].0.into(), - validator_list: ix.accounts[3].0.into(), - reserve_stake: ix.accounts[4].0.into(), - transient_stake: ix.accounts[5].0.into(), - validator_stake: ix.accounts[6].0.into(), - validator: ix.accounts[7].0.into(), - clock: ix.accounts[8].0.into(), - rent: ix.accounts[9].0.into(), - sysvar_stake_history: ix.accounts[10].0.into(), - stake_config: ix.accounts[11].0.into(), - system_program: ix.accounts[12].0.into(), - stake_program: ix.accounts[13].0.into(), - }; - - let de_ix_data: IncreaseValidatorStakeData = IncreaseValidatorStakeData { + stake_pool: ix.accounts[0], + staker: ix.accounts[1], + stake_pool_withdraw_authority: ix.accounts[2], + validator_list: ix.accounts[3], + reserve_stake: ix.accounts[4], + transient_stake: ix.accounts[5], + validator_stake: ix.accounts[6], + validator: ix.accounts[7], + clock: ix.accounts[8], + rent: ix.accounts[9], + sysvar_stake_history: ix.accounts[10], + stake_config: ix.accounts[11], + system_program: ix.accounts[12], + stake_program: ix.accounts[13], + }; + + let args = IncreaseValidatorStakeArgs { lamports, transient_stake_seed, }; - Ok(StakePoolProgramIx::IncreaseValidatorStake( - ix_accounts, - de_ix_data, - )) + Ok(StakePoolProgramInstruction::IncreaseValidatorStake { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::SetPreferredValidator { validator_type, @@ -212,20 +217,20 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 3)?; let ix_accounts = SetPreferredValidatorAccounts { - stake_pool_address: ix.accounts[0].0.into(), - staker: ix.accounts[1].0.into(), - validator_list_address: ix.accounts[2].0.into(), + stake_pool_address: ix.accounts[0], + staker: ix.accounts[1], + validator_list_address: ix.accounts[2], }; - let de_ix_data: SetPreferredValidatorData = SetPreferredValidatorData { + let args = SetPreferredValidatorArgs { validator_type, - validator_vote_address, + validator_vote_address: validator_vote_address.map(|p| p.to_bytes().into()), }; - Ok(StakePoolProgramIx::SetPreferredValidator( - ix_accounts, - de_ix_data, - )) + Ok(StakePoolProgramInstruction::SetPreferredValidator { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::UpdateValidatorListBalance { start_index, @@ -234,244 +239,263 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 7)?; let ix_accounts = UpdateValidatorListBalanceAccounts { - stake_pool: ix.accounts[0].0.into(), - stake_pool_withdraw_authority: ix.accounts[1].0.into(), - validator_list_address: ix.accounts[2].0.into(), - reserve_stake: ix.accounts[3].0.into(), - clock: ix.accounts[4].0.into(), - sysvar_stake_history: ix.accounts[5].0.into(), - stake_program: ix.accounts[6].0.into(), + stake_pool: ix.accounts[0], + stake_pool_withdraw_authority: ix.accounts[1], + validator_list_address: ix.accounts[2], + reserve_stake: ix.accounts[3], + clock: ix.accounts[4], + sysvar_stake_history: ix.accounts[5], + stake_program: ix.accounts[6], }; - let de_ix_data: UpdateValidatorListBalanceData = UpdateValidatorListBalanceData { + let args = UpdateValidatorListBalanceArgs { start_index, no_merge, }; - Ok(StakePoolProgramIx::UpdateValidatorListBalance( - ix_accounts, - de_ix_data, - )) + Ok(StakePoolProgramInstruction::UpdateValidatorListBalance { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::UpdateStakePoolBalance => { check_min_accounts_req(accounts_len, 7)?; let ix_accounts = UpdateStakePoolBalanceAccounts { - stake_pool: ix.accounts[0].0.into(), - withdraw_authority: ix.accounts[1].0.into(), - validator_list_storage: ix.accounts[2].0.into(), - reserve_stake: ix.accounts[3].0.into(), - manager_fee_account: ix.accounts[4].0.into(), - stake_pool_mint: ix.accounts[5].0.into(), - token_program: ix.accounts[6].0.into(), - }; - - Ok(StakePoolProgramIx::UpdateStakePoolBalance(ix_accounts)) + stake_pool: ix.accounts[0], + withdraw_authority: ix.accounts[1], + validator_list_storage: ix.accounts[2], + reserve_stake: ix.accounts[3], + manager_fee_account: ix.accounts[4], + stake_pool_mint: ix.accounts[5], + token_program: ix.accounts[6], + }; + + Ok(StakePoolProgramInstruction::UpdateStakePoolBalance { + accounts: ix_accounts, + }) }, StakePoolInstruction::CleanupRemovedValidatorEntries => { check_min_accounts_req(accounts_len, 2)?; let ix_accounts = CleanupRemovedValidatorEntriesAccounts { - stake_pool: ix.accounts[0].0.into(), - validator_list_storage: ix.accounts[1].0.into(), + stake_pool: ix.accounts[0], + validator_list_storage: ix.accounts[1], }; - Ok(StakePoolProgramIx::CleanupRemovedValidatorEntries( - ix_accounts, - )) + Ok( + StakePoolProgramInstruction::CleanupRemovedValidatorEntries { + accounts: ix_accounts, + }, + ) }, StakePoolInstruction::DepositStake => { check_min_accounts_req(accounts_len, 15)?; let ix_accounts = DepositStakeAccounts { - stake_pool: ix.accounts[0].0.into(), - validator_list_storage: ix.accounts[1].0.into(), - stake_pool_deposit_authority: ix.accounts[2].0.into(), - stake_pool_withdraw_authority: ix.accounts[3].0.into(), - deposit_stake_address: ix.accounts[4].0.into(), - validator_stake_account: ix.accounts[5].0.into(), - reserve_stake_account: ix.accounts[6].0.into(), - pool_tokens_to: ix.accounts[7].0.into(), - manager_fee_account: ix.accounts[8].0.into(), - referrer_pool_tokens_account: ix.accounts[9].0.into(), - pool_mint: ix.accounts[10].0.into(), - clock: ix.accounts[11].0.into(), - sysvar_stake_history: ix.accounts[12].0.into(), - token_program: ix.accounts[13].0.into(), - stake_program: ix.accounts[14].0.into(), - }; - - Ok(StakePoolProgramIx::DepositStake(ix_accounts)) + stake_pool: ix.accounts[0], + validator_list_storage: ix.accounts[1], + stake_pool_deposit_authority: ix.accounts[2], + stake_pool_withdraw_authority: ix.accounts[3], + deposit_stake_address: ix.accounts[4], + validator_stake_account: ix.accounts[5], + reserve_stake_account: ix.accounts[6], + pool_tokens_to: ix.accounts[7], + manager_fee_account: ix.accounts[8], + referrer_pool_tokens_account: ix.accounts[9], + pool_mint: ix.accounts[10], + clock: ix.accounts[11], + sysvar_stake_history: ix.accounts[12], + token_program: ix.accounts[13], + stake_program: ix.accounts[14], + }; + + Ok(StakePoolProgramInstruction::DepositStake { + accounts: ix_accounts, + }) }, StakePoolInstruction::WithdrawStake(amount) => { check_min_accounts_req(accounts_len, 13)?; let ix_accounts = WithdrawStakeAccounts { - stake_pool: ix.accounts[0].0.into(), - validator_list_storage: ix.accounts[1].0.into(), - stake_pool_withdraw: ix.accounts[2].0.into(), - stake_to_split: ix.accounts[3].0.into(), - stake_to_receive: ix.accounts[4].0.into(), - user_stake_authority: ix.accounts[5].0.into(), - user_transfer_authority: ix.accounts[6].0.into(), - user_pool_token_account: ix.accounts[7].0.into(), - manager_fee_account: ix.accounts[8].0.into(), - pool_mint: ix.accounts[9].0.into(), - clock: ix.accounts[10].0.into(), - token_program: ix.accounts[11].0.into(), - stake_program: ix.accounts[12].0.into(), - }; - - let de_ix_data: WithdrawStakeData = WithdrawStakeData { arg: amount }; - - Ok(StakePoolProgramIx::WithdrawStake(ix_accounts, de_ix_data)) + stake_pool: ix.accounts[0], + validator_list_storage: ix.accounts[1], + stake_pool_withdraw: ix.accounts[2], + stake_to_split: ix.accounts[3], + stake_to_receive: ix.accounts[4], + user_stake_authority: ix.accounts[5], + user_transfer_authority: ix.accounts[6], + user_pool_token_account: ix.accounts[7], + manager_fee_account: ix.accounts[8], + pool_mint: ix.accounts[9], + clock: ix.accounts[10], + token_program: ix.accounts[11], + stake_program: ix.accounts[12], + }; + + let args = WithdrawStakeArgs { arg: amount }; + + Ok(StakePoolProgramInstruction::WithdrawStake { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::SetManager => { check_min_accounts_req(accounts_len, 4)?; let ix_accounts = SetManagerAccounts { - stake_pool: ix.accounts[0].0.into(), - manager: ix.accounts[1].0.into(), - new_manager: ix.accounts[2].0.into(), - new_fee_receiver: ix.accounts[3].0.into(), + stake_pool: ix.accounts[0], + manager: ix.accounts[1], + new_manager: ix.accounts[2], + new_fee_receiver: ix.accounts[3], }; - Ok(StakePoolProgramIx::SetManager(ix_accounts)) + Ok(StakePoolProgramInstruction::SetManager { + accounts: ix_accounts, + }) }, StakePoolInstruction::SetFee { fee } => { check_min_accounts_req(accounts_len, 2)?; let ix_accounts = SetFeeAccounts { - stake_pool: ix.accounts[0].0.into(), - manager: ix.accounts[1].0.into(), + stake_pool: ix.accounts[0], + manager: ix.accounts[1], }; - let de_ix_data: SetFeeData = SetFeeData { fee }; + let args = SetFeeArgs { fee }; - Ok(StakePoolProgramIx::SetFee(ix_accounts, de_ix_data)) + Ok(StakePoolProgramInstruction::SetFee { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::SetStaker => { check_min_accounts_req(accounts_len, 3)?; let ix_accounts = SetStakerAccounts { - stake_pool: ix.accounts[0].0.into(), - set_staker_authority: ix.accounts[1].0.into(), - new_staker: ix.accounts[2].0.into(), + stake_pool: ix.accounts[0], + set_staker_authority: ix.accounts[1], + new_staker: ix.accounts[2], }; - Ok(StakePoolProgramIx::SetStaker(ix_accounts)) + Ok(StakePoolProgramInstruction::SetStaker { + accounts: ix_accounts, + }) }, StakePoolInstruction::DepositSol(amount) => { check_min_accounts_req(accounts_len, 10)?; let ix_accounts = DepositSolAccounts { - stake_pool: ix.accounts[0].0.into(), - stake_pool_withdraw_authority: ix.accounts[1].0.into(), - reserve_stake_account: ix.accounts[2].0.into(), - lamports_from: ix.accounts[3].0.into(), - pool_tokens_to: ix.accounts[4].0.into(), - manager_fee_account: ix.accounts[5].0.into(), - referrer_pool_tokens_account: ix.accounts[6].0.into(), - pool_mint: ix.accounts[7].0.into(), - system_program: ix.accounts[8].0.into(), - token_program: ix.accounts[9].0.into(), + stake_pool: ix.accounts[0], + stake_pool_withdraw_authority: ix.accounts[1], + reserve_stake_account: ix.accounts[2], + lamports_from: ix.accounts[3], + pool_tokens_to: ix.accounts[4], + manager_fee_account: ix.accounts[5], + referrer_pool_tokens_account: ix.accounts[6], + pool_mint: ix.accounts[7], + system_program: ix.accounts[8], + token_program: ix.accounts[9], deposit_authority: ix .accounts .get(10) - .map(|account| Some(account.0.into())) + .map(|account| Some(account.to_owned())) .unwrap_or(None), }; - let de_ix_data: DepositSolData = DepositSolData { arg: amount }; + let args = DepositSolArgs { arg: amount }; - Ok(StakePoolProgramIx::DepositSol(ix_accounts, de_ix_data)) + Ok(StakePoolProgramInstruction::DepositSol { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::SetFundingAuthority(funding_type) => { check_min_accounts_req(accounts_len, 2)?; let ix_accounts = SetFundingAuthorityAccounts { - stake_pool: ix.accounts[0].0.into(), - manager: ix.accounts[1].0.into(), + stake_pool: ix.accounts[0], + manager: ix.accounts[1], auth: ix .accounts - .get(12) - .map(|account| Some(account.0.into())) + .get(2) + .map(|account| Some(account.to_owned())) .unwrap_or(None), }; - let de_ix_data: SetFundingAuthorityData = - SetFundingAuthorityData { arg: funding_type }; + let args = SetFundingAuthorityArgs { arg: funding_type }; - Ok(StakePoolProgramIx::SetFundingAuthority( - ix_accounts, - de_ix_data, - )) + Ok(StakePoolProgramInstruction::SetFundingAuthority { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::WithdrawSol(amount) => { check_min_accounts_req(accounts_len, 12)?; let ix_accounts = WithdrawSolAccounts { - stake_pool: ix.accounts[0].0.into(), - stake_pool_withdraw_authority: ix.accounts[1].0.into(), - user_transfer_authority: ix.accounts[2].0.into(), - pool_tokens_from: ix.accounts[3].0.into(), - reserve_stake_account: ix.accounts[4].0.into(), - lamports_to: ix.accounts[5].0.into(), - manager_fee_account: ix.accounts[6].0.into(), - pool_mint: ix.accounts[7].0.into(), - clock: ix.accounts[8].0.into(), - sysvar_stake_history: ix.accounts[9].0.into(), - stake_program: ix.accounts[10].0.into(), - token_program: ix.accounts[11].0.into(), + stake_pool: ix.accounts[0], + stake_pool_withdraw_authority: ix.accounts[1], + user_transfer_authority: ix.accounts[2], + pool_tokens_from: ix.accounts[3], + reserve_stake_account: ix.accounts[4], + lamports_to: ix.accounts[5], + manager_fee_account: ix.accounts[6], + pool_mint: ix.accounts[7], + clock: ix.accounts[8], + sysvar_stake_history: ix.accounts[9], + stake_program: ix.accounts[10], + token_program: ix.accounts[11], sol_withdraw_authority: ix .accounts .get(12) - .map(|account| Some(account.0.into())) + .map(|account| Some(account.to_owned())) .unwrap_or(None), }; - let de_ix_data: WithdrawSolData = WithdrawSolData { arg: amount }; - Ok(StakePoolProgramIx::WithdrawSol(ix_accounts, de_ix_data)) + let args = WithdrawSolArgs { arg: amount }; + Ok(StakePoolProgramInstruction::WithdrawSol { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::CreateTokenMetadata { name, symbol, uri } => { check_min_accounts_req(accounts_len, 9)?; let ix_accounts = CreateTokenMetadataAccounts { - stake_pool: ix.accounts[0].0.into(), - manager: ix.accounts[1].0.into(), - stake_pool_withdraw_authority: ix.accounts[2].0.into(), - pool_mint: ix.accounts[3].0.into(), - payer: ix.accounts[4].0.into(), - token_metadata: ix.accounts[5].0.into(), - mpl_token_metadata: ix.accounts[6].0.into(), - system_program: ix.accounts[7].0.into(), - }; - - let de_ix_data: CreateTokenMetadataData = - CreateTokenMetadataData { name, symbol, uri }; - Ok(StakePoolProgramIx::CreateTokenMetadata( - ix_accounts, - de_ix_data, - )) + stake_pool: ix.accounts[0], + manager: ix.accounts[1], + stake_pool_withdraw_authority: ix.accounts[2], + pool_mint: ix.accounts[3], + payer: ix.accounts[4], + token_metadata: ix.accounts[5], + mpl_token_metadata: ix.accounts[6], + system_program: ix.accounts[7], + }; + + let args = CreateTokenMetadataArgs { name, symbol, uri }; + Ok(StakePoolProgramInstruction::CreateTokenMetadata { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::UpdateTokenMetadata { name, symbol, uri } => { check_min_accounts_req(accounts_len, 5)?; let ix_accounts = UpdateTokenMetadataAccounts { - stake_pool: ix.accounts[0].0.into(), - manager: ix.accounts[1].0.into(), - stake_pool_withdraw_authority: ix.accounts[2].0.into(), - token_metadata: ix.accounts[3].0.into(), - mpl_token_metadata: ix.accounts[4].0.into(), + stake_pool: ix.accounts[0], + manager: ix.accounts[1], + stake_pool_withdraw_authority: ix.accounts[2], + token_metadata: ix.accounts[3], + mpl_token_metadata: ix.accounts[4], }; - let de_ix_data: UpdateTokenMetadataData = - UpdateTokenMetadataData { name, symbol, uri }; + let args = UpdateTokenMetadataArgs { name, symbol, uri }; - Ok(StakePoolProgramIx::UpdateTokenMetadata( - ix_accounts, - de_ix_data, - )) + Ok(StakePoolProgramInstruction::UpdateTokenMetadata { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::IncreaseAdditionalValidatorStake { lamports, @@ -481,33 +505,34 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 14)?; let ix_accounts = IncreaseAdditionalValidatorStakeAccounts { - stake_pool: ix.accounts[0].0.into(), - staker: ix.accounts[1].0.into(), - stake_pool_withdraw_authority: ix.accounts[2].0.into(), - validator_list: ix.accounts[3].0.into(), - reserve_stake: ix.accounts[4].0.into(), - ephemeral_stake: ix.accounts[5].0.into(), - transient_stake: ix.accounts[6].0.into(), - validator_stake: ix.accounts[7].0.into(), - validator: ix.accounts[8].0.into(), - clock: ix.accounts[9].0.into(), - stake_history: ix.accounts[10].0.into(), - stake_config: ix.accounts[11].0.into(), - system_program: ix.accounts[12].0.into(), - stake_program: ix.accounts[13].0.into(), - }; - - let de_ix_data: IncreaseAdditionalValidatorStakeData = - IncreaseAdditionalValidatorStakeData { - lamports, - transient_stake_seed, - ephemeral_stake_seed, - }; - - Ok(StakePoolProgramIx::IncreaseAdditionalValidatorStake( - ix_accounts, - de_ix_data, - )) + stake_pool: ix.accounts[0], + staker: ix.accounts[1], + stake_pool_withdraw_authority: ix.accounts[2], + validator_list: ix.accounts[3], + reserve_stake: ix.accounts[4], + ephemeral_stake: ix.accounts[5], + transient_stake: ix.accounts[6], + validator_stake: ix.accounts[7], + validator: ix.accounts[8], + clock: ix.accounts[9], + stake_history: ix.accounts[10], + stake_config: ix.accounts[11], + system_program: ix.accounts[12], + stake_program: ix.accounts[13], + }; + + let args = IncreaseAdditionalValidatorStakeArgs { + lamports, + transient_stake_seed, + ephemeral_stake_seed, + }; + + Ok( + StakePoolProgramInstruction::IncreaseAdditionalValidatorStake { + accounts: ix_accounts, + args, + }, + ) }, StakePoolInstruction::DecreaseAdditionalValidatorStake { lamports, @@ -517,30 +542,32 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 12)?; let ix_accounts = DecreaseAdditionalValidatorStakeAccounts { - stake_pool: ix.accounts[0].0.into(), - staker: ix.accounts[1].0.into(), - stake_pool_withdraw_authority: ix.accounts[2].0.into(), - validator_list: ix.accounts[3].0.into(), - reserve_stake: ix.accounts[4].0.into(), - validator_stake: ix.accounts[5].0.into(), - ephemeral_stake: ix.accounts[6].0.into(), - transient_stake: ix.accounts[7].0.into(), - clock: ix.accounts[8].0.into(), - stake_history: ix.accounts[9].0.into(), - system_program: ix.accounts[10].0.into(), - stake_program: ix.accounts[11].0.into(), - }; - - let de_ix_data = DecreaseAdditionalValidatorStakeData { + stake_pool: ix.accounts[0], + staker: ix.accounts[1], + stake_pool_withdraw_authority: ix.accounts[2], + validator_list: ix.accounts[3], + reserve_stake: ix.accounts[4], + validator_stake: ix.accounts[5], + ephemeral_stake: ix.accounts[6], + transient_stake: ix.accounts[7], + clock: ix.accounts[8], + stake_history: ix.accounts[9], + system_program: ix.accounts[10], + stake_program: ix.accounts[11], + }; + + let args = DecreaseAdditionalValidatorStakeArgs { lamports, transient_stake_seed, ephemeral_stake_seed, }; - Ok(StakePoolProgramIx::DecreaseAdditionalValidatorStake( - ix_accounts, - de_ix_data, - )) + Ok( + StakePoolProgramInstruction::DecreaseAdditionalValidatorStake { + accounts: ix_accounts, + args, + }, + ) }, StakePoolInstruction::DecreaseValidatorStakeWithReserve { lamports, @@ -549,28 +576,30 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 11)?; let ix_accounts = DecreaseValidatorStakeWithReserveAccounts { - stake_pool: ix.accounts[0].0.into(), - staker: ix.accounts[1].0.into(), - stake_pool_withdraw_authority: ix.accounts[2].0.into(), - validator_list: ix.accounts[3].0.into(), - reserve_stake: ix.accounts[4].0.into(), - validator_stake: ix.accounts[5].0.into(), - transient_stake: ix.accounts[6].0.into(), - clock: ix.accounts[7].0.into(), - stake_history: ix.accounts[8].0.into(), - system_program: ix.accounts[9].0.into(), - stake_program: ix.accounts[10].0.into(), - }; - - let de_ix_data = DecreaseValidatorStakeWithReserveData { + stake_pool: ix.accounts[0], + staker: ix.accounts[1], + stake_pool_withdraw_authority: ix.accounts[2], + validator_list: ix.accounts[3], + reserve_stake: ix.accounts[4], + validator_stake: ix.accounts[5], + transient_stake: ix.accounts[6], + clock: ix.accounts[7], + stake_history: ix.accounts[8], + system_program: ix.accounts[9], + stake_program: ix.accounts[10], + }; + + let args = DecreaseValidatorStakeWithReserveArgs { lamports, transient_stake_seed, }; - Ok(StakePoolProgramIx::DecreaseValidatorStakeWithReserve( - ix_accounts, - de_ix_data, - )) + Ok( + StakePoolProgramInstruction::DecreaseValidatorStakeWithReserve { + accounts: ix_accounts, + args, + }, + ) }, StakePoolInstruction::DepositStakeWithSlippage { minimum_pool_tokens_out, @@ -578,31 +607,31 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 15)?; let ix_accounts = DepositStakeWithSlippageAccounts { - stake_pool: ix.accounts[0].0.into(), - validator_list_storage: ix.accounts[1].0.into(), - stake_pool_deposit_authority: ix.accounts[2].0.into(), - stake_pool_withdraw_authority: ix.accounts[3].0.into(), - deposit_stake_address: ix.accounts[4].0.into(), - validator_stake_account: ix.accounts[5].0.into(), - reserve_stake_account: ix.accounts[6].0.into(), - pool_tokens_to: ix.accounts[7].0.into(), - manager_fee_account: ix.accounts[8].0.into(), - referrer_pool_tokens_account: ix.accounts[9].0.into(), - pool_mint: ix.accounts[10].0.into(), - clock: ix.accounts[11].0.into(), - sysvar_stake_history: ix.accounts[12].0.into(), - token_program: ix.accounts[13].0.into(), - stake_program: ix.accounts[14].0.into(), - }; - - let de_ix_data = DepositStakeWithSlippageData { + stake_pool: ix.accounts[0], + validator_list_storage: ix.accounts[1], + stake_pool_deposit_authority: ix.accounts[2], + stake_pool_withdraw_authority: ix.accounts[3], + deposit_stake_address: ix.accounts[4], + validator_stake_account: ix.accounts[5], + reserve_stake_account: ix.accounts[6], + pool_tokens_to: ix.accounts[7], + manager_fee_account: ix.accounts[8], + referrer_pool_tokens_account: ix.accounts[9], + pool_mint: ix.accounts[10], + clock: ix.accounts[11], + sysvar_stake_history: ix.accounts[12], + token_program: ix.accounts[13], + stake_program: ix.accounts[14], + }; + + let args = DepositStakeWithSlippageArgs { minimum_pool_tokens_out, }; - Ok(StakePoolProgramIx::DepositStakeWithSlippage( - ix_accounts, - de_ix_data, - )) + Ok(StakePoolProgramInstruction::DepositStakeWithSlippage { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::WithdrawStakeWithSlippage { pool_tokens_in, @@ -611,30 +640,30 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 13)?; let ix_accounts = WithdrawStakeWithSlippageAccounts { - stake_pool: ix.accounts[0].0.into(), - validator_list_storage: ix.accounts[1].0.into(), - stake_pool_withdraw: ix.accounts[2].0.into(), - stake_to_split: ix.accounts[3].0.into(), - stake_to_receive: ix.accounts[4].0.into(), - user_stake_authority: ix.accounts[5].0.into(), - user_transfer_authority: ix.accounts[6].0.into(), - user_pool_token_account: ix.accounts[7].0.into(), - manager_fee_account: ix.accounts[8].0.into(), - pool_mint: ix.accounts[9].0.into(), - clock: ix.accounts[10].0.into(), - token_program: ix.accounts[11].0.into(), - stake_program: ix.accounts[12].0.into(), - }; - - let de_ix_data = WithdrawStakeWithSlippageData { + stake_pool: ix.accounts[0], + validator_list_storage: ix.accounts[1], + stake_pool_withdraw: ix.accounts[2], + stake_to_split: ix.accounts[3], + stake_to_receive: ix.accounts[4], + user_stake_authority: ix.accounts[5], + user_transfer_authority: ix.accounts[6], + user_pool_token_account: ix.accounts[7], + manager_fee_account: ix.accounts[8], + pool_mint: ix.accounts[9], + clock: ix.accounts[10], + token_program: ix.accounts[11], + stake_program: ix.accounts[12], + }; + + let args = WithdrawStakeWithSlippageArgs { pool_tokens_in, minimum_lamports_out, }; - Ok(StakePoolProgramIx::WithdrawStakeWithSlippage( - ix_accounts, - de_ix_data, - )) + Ok(StakePoolProgramInstruction::WithdrawStakeWithSlippage { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::DepositSolWithSlippage { lamports_in, @@ -643,32 +672,32 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 13)?; let ix_accounts = DepositSolWithSlippageAccounts { - stake_pool: ix.accounts[0].0.into(), - stake_pool_withdraw_authority: ix.accounts[1].0.into(), - reserve_stake_account: ix.accounts[2].0.into(), - lamports_from: ix.accounts[3].0.into(), - pool_tokens_to: ix.accounts[4].0.into(), - manager_fee_account: ix.accounts[5].0.into(), - referrer_pool_tokens_account: ix.accounts[6].0.into(), - pool_mint: ix.accounts[7].0.into(), - system_program: ix.accounts[8].0.into(), - token_program: ix.accounts[9].0.into(), + stake_pool: ix.accounts[0], + stake_pool_withdraw_authority: ix.accounts[1], + reserve_stake_account: ix.accounts[2], + lamports_from: ix.accounts[3], + pool_tokens_to: ix.accounts[4], + manager_fee_account: ix.accounts[5], + referrer_pool_tokens_account: ix.accounts[6], + pool_mint: ix.accounts[7], + system_program: ix.accounts[8], + token_program: ix.accounts[9], deposit_authority: ix .accounts .get(10) - .map(|account| Some(account.0.into())) + .map(|account| Some(account.to_owned())) .unwrap_or(None), }; - let de_ix_data = DepositSolWithSlippageData { + let args = DepositSolWithSlippageArgs { lamports_in, minimum_pool_tokens_out, }; - Ok(StakePoolProgramIx::DepositSolWithSlippage( - ix_accounts, - de_ix_data, - )) + Ok(StakePoolProgramInstruction::DepositSolWithSlippage { + accounts: ix_accounts, + args, + }) }, StakePoolInstruction::WithdrawSolWithSlippage { pool_tokens_in, @@ -677,34 +706,34 @@ impl InstructionParser { check_min_accounts_req(accounts_len, 13)?; let ix_accounts = WithdrawSolWithSlippageAccounts { - stake_pool: ix.accounts[0].0.into(), - stake_pool_withdraw_authority: ix.accounts[1].0.into(), - user_transfer_authority: ix.accounts[2].0.into(), - pool_tokens_from: ix.accounts[3].0.into(), - reserve_stake_account: ix.accounts[4].0.into(), - lamports_to: ix.accounts[5].0.into(), - manager_fee_account: ix.accounts[6].0.into(), - pool_mint: ix.accounts[7].0.into(), - clock: ix.accounts[8].0.into(), - sysvar_stake_history: ix.accounts[9].0.into(), - stake_program: ix.accounts[10].0.into(), - token_program: ix.accounts[11].0.into(), + stake_pool: ix.accounts[0], + stake_pool_withdraw_authority: ix.accounts[1], + user_transfer_authority: ix.accounts[2], + pool_tokens_from: ix.accounts[3], + reserve_stake_account: ix.accounts[4], + lamports_to: ix.accounts[5], + manager_fee_account: ix.accounts[6], + pool_mint: ix.accounts[7], + clock: ix.accounts[8], + sysvar_stake_history: ix.accounts[9], + stake_program: ix.accounts[10], + token_program: ix.accounts[11], sol_withdraw_authority: ix .accounts .get(12) - .map(|account| Some(account.0.into())) + .map(|account| Some(account.to_owned())) .unwrap_or(None), }; - let de_ix_data = WithdrawSolWithSlippageData { + let args = WithdrawSolWithSlippageArgs { pool_tokens_in, minimum_lamports_out, }; - Ok(StakePoolProgramIx::WithdrawSolWithSlippage( - ix_accounts, - de_ix_data, - )) + Ok(StakePoolProgramInstruction::WithdrawSolWithSlippage { + accounts: ix_accounts, + args, + }) }, _ => Err(yellowstone_vixen_core::ParseError::from( "Invalid Instruction discriminator".to_owned(), @@ -712,16 +741,3 @@ impl InstructionParser { } } } - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} diff --git a/crates/virtuals-parser/Cargo.toml b/crates/virtuals-parser/Cargo.toml deleted file mode 100644 index d4fbbb44..00000000 --- a/crates/virtuals-parser/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "yellowstone-vixen-virtuals-parser" -version.workspace = true -edition.workspace = true -description = "Vixen program parser for Virtuals program" -license = "MIT" -repository = "https://github.com/rpcpool/yellowstone-vixen" - - -[dependencies] -prost = { workspace = true } -yellowstone-vixen-core = { workspace = true, features = ["proto"] } -tonic = { workspace = true, features = ["gzip", "zstd"] } -solana-account-info = { workspace = true } -solana-cpi = { workspace = true } -solana-decode-error = { workspace = true } -solana-pubkey = { workspace = true, features = ["curve25519", "borsh"] } -solana-instruction = { workspace = true } -solana-msg = { workspace = true } -solana-program-entrypoint = { workspace = true } -solana-program-error = { workspace = true } -borsh = { workspace = true } -num-derive = { workspace = true } -thiserror = { workspace = true } -num-traits = { workspace = true } -tracing = { workspace = true, optional = true } -strum = { workspace = true, optional = true } -strum_macros = { workspace = true, optional = true } - -[features] -anchor = [] -anchor-idl-build = [] -serde = [] -test-sbf = [] -fetch = [] -tracing = ["dep:tracing", "dep:strum", "dep:strum_macros"] -# Exposes shared transaction data like tx signature, slot and more, to be available in Vixen Handlers -shared-data = [] - -[build-dependencies] -prost-build = { workspace = true } diff --git a/crates/virtuals-parser/build.rs b/crates/virtuals-parser/build.rs deleted file mode 100644 index 57e2fcf4..00000000 --- a/crates/virtuals-parser/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use std::{env, path::PathBuf}; - -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - - // #[cfg(feature = "proto")] - prost_build::Config::new() - .enable_type_names() - .file_descriptor_set_path(out_dir.join("descriptor.bin")) - .compile_protos(&["proto/virtuals.proto"], &["proto"]) - .unwrap(); -} diff --git a/crates/virtuals-parser/idl.json b/crates/virtuals-parser/idl.json deleted file mode 100644 index 554d2801..00000000 --- a/crates/virtuals-parser/idl.json +++ /dev/null @@ -1,3373 +0,0 @@ -{ - "address": "5U3EU2ubXtK84QcRjWVmYt9RaDyA8gKxdUrPFXmZyaki", - "metadata": { - "name": "virtuals_program", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "buy", - "discriminator": [ - 102, - 6, - 61, - 18, - 1, - 218, - 235, - 234 - ], - "accounts": [ - { - "name": "user", - "signer": true - }, - { - "name": "vpool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "token_mint" - } - ] - } - }, - { - "name": "token_mint" - }, - { - "name": "user_virtuals_ata", - "writable": true - }, - { - "name": "user_token_ata", - "writable": true - }, - { - "name": "vpool_token_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "token_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": "platform_prototype", - "writable": true, - "address": "933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL" - }, - { - "name": "platform_prototype_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "platform_prototype" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "const", - "value": [ - 40, - 82, - 144, - 230, - 223, - 30, - 203, - 194, - 218, - 8, - 182, - 83, - 3, - 69, - 230, - 99, - 143, - 96, - 63, - 54, - 49, - 170, - 42, - 186, - 128, - 143, - 177, - 157, - 236, - 50, - 113, - 76 - ] - } - ], - "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": "vpool_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "const", - "value": [ - 40, - 82, - 144, - 230, - 223, - 30, - 203, - 194, - 218, - 8, - 182, - 83, - 3, - 69, - 230, - 99, - 143, - 96, - 63, - 54, - 49, - 170, - 42, - 186, - 128, - 143, - 177, - 157, - 236, - 50, - 113, - 76 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "max_amount_out", - "type": "u64" - } - ] - }, - { - "name": "claim_fees", - "discriminator": [ - 82, - 251, - 233, - 156, - 12, - 52, - 184, - 202 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "vpool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "token_mint" - } - ] - } - }, - { - "name": "virtuals_mint", - "address": "3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y" - }, - { - "name": "token_mint" - }, - { - "name": "vpool_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "virtuals_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": "vpool_token_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "token_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": "platform", - "writable": true, - "address": "FxKXqCKXdxPbfYau83ZkGUXgcZWhKBTfAjGg2KzYSopS" - }, - { - "name": "platform_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "platform" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "virtuals_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": "platform_token_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "platform" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "token_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": "creator_virtuals_ata", - "writable": true - }, - { - "name": "creator_token_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool.creator", - "account": "VirtualsPool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "token_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": "pool", - "writable": true - }, - { - "name": "lp_mint", - "writable": true - }, - { - "name": "lock_escrow", - "writable": true - }, - { - "name": "escrow_vault", - "writable": true - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "virtuals_vault", - "writable": true - }, - { - "name": "token_vault", - "writable": true - }, - { - "name": "virtuals_token_vault", - "writable": true - }, - { - "name": "token_token_vault", - "writable": true - }, - { - "name": "virtuals_vault_lp_mint", - "writable": true - }, - { - "name": "token_vault_lp_mint", - "writable": true - }, - { - "name": "virtuals_vault_lp", - "writable": true - }, - { - "name": "token_vault_lp", - "writable": true - }, - { - "name": "vault_program", - "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "dynamic_amm_program", - "address": "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" - } - ], - "args": [] - }, - { - "name": "create_meteora_pool", - "discriminator": [ - 246, - 254, - 33, - 37, - 225, - 176, - 41, - 232 - ], - "accounts": [ - { - "name": "vpool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "token_mint" - } - ] - } - }, - { - "name": "meteora_deployer", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 116, - 101, - 111, - 114, - 97, - 95, - 100, - 101, - 112, - 108, - 111, - 121, - 101, - 114 - ] - } - ] - } - }, - { - "name": "meteora_deployer_virtuals_ata", - "writable": true - }, - { - "name": "meteora_deployer_token_ata", - "writable": true - }, - { - "name": "vpool_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "virtuals_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": "vpool_token_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "token_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": "lock_escrow", - "writable": true - }, - { - "name": "escrow_vault", - "writable": true - }, - { - "name": "pool", - "writable": true - }, - { - "name": "config", - "address": "B6FT4AHhQJ7BttrC1i223km5bYRUA2nVwBR7k5TVwLtx" - }, - { - "name": "lp_mint", - "writable": true - }, - { - "name": "virtuals_mint", - "address": "3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y" - }, - { - "name": "token_mint" - }, - { - "name": "virtuals_vault", - "writable": true - }, - { - "name": "token_vault", - "writable": true - }, - { - "name": "virtuals_token_vault", - "writable": true - }, - { - "name": "token_token_vault", - "writable": true - }, - { - "name": "virtuals_vault_lp_mint", - "writable": true - }, - { - "name": "token_vault_lp_mint", - "writable": true - }, - { - "name": "virtuals_vault_lp", - "writable": true - }, - { - "name": "token_vault_lp", - "writable": true - }, - { - "name": "pool_virtuals_ata", - "writable": true - }, - { - "name": "pool_token_ata", - "writable": true - }, - { - "name": "meteora_deployer_pool_lp", - "writable": true - }, - { - "name": "protocol_virtuals_fee", - "writable": true - }, - { - "name": "protocol_token_fee", - "writable": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "token_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "metadata_program" - }, - { - "kind": "account", - "path": "token_mint" - } - ], - "program": { - "kind": "const", - "value": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - } - } - }, - { - "name": "rent", - "docs": [ - "Rent account." - ], - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "mint_metadata", - "writable": true - }, - { - "name": "metadata_program", - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - }, - { - "name": "vault_program", - "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" - }, - { - "name": "token_program", - "docs": [ - "Token program." - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "docs": [ - "Associated token program." - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "docs": [ - "System program." - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "dynamic_amm_program", - "address": "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" - } - ], - "args": [] - }, - { - "name": "initialize", - "docs": [ - "# Initialize Pool", - "", - "This is where Virtuals creates a new mint address and pool and mints the initial 1,000,000,000 tokens.", - "This enabels Virtuals to premine addresses and \\", - "sell\\\\", - "them to customers without any delays of mining the", - "address. While this instruction could be permissioned, it is currently permissionless. As such, we make", - "sure to handle all the necessary checks such as: address suffix, zero supply, 6 decimals, correct mint", - "authority." - ], - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "virtuals_mint", - "address": "3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y" - }, - { - "name": "token_mint", - "writable": true - }, - { - "name": "vpool_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "virtuals_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": "vpool_token_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "token_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": "vpool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "token_mint" - } - ] - } - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "initialize_meteora_accounts", - "discriminator": [ - 53, - 12, - 118, - 158, - 253, - 239, - 185, - 214 - ], - "accounts": [ - { - "name": "vpool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "token_mint" - } - ] - } - }, - { - "name": "meteora_deployer", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 116, - 101, - 111, - 114, - 97, - 95, - 100, - 101, - 112, - 108, - 111, - 121, - 101, - 114 - ] - } - ] - } - }, - { - "name": "meteora_deployer_virtuals_ata", - "writable": true - }, - { - "name": "meteora_deployer_token_ata", - "writable": true - }, - { - "name": "vpool_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "virtuals_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": "vpool_token_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "token_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": "lock_escrow", - "writable": true - }, - { - "name": "escrow_vault", - "writable": true - }, - { - "name": "pool", - "writable": true - }, - { - "name": "config", - "address": "B6FT4AHhQJ7BttrC1i223km5bYRUA2nVwBR7k5TVwLtx" - }, - { - "name": "lp_mint", - "writable": true - }, - { - "name": "virtuals_mint", - "address": "3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y" - }, - { - "name": "token_mint" - }, - { - "name": "virtuals_vault", - "writable": true - }, - { - "name": "token_vault", - "writable": true - }, - { - "name": "virtuals_token_vault", - "writable": true - }, - { - "name": "token_token_vault", - "writable": true - }, - { - "name": "virtuals_vault_lp_mint", - "writable": true - }, - { - "name": "token_vault_lp_mint", - "writable": true - }, - { - "name": "virtuals_vault_lp", - "writable": true - }, - { - "name": "token_vault_lp", - "writable": true - }, - { - "name": "pool_virtuals_ata", - "writable": true - }, - { - "name": "pool_token_ata", - "writable": true - }, - { - "name": "meteora_deployer_pool_lp", - "writable": true - }, - { - "name": "protocol_virtuals_fee", - "writable": true - }, - { - "name": "protocol_token_fee", - "writable": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "token_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "metadata_program" - }, - { - "kind": "account", - "path": "token_mint" - } - ], - "program": { - "kind": "const", - "value": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - } - } - }, - { - "name": "rent", - "docs": [ - "Rent account." - ], - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "mint_metadata", - "writable": true - }, - { - "name": "metadata_program", - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - }, - { - "name": "vault_program", - "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" - }, - { - "name": "token_program", - "docs": [ - "Token program." - ], - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "docs": [ - "Associated token program." - ], - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "docs": [ - "System program." - ], - "address": "11111111111111111111111111111111" - }, - { - "name": "dynamic_amm_program", - "address": "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" - } - ], - "args": [] - }, - { - "name": "launch", - "docs": [ - "", - "This is where a user comes along and purchases a mint address and pool. The user will provide a name,", - "symbol and URI containing offchain metadata. The contract will initialize a new onchain metadata", - "account containing these values, then revoke the mint authority.", - "" - ], - "discriminator": [ - 153, - 241, - 93, - 225, - 22, - 69, - 74, - 61 - ], - "accounts": [ - { - "name": "creator", - "writable": true, - "signer": true - }, - { - "name": "creator_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "creator" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "const", - "value": [ - 40, - 82, - 144, - 230, - 223, - 30, - 203, - 194, - 218, - 8, - 182, - 83, - 3, - 69, - 230, - 99, - 143, - 96, - 63, - 54, - 49, - 170, - 42, - 186, - 128, - 143, - 177, - 157, - 236, - 50, - 113, - 76 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "token_mint", - "writable": true - }, - { - "name": "platform_prototype", - "writable": true, - "address": "933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL" - }, - { - "name": "platform_prototype_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "platform_prototype" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "const", - "value": [ - 40, - 82, - 144, - 230, - 223, - 30, - 203, - 194, - 218, - 8, - 182, - 83, - 3, - 69, - 230, - 99, - 143, - 96, - 63, - 54, - 49, - 170, - 42, - 186, - 128, - 143, - 177, - 157, - 236, - 50, - 113, - 76 - ] - } - ], - "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": "vpool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "token_mint" - } - ] - } - }, - { - "name": "token_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "metadata_program" - }, - { - "kind": "account", - "path": "token_mint" - } - ], - "program": { - "kind": "const", - "value": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - } - } - }, - { - "name": "metadata_program", - "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - } - ], - "args": [ - { - "name": "symbol", - "type": "string" - }, - { - "name": "name", - "type": "string" - }, - { - "name": "uri", - "type": "string" - } - ] - }, - { - "name": "sell", - "discriminator": [ - 51, - 230, - 133, - 164, - 1, - 127, - 131, - 173 - ], - "accounts": [ - { - "name": "user", - "signer": true - }, - { - "name": "vpool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "token_mint" - } - ] - } - }, - { - "name": "token_mint" - }, - { - "name": "user_virtuals_ata", - "writable": true - }, - { - "name": "user_token_ata", - "writable": true - }, - { - "name": "vpool_token_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "token_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": "platform_prototype", - "writable": true, - "address": "933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL" - }, - { - "name": "platform_prototype_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "platform_prototype" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "const", - "value": [ - 40, - 82, - 144, - 230, - 223, - 30, - 203, - 194, - 218, - 8, - 182, - 83, - 3, - 69, - 230, - 99, - 143, - 96, - 63, - 54, - 49, - 170, - 42, - 186, - 128, - 143, - 177, - 157, - 236, - 50, - 113, - 76 - ] - } - ], - "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": "vpool_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "vpool" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "const", - "value": [ - 40, - 82, - 144, - 230, - 223, - 30, - 203, - 194, - 218, - 8, - 182, - 83, - 3, - 69, - 230, - 99, - 143, - 96, - 63, - 54, - 49, - 170, - 42, - 186, - 128, - 143, - 177, - 157, - 236, - 50, - 113, - 76 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "min_amount_out", - "type": "u64" - } - ] - }, - { - "name": "update_pool_creator", - "discriminator": [ - 113, - 225, - 166, - 185, - 94, - 231, - 96, - 28 - ], - "accounts": [ - { - "name": "creator", - "writable": true, - "signer": true, - "relations": [ - "vpool" - ] - }, - { - "name": "new_creator" - }, - { - "name": "virtuals_mint", - "address": "3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y" - }, - { - "name": "token_mint" - }, - { - "name": "new_creator_virtuals_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "new_creator" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "virtuals_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": "new_creator_token_ata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "new_creator" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "token_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": "vpool", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "account", - "path": "token_mint" - } - ] - } - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - } - ], - "accounts": [ - { - "name": "VirtualsPool", - "discriminator": [ - 71, - 118, - 5, - 203, - 5, - 98, - 135, - 116 - ] - } - ], - "events": [ - { - "name": "BuyEvent", - "discriminator": [ - 103, - 244, - 82, - 31, - 44, - 245, - 119, - 119 - ] - }, - { - "name": "GraduationEvent", - "discriminator": [ - 10, - 246, - 223, - 127, - 48, - 98, - 149, - 55 - ] - }, - { - "name": "LaunchEvent", - "discriminator": [ - 27, - 193, - 47, - 130, - 115, - 92, - 239, - 94 - ] - }, - { - "name": "SellEvent", - "discriminator": [ - 62, - 47, - 55, - 10, - 165, - 3, - 220, - 42 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "InvalidMintAddress", - "msg": "Invalid mint address" - }, - { - "code": 6001, - "name": "InvalidMintParams", - "msg": "Invalid mint params" - }, - { - "code": 6002, - "name": "CurveError", - "msg": "Curve error" - }, - { - "code": 6003, - "name": "InvalidFee", - "msg": "Fee cannot exceed 100%" - }, - { - "code": 6004, - "name": "NameTooLong", - "msg": "Name too long. Max length = 20" - }, - { - "code": 6005, - "name": "SymbolTooLong", - "msg": "Symbol too long. Max length = 10" - }, - { - "code": 6006, - "name": "URITooLong", - "msg": "URI too long. Max length = 200" - }, - { - "code": 6007, - "name": "InvalidAmount", - "msg": "Amount must be >0" - }, - { - "code": 6008, - "name": "SlippageExceeded", - "msg": "Slippage exceeded" - }, - { - "code": 6009, - "name": "InvalidVPoolState", - "msg": "Invalid vpool state" - }, - { - "code": 6010, - "name": "InvalidName", - "msg": "Invalid name" - }, - { - "code": 6011, - "name": "InvalidSymbol", - "msg": "Invalid symbol" - }, - { - "code": 6012, - "name": "InvalidURI", - "msg": "Invalid URI" - } - ], - "types": [ - { - "name": "BuyEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "buy_amount", - "type": "u64" - }, - { - "name": "virtuals_amount", - "type": "u64" - } - ] - } - }, - { - "name": "GraduationEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "vpool", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "balance", - "type": "u64" - } - ] - } - }, - { - "name": "LaunchEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "vpool", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "creator", - "type": "pubkey" - } - ] - } - }, - { - "name": "PoolState", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Initialized" - }, - { - "name": "Active" - }, - { - "name": "Graduated" - }, - { - "name": "Migrated" - } - ] - } - }, - { - "name": "SellEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "sell_amount", - "type": "u64" - }, - { - "name": "virtuals_amount", - "type": "u64" - } - ] - } - }, - { - "name": "VirtualsPool", - "type": { - "kind": "struct", - "fields": [ - { - "name": "creator", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "virtual_y", - "type": "u64" - }, - { - "name": "graduation_x", - "type": "u64" - }, - { - "name": "state", - "type": { - "defined": { - "name": "PoolState" - } - } - }, - { - "name": "bump", - "type": "u8" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/crates/virtuals-parser/proto/virtuals.proto b/crates/virtuals-parser/proto/virtuals.proto deleted file mode 100644 index 9e36d9c2..00000000 --- a/crates/virtuals-parser/proto/virtuals.proto +++ /dev/null @@ -1,302 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! -syntax = "proto3"; - -package vixen.parser.virtuals; - -message BuyIx { - BuyIxAccounts accounts = 1; - BuyIxData data = 2; -} - -message ClaimFeesIx { - ClaimFeesIxAccounts accounts = 1; -} - -message CreateMeteoraPoolIx { - CreateMeteoraPoolIxAccounts accounts = 1; -} - -message InitializeIx { - InitializeIxAccounts accounts = 1; -} - -message InitializeMeteoraAccountsIx { - InitializeMeteoraAccountsIxAccounts accounts = 1; -} - -message LaunchIx { - LaunchIxAccounts accounts = 1; - LaunchIxData data = 2; -} - -message SellIx { - SellIxAccounts accounts = 1; - SellIxData data = 2; -} - -message UpdatePoolCreatorIx { - UpdatePoolCreatorIxAccounts accounts = 1; -} - - -message BuyEvent { - uint64 buy_amount = 1; - uint64 virtuals_amount = 2; -} - -message GraduationEvent { - string vpool = 1; - string mint = 2; - uint64 balance = 3; -} - -message LaunchEvent { - string vpool = 1; - string mint = 2; - string creator = 3; -} - -enum PoolState { - PoolStateInitialized = 0; - PoolStateActive = 1; - PoolStateGraduated = 2; - PoolStateMigrated = 3; -} - -message SellEvent { - uint64 sell_amount = 1; - uint64 virtuals_amount = 2; -} - - -message VirtualsPool { - string creator = 1; - string mint = 2; - uint64 virtual_y = 3; - uint64 graduation_x = 4; - PoolState state = 5; - uint32 bump = 6; -} - - -message BuyIxAccounts { - string user = 1; - string vpool = 2; - string token_mint = 3; - string user_virtuals_ata = 4; - string user_token_ata = 5; - string vpool_token_ata = 6; - string platform_prototype = 7; - string platform_prototype_virtuals_ata = 8; - string vpool_virtuals_ata = 9; - string token_program = 10; -} - -message BuyIxData { - uint64 amount = 1; - uint64 max_amount_out = 2; -} - -message ClaimFeesIxAccounts { - string payer = 1; - string vpool = 2; - string virtuals_mint = 3; - string token_mint = 4; - string vpool_virtuals_ata = 5; - string vpool_token_ata = 6; - string platform = 7; - string platform_virtuals_ata = 8; - string platform_token_ata = 9; - string creator_virtuals_ata = 10; - string creator_token_ata = 11; - string pool = 12; - string lp_mint = 13; - string lock_escrow = 14; - string escrow_vault = 15; - string token_program = 16; - string virtuals_vault = 17; - string token_vault = 18; - string virtuals_token_vault = 19; - string token_token_vault = 20; - string virtuals_vault_lp_mint = 21; - string token_vault_lp_mint = 22; - string virtuals_vault_lp = 23; - string token_vault_lp = 24; - string vault_program = 25; - string associated_token_program = 26; - string system_program = 27; - string dynamic_amm_program = 28; -} - - -message CreateMeteoraPoolIxAccounts { - string vpool = 1; - string meteora_deployer = 2; - string meteora_deployer_virtuals_ata = 3; - string meteora_deployer_token_ata = 4; - string vpool_virtuals_ata = 5; - string vpool_token_ata = 6; - string lock_escrow = 7; - string escrow_vault = 8; - string pool = 9; - string config = 10; - string lp_mint = 11; - string virtuals_mint = 12; - string token_mint = 13; - string virtuals_vault = 14; - string token_vault = 15; - string virtuals_token_vault = 16; - string token_token_vault = 17; - string virtuals_vault_lp_mint = 18; - string token_vault_lp_mint = 19; - string virtuals_vault_lp = 20; - string token_vault_lp = 21; - string pool_virtuals_ata = 22; - string pool_token_ata = 23; - string meteora_deployer_pool_lp = 24; - string protocol_virtuals_fee = 25; - string protocol_token_fee = 26; - string payer = 27; - string token_metadata = 28; - string rent = 29; - string mint_metadata = 30; - string metadata_program = 31; - string vault_program = 32; - string token_program = 33; - string associated_token_program = 34; - string system_program = 35; - string dynamic_amm_program = 36; -} - - -message InitializeIxAccounts { - string payer = 1; - string virtuals_mint = 2; - string token_mint = 3; - string vpool_virtuals_ata = 4; - string vpool_token_ata = 5; - string vpool = 6; - string token_program = 7; - string associated_token_program = 8; - string system_program = 9; -} - - -message InitializeMeteoraAccountsIxAccounts { - string vpool = 1; - string meteora_deployer = 2; - string meteora_deployer_virtuals_ata = 3; - string meteora_deployer_token_ata = 4; - string vpool_virtuals_ata = 5; - string vpool_token_ata = 6; - string lock_escrow = 7; - string escrow_vault = 8; - string pool = 9; - string config = 10; - string lp_mint = 11; - string virtuals_mint = 12; - string token_mint = 13; - string virtuals_vault = 14; - string token_vault = 15; - string virtuals_token_vault = 16; - string token_token_vault = 17; - string virtuals_vault_lp_mint = 18; - string token_vault_lp_mint = 19; - string virtuals_vault_lp = 20; - string token_vault_lp = 21; - string pool_virtuals_ata = 22; - string pool_token_ata = 23; - string meteora_deployer_pool_lp = 24; - string protocol_virtuals_fee = 25; - string protocol_token_fee = 26; - string payer = 27; - string token_metadata = 28; - string rent = 29; - string mint_metadata = 30; - string metadata_program = 31; - string vault_program = 32; - string token_program = 33; - string associated_token_program = 34; - string system_program = 35; - string dynamic_amm_program = 36; -} - - -message LaunchIxAccounts { - string creator = 1; - string creator_virtuals_ata = 2; - string token_mint = 3; - string platform_prototype = 4; - string platform_prototype_virtuals_ata = 5; - string vpool = 6; - string token_metadata = 7; - string metadata_program = 8; - string token_program = 9; - string associated_token_program = 10; - string system_program = 11; - string rent = 12; -} - -message LaunchIxData { - string symbol = 1; - string name = 2; - string uri = 3; -} - -message SellIxAccounts { - string user = 1; - string vpool = 2; - string token_mint = 3; - string user_virtuals_ata = 4; - string user_token_ata = 5; - string vpool_token_ata = 6; - string platform_prototype = 7; - string platform_prototype_virtuals_ata = 8; - string vpool_virtuals_ata = 9; - string token_program = 10; -} - -message SellIxData { - uint64 amount = 1; - uint64 min_amount_out = 2; -} - -message UpdatePoolCreatorIxAccounts { - string creator = 1; - string new_creator = 2; - string virtuals_mint = 3; - string token_mint = 4; - string new_creator_virtuals_ata = 5; - string new_creator_token_ata = 6; - string vpool = 7; - string token_program = 8; - string associated_token_program = 9; - string system_program = 10; -} - - - -message ProgramState { - oneof state_oneof { - VirtualsPool virtuals_pool = 1; - } -} - -message ProgramIxs { - oneof ix_oneof { - BuyIx buy = 1; - ClaimFeesIx claim_fees = 2; - CreateMeteoraPoolIx create_meteora_pool = 3; - InitializeIx initialize = 4; - InitializeMeteoraAccountsIx initialize_meteora_accounts = 5; - LaunchIx launch = 6; - SellIx sell = 7; - UpdatePoolCreatorIx update_pool_creator = 8; - } -} - diff --git a/crates/virtuals-parser/src/generated_parser/accounts_parser.rs b/crates/virtuals-parser/src/generated_parser/accounts_parser.rs deleted file mode 100644 index 6f5d57bc..00000000 --- a/crates/virtuals-parser/src/generated_parser/accounts_parser.rs +++ /dev/null @@ -1,142 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use crate::{accounts::VirtualsPool, deserialize_checked, ID}; - -/// VirtualsProgram Program State -#[allow(clippy::large_enum_variant)] -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum VirtualsProgramProgramState { - VirtualsPool(VirtualsPool), -} - -impl VirtualsProgramProgramState { - pub fn try_unpack(data_bytes: &[u8]) -> yellowstone_vixen_core::ParseResult { - let acc_discriminator: [u8; 8] = data_bytes[0..8].try_into()?; - let acc = match acc_discriminator { - [71, 118, 5, 203, 5, 98, 135, 116] => Ok(VirtualsProgramProgramState::VirtualsPool( - deserialize_checked(data_bytes, &acc_discriminator)?, - )), - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Account discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &acc { - Ok(acc) => { - tracing::info!( - name: "correctly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = acc.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "error", - discriminator = ?acc_discriminator, - error = ?e - ); - }, - } - - acc - } -} - -#[derive(Debug, Copy, Clone)] -pub struct AccountParser; - -impl yellowstone_vixen_core::Parser for AccountParser { - type Input = yellowstone_vixen_core::AccountUpdate; - type Output = VirtualsProgramProgramState; - - fn id(&self) -> std::borrow::Cow<'static, str> { "virtuals_program::AccountParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .account_owners([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - acct: &yellowstone_vixen_core::AccountUpdate, - ) -> yellowstone_vixen_core::ParseResult { - let inner = acct - .account - .as_ref() - .ok_or(solana_program_error::ProgramError::InvalidArgument)?; - let res = VirtualsProgramProgramState::try_unpack(&inner.data); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let acc_discriminator: [u8; 8] = inner.data[0..8].try_into()?; - tracing::info!( - name: "incorrectly_parsed_account", - name = "account_update", - program = ID.to_string(), - account = "deserialization_error", - discriminator = ?acc_discriminator, - error = ?e - ); - } - - res - } -} - -impl yellowstone_vixen_core::ProgramParser for AccountParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{AccountParser, VirtualsPool, VirtualsProgramProgramState}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for VirtualsPool { - fn into_proto(self) -> proto_def::VirtualsPool { - proto_def::VirtualsPool { - creator: self.creator.to_string(), - mint: self.mint.to_string(), - virtual_y: self.virtual_y, - graduation_x: self.graduation_x, - state: self.state as i32, - bump: self.bump.into(), - } - } - } - - impl IntoProto for VirtualsProgramProgramState { - fn into_proto(self) -> proto_def::ProgramState { - let state_oneof = match self { - VirtualsProgramProgramState::VirtualsPool(data) => { - proto_def::program_state::StateOneof::VirtualsPool(data.into_proto()) - }, - }; - - proto_def::ProgramState { - state_oneof: Some(state_oneof), - } - } - } - - impl ParseProto for AccountParser { - type Message = proto_def::ProgramState; - - fn output_into_message(value: Self::Output) -> Self::Message { value.into_proto() } - } -} diff --git a/crates/virtuals-parser/src/generated_parser/instructions_parser.rs b/crates/virtuals-parser/src/generated_parser/instructions_parser.rs deleted file mode 100644 index ff44476b..00000000 --- a/crates/virtuals-parser/src/generated_parser/instructions_parser.rs +++ /dev/null @@ -1,727 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "shared-data")] -use std::sync::Arc; - -#[cfg(feature = "shared-data")] -use yellowstone_vixen_core::InstructionUpdateOutput; - -use crate::{ - deserialize_checked, - instructions::{ - Buy as BuyIxAccounts, BuyInstructionArgs as BuyIxData, ClaimFees as ClaimFeesIxAccounts, - CreateMeteoraPool as CreateMeteoraPoolIxAccounts, Initialize as InitializeIxAccounts, - InitializeMeteoraAccounts as InitializeMeteoraAccountsIxAccounts, - Launch as LaunchIxAccounts, LaunchInstructionArgs as LaunchIxData, Sell as SellIxAccounts, - SellInstructionArgs as SellIxData, UpdatePoolCreator as UpdatePoolCreatorIxAccounts, - }, - ID, -}; - -/// VirtualsProgram Instructions -#[derive(Debug)] -#[cfg_attr(feature = "tracing", derive(strum_macros::Display))] -pub enum VirtualsProgramProgramIx { - Buy(BuyIxAccounts, BuyIxData), - ClaimFees(ClaimFeesIxAccounts), - CreateMeteoraPool(CreateMeteoraPoolIxAccounts), - Initialize(InitializeIxAccounts), - InitializeMeteoraAccounts(InitializeMeteoraAccountsIxAccounts), - Launch(LaunchIxAccounts, LaunchIxData), - Sell(SellIxAccounts, SellIxData), - UpdatePoolCreator(UpdatePoolCreatorIxAccounts), -} - -#[derive(Debug, Copy, Clone)] -pub struct InstructionParser; - -impl yellowstone_vixen_core::Parser for InstructionParser { - type Input = yellowstone_vixen_core::instruction::InstructionUpdate; - #[cfg(not(feature = "shared-data"))] - type Output = VirtualsProgramProgramIx; - #[cfg(feature = "shared-data")] - type Output = InstructionUpdateOutput; - - fn id(&self) -> std::borrow::Cow<'static, str> { "VirtualsProgram::InstructionParser".into() } - - fn prefilter(&self) -> yellowstone_vixen_core::Prefilter { - yellowstone_vixen_core::Prefilter::builder() - .transaction_accounts([ID]) - .build() - .unwrap() - } - - async fn parse( - &self, - ix_update: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult { - if ix_update.program.equals_ref(ID) { - let res = InstructionParser::parse_impl(ix_update); - - #[cfg(feature = "tracing")] - if let Err(e) = &res { - let ix_discriminator: [u8; 8] = ix_update.data[0..8].try_into()?; - - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "deserialization_error", - discriminator = ?ix_discriminator, - error = ?e - ); - } - - res - } else { - Err(yellowstone_vixen_core::ParseError::Filtered) - } - } -} - -impl yellowstone_vixen_core::ProgramParser for InstructionParser { - #[inline] - fn program_id(&self) -> yellowstone_vixen_core::Pubkey { ID.to_bytes().into() } -} - -impl InstructionParser { - pub(crate) fn parse_impl( - ix: &yellowstone_vixen_core::instruction::InstructionUpdate, - ) -> yellowstone_vixen_core::ParseResult<::Output> { - let accounts_len = ix.accounts.len(); - let accounts = &mut ix.accounts.iter(); - - #[cfg(feature = "shared-data")] - let shared_data = Arc::clone(&ix.shared); - - let ix_discriminator: [u8; 8] = ix.data[0..8].try_into()?; - let ix_data = &ix.data[8..]; - let ix = match ix_discriminator { - [102, 6, 61, 18, 1, 218, 235, 234] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = BuyIxAccounts { - user: next_account(accounts)?, - vpool: next_account(accounts)?, - token_mint: next_account(accounts)?, - user_virtuals_ata: next_account(accounts)?, - user_token_ata: next_account(accounts)?, - vpool_token_ata: next_account(accounts)?, - platform_prototype: next_account(accounts)?, - platform_prototype_virtuals_ata: next_account(accounts)?, - vpool_virtuals_ata: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: BuyIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VirtualsProgramProgramIx::Buy(ix_accounts, de_ix_data)) - }, - [82, 251, 233, 156, 12, 52, 184, 202] => { - let expected_accounts_len = 28; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = ClaimFeesIxAccounts { - payer: next_account(accounts)?, - vpool: next_account(accounts)?, - virtuals_mint: next_account(accounts)?, - token_mint: next_account(accounts)?, - vpool_virtuals_ata: next_account(accounts)?, - vpool_token_ata: next_account(accounts)?, - platform: next_account(accounts)?, - platform_virtuals_ata: next_account(accounts)?, - platform_token_ata: next_account(accounts)?, - creator_virtuals_ata: next_account(accounts)?, - creator_token_ata: next_account(accounts)?, - pool: next_account(accounts)?, - lp_mint: next_account(accounts)?, - lock_escrow: next_account(accounts)?, - escrow_vault: next_account(accounts)?, - token_program: next_account(accounts)?, - virtuals_vault: next_account(accounts)?, - token_vault: next_account(accounts)?, - virtuals_token_vault: next_account(accounts)?, - token_token_vault: next_account(accounts)?, - virtuals_vault_lp_mint: next_account(accounts)?, - token_vault_lp_mint: next_account(accounts)?, - virtuals_vault_lp: next_account(accounts)?, - token_vault_lp: next_account(accounts)?, - vault_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - dynamic_amm_program: next_account(accounts)?, - }; - Ok(VirtualsProgramProgramIx::ClaimFees(ix_accounts)) - }, - [246, 254, 33, 37, 225, 176, 41, 232] => { - let expected_accounts_len = 36; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = CreateMeteoraPoolIxAccounts { - vpool: next_account(accounts)?, - meteora_deployer: next_account(accounts)?, - meteora_deployer_virtuals_ata: next_account(accounts)?, - meteora_deployer_token_ata: next_account(accounts)?, - vpool_virtuals_ata: next_account(accounts)?, - vpool_token_ata: next_account(accounts)?, - lock_escrow: next_account(accounts)?, - escrow_vault: next_account(accounts)?, - pool: next_account(accounts)?, - config: next_account(accounts)?, - lp_mint: next_account(accounts)?, - virtuals_mint: next_account(accounts)?, - token_mint: next_account(accounts)?, - virtuals_vault: next_account(accounts)?, - token_vault: next_account(accounts)?, - virtuals_token_vault: next_account(accounts)?, - token_token_vault: next_account(accounts)?, - virtuals_vault_lp_mint: next_account(accounts)?, - token_vault_lp_mint: next_account(accounts)?, - virtuals_vault_lp: next_account(accounts)?, - token_vault_lp: next_account(accounts)?, - pool_virtuals_ata: next_account(accounts)?, - pool_token_ata: next_account(accounts)?, - meteora_deployer_pool_lp: next_account(accounts)?, - protocol_virtuals_fee: next_account(accounts)?, - protocol_token_fee: next_account(accounts)?, - payer: next_account(accounts)?, - token_metadata: next_account(accounts)?, - rent: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - dynamic_amm_program: next_account(accounts)?, - }; - Ok(VirtualsProgramProgramIx::CreateMeteoraPool(ix_accounts)) - }, - [175, 175, 109, 31, 13, 152, 155, 237] => { - let expected_accounts_len = 9; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeIxAccounts { - payer: next_account(accounts)?, - virtuals_mint: next_account(accounts)?, - token_mint: next_account(accounts)?, - vpool_virtuals_ata: next_account(accounts)?, - vpool_token_ata: next_account(accounts)?, - vpool: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(VirtualsProgramProgramIx::Initialize(ix_accounts)) - }, - [53, 12, 118, 158, 253, 239, 185, 214] => { - let expected_accounts_len = 36; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = InitializeMeteoraAccountsIxAccounts { - vpool: next_account(accounts)?, - meteora_deployer: next_account(accounts)?, - meteora_deployer_virtuals_ata: next_account(accounts)?, - meteora_deployer_token_ata: next_account(accounts)?, - vpool_virtuals_ata: next_account(accounts)?, - vpool_token_ata: next_account(accounts)?, - lock_escrow: next_account(accounts)?, - escrow_vault: next_account(accounts)?, - pool: next_account(accounts)?, - config: next_account(accounts)?, - lp_mint: next_account(accounts)?, - virtuals_mint: next_account(accounts)?, - token_mint: next_account(accounts)?, - virtuals_vault: next_account(accounts)?, - token_vault: next_account(accounts)?, - virtuals_token_vault: next_account(accounts)?, - token_token_vault: next_account(accounts)?, - virtuals_vault_lp_mint: next_account(accounts)?, - token_vault_lp_mint: next_account(accounts)?, - virtuals_vault_lp: next_account(accounts)?, - token_vault_lp: next_account(accounts)?, - pool_virtuals_ata: next_account(accounts)?, - pool_token_ata: next_account(accounts)?, - meteora_deployer_pool_lp: next_account(accounts)?, - protocol_virtuals_fee: next_account(accounts)?, - protocol_token_fee: next_account(accounts)?, - payer: next_account(accounts)?, - token_metadata: next_account(accounts)?, - rent: next_account(accounts)?, - mint_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - vault_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - dynamic_amm_program: next_account(accounts)?, - }; - Ok(VirtualsProgramProgramIx::InitializeMeteoraAccounts( - ix_accounts, - )) - }, - [153, 241, 93, 225, 22, 69, 74, 61] => { - let expected_accounts_len = 12; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = LaunchIxAccounts { - creator: next_account(accounts)?, - creator_virtuals_ata: next_account(accounts)?, - token_mint: next_account(accounts)?, - platform_prototype: next_account(accounts)?, - platform_prototype_virtuals_ata: next_account(accounts)?, - vpool: next_account(accounts)?, - token_metadata: next_account(accounts)?, - metadata_program: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - rent: next_account(accounts)?, - }; - let de_ix_data: LaunchIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VirtualsProgramProgramIx::Launch(ix_accounts, de_ix_data)) - }, - [51, 230, 133, 164, 1, 127, 131, 173] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = SellIxAccounts { - user: next_account(accounts)?, - vpool: next_account(accounts)?, - token_mint: next_account(accounts)?, - user_virtuals_ata: next_account(accounts)?, - user_token_ata: next_account(accounts)?, - vpool_token_ata: next_account(accounts)?, - platform_prototype: next_account(accounts)?, - platform_prototype_virtuals_ata: next_account(accounts)?, - vpool_virtuals_ata: next_account(accounts)?, - token_program: next_account(accounts)?, - }; - let de_ix_data: SellIxData = deserialize_checked(ix_data, &ix_discriminator)?; - Ok(VirtualsProgramProgramIx::Sell(ix_accounts, de_ix_data)) - }, - [113, 225, 166, 185, 94, 231, 96, 28] => { - let expected_accounts_len = 10; - check_min_accounts_req(accounts_len, expected_accounts_len)?; - let ix_accounts = UpdatePoolCreatorIxAccounts { - creator: next_account(accounts)?, - new_creator: next_account(accounts)?, - virtuals_mint: next_account(accounts)?, - token_mint: next_account(accounts)?, - new_creator_virtuals_ata: next_account(accounts)?, - new_creator_token_ata: next_account(accounts)?, - vpool: next_account(accounts)?, - token_program: next_account(accounts)?, - associated_token_program: next_account(accounts)?, - system_program: next_account(accounts)?, - }; - Ok(VirtualsProgramProgramIx::UpdatePoolCreator(ix_accounts)) - }, - _ => Err(yellowstone_vixen_core::ParseError::from( - "Invalid Instruction discriminator".to_owned(), - )), - }; - - #[cfg(feature = "tracing")] - match &ix { - Ok(ix) => { - tracing::info!( - name: "correctly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = ix.to_string() - ); - }, - Err(e) => { - tracing::info!( - name: "incorrectly_parsed_instruction", - name = "ix_update", - program = ID.to_string(), - ix = "error", - discriminator = ?ix_discriminator, - error = ?e - ); - }, - } - - #[cfg(not(feature = "shared-data"))] - return ix; - - #[cfg(feature = "shared-data")] - ix.map(|ix| InstructionUpdateOutput { - parsed_ix: ix, - shared_data, - }) - } -} - -pub fn check_min_accounts_req( - actual: usize, - expected: usize, -) -> yellowstone_vixen_core::ParseResult<()> { - if actual < expected { - Err(yellowstone_vixen_core::ParseError::from(format!( - "Too few accounts provided: expected {expected}, got {actual}" - ))) - } else { - Ok(()) - } -} - -fn next_account<'a, T: Iterator>>( - accounts: &mut T, -) -> Result { - accounts - .next() - .ok_or(yellowstone_vixen_core::ParseError::from( - "No more accounts to parse", - )) - .map(|acc| acc.0.into()) -} - -/// Gets the next optional account using the ommited account strategy (account is not passed at all at the instruction). -/// ### Be careful to use this function when more than one account is optional in the Instruction. -/// Only by order there is no way to which ones of the optional accounts are present. -pub fn next_optional_account<'a, T: Iterator>>( - accounts: &mut T, - actual_accounts_len: usize, - expected_accounts_len: &mut usize, -) -> Result, yellowstone_vixen_core::ParseError> { - if actual_accounts_len == *expected_accounts_len + 1 { - *expected_accounts_len += 1; - Ok(Some(next_account(accounts)?)) - } else { - Ok(None) - } -} - -/// Gets the next optional account using the traditional Program ID strategy. -/// (If account key is the program ID, means account is not present) -pub fn next_program_id_optional_account< - 'a, - T: Iterator>, ->( - accounts: &mut T, -) -> Result, yellowstone_vixen_core::ParseError> { - let account_key = next_account(accounts)?; - if account_key.eq(&ID) { - Ok(None) - } else { - Ok(Some(account_key)) - } -} - -// #[cfg(feature = "proto")] -mod proto_parser { - use yellowstone_vixen_core::proto::ParseProto; - - use super::{BuyIxAccounts, InstructionParser, VirtualsProgramProgramIx}; - use crate::{proto_def, proto_helpers::proto_types_parsers::IntoProto}; - impl IntoProto for BuyIxAccounts { - fn into_proto(self) -> proto_def::BuyIxAccounts { - proto_def::BuyIxAccounts { - user: self.user.to_string(), - vpool: self.vpool.to_string(), - token_mint: self.token_mint.to_string(), - user_virtuals_ata: self.user_virtuals_ata.to_string(), - user_token_ata: self.user_token_ata.to_string(), - vpool_token_ata: self.vpool_token_ata.to_string(), - platform_prototype: self.platform_prototype.to_string(), - platform_prototype_virtuals_ata: self.platform_prototype_virtuals_ata.to_string(), - vpool_virtuals_ata: self.vpool_virtuals_ata.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::BuyIxData; - impl IntoProto for BuyIxData { - fn into_proto(self) -> proto_def::BuyIxData { - proto_def::BuyIxData { - amount: self.amount, - max_amount_out: self.max_amount_out, - } - } - } - use super::ClaimFeesIxAccounts; - impl IntoProto for ClaimFeesIxAccounts { - fn into_proto(self) -> proto_def::ClaimFeesIxAccounts { - proto_def::ClaimFeesIxAccounts { - payer: self.payer.to_string(), - vpool: self.vpool.to_string(), - virtuals_mint: self.virtuals_mint.to_string(), - token_mint: self.token_mint.to_string(), - vpool_virtuals_ata: self.vpool_virtuals_ata.to_string(), - vpool_token_ata: self.vpool_token_ata.to_string(), - platform: self.platform.to_string(), - platform_virtuals_ata: self.platform_virtuals_ata.to_string(), - platform_token_ata: self.platform_token_ata.to_string(), - creator_virtuals_ata: self.creator_virtuals_ata.to_string(), - creator_token_ata: self.creator_token_ata.to_string(), - pool: self.pool.to_string(), - lp_mint: self.lp_mint.to_string(), - lock_escrow: self.lock_escrow.to_string(), - escrow_vault: self.escrow_vault.to_string(), - token_program: self.token_program.to_string(), - virtuals_vault: self.virtuals_vault.to_string(), - token_vault: self.token_vault.to_string(), - virtuals_token_vault: self.virtuals_token_vault.to_string(), - token_token_vault: self.token_token_vault.to_string(), - virtuals_vault_lp_mint: self.virtuals_vault_lp_mint.to_string(), - token_vault_lp_mint: self.token_vault_lp_mint.to_string(), - virtuals_vault_lp: self.virtuals_vault_lp.to_string(), - token_vault_lp: self.token_vault_lp.to_string(), - vault_program: self.vault_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - dynamic_amm_program: self.dynamic_amm_program.to_string(), - } - } - } - use super::CreateMeteoraPoolIxAccounts; - impl IntoProto for CreateMeteoraPoolIxAccounts { - fn into_proto(self) -> proto_def::CreateMeteoraPoolIxAccounts { - proto_def::CreateMeteoraPoolIxAccounts { - vpool: self.vpool.to_string(), - meteora_deployer: self.meteora_deployer.to_string(), - meteora_deployer_virtuals_ata: self.meteora_deployer_virtuals_ata.to_string(), - meteora_deployer_token_ata: self.meteora_deployer_token_ata.to_string(), - vpool_virtuals_ata: self.vpool_virtuals_ata.to_string(), - vpool_token_ata: self.vpool_token_ata.to_string(), - lock_escrow: self.lock_escrow.to_string(), - escrow_vault: self.escrow_vault.to_string(), - pool: self.pool.to_string(), - config: self.config.to_string(), - lp_mint: self.lp_mint.to_string(), - virtuals_mint: self.virtuals_mint.to_string(), - token_mint: self.token_mint.to_string(), - virtuals_vault: self.virtuals_vault.to_string(), - token_vault: self.token_vault.to_string(), - virtuals_token_vault: self.virtuals_token_vault.to_string(), - token_token_vault: self.token_token_vault.to_string(), - virtuals_vault_lp_mint: self.virtuals_vault_lp_mint.to_string(), - token_vault_lp_mint: self.token_vault_lp_mint.to_string(), - virtuals_vault_lp: self.virtuals_vault_lp.to_string(), - token_vault_lp: self.token_vault_lp.to_string(), - pool_virtuals_ata: self.pool_virtuals_ata.to_string(), - pool_token_ata: self.pool_token_ata.to_string(), - meteora_deployer_pool_lp: self.meteora_deployer_pool_lp.to_string(), - protocol_virtuals_fee: self.protocol_virtuals_fee.to_string(), - protocol_token_fee: self.protocol_token_fee.to_string(), - payer: self.payer.to_string(), - token_metadata: self.token_metadata.to_string(), - rent: self.rent.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - dynamic_amm_program: self.dynamic_amm_program.to_string(), - } - } - } - use super::InitializeIxAccounts; - impl IntoProto for InitializeIxAccounts { - fn into_proto(self) -> proto_def::InitializeIxAccounts { - proto_def::InitializeIxAccounts { - payer: self.payer.to_string(), - virtuals_mint: self.virtuals_mint.to_string(), - token_mint: self.token_mint.to_string(), - vpool_virtuals_ata: self.vpool_virtuals_ata.to_string(), - vpool_token_ata: self.vpool_token_ata.to_string(), - vpool: self.vpool.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - use super::InitializeMeteoraAccountsIxAccounts; - impl IntoProto - for InitializeMeteoraAccountsIxAccounts - { - fn into_proto(self) -> proto_def::InitializeMeteoraAccountsIxAccounts { - proto_def::InitializeMeteoraAccountsIxAccounts { - vpool: self.vpool.to_string(), - meteora_deployer: self.meteora_deployer.to_string(), - meteora_deployer_virtuals_ata: self.meteora_deployer_virtuals_ata.to_string(), - meteora_deployer_token_ata: self.meteora_deployer_token_ata.to_string(), - vpool_virtuals_ata: self.vpool_virtuals_ata.to_string(), - vpool_token_ata: self.vpool_token_ata.to_string(), - lock_escrow: self.lock_escrow.to_string(), - escrow_vault: self.escrow_vault.to_string(), - pool: self.pool.to_string(), - config: self.config.to_string(), - lp_mint: self.lp_mint.to_string(), - virtuals_mint: self.virtuals_mint.to_string(), - token_mint: self.token_mint.to_string(), - virtuals_vault: self.virtuals_vault.to_string(), - token_vault: self.token_vault.to_string(), - virtuals_token_vault: self.virtuals_token_vault.to_string(), - token_token_vault: self.token_token_vault.to_string(), - virtuals_vault_lp_mint: self.virtuals_vault_lp_mint.to_string(), - token_vault_lp_mint: self.token_vault_lp_mint.to_string(), - virtuals_vault_lp: self.virtuals_vault_lp.to_string(), - token_vault_lp: self.token_vault_lp.to_string(), - pool_virtuals_ata: self.pool_virtuals_ata.to_string(), - pool_token_ata: self.pool_token_ata.to_string(), - meteora_deployer_pool_lp: self.meteora_deployer_pool_lp.to_string(), - protocol_virtuals_fee: self.protocol_virtuals_fee.to_string(), - protocol_token_fee: self.protocol_token_fee.to_string(), - payer: self.payer.to_string(), - token_metadata: self.token_metadata.to_string(), - rent: self.rent.to_string(), - mint_metadata: self.mint_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - vault_program: self.vault_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - dynamic_amm_program: self.dynamic_amm_program.to_string(), - } - } - } - use super::LaunchIxAccounts; - impl IntoProto for LaunchIxAccounts { - fn into_proto(self) -> proto_def::LaunchIxAccounts { - proto_def::LaunchIxAccounts { - creator: self.creator.to_string(), - creator_virtuals_ata: self.creator_virtuals_ata.to_string(), - token_mint: self.token_mint.to_string(), - platform_prototype: self.platform_prototype.to_string(), - platform_prototype_virtuals_ata: self.platform_prototype_virtuals_ata.to_string(), - vpool: self.vpool.to_string(), - token_metadata: self.token_metadata.to_string(), - metadata_program: self.metadata_program.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - rent: self.rent.to_string(), - } - } - } - use super::LaunchIxData; - impl IntoProto for LaunchIxData { - fn into_proto(self) -> proto_def::LaunchIxData { - proto_def::LaunchIxData { - symbol: self.symbol, - name: self.name, - uri: self.uri, - } - } - } - use super::SellIxAccounts; - impl IntoProto for SellIxAccounts { - fn into_proto(self) -> proto_def::SellIxAccounts { - proto_def::SellIxAccounts { - user: self.user.to_string(), - vpool: self.vpool.to_string(), - token_mint: self.token_mint.to_string(), - user_virtuals_ata: self.user_virtuals_ata.to_string(), - user_token_ata: self.user_token_ata.to_string(), - vpool_token_ata: self.vpool_token_ata.to_string(), - platform_prototype: self.platform_prototype.to_string(), - platform_prototype_virtuals_ata: self.platform_prototype_virtuals_ata.to_string(), - vpool_virtuals_ata: self.vpool_virtuals_ata.to_string(), - token_program: self.token_program.to_string(), - } - } - } - use super::SellIxData; - impl IntoProto for SellIxData { - fn into_proto(self) -> proto_def::SellIxData { - proto_def::SellIxData { - amount: self.amount, - min_amount_out: self.min_amount_out, - } - } - } - use super::UpdatePoolCreatorIxAccounts; - impl IntoProto for UpdatePoolCreatorIxAccounts { - fn into_proto(self) -> proto_def::UpdatePoolCreatorIxAccounts { - proto_def::UpdatePoolCreatorIxAccounts { - creator: self.creator.to_string(), - new_creator: self.new_creator.to_string(), - virtuals_mint: self.virtuals_mint.to_string(), - token_mint: self.token_mint.to_string(), - new_creator_virtuals_ata: self.new_creator_virtuals_ata.to_string(), - new_creator_token_ata: self.new_creator_token_ata.to_string(), - vpool: self.vpool.to_string(), - token_program: self.token_program.to_string(), - associated_token_program: self.associated_token_program.to_string(), - system_program: self.system_program.to_string(), - } - } - } - - impl IntoProto for VirtualsProgramProgramIx { - fn into_proto(self) -> proto_def::ProgramIxs { - match self { - VirtualsProgramProgramIx::Buy(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Buy(proto_def::BuyIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - VirtualsProgramProgramIx::ClaimFees(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::ClaimFees( - proto_def::ClaimFeesIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - VirtualsProgramProgramIx::CreateMeteoraPool(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::CreateMeteoraPool( - proto_def::CreateMeteoraPoolIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - VirtualsProgramProgramIx::Initialize(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Initialize( - proto_def::InitializeIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - VirtualsProgramProgramIx::InitializeMeteoraAccounts(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::InitializeMeteoraAccounts( - proto_def::InitializeMeteoraAccountsIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - VirtualsProgramProgramIx::Launch(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Launch( - proto_def::LaunchIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - }, - )), - }, - VirtualsProgramProgramIx::Sell(acc, data) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::Sell(proto_def::SellIx { - accounts: Some(acc.into_proto()), - data: Some(data.into_proto()), - })), - }, - VirtualsProgramProgramIx::UpdatePoolCreator(acc) => proto_def::ProgramIxs { - ix_oneof: Some(proto_def::program_ixs::IxOneof::UpdatePoolCreator( - proto_def::UpdatePoolCreatorIx { - accounts: Some(acc.into_proto()), - }, - )), - }, - } - } - } - - impl ParseProto for InstructionParser { - type Message = proto_def::ProgramIxs; - - fn output_into_message(value: Self::Output) -> Self::Message { - #[cfg(not(feature = "shared-data"))] - return value.into_proto(); - - #[cfg(feature = "shared-data")] - value.parsed_ix.into_proto() - } - } -} diff --git a/crates/virtuals-parser/src/generated_parser/mod.rs b/crates/virtuals-parser/src/generated_parser/mod.rs deleted file mode 100644 index e4c7b5b2..00000000 --- a/crates/virtuals-parser/src/generated_parser/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts_parser; - -pub mod instructions_parser; - -pub mod proto_helpers; - -/// Deserialize a Borsh-encoded account, checking that all significant bytes are read. -pub fn deserialize_checked( - data: &[u8], - _discriminator: &[u8], -) -> Result { - let mut data_bytes = data; - let account = T::deserialize(&mut data_bytes)?; - - if !data_bytes.is_empty() && data_bytes.iter().any(|b| *b != 0) { - #[cfg(feature = "tracing")] - tracing::warn!( - name: "non_zeroed_end_bytes", - name = "non_zeroed_end_bytes", - length = data_bytes.len(), - program = crate::ID.to_string(), - type_name = ?_discriminator, - ); - } - - Ok(account) -} diff --git a/crates/virtuals-parser/src/generated_parser/proto_helpers.rs b/crates/virtuals-parser/src/generated_parser/proto_helpers.rs deleted file mode 100644 index 222cc194..00000000 --- a/crates/virtuals-parser/src/generated_parser/proto_helpers.rs +++ /dev/null @@ -1,50 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -// #[cfg(feature = "proto")] -pub mod proto_types_parsers { - use yellowstone_vixen_core::proto_helper_traits; - proto_helper_traits!(); - use crate::{proto_def, types::BuyEvent}; - impl IntoProto for BuyEvent { - fn into_proto(self) -> proto_def::BuyEvent { - proto_def::BuyEvent { - buy_amount: self.buy_amount, - virtuals_amount: self.virtuals_amount, - } - } - } - use crate::types::GraduationEvent; - impl IntoProto for GraduationEvent { - fn into_proto(self) -> proto_def::GraduationEvent { - proto_def::GraduationEvent { - vpool: self.vpool.to_string(), - mint: self.mint.to_string(), - balance: self.balance, - } - } - } - use crate::types::LaunchEvent; - impl IntoProto for LaunchEvent { - fn into_proto(self) -> proto_def::LaunchEvent { - proto_def::LaunchEvent { - vpool: self.vpool.to_string(), - mint: self.mint.to_string(), - creator: self.creator.to_string(), - } - } - } - use crate::types::SellEvent; - impl IntoProto for SellEvent { - fn into_proto(self) -> proto_def::SellEvent { - proto_def::SellEvent { - sell_amount: self.sell_amount, - virtuals_amount: self.virtuals_amount, - } - } - } -} diff --git a/crates/virtuals-parser/src/generated_sdk/accounts/mod.rs b/crates/virtuals-parser/src/generated_sdk/accounts/mod.rs deleted file mode 100644 index ade69f88..00000000 --- a/crates/virtuals-parser/src/generated_sdk/accounts/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#virtuals_pool; - -pub use self::r#virtuals_pool::*; diff --git a/crates/virtuals-parser/src/generated_sdk/accounts/virtuals_pool.rs b/crates/virtuals-parser/src/generated_sdk/accounts/virtuals_pool.rs deleted file mode 100644 index d9744bbb..00000000 --- a/crates/virtuals-parser/src/generated_sdk/accounts/virtuals_pool.rs +++ /dev/null @@ -1,143 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -use crate::generated::types::PoolState; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct VirtualsPool { - pub discriminator: [u8; 8], - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub virtual_y: u64, - pub graduation_x: u64, - pub state: PoolState, - pub bump: u8, -} - -impl VirtualsPool { - pub const LEN: usize = 90; - - #[inline(always)] - pub fn from_bytes(data: &[u8]) -> Result { - let mut data = data; - Self::deserialize(&mut data) - } -} - -impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for VirtualsPool { - type Error = std::io::Error; - - fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { - let mut data: &[u8] = &(*account_info.data).borrow(); - Self::deserialize(&mut data) - } -} - -#[cfg(feature = "fetch")] -pub fn fetch_virtuals_pool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_virtuals_pool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_virtuals_pool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - let account = accounts[i].as_ref().ok_or(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Account not found: {}", address), - ))?; - let data = VirtualsPool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }); - } - Ok(decoded_accounts) -} - -#[cfg(feature = "fetch")] -pub fn fetch_maybe_virtuals_pool( - rpc: &solana_client::rpc_client::RpcClient, - address: &solana_pubkey::Pubkey, -) -> Result, std::io::Error> { - let accounts = fetch_all_maybe_virtuals_pool(rpc, &[*address])?; - Ok(accounts[0].clone()) -} - -#[cfg(feature = "fetch")] -pub fn fetch_all_maybe_virtuals_pool( - rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_pubkey::Pubkey], -) -> Result>, std::io::Error> { - let accounts = rpc - .get_multiple_accounts(addresses) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let mut decoded_accounts: Vec> = Vec::new(); - for i in 0..addresses.len() { - let address = addresses[i]; - if let Some(account) = accounts[i].as_ref() { - let data = VirtualsPool::from_bytes(&account.data)?; - decoded_accounts.push(crate::shared::MaybeAccount::Exists( - crate::shared::DecodedAccount { - address, - account: account.clone(), - data, - }, - )); - } else { - decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address)); - } - } - Ok(decoded_accounts) -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountDeserialize for VirtualsPool { - fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - Ok(Self::deserialize(buf)?) - } -} - -#[cfg(feature = "anchor")] -impl anchor_lang::AccountSerialize for VirtualsPool {} - -#[cfg(feature = "anchor")] -impl anchor_lang::Owner for VirtualsPool { - fn owner() -> Pubkey { crate::VIRTUALS_PROGRAM_ID } -} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::IdlBuild for VirtualsPool {} - -#[cfg(feature = "anchor-idl-build")] -impl anchor_lang::Discriminator for VirtualsPool { - const DISCRIMINATOR: [u8; 8] = [0; 8]; -} diff --git a/crates/virtuals-parser/src/generated_sdk/errors/mod.rs b/crates/virtuals-parser/src/generated_sdk/errors/mod.rs deleted file mode 100644 index 2ee35fd5..00000000 --- a/crates/virtuals-parser/src/generated_sdk/errors/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod virtuals_program; - -pub use self::virtuals_program::VirtualsProgramError; diff --git a/crates/virtuals-parser/src/generated_sdk/errors/virtuals_program.rs b/crates/virtuals-parser/src/generated_sdk/errors/virtuals_program.rs deleted file mode 100644 index f4956720..00000000 --- a/crates/virtuals-parser/src/generated_sdk/errors/virtuals_program.rs +++ /dev/null @@ -1,64 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use num_derive::FromPrimitive; -use thiserror::Error; - -#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] -pub enum VirtualsProgramError { - /// 6000 - Invalid mint address - #[error("Invalid mint address")] - InvalidMintAddress = 0x1770, - /// 6001 - Invalid mint params - #[error("Invalid mint params")] - InvalidMintParams = 0x1771, - /// 6002 - Curve error - #[error("Curve error")] - CurveError = 0x1772, - /// 6003 - Fee cannot exceed 100% - #[error("Fee cannot exceed 100%")] - InvalidFee = 0x1773, - /// 6004 - Name too long. Max length = 20 - #[error("Name too long. Max length = 20")] - NameTooLong = 0x1774, - /// 6005 - Symbol too long. Max length = 10 - #[error("Symbol too long. Max length = 10")] - SymbolTooLong = 0x1775, - /// 6006 - URI too long. Max length = 200 - #[error("URI too long. Max length = 200")] - URITooLong = 0x1776, - /// 6007 - Amount must be >0 - #[error("Amount must be >0")] - InvalidAmount = 0x1777, - /// 6008 - Slippage exceeded - #[error("Slippage exceeded")] - SlippageExceeded = 0x1778, - /// 6009 - Invalid vpool state - #[error("Invalid vpool state")] - InvalidVPoolState = 0x1779, - /// 6010 - Invalid name - #[error("Invalid name")] - InvalidName = 0x177a, - /// 6011 - Invalid symbol - #[error("Invalid symbol")] - InvalidSymbol = 0x177b, - /// 6012 - Invalid URI - #[error("Invalid URI")] - InvalidURI = 0x177c, -} - -#[allow(deprecated)] -impl solana_program_error::PrintProgramError for VirtualsProgramError { - fn print(&self) { - solana_msg::msg!(&self.to_string()); - } -} - -#[allow(deprecated)] -impl solana_decode_error::DecodeError for VirtualsProgramError { - fn type_of() -> &'static str { "VirtualsProgramError" } -} diff --git a/crates/virtuals-parser/src/generated_sdk/instructions/buy.rs b/crates/virtuals-parser/src/generated_sdk/instructions/buy.rs deleted file mode 100644 index 048c7789..00000000 --- a/crates/virtuals-parser/src/generated_sdk/instructions/buy.rs +++ /dev/null @@ -1,716 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Buy { - pub user: solana_pubkey::Pubkey, - - pub vpool: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub user_virtuals_ata: solana_pubkey::Pubkey, - - pub user_token_ata: solana_pubkey::Pubkey, - - pub vpool_token_ata: solana_pubkey::Pubkey, - - pub platform_prototype: solana_pubkey::Pubkey, - - pub platform_prototype_virtuals_ata: solana_pubkey::Pubkey, - - pub vpool_virtuals_ata: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl Buy { - pub fn instruction(&self, args: BuyInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: BuyInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.vpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_prototype, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_prototype_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&BuyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyInstructionData { - discriminator: [u8; 8], -} - -impl BuyInstructionData { - pub fn new() -> Self { - Self { - discriminator: [102, 6, 61, 18, 1, 218, 235, 234], - } - } -} - -impl Default for BuyInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyInstructionArgs { - pub amount: u64, - pub max_amount_out: u64, -} - -/// Instruction builder for `Buy`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` user -/// 1. `[writable]` vpool -/// 2. `[]` token_mint -/// 3. `[writable]` user_virtuals_ata -/// 4. `[writable]` user_token_ata -/// 5. `[writable]` vpool_token_ata -/// 6. `[writable, optional]` platform_prototype (default to `933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL`) -/// 7. `[writable]` platform_prototype_virtuals_ata -/// 8. `[writable]` vpool_virtuals_ata -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct BuyBuilder { - user: Option, - vpool: Option, - token_mint: Option, - user_virtuals_ata: Option, - user_token_ata: Option, - vpool_token_ata: Option, - platform_prototype: Option, - platform_prototype_virtuals_ata: Option, - vpool_virtuals_ata: Option, - token_program: Option, - amount: Option, - max_amount_out: Option, - __remaining_accounts: Vec, -} - -impl BuyBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: solana_pubkey::Pubkey) -> &mut Self { - self.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn user_virtuals_ata(&mut self, user_virtuals_ata: solana_pubkey::Pubkey) -> &mut Self { - self.user_virtuals_ata = Some(user_virtuals_ata); - self - } - - #[inline(always)] - pub fn user_token_ata(&mut self, user_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_ata = Some(user_token_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata(&mut self, vpool_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_token_ata = Some(vpool_token_ata); - self - } - - /// `[optional account, default to '933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL']` - #[inline(always)] - pub fn platform_prototype(&mut self, platform_prototype: solana_pubkey::Pubkey) -> &mut Self { - self.platform_prototype = Some(platform_prototype); - self - } - - #[inline(always)] - pub fn platform_prototype_virtuals_ata( - &mut self, - platform_prototype_virtuals_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.platform_prototype_virtuals_ata = Some(platform_prototype_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata(&mut self, vpool_virtuals_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn max_amount_out(&mut self, max_amount_out: u64) -> &mut Self { - self.max_amount_out = Some(max_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Buy { - user: self.user.expect("user is not set"), - vpool: self.vpool.expect("vpool is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - user_virtuals_ata: self - .user_virtuals_ata - .expect("user_virtuals_ata is not set"), - user_token_ata: self.user_token_ata.expect("user_token_ata is not set"), - vpool_token_ata: self.vpool_token_ata.expect("vpool_token_ata is not set"), - platform_prototype: self.platform_prototype.unwrap_or(solana_pubkey::pubkey!( - "933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL" - )), - platform_prototype_virtuals_ata: self - .platform_prototype_virtuals_ata - .expect("platform_prototype_virtuals_ata is not set"), - vpool_virtuals_ata: self - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = BuyInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - max_amount_out: self - .max_amount_out - .clone() - .expect("max_amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `buy` CPI accounts. -pub struct BuyCpiAccounts<'a, 'b> { - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `buy` CPI instruction. -pub struct BuyCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: BuyInstructionArgs, -} - -impl<'a, 'b> BuyCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: BuyCpiAccounts<'a, 'b>, - args: BuyInstructionArgs, - ) -> Self { - Self { - __program: program, - user: accounts.user, - vpool: accounts.vpool, - token_mint: accounts.token_mint, - user_virtuals_ata: accounts.user_virtuals_ata, - user_token_ata: accounts.user_token_ata, - vpool_token_ata: accounts.vpool_token_ata, - platform_prototype: accounts.platform_prototype, - platform_prototype_virtuals_ata: accounts.platform_prototype_virtuals_ata, - vpool_virtuals_ata: accounts.vpool_virtuals_ata, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.vpool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_prototype.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_prototype_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&BuyInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.vpool.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.user_virtuals_ata.clone()); - account_infos.push(self.user_token_ata.clone()); - account_infos.push(self.vpool_token_ata.clone()); - account_infos.push(self.platform_prototype.clone()); - account_infos.push(self.platform_prototype_virtuals_ata.clone()); - account_infos.push(self.vpool_virtuals_ata.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Buy` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` user -/// 1. `[writable]` vpool -/// 2. `[]` token_mint -/// 3. `[writable]` user_virtuals_ata -/// 4. `[writable]` user_token_ata -/// 5. `[writable]` vpool_token_ata -/// 6. `[writable]` platform_prototype -/// 7. `[writable]` platform_prototype_virtuals_ata -/// 8. `[writable]` vpool_virtuals_ata -/// 9. `[]` token_program -#[derive(Clone, Debug)] -pub struct BuyCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> BuyCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(BuyCpiBuilderInstruction { - __program: program, - user: None, - vpool: None, - token_mint: None, - user_virtuals_ata: None, - user_token_ata: None, - vpool_token_ata: None, - platform_prototype: None, - platform_prototype_virtuals_ata: None, - vpool_virtuals_ata: None, - token_program: None, - amount: None, - max_amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn user_virtuals_ata( - &mut self, - user_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_virtuals_ata = Some(user_virtuals_ata); - self - } - - #[inline(always)] - pub fn user_token_ata( - &mut self, - user_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_ata = Some(user_token_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata( - &mut self, - vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_token_ata = Some(vpool_token_ata); - self - } - - #[inline(always)] - pub fn platform_prototype( - &mut self, - platform_prototype: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_prototype = Some(platform_prototype); - self - } - - #[inline(always)] - pub fn platform_prototype_virtuals_ata( - &mut self, - platform_prototype_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_prototype_virtuals_ata = Some(platform_prototype_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata( - &mut self, - vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn max_amount_out(&mut self, max_amount_out: u64) -> &mut Self { - self.instruction.max_amount_out = Some(max_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = BuyInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - max_amount_out: self - .instruction - .max_amount_out - .clone() - .expect("max_amount_out is not set"), - }; - let instruction = BuyCpi { - __program: self.instruction.__program, - - user: self.instruction.user.expect("user is not set"), - - vpool: self.instruction.vpool.expect("vpool is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - user_virtuals_ata: self - .instruction - .user_virtuals_ata - .expect("user_virtuals_ata is not set"), - - user_token_ata: self - .instruction - .user_token_ata - .expect("user_token_ata is not set"), - - vpool_token_ata: self - .instruction - .vpool_token_ata - .expect("vpool_token_ata is not set"), - - platform_prototype: self - .instruction - .platform_prototype - .expect("platform_prototype is not set"), - - platform_prototype_virtuals_ata: self - .instruction - .platform_prototype_virtuals_ata - .expect("platform_prototype_virtuals_ata is not set"), - - vpool_virtuals_ata: self - .instruction - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct BuyCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_prototype: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_prototype_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - max_amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/virtuals-parser/src/generated_sdk/instructions/claim_fees.rs b/crates/virtuals-parser/src/generated_sdk/instructions/claim_fees.rs deleted file mode 100644 index 33159452..00000000 --- a/crates/virtuals-parser/src/generated_sdk/instructions/claim_fees.rs +++ /dev/null @@ -1,1416 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct ClaimFees { - pub payer: solana_pubkey::Pubkey, - - pub vpool: solana_pubkey::Pubkey, - - pub virtuals_mint: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub vpool_virtuals_ata: solana_pubkey::Pubkey, - - pub vpool_token_ata: solana_pubkey::Pubkey, - - pub platform: solana_pubkey::Pubkey, - - pub platform_virtuals_ata: solana_pubkey::Pubkey, - - pub platform_token_ata: solana_pubkey::Pubkey, - - pub creator_virtuals_ata: solana_pubkey::Pubkey, - - pub creator_token_ata: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub lock_escrow: solana_pubkey::Pubkey, - - pub escrow_vault: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub virtuals_vault: solana_pubkey::Pubkey, - - pub token_vault: solana_pubkey::Pubkey, - - pub virtuals_token_vault: solana_pubkey::Pubkey, - - pub token_token_vault: solana_pubkey::Pubkey, - - pub virtuals_vault_lp_mint: solana_pubkey::Pubkey, - - pub token_vault_lp_mint: solana_pubkey::Pubkey, - - pub virtuals_vault_lp: solana_pubkey::Pubkey, - - pub token_vault_lp: solana_pubkey::Pubkey, - - pub vault_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub dynamic_amm_program: solana_pubkey::Pubkey, -} - -impl ClaimFees { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(28 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new(self.vpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.virtuals_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.platform, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.lock_escrow, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.escrow_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.dynamic_amm_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&ClaimFeesInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ClaimFeesInstructionData { - discriminator: [u8; 8], -} - -impl ClaimFeesInstructionData { - pub fn new() -> Self { - Self { - discriminator: [82, 251, 233, 156, 12, 52, 184, 202], - } - } -} - -impl Default for ClaimFeesInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `ClaimFees`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[writable]` vpool -/// 2. `[optional]` virtuals_mint (default to `3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y`) -/// 3. `[]` token_mint -/// 4. `[writable]` vpool_virtuals_ata -/// 5. `[writable]` vpool_token_ata -/// 6. `[writable, optional]` platform (default to `FxKXqCKXdxPbfYau83ZkGUXgcZWhKBTfAjGg2KzYSopS`) -/// 7. `[writable]` platform_virtuals_ata -/// 8. `[writable]` platform_token_ata -/// 9. `[writable]` creator_virtuals_ata -/// 10. `[writable]` creator_token_ata -/// 11. `[writable]` pool -/// 12. `[writable]` lp_mint -/// 13. `[writable]` lock_escrow -/// 14. `[writable]` escrow_vault -/// 15. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 16. `[writable]` virtuals_vault -/// 17. `[writable]` token_vault -/// 18. `[writable]` virtuals_token_vault -/// 19. `[writable]` token_token_vault -/// 20. `[writable]` virtuals_vault_lp_mint -/// 21. `[writable]` token_vault_lp_mint -/// 22. `[writable]` virtuals_vault_lp -/// 23. `[writable]` token_vault_lp -/// 24. `[optional]` vault_program (default to `24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi`) -/// 25. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 26. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 27. `[optional]` dynamic_amm_program (default to `Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB`) -#[derive(Clone, Debug, Default)] -pub struct ClaimFeesBuilder { - payer: Option, - vpool: Option, - virtuals_mint: Option, - token_mint: Option, - vpool_virtuals_ata: Option, - vpool_token_ata: Option, - platform: Option, - platform_virtuals_ata: Option, - platform_token_ata: Option, - creator_virtuals_ata: Option, - creator_token_ata: Option, - pool: Option, - lp_mint: Option, - lock_escrow: Option, - escrow_vault: Option, - token_program: Option, - virtuals_vault: Option, - token_vault: Option, - virtuals_token_vault: Option, - token_token_vault: Option, - virtuals_vault_lp_mint: Option, - token_vault_lp_mint: Option, - virtuals_vault_lp: Option, - token_vault_lp: Option, - vault_program: Option, - associated_token_program: Option, - system_program: Option, - dynamic_amm_program: Option, - __remaining_accounts: Vec, -} - -impl ClaimFeesBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: solana_pubkey::Pubkey) -> &mut Self { - self.vpool = Some(vpool); - self - } - - /// `[optional account, default to '3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y']` - #[inline(always)] - pub fn virtuals_mint(&mut self, virtuals_mint: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_mint = Some(virtuals_mint); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata(&mut self, vpool_virtuals_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata(&mut self, vpool_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_token_ata = Some(vpool_token_ata); - self - } - - /// `[optional account, default to 'FxKXqCKXdxPbfYau83ZkGUXgcZWhKBTfAjGg2KzYSopS']` - #[inline(always)] - pub fn platform(&mut self, platform: solana_pubkey::Pubkey) -> &mut Self { - self.platform = Some(platform); - self - } - - #[inline(always)] - pub fn platform_virtuals_ata( - &mut self, - platform_virtuals_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.platform_virtuals_ata = Some(platform_virtuals_ata); - self - } - - #[inline(always)] - pub fn platform_token_ata(&mut self, platform_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.platform_token_ata = Some(platform_token_ata); - self - } - - #[inline(always)] - pub fn creator_virtuals_ata( - &mut self, - creator_virtuals_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.creator_virtuals_ata = Some(creator_virtuals_ata); - self - } - - #[inline(always)] - pub fn creator_token_ata(&mut self, creator_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.creator_token_ata = Some(creator_token_ata); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn lock_escrow(&mut self, lock_escrow: solana_pubkey::Pubkey) -> &mut Self { - self.lock_escrow = Some(lock_escrow); - self - } - - #[inline(always)] - pub fn escrow_vault(&mut self, escrow_vault: solana_pubkey::Pubkey) -> &mut Self { - self.escrow_vault = Some(escrow_vault); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn virtuals_vault(&mut self, virtuals_vault: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_vault = Some(virtuals_vault); - self - } - - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - #[inline(always)] - pub fn virtuals_token_vault( - &mut self, - virtuals_token_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.virtuals_token_vault = Some(virtuals_token_vault); - self - } - - #[inline(always)] - pub fn token_token_vault(&mut self, token_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_token_vault = Some(token_token_vault); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp_mint( - &mut self, - virtuals_vault_lp_mint: solana_pubkey::Pubkey, - ) -> &mut Self { - self.virtuals_vault_lp_mint = Some(virtuals_vault_lp_mint); - self - } - - #[inline(always)] - pub fn token_vault_lp_mint(&mut self, token_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_lp_mint = Some(token_vault_lp_mint); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp(&mut self, virtuals_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_vault_lp = Some(virtuals_vault_lp); - self - } - - #[inline(always)] - pub fn token_vault_lp(&mut self, token_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_lp = Some(token_vault_lp); - self - } - - /// `[optional account, default to '24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi']` - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB']` - #[inline(always)] - pub fn dynamic_amm_program(&mut self, dynamic_amm_program: solana_pubkey::Pubkey) -> &mut Self { - self.dynamic_amm_program = Some(dynamic_amm_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = ClaimFees { - payer: self.payer.expect("payer is not set"), - vpool: self.vpool.expect("vpool is not set"), - virtuals_mint: self.virtuals_mint.unwrap_or(solana_pubkey::pubkey!( - "3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y" - )), - token_mint: self.token_mint.expect("token_mint is not set"), - vpool_virtuals_ata: self - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - vpool_token_ata: self.vpool_token_ata.expect("vpool_token_ata is not set"), - platform: self.platform.unwrap_or(solana_pubkey::pubkey!( - "FxKXqCKXdxPbfYau83ZkGUXgcZWhKBTfAjGg2KzYSopS" - )), - platform_virtuals_ata: self - .platform_virtuals_ata - .expect("platform_virtuals_ata is not set"), - platform_token_ata: self - .platform_token_ata - .expect("platform_token_ata is not set"), - creator_virtuals_ata: self - .creator_virtuals_ata - .expect("creator_virtuals_ata is not set"), - creator_token_ata: self - .creator_token_ata - .expect("creator_token_ata is not set"), - pool: self.pool.expect("pool is not set"), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - lock_escrow: self.lock_escrow.expect("lock_escrow is not set"), - escrow_vault: self.escrow_vault.expect("escrow_vault is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - virtuals_vault: self.virtuals_vault.expect("virtuals_vault is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - virtuals_token_vault: self - .virtuals_token_vault - .expect("virtuals_token_vault is not set"), - token_token_vault: self - .token_token_vault - .expect("token_token_vault is not set"), - virtuals_vault_lp_mint: self - .virtuals_vault_lp_mint - .expect("virtuals_vault_lp_mint is not set"), - token_vault_lp_mint: self - .token_vault_lp_mint - .expect("token_vault_lp_mint is not set"), - virtuals_vault_lp: self - .virtuals_vault_lp - .expect("virtuals_vault_lp is not set"), - token_vault_lp: self.token_vault_lp.expect("token_vault_lp is not set"), - vault_program: self.vault_program.unwrap_or(solana_pubkey::pubkey!( - "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - dynamic_amm_program: self.dynamic_amm_program.unwrap_or(solana_pubkey::pubkey!( - "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `claim_fees` CPI accounts. -pub struct ClaimFeesCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub platform: &'b solana_account_info::AccountInfo<'a>, - - pub platform_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub platform_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub creator_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub creator_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub dynamic_amm_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `claim_fees` CPI instruction. -pub struct ClaimFeesCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub platform: &'b solana_account_info::AccountInfo<'a>, - - pub platform_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub platform_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub creator_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub creator_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub dynamic_amm_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> ClaimFeesCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: ClaimFeesCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - vpool: accounts.vpool, - virtuals_mint: accounts.virtuals_mint, - token_mint: accounts.token_mint, - vpool_virtuals_ata: accounts.vpool_virtuals_ata, - vpool_token_ata: accounts.vpool_token_ata, - platform: accounts.platform, - platform_virtuals_ata: accounts.platform_virtuals_ata, - platform_token_ata: accounts.platform_token_ata, - creator_virtuals_ata: accounts.creator_virtuals_ata, - creator_token_ata: accounts.creator_token_ata, - pool: accounts.pool, - lp_mint: accounts.lp_mint, - lock_escrow: accounts.lock_escrow, - escrow_vault: accounts.escrow_vault, - token_program: accounts.token_program, - virtuals_vault: accounts.virtuals_vault, - token_vault: accounts.token_vault, - virtuals_token_vault: accounts.virtuals_token_vault, - token_token_vault: accounts.token_token_vault, - virtuals_vault_lp_mint: accounts.virtuals_vault_lp_mint, - token_vault_lp_mint: accounts.token_vault_lp_mint, - virtuals_vault_lp: accounts.virtuals_vault_lp, - token_vault_lp: accounts.token_vault_lp, - vault_program: accounts.vault_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - dynamic_amm_program: accounts.dynamic_amm_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(28 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new(*self.vpool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.virtuals_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lock_escrow.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.escrow_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.dynamic_amm_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&ClaimFeesInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(29 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.vpool.clone()); - account_infos.push(self.virtuals_mint.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.vpool_virtuals_ata.clone()); - account_infos.push(self.vpool_token_ata.clone()); - account_infos.push(self.platform.clone()); - account_infos.push(self.platform_virtuals_ata.clone()); - account_infos.push(self.platform_token_ata.clone()); - account_infos.push(self.creator_virtuals_ata.clone()); - account_infos.push(self.creator_token_ata.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.lock_escrow.clone()); - account_infos.push(self.escrow_vault.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.virtuals_vault.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.virtuals_token_vault.clone()); - account_infos.push(self.token_token_vault.clone()); - account_infos.push(self.virtuals_vault_lp_mint.clone()); - account_infos.push(self.token_vault_lp_mint.clone()); - account_infos.push(self.virtuals_vault_lp.clone()); - account_infos.push(self.token_vault_lp.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.dynamic_amm_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `ClaimFees` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[writable]` vpool -/// 2. `[]` virtuals_mint -/// 3. `[]` token_mint -/// 4. `[writable]` vpool_virtuals_ata -/// 5. `[writable]` vpool_token_ata -/// 6. `[writable]` platform -/// 7. `[writable]` platform_virtuals_ata -/// 8. `[writable]` platform_token_ata -/// 9. `[writable]` creator_virtuals_ata -/// 10. `[writable]` creator_token_ata -/// 11. `[writable]` pool -/// 12. `[writable]` lp_mint -/// 13. `[writable]` lock_escrow -/// 14. `[writable]` escrow_vault -/// 15. `[]` token_program -/// 16. `[writable]` virtuals_vault -/// 17. `[writable]` token_vault -/// 18. `[writable]` virtuals_token_vault -/// 19. `[writable]` token_token_vault -/// 20. `[writable]` virtuals_vault_lp_mint -/// 21. `[writable]` token_vault_lp_mint -/// 22. `[writable]` virtuals_vault_lp -/// 23. `[writable]` token_vault_lp -/// 24. `[]` vault_program -/// 25. `[]` associated_token_program -/// 26. `[]` system_program -/// 27. `[]` dynamic_amm_program -#[derive(Clone, Debug)] -pub struct ClaimFeesCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> ClaimFeesCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(ClaimFeesCpiBuilderInstruction { - __program: program, - payer: None, - vpool: None, - virtuals_mint: None, - token_mint: None, - vpool_virtuals_ata: None, - vpool_token_ata: None, - platform: None, - platform_virtuals_ata: None, - platform_token_ata: None, - creator_virtuals_ata: None, - creator_token_ata: None, - pool: None, - lp_mint: None, - lock_escrow: None, - escrow_vault: None, - token_program: None, - virtuals_vault: None, - token_vault: None, - virtuals_token_vault: None, - token_token_vault: None, - virtuals_vault_lp_mint: None, - token_vault_lp_mint: None, - virtuals_vault_lp: None, - token_vault_lp: None, - vault_program: None, - associated_token_program: None, - system_program: None, - dynamic_amm_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn virtuals_mint( - &mut self, - virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_mint = Some(virtuals_mint); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata( - &mut self, - vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata( - &mut self, - vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_token_ata = Some(vpool_token_ata); - self - } - - #[inline(always)] - pub fn platform(&mut self, platform: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.platform = Some(platform); - self - } - - #[inline(always)] - pub fn platform_virtuals_ata( - &mut self, - platform_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_virtuals_ata = Some(platform_virtuals_ata); - self - } - - #[inline(always)] - pub fn platform_token_ata( - &mut self, - platform_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_token_ata = Some(platform_token_ata); - self - } - - #[inline(always)] - pub fn creator_virtuals_ata( - &mut self, - creator_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_virtuals_ata = Some(creator_virtuals_ata); - self - } - - #[inline(always)] - pub fn creator_token_ata( - &mut self, - creator_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_token_ata = Some(creator_token_ata); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn lock_escrow( - &mut self, - lock_escrow: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_escrow = Some(lock_escrow); - self - } - - #[inline(always)] - pub fn escrow_vault( - &mut self, - escrow_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.escrow_vault = Some(escrow_vault); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn virtuals_vault( - &mut self, - virtuals_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_vault = Some(virtuals_vault); - self - } - - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - #[inline(always)] - pub fn virtuals_token_vault( - &mut self, - virtuals_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_token_vault = Some(virtuals_token_vault); - self - } - - #[inline(always)] - pub fn token_token_vault( - &mut self, - token_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_token_vault = Some(token_token_vault); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp_mint( - &mut self, - virtuals_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_vault_lp_mint = Some(virtuals_vault_lp_mint); - self - } - - #[inline(always)] - pub fn token_vault_lp_mint( - &mut self, - token_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_lp_mint = Some(token_vault_lp_mint); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp( - &mut self, - virtuals_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_vault_lp = Some(virtuals_vault_lp); - self - } - - #[inline(always)] - pub fn token_vault_lp( - &mut self, - token_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_lp = Some(token_vault_lp); - self - } - - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn dynamic_amm_program( - &mut self, - dynamic_amm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.dynamic_amm_program = Some(dynamic_amm_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = ClaimFeesCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - vpool: self.instruction.vpool.expect("vpool is not set"), - - virtuals_mint: self - .instruction - .virtuals_mint - .expect("virtuals_mint is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - vpool_virtuals_ata: self - .instruction - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - - vpool_token_ata: self - .instruction - .vpool_token_ata - .expect("vpool_token_ata is not set"), - - platform: self.instruction.platform.expect("platform is not set"), - - platform_virtuals_ata: self - .instruction - .platform_virtuals_ata - .expect("platform_virtuals_ata is not set"), - - platform_token_ata: self - .instruction - .platform_token_ata - .expect("platform_token_ata is not set"), - - creator_virtuals_ata: self - .instruction - .creator_virtuals_ata - .expect("creator_virtuals_ata is not set"), - - creator_token_ata: self - .instruction - .creator_token_ata - .expect("creator_token_ata is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - lock_escrow: self - .instruction - .lock_escrow - .expect("lock_escrow is not set"), - - escrow_vault: self - .instruction - .escrow_vault - .expect("escrow_vault is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - virtuals_vault: self - .instruction - .virtuals_vault - .expect("virtuals_vault is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - virtuals_token_vault: self - .instruction - .virtuals_token_vault - .expect("virtuals_token_vault is not set"), - - token_token_vault: self - .instruction - .token_token_vault - .expect("token_token_vault is not set"), - - virtuals_vault_lp_mint: self - .instruction - .virtuals_vault_lp_mint - .expect("virtuals_vault_lp_mint is not set"), - - token_vault_lp_mint: self - .instruction - .token_vault_lp_mint - .expect("token_vault_lp_mint is not set"), - - virtuals_vault_lp: self - .instruction - .virtuals_vault_lp - .expect("virtuals_vault_lp is not set"), - - token_vault_lp: self - .instruction - .token_vault_lp - .expect("token_vault_lp is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - dynamic_amm_program: self - .instruction - .dynamic_amm_program - .expect("dynamic_amm_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct ClaimFeesCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - platform: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_escrow: Option<&'b solana_account_info::AccountInfo<'a>>, - escrow_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - dynamic_amm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/virtuals-parser/src/generated_sdk/instructions/create_meteora_pool.rs b/crates/virtuals-parser/src/generated_sdk/instructions/create_meteora_pool.rs deleted file mode 100644 index aa0108d6..00000000 --- a/crates/virtuals-parser/src/generated_sdk/instructions/create_meteora_pool.rs +++ /dev/null @@ -1,1772 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct CreateMeteoraPool { - pub vpool: solana_pubkey::Pubkey, - - pub meteora_deployer: solana_pubkey::Pubkey, - - pub meteora_deployer_virtuals_ata: solana_pubkey::Pubkey, - - pub meteora_deployer_token_ata: solana_pubkey::Pubkey, - - pub vpool_virtuals_ata: solana_pubkey::Pubkey, - - pub vpool_token_ata: solana_pubkey::Pubkey, - - pub lock_escrow: solana_pubkey::Pubkey, - - pub escrow_vault: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub virtuals_mint: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub virtuals_vault: solana_pubkey::Pubkey, - - pub token_vault: solana_pubkey::Pubkey, - - pub virtuals_token_vault: solana_pubkey::Pubkey, - - pub token_token_vault: solana_pubkey::Pubkey, - - pub virtuals_vault_lp_mint: solana_pubkey::Pubkey, - - pub token_vault_lp_mint: solana_pubkey::Pubkey, - - pub virtuals_vault_lp: solana_pubkey::Pubkey, - - pub token_vault_lp: solana_pubkey::Pubkey, - - pub pool_virtuals_ata: solana_pubkey::Pubkey, - - pub pool_token_ata: solana_pubkey::Pubkey, - - pub meteora_deployer_pool_lp: solana_pubkey::Pubkey, - - pub protocol_virtuals_fee: solana_pubkey::Pubkey, - - pub protocol_token_fee: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub token_metadata: solana_pubkey::Pubkey, - /// Rent account. - pub rent: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, - /// Associated token program. - pub associated_token_program: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, - - pub dynamic_amm_program: solana_pubkey::Pubkey, -} - -impl CreateMeteoraPool { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(36 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vpool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.meteora_deployer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.meteora_deployer_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.meteora_deployer_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lock_escrow, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.escrow_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.virtuals_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.meteora_deployer_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_virtuals_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.dynamic_amm_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&CreateMeteoraPoolInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CreateMeteoraPoolInstructionData { - discriminator: [u8; 8], -} - -impl CreateMeteoraPoolInstructionData { - pub fn new() -> Self { - Self { - discriminator: [246, 254, 33, 37, 225, 176, 41, 232], - } - } -} - -impl Default for CreateMeteoraPoolInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `CreateMeteoraPool`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vpool -/// 1. `[writable]` meteora_deployer -/// 2. `[writable]` meteora_deployer_virtuals_ata -/// 3. `[writable]` meteora_deployer_token_ata -/// 4. `[writable]` vpool_virtuals_ata -/// 5. `[writable]` vpool_token_ata -/// 6. `[writable]` lock_escrow -/// 7. `[writable]` escrow_vault -/// 8. `[writable]` pool -/// 9. `[optional]` config (default to `B6FT4AHhQJ7BttrC1i223km5bYRUA2nVwBR7k5TVwLtx`) -/// 10. `[writable]` lp_mint -/// 11. `[optional]` virtuals_mint (default to `3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y`) -/// 12. `[]` token_mint -/// 13. `[writable]` virtuals_vault -/// 14. `[writable]` token_vault -/// 15. `[writable]` virtuals_token_vault -/// 16. `[writable]` token_token_vault -/// 17. `[writable]` virtuals_vault_lp_mint -/// 18. `[writable]` token_vault_lp_mint -/// 19. `[writable]` virtuals_vault_lp -/// 20. `[writable]` token_vault_lp -/// 21. `[writable]` pool_virtuals_ata -/// 22. `[writable]` pool_token_ata -/// 23. `[writable]` meteora_deployer_pool_lp -/// 24. `[writable]` protocol_virtuals_fee -/// 25. `[writable]` protocol_token_fee -/// 26. `[writable, signer]` payer -/// 27. `[writable]` token_metadata -/// 28. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 29. `[writable]` mint_metadata -/// 30. `[optional]` metadata_program (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -/// 31. `[optional]` vault_program (default to `24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi`) -/// 32. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 33. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 34. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 35. `[optional]` dynamic_amm_program (default to `Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB`) -#[derive(Clone, Debug, Default)] -pub struct CreateMeteoraPoolBuilder { - vpool: Option, - meteora_deployer: Option, - meteora_deployer_virtuals_ata: Option, - meteora_deployer_token_ata: Option, - vpool_virtuals_ata: Option, - vpool_token_ata: Option, - lock_escrow: Option, - escrow_vault: Option, - pool: Option, - config: Option, - lp_mint: Option, - virtuals_mint: Option, - token_mint: Option, - virtuals_vault: Option, - token_vault: Option, - virtuals_token_vault: Option, - token_token_vault: Option, - virtuals_vault_lp_mint: Option, - token_vault_lp_mint: Option, - virtuals_vault_lp: Option, - token_vault_lp: Option, - pool_virtuals_ata: Option, - pool_token_ata: Option, - meteora_deployer_pool_lp: Option, - protocol_virtuals_fee: Option, - protocol_token_fee: Option, - payer: Option, - token_metadata: Option, - rent: Option, - mint_metadata: Option, - metadata_program: Option, - vault_program: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - dynamic_amm_program: Option, - __remaining_accounts: Vec, -} - -impl CreateMeteoraPoolBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn vpool(&mut self, vpool: solana_pubkey::Pubkey) -> &mut Self { - self.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn meteora_deployer(&mut self, meteora_deployer: solana_pubkey::Pubkey) -> &mut Self { - self.meteora_deployer = Some(meteora_deployer); - self - } - - #[inline(always)] - pub fn meteora_deployer_virtuals_ata( - &mut self, - meteora_deployer_virtuals_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.meteora_deployer_virtuals_ata = Some(meteora_deployer_virtuals_ata); - self - } - - #[inline(always)] - pub fn meteora_deployer_token_ata( - &mut self, - meteora_deployer_token_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.meteora_deployer_token_ata = Some(meteora_deployer_token_ata); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata(&mut self, vpool_virtuals_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata(&mut self, vpool_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_token_ata = Some(vpool_token_ata); - self - } - - #[inline(always)] - pub fn lock_escrow(&mut self, lock_escrow: solana_pubkey::Pubkey) -> &mut Self { - self.lock_escrow = Some(lock_escrow); - self - } - - #[inline(always)] - pub fn escrow_vault(&mut self, escrow_vault: solana_pubkey::Pubkey) -> &mut Self { - self.escrow_vault = Some(escrow_vault); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// `[optional account, default to 'B6FT4AHhQJ7BttrC1i223km5bYRUA2nVwBR7k5TVwLtx']` - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// `[optional account, default to '3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y']` - #[inline(always)] - pub fn virtuals_mint(&mut self, virtuals_mint: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_mint = Some(virtuals_mint); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn virtuals_vault(&mut self, virtuals_vault: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_vault = Some(virtuals_vault); - self - } - - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - #[inline(always)] - pub fn virtuals_token_vault( - &mut self, - virtuals_token_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.virtuals_token_vault = Some(virtuals_token_vault); - self - } - - #[inline(always)] - pub fn token_token_vault(&mut self, token_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_token_vault = Some(token_token_vault); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp_mint( - &mut self, - virtuals_vault_lp_mint: solana_pubkey::Pubkey, - ) -> &mut Self { - self.virtuals_vault_lp_mint = Some(virtuals_vault_lp_mint); - self - } - - #[inline(always)] - pub fn token_vault_lp_mint(&mut self, token_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_lp_mint = Some(token_vault_lp_mint); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp(&mut self, virtuals_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_vault_lp = Some(virtuals_vault_lp); - self - } - - #[inline(always)] - pub fn token_vault_lp(&mut self, token_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_lp = Some(token_vault_lp); - self - } - - #[inline(always)] - pub fn pool_virtuals_ata(&mut self, pool_virtuals_ata: solana_pubkey::Pubkey) -> &mut Self { - self.pool_virtuals_ata = Some(pool_virtuals_ata); - self - } - - #[inline(always)] - pub fn pool_token_ata(&mut self, pool_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.pool_token_ata = Some(pool_token_ata); - self - } - - #[inline(always)] - pub fn meteora_deployer_pool_lp( - &mut self, - meteora_deployer_pool_lp: solana_pubkey::Pubkey, - ) -> &mut Self { - self.meteora_deployer_pool_lp = Some(meteora_deployer_pool_lp); - self - } - - #[inline(always)] - pub fn protocol_virtuals_fee( - &mut self, - protocol_virtuals_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_virtuals_fee = Some(protocol_virtuals_fee); - self - } - - #[inline(always)] - pub fn protocol_token_fee(&mut self, protocol_token_fee: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_token_fee = Some(protocol_token_fee); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn token_metadata(&mut self, token_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.token_metadata = Some(token_metadata); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// `[optional account, default to '24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi']` - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB']` - #[inline(always)] - pub fn dynamic_amm_program(&mut self, dynamic_amm_program: solana_pubkey::Pubkey) -> &mut Self { - self.dynamic_amm_program = Some(dynamic_amm_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = CreateMeteoraPool { - vpool: self.vpool.expect("vpool is not set"), - meteora_deployer: self.meteora_deployer.expect("meteora_deployer is not set"), - meteora_deployer_virtuals_ata: self - .meteora_deployer_virtuals_ata - .expect("meteora_deployer_virtuals_ata is not set"), - meteora_deployer_token_ata: self - .meteora_deployer_token_ata - .expect("meteora_deployer_token_ata is not set"), - vpool_virtuals_ata: self - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - vpool_token_ata: self.vpool_token_ata.expect("vpool_token_ata is not set"), - lock_escrow: self.lock_escrow.expect("lock_escrow is not set"), - escrow_vault: self.escrow_vault.expect("escrow_vault is not set"), - pool: self.pool.expect("pool is not set"), - config: self.config.unwrap_or(solana_pubkey::pubkey!( - "B6FT4AHhQJ7BttrC1i223km5bYRUA2nVwBR7k5TVwLtx" - )), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - virtuals_mint: self.virtuals_mint.unwrap_or(solana_pubkey::pubkey!( - "3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y" - )), - token_mint: self.token_mint.expect("token_mint is not set"), - virtuals_vault: self.virtuals_vault.expect("virtuals_vault is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - virtuals_token_vault: self - .virtuals_token_vault - .expect("virtuals_token_vault is not set"), - token_token_vault: self - .token_token_vault - .expect("token_token_vault is not set"), - virtuals_vault_lp_mint: self - .virtuals_vault_lp_mint - .expect("virtuals_vault_lp_mint is not set"), - token_vault_lp_mint: self - .token_vault_lp_mint - .expect("token_vault_lp_mint is not set"), - virtuals_vault_lp: self - .virtuals_vault_lp - .expect("virtuals_vault_lp is not set"), - token_vault_lp: self.token_vault_lp.expect("token_vault_lp is not set"), - pool_virtuals_ata: self - .pool_virtuals_ata - .expect("pool_virtuals_ata is not set"), - pool_token_ata: self.pool_token_ata.expect("pool_token_ata is not set"), - meteora_deployer_pool_lp: self - .meteora_deployer_pool_lp - .expect("meteora_deployer_pool_lp is not set"), - protocol_virtuals_fee: self - .protocol_virtuals_fee - .expect("protocol_virtuals_fee is not set"), - protocol_token_fee: self - .protocol_token_fee - .expect("protocol_token_fee is not set"), - payer: self.payer.expect("payer is not set"), - token_metadata: self.token_metadata.expect("token_metadata is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.unwrap_or(solana_pubkey::pubkey!( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - )), - vault_program: self.vault_program.unwrap_or(solana_pubkey::pubkey!( - "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" - )), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - dynamic_amm_program: self.dynamic_amm_program.unwrap_or(solana_pubkey::pubkey!( - "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `create_meteora_pool` CPI accounts. -pub struct CreateMeteoraPoolCpiAccounts<'a, 'b> { - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub pool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub pool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_virtuals_fee: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_fee: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub token_metadata: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub dynamic_amm_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `create_meteora_pool` CPI instruction. -pub struct CreateMeteoraPoolCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub pool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub pool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_virtuals_fee: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_fee: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub token_metadata: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub dynamic_amm_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> CreateMeteoraPoolCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: CreateMeteoraPoolCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - vpool: accounts.vpool, - meteora_deployer: accounts.meteora_deployer, - meteora_deployer_virtuals_ata: accounts.meteora_deployer_virtuals_ata, - meteora_deployer_token_ata: accounts.meteora_deployer_token_ata, - vpool_virtuals_ata: accounts.vpool_virtuals_ata, - vpool_token_ata: accounts.vpool_token_ata, - lock_escrow: accounts.lock_escrow, - escrow_vault: accounts.escrow_vault, - pool: accounts.pool, - config: accounts.config, - lp_mint: accounts.lp_mint, - virtuals_mint: accounts.virtuals_mint, - token_mint: accounts.token_mint, - virtuals_vault: accounts.virtuals_vault, - token_vault: accounts.token_vault, - virtuals_token_vault: accounts.virtuals_token_vault, - token_token_vault: accounts.token_token_vault, - virtuals_vault_lp_mint: accounts.virtuals_vault_lp_mint, - token_vault_lp_mint: accounts.token_vault_lp_mint, - virtuals_vault_lp: accounts.virtuals_vault_lp, - token_vault_lp: accounts.token_vault_lp, - pool_virtuals_ata: accounts.pool_virtuals_ata, - pool_token_ata: accounts.pool_token_ata, - meteora_deployer_pool_lp: accounts.meteora_deployer_pool_lp, - protocol_virtuals_fee: accounts.protocol_virtuals_fee, - protocol_token_fee: accounts.protocol_token_fee, - payer: accounts.payer, - token_metadata: accounts.token_metadata, - rent: accounts.rent, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - dynamic_amm_program: accounts.dynamic_amm_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(36 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vpool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.meteora_deployer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.meteora_deployer_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.meteora_deployer_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lock_escrow.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.escrow_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.virtuals_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.meteora_deployer_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_virtuals_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.dynamic_amm_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&CreateMeteoraPoolInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(37 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vpool.clone()); - account_infos.push(self.meteora_deployer.clone()); - account_infos.push(self.meteora_deployer_virtuals_ata.clone()); - account_infos.push(self.meteora_deployer_token_ata.clone()); - account_infos.push(self.vpool_virtuals_ata.clone()); - account_infos.push(self.vpool_token_ata.clone()); - account_infos.push(self.lock_escrow.clone()); - account_infos.push(self.escrow_vault.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.virtuals_mint.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.virtuals_vault.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.virtuals_token_vault.clone()); - account_infos.push(self.token_token_vault.clone()); - account_infos.push(self.virtuals_vault_lp_mint.clone()); - account_infos.push(self.token_vault_lp_mint.clone()); - account_infos.push(self.virtuals_vault_lp.clone()); - account_infos.push(self.token_vault_lp.clone()); - account_infos.push(self.pool_virtuals_ata.clone()); - account_infos.push(self.pool_token_ata.clone()); - account_infos.push(self.meteora_deployer_pool_lp.clone()); - account_infos.push(self.protocol_virtuals_fee.clone()); - account_infos.push(self.protocol_token_fee.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_metadata.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.dynamic_amm_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `CreateMeteoraPool` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vpool -/// 1. `[writable]` meteora_deployer -/// 2. `[writable]` meteora_deployer_virtuals_ata -/// 3. `[writable]` meteora_deployer_token_ata -/// 4. `[writable]` vpool_virtuals_ata -/// 5. `[writable]` vpool_token_ata -/// 6. `[writable]` lock_escrow -/// 7. `[writable]` escrow_vault -/// 8. `[writable]` pool -/// 9. `[]` config -/// 10. `[writable]` lp_mint -/// 11. `[]` virtuals_mint -/// 12. `[]` token_mint -/// 13. `[writable]` virtuals_vault -/// 14. `[writable]` token_vault -/// 15. `[writable]` virtuals_token_vault -/// 16. `[writable]` token_token_vault -/// 17. `[writable]` virtuals_vault_lp_mint -/// 18. `[writable]` token_vault_lp_mint -/// 19. `[writable]` virtuals_vault_lp -/// 20. `[writable]` token_vault_lp -/// 21. `[writable]` pool_virtuals_ata -/// 22. `[writable]` pool_token_ata -/// 23. `[writable]` meteora_deployer_pool_lp -/// 24. `[writable]` protocol_virtuals_fee -/// 25. `[writable]` protocol_token_fee -/// 26. `[writable, signer]` payer -/// 27. `[writable]` token_metadata -/// 28. `[]` rent -/// 29. `[writable]` mint_metadata -/// 30. `[]` metadata_program -/// 31. `[]` vault_program -/// 32. `[]` token_program -/// 33. `[]` associated_token_program -/// 34. `[]` system_program -/// 35. `[]` dynamic_amm_program -#[derive(Clone, Debug)] -pub struct CreateMeteoraPoolCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> CreateMeteoraPoolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(CreateMeteoraPoolCpiBuilderInstruction { - __program: program, - vpool: None, - meteora_deployer: None, - meteora_deployer_virtuals_ata: None, - meteora_deployer_token_ata: None, - vpool_virtuals_ata: None, - vpool_token_ata: None, - lock_escrow: None, - escrow_vault: None, - pool: None, - config: None, - lp_mint: None, - virtuals_mint: None, - token_mint: None, - virtuals_vault: None, - token_vault: None, - virtuals_token_vault: None, - token_token_vault: None, - virtuals_vault_lp_mint: None, - token_vault_lp_mint: None, - virtuals_vault_lp: None, - token_vault_lp: None, - pool_virtuals_ata: None, - pool_token_ata: None, - meteora_deployer_pool_lp: None, - protocol_virtuals_fee: None, - protocol_token_fee: None, - payer: None, - token_metadata: None, - rent: None, - mint_metadata: None, - metadata_program: None, - vault_program: None, - token_program: None, - associated_token_program: None, - system_program: None, - dynamic_amm_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn meteora_deployer( - &mut self, - meteora_deployer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.meteora_deployer = Some(meteora_deployer); - self - } - - #[inline(always)] - pub fn meteora_deployer_virtuals_ata( - &mut self, - meteora_deployer_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.meteora_deployer_virtuals_ata = Some(meteora_deployer_virtuals_ata); - self - } - - #[inline(always)] - pub fn meteora_deployer_token_ata( - &mut self, - meteora_deployer_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.meteora_deployer_token_ata = Some(meteora_deployer_token_ata); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata( - &mut self, - vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata( - &mut self, - vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_token_ata = Some(vpool_token_ata); - self - } - - #[inline(always)] - pub fn lock_escrow( - &mut self, - lock_escrow: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_escrow = Some(lock_escrow); - self - } - - #[inline(always)] - pub fn escrow_vault( - &mut self, - escrow_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.escrow_vault = Some(escrow_vault); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn virtuals_mint( - &mut self, - virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_mint = Some(virtuals_mint); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn virtuals_vault( - &mut self, - virtuals_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_vault = Some(virtuals_vault); - self - } - - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - #[inline(always)] - pub fn virtuals_token_vault( - &mut self, - virtuals_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_token_vault = Some(virtuals_token_vault); - self - } - - #[inline(always)] - pub fn token_token_vault( - &mut self, - token_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_token_vault = Some(token_token_vault); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp_mint( - &mut self, - virtuals_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_vault_lp_mint = Some(virtuals_vault_lp_mint); - self - } - - #[inline(always)] - pub fn token_vault_lp_mint( - &mut self, - token_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_lp_mint = Some(token_vault_lp_mint); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp( - &mut self, - virtuals_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_vault_lp = Some(virtuals_vault_lp); - self - } - - #[inline(always)] - pub fn token_vault_lp( - &mut self, - token_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_lp = Some(token_vault_lp); - self - } - - #[inline(always)] - pub fn pool_virtuals_ata( - &mut self, - pool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_virtuals_ata = Some(pool_virtuals_ata); - self - } - - #[inline(always)] - pub fn pool_token_ata( - &mut self, - pool_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_token_ata = Some(pool_token_ata); - self - } - - #[inline(always)] - pub fn meteora_deployer_pool_lp( - &mut self, - meteora_deployer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.meteora_deployer_pool_lp = Some(meteora_deployer_pool_lp); - self - } - - #[inline(always)] - pub fn protocol_virtuals_fee( - &mut self, - protocol_virtuals_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_virtuals_fee = Some(protocol_virtuals_fee); - self - } - - #[inline(always)] - pub fn protocol_token_fee( - &mut self, - protocol_token_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_fee = Some(protocol_token_fee); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn token_metadata( - &mut self, - token_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_metadata = Some(token_metadata); - self - } - - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn dynamic_amm_program( - &mut self, - dynamic_amm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.dynamic_amm_program = Some(dynamic_amm_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = CreateMeteoraPoolCpi { - __program: self.instruction.__program, - - vpool: self.instruction.vpool.expect("vpool is not set"), - - meteora_deployer: self - .instruction - .meteora_deployer - .expect("meteora_deployer is not set"), - - meteora_deployer_virtuals_ata: self - .instruction - .meteora_deployer_virtuals_ata - .expect("meteora_deployer_virtuals_ata is not set"), - - meteora_deployer_token_ata: self - .instruction - .meteora_deployer_token_ata - .expect("meteora_deployer_token_ata is not set"), - - vpool_virtuals_ata: self - .instruction - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - - vpool_token_ata: self - .instruction - .vpool_token_ata - .expect("vpool_token_ata is not set"), - - lock_escrow: self - .instruction - .lock_escrow - .expect("lock_escrow is not set"), - - escrow_vault: self - .instruction - .escrow_vault - .expect("escrow_vault is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - config: self.instruction.config.expect("config is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - virtuals_mint: self - .instruction - .virtuals_mint - .expect("virtuals_mint is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - virtuals_vault: self - .instruction - .virtuals_vault - .expect("virtuals_vault is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - virtuals_token_vault: self - .instruction - .virtuals_token_vault - .expect("virtuals_token_vault is not set"), - - token_token_vault: self - .instruction - .token_token_vault - .expect("token_token_vault is not set"), - - virtuals_vault_lp_mint: self - .instruction - .virtuals_vault_lp_mint - .expect("virtuals_vault_lp_mint is not set"), - - token_vault_lp_mint: self - .instruction - .token_vault_lp_mint - .expect("token_vault_lp_mint is not set"), - - virtuals_vault_lp: self - .instruction - .virtuals_vault_lp - .expect("virtuals_vault_lp is not set"), - - token_vault_lp: self - .instruction - .token_vault_lp - .expect("token_vault_lp is not set"), - - pool_virtuals_ata: self - .instruction - .pool_virtuals_ata - .expect("pool_virtuals_ata is not set"), - - pool_token_ata: self - .instruction - .pool_token_ata - .expect("pool_token_ata is not set"), - - meteora_deployer_pool_lp: self - .instruction - .meteora_deployer_pool_lp - .expect("meteora_deployer_pool_lp is not set"), - - protocol_virtuals_fee: self - .instruction - .protocol_virtuals_fee - .expect("protocol_virtuals_fee is not set"), - - protocol_token_fee: self - .instruction - .protocol_token_fee - .expect("protocol_token_fee is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_metadata: self - .instruction - .token_metadata - .expect("token_metadata is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - dynamic_amm_program: self - .instruction - .dynamic_amm_program - .expect("dynamic_amm_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct CreateMeteoraPoolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vpool: Option<&'b solana_account_info::AccountInfo<'a>>, - meteora_deployer: Option<&'b solana_account_info::AccountInfo<'a>>, - meteora_deployer_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - meteora_deployer_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_escrow: Option<&'b solana_account_info::AccountInfo<'a>>, - escrow_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - meteora_deployer_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_virtuals_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - dynamic_amm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/virtuals-parser/src/generated_sdk/instructions/initialize.rs b/crates/virtuals-parser/src/generated_sdk/instructions/initialize.rs deleted file mode 100644 index 9be46a66..00000000 --- a/crates/virtuals-parser/src/generated_sdk/instructions/initialize.rs +++ /dev/null @@ -1,606 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Initialize { - pub payer: solana_pubkey::Pubkey, - - pub virtuals_mint: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub vpool_virtuals_ata: solana_pubkey::Pubkey, - - pub vpool_token_ata: solana_pubkey::Pubkey, - - pub vpool: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl Initialize { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.virtuals_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.token_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.vpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeInstructionData { - discriminator: [u8; 8], -} - -impl InitializeInstructionData { - pub fn new() -> Self { - Self { - discriminator: [175, 175, 109, 31, 13, 152, 155, 237], - } - } -} - -impl Default for InitializeInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `Initialize`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[optional]` virtuals_mint (default to `3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y`) -/// 2. `[writable]` token_mint -/// 3. `[writable]` vpool_virtuals_ata -/// 4. `[writable]` vpool_token_ata -/// 5. `[writable]` vpool -/// 6. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 7. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 8. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct InitializeBuilder { - payer: Option, - virtuals_mint: Option, - token_mint: Option, - vpool_virtuals_ata: Option, - vpool_token_ata: Option, - vpool: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl InitializeBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - /// `[optional account, default to '3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y']` - #[inline(always)] - pub fn virtuals_mint(&mut self, virtuals_mint: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_mint = Some(virtuals_mint); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata(&mut self, vpool_virtuals_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata(&mut self, vpool_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_token_ata = Some(vpool_token_ata); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: solana_pubkey::Pubkey) -> &mut Self { - self.vpool = Some(vpool); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Initialize { - payer: self.payer.expect("payer is not set"), - virtuals_mint: self.virtuals_mint.unwrap_or(solana_pubkey::pubkey!( - "3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y" - )), - token_mint: self.token_mint.expect("token_mint is not set"), - vpool_virtuals_ata: self - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - vpool_token_ata: self.vpool_token_ata.expect("vpool_token_ata is not set"), - vpool: self.vpool.expect("vpool is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize` CPI accounts. -pub struct InitializeCpiAccounts<'a, 'b> { - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize` CPI instruction. -pub struct InitializeCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializeCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - payer: accounts.payer, - virtuals_mint: accounts.virtuals_mint, - token_mint: accounts.token_mint, - vpool_virtuals_ata: accounts.vpool_virtuals_ata, - vpool_token_ata: accounts.vpool_token_ata, - vpool: accounts.vpool, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.virtuals_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.vpool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializeInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.virtuals_mint.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.vpool_virtuals_ata.clone()); - account_infos.push(self.vpool_token_ata.clone()); - account_infos.push(self.vpool.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Initialize` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` payer -/// 1. `[]` virtuals_mint -/// 2. `[writable]` token_mint -/// 3. `[writable]` vpool_virtuals_ata -/// 4. `[writable]` vpool_token_ata -/// 5. `[writable]` vpool -/// 6. `[]` token_program -/// 7. `[]` associated_token_program -/// 8. `[]` system_program -#[derive(Clone, Debug)] -pub struct InitializeCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeCpiBuilderInstruction { - __program: program, - payer: None, - virtuals_mint: None, - token_mint: None, - vpool_virtuals_ata: None, - vpool_token_ata: None, - vpool: None, - token_program: None, - associated_token_program: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn virtuals_mint( - &mut self, - virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_mint = Some(virtuals_mint); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata( - &mut self, - vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata( - &mut self, - vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_token_ata = Some(vpool_token_ata); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializeCpi { - __program: self.instruction.__program, - - payer: self.instruction.payer.expect("payer is not set"), - - virtuals_mint: self - .instruction - .virtuals_mint - .expect("virtuals_mint is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - vpool_virtuals_ata: self - .instruction - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - - vpool_token_ata: self - .instruction - .vpool_token_ata - .expect("vpool_token_ata is not set"), - - vpool: self.instruction.vpool.expect("vpool is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/virtuals-parser/src/generated_sdk/instructions/initialize_meteora_accounts.rs b/crates/virtuals-parser/src/generated_sdk/instructions/initialize_meteora_accounts.rs deleted file mode 100644 index 34548fb7..00000000 --- a/crates/virtuals-parser/src/generated_sdk/instructions/initialize_meteora_accounts.rs +++ /dev/null @@ -1,1772 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct InitializeMeteoraAccounts { - pub vpool: solana_pubkey::Pubkey, - - pub meteora_deployer: solana_pubkey::Pubkey, - - pub meteora_deployer_virtuals_ata: solana_pubkey::Pubkey, - - pub meteora_deployer_token_ata: solana_pubkey::Pubkey, - - pub vpool_virtuals_ata: solana_pubkey::Pubkey, - - pub vpool_token_ata: solana_pubkey::Pubkey, - - pub lock_escrow: solana_pubkey::Pubkey, - - pub escrow_vault: solana_pubkey::Pubkey, - - pub pool: solana_pubkey::Pubkey, - - pub config: solana_pubkey::Pubkey, - - pub lp_mint: solana_pubkey::Pubkey, - - pub virtuals_mint: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub virtuals_vault: solana_pubkey::Pubkey, - - pub token_vault: solana_pubkey::Pubkey, - - pub virtuals_token_vault: solana_pubkey::Pubkey, - - pub token_token_vault: solana_pubkey::Pubkey, - - pub virtuals_vault_lp_mint: solana_pubkey::Pubkey, - - pub token_vault_lp_mint: solana_pubkey::Pubkey, - - pub virtuals_vault_lp: solana_pubkey::Pubkey, - - pub token_vault_lp: solana_pubkey::Pubkey, - - pub pool_virtuals_ata: solana_pubkey::Pubkey, - - pub pool_token_ata: solana_pubkey::Pubkey, - - pub meteora_deployer_pool_lp: solana_pubkey::Pubkey, - - pub protocol_virtuals_fee: solana_pubkey::Pubkey, - - pub protocol_token_fee: solana_pubkey::Pubkey, - - pub payer: solana_pubkey::Pubkey, - - pub token_metadata: solana_pubkey::Pubkey, - /// Rent account. - pub rent: solana_pubkey::Pubkey, - - pub mint_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - - pub vault_program: solana_pubkey::Pubkey, - /// Token program. - pub token_program: solana_pubkey::Pubkey, - /// Associated token program. - pub associated_token_program: solana_pubkey::Pubkey, - /// System program. - pub system_program: solana_pubkey::Pubkey, - - pub dynamic_amm_program: solana_pubkey::Pubkey, -} - -impl InitializeMeteoraAccounts { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(36 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.vpool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.meteora_deployer, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.meteora_deployer_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.meteora_deployer_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.lock_escrow, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.escrow_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.pool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.config, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.virtuals_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_token_vault, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_lp_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.virtuals_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.token_vault_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.pool_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.meteora_deployer_pool_lp, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_virtuals_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.protocol_token_fee, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.mint_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vault_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.dynamic_amm_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&InitializeMeteoraAccountsInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct InitializeMeteoraAccountsInstructionData { - discriminator: [u8; 8], -} - -impl InitializeMeteoraAccountsInstructionData { - pub fn new() -> Self { - Self { - discriminator: [53, 12, 118, 158, 253, 239, 185, 214], - } - } -} - -impl Default for InitializeMeteoraAccountsInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `InitializeMeteoraAccounts`. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vpool -/// 1. `[writable]` meteora_deployer -/// 2. `[writable]` meteora_deployer_virtuals_ata -/// 3. `[writable]` meteora_deployer_token_ata -/// 4. `[writable]` vpool_virtuals_ata -/// 5. `[writable]` vpool_token_ata -/// 6. `[writable]` lock_escrow -/// 7. `[writable]` escrow_vault -/// 8. `[writable]` pool -/// 9. `[optional]` config (default to `B6FT4AHhQJ7BttrC1i223km5bYRUA2nVwBR7k5TVwLtx`) -/// 10. `[writable]` lp_mint -/// 11. `[optional]` virtuals_mint (default to `3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y`) -/// 12. `[]` token_mint -/// 13. `[writable]` virtuals_vault -/// 14. `[writable]` token_vault -/// 15. `[writable]` virtuals_token_vault -/// 16. `[writable]` token_token_vault -/// 17. `[writable]` virtuals_vault_lp_mint -/// 18. `[writable]` token_vault_lp_mint -/// 19. `[writable]` virtuals_vault_lp -/// 20. `[writable]` token_vault_lp -/// 21. `[writable]` pool_virtuals_ata -/// 22. `[writable]` pool_token_ata -/// 23. `[writable]` meteora_deployer_pool_lp -/// 24. `[writable]` protocol_virtuals_fee -/// 25. `[writable]` protocol_token_fee -/// 26. `[writable, signer]` payer -/// 27. `[writable]` token_metadata -/// 28. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -/// 29. `[writable]` mint_metadata -/// 30. `[optional]` metadata_program (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -/// 31. `[optional]` vault_program (default to `24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi`) -/// 32. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 33. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 34. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 35. `[optional]` dynamic_amm_program (default to `Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB`) -#[derive(Clone, Debug, Default)] -pub struct InitializeMeteoraAccountsBuilder { - vpool: Option, - meteora_deployer: Option, - meteora_deployer_virtuals_ata: Option, - meteora_deployer_token_ata: Option, - vpool_virtuals_ata: Option, - vpool_token_ata: Option, - lock_escrow: Option, - escrow_vault: Option, - pool: Option, - config: Option, - lp_mint: Option, - virtuals_mint: Option, - token_mint: Option, - virtuals_vault: Option, - token_vault: Option, - virtuals_token_vault: Option, - token_token_vault: Option, - virtuals_vault_lp_mint: Option, - token_vault_lp_mint: Option, - virtuals_vault_lp: Option, - token_vault_lp: Option, - pool_virtuals_ata: Option, - pool_token_ata: Option, - meteora_deployer_pool_lp: Option, - protocol_virtuals_fee: Option, - protocol_token_fee: Option, - payer: Option, - token_metadata: Option, - rent: Option, - mint_metadata: Option, - metadata_program: Option, - vault_program: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - dynamic_amm_program: Option, - __remaining_accounts: Vec, -} - -impl InitializeMeteoraAccountsBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn vpool(&mut self, vpool: solana_pubkey::Pubkey) -> &mut Self { - self.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn meteora_deployer(&mut self, meteora_deployer: solana_pubkey::Pubkey) -> &mut Self { - self.meteora_deployer = Some(meteora_deployer); - self - } - - #[inline(always)] - pub fn meteora_deployer_virtuals_ata( - &mut self, - meteora_deployer_virtuals_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.meteora_deployer_virtuals_ata = Some(meteora_deployer_virtuals_ata); - self - } - - #[inline(always)] - pub fn meteora_deployer_token_ata( - &mut self, - meteora_deployer_token_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.meteora_deployer_token_ata = Some(meteora_deployer_token_ata); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata(&mut self, vpool_virtuals_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata(&mut self, vpool_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_token_ata = Some(vpool_token_ata); - self - } - - #[inline(always)] - pub fn lock_escrow(&mut self, lock_escrow: solana_pubkey::Pubkey) -> &mut Self { - self.lock_escrow = Some(lock_escrow); - self - } - - #[inline(always)] - pub fn escrow_vault(&mut self, escrow_vault: solana_pubkey::Pubkey) -> &mut Self { - self.escrow_vault = Some(escrow_vault); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self { - self.pool = Some(pool); - self - } - - /// `[optional account, default to 'B6FT4AHhQJ7BttrC1i223km5bYRUA2nVwBR7k5TVwLtx']` - #[inline(always)] - pub fn config(&mut self, config: solana_pubkey::Pubkey) -> &mut Self { - self.config = Some(config); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.lp_mint = Some(lp_mint); - self - } - - /// `[optional account, default to '3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y']` - #[inline(always)] - pub fn virtuals_mint(&mut self, virtuals_mint: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_mint = Some(virtuals_mint); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn virtuals_vault(&mut self, virtuals_vault: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_vault = Some(virtuals_vault); - self - } - - #[inline(always)] - pub fn token_vault(&mut self, token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault = Some(token_vault); - self - } - - #[inline(always)] - pub fn virtuals_token_vault( - &mut self, - virtuals_token_vault: solana_pubkey::Pubkey, - ) -> &mut Self { - self.virtuals_token_vault = Some(virtuals_token_vault); - self - } - - #[inline(always)] - pub fn token_token_vault(&mut self, token_token_vault: solana_pubkey::Pubkey) -> &mut Self { - self.token_token_vault = Some(token_token_vault); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp_mint( - &mut self, - virtuals_vault_lp_mint: solana_pubkey::Pubkey, - ) -> &mut Self { - self.virtuals_vault_lp_mint = Some(virtuals_vault_lp_mint); - self - } - - #[inline(always)] - pub fn token_vault_lp_mint(&mut self, token_vault_lp_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_lp_mint = Some(token_vault_lp_mint); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp(&mut self, virtuals_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_vault_lp = Some(virtuals_vault_lp); - self - } - - #[inline(always)] - pub fn token_vault_lp(&mut self, token_vault_lp: solana_pubkey::Pubkey) -> &mut Self { - self.token_vault_lp = Some(token_vault_lp); - self - } - - #[inline(always)] - pub fn pool_virtuals_ata(&mut self, pool_virtuals_ata: solana_pubkey::Pubkey) -> &mut Self { - self.pool_virtuals_ata = Some(pool_virtuals_ata); - self - } - - #[inline(always)] - pub fn pool_token_ata(&mut self, pool_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.pool_token_ata = Some(pool_token_ata); - self - } - - #[inline(always)] - pub fn meteora_deployer_pool_lp( - &mut self, - meteora_deployer_pool_lp: solana_pubkey::Pubkey, - ) -> &mut Self { - self.meteora_deployer_pool_lp = Some(meteora_deployer_pool_lp); - self - } - - #[inline(always)] - pub fn protocol_virtuals_fee( - &mut self, - protocol_virtuals_fee: solana_pubkey::Pubkey, - ) -> &mut Self { - self.protocol_virtuals_fee = Some(protocol_virtuals_fee); - self - } - - #[inline(always)] - pub fn protocol_token_fee(&mut self, protocol_token_fee: solana_pubkey::Pubkey) -> &mut Self { - self.protocol_token_fee = Some(protocol_token_fee); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { - self.payer = Some(payer); - self - } - - #[inline(always)] - pub fn token_metadata(&mut self, token_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.token_metadata = Some(token_metadata); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata(&mut self, mint_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.mint_metadata = Some(mint_metadata); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// `[optional account, default to '24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi']` - #[inline(always)] - pub fn vault_program(&mut self, vault_program: solana_pubkey::Pubkey) -> &mut Self { - self.vault_program = Some(vault_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - /// Token program. - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - /// System program. - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB']` - #[inline(always)] - pub fn dynamic_amm_program(&mut self, dynamic_amm_program: solana_pubkey::Pubkey) -> &mut Self { - self.dynamic_amm_program = Some(dynamic_amm_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = InitializeMeteoraAccounts { - vpool: self.vpool.expect("vpool is not set"), - meteora_deployer: self.meteora_deployer.expect("meteora_deployer is not set"), - meteora_deployer_virtuals_ata: self - .meteora_deployer_virtuals_ata - .expect("meteora_deployer_virtuals_ata is not set"), - meteora_deployer_token_ata: self - .meteora_deployer_token_ata - .expect("meteora_deployer_token_ata is not set"), - vpool_virtuals_ata: self - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - vpool_token_ata: self.vpool_token_ata.expect("vpool_token_ata is not set"), - lock_escrow: self.lock_escrow.expect("lock_escrow is not set"), - escrow_vault: self.escrow_vault.expect("escrow_vault is not set"), - pool: self.pool.expect("pool is not set"), - config: self.config.unwrap_or(solana_pubkey::pubkey!( - "B6FT4AHhQJ7BttrC1i223km5bYRUA2nVwBR7k5TVwLtx" - )), - lp_mint: self.lp_mint.expect("lp_mint is not set"), - virtuals_mint: self.virtuals_mint.unwrap_or(solana_pubkey::pubkey!( - "3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y" - )), - token_mint: self.token_mint.expect("token_mint is not set"), - virtuals_vault: self.virtuals_vault.expect("virtuals_vault is not set"), - token_vault: self.token_vault.expect("token_vault is not set"), - virtuals_token_vault: self - .virtuals_token_vault - .expect("virtuals_token_vault is not set"), - token_token_vault: self - .token_token_vault - .expect("token_token_vault is not set"), - virtuals_vault_lp_mint: self - .virtuals_vault_lp_mint - .expect("virtuals_vault_lp_mint is not set"), - token_vault_lp_mint: self - .token_vault_lp_mint - .expect("token_vault_lp_mint is not set"), - virtuals_vault_lp: self - .virtuals_vault_lp - .expect("virtuals_vault_lp is not set"), - token_vault_lp: self.token_vault_lp.expect("token_vault_lp is not set"), - pool_virtuals_ata: self - .pool_virtuals_ata - .expect("pool_virtuals_ata is not set"), - pool_token_ata: self.pool_token_ata.expect("pool_token_ata is not set"), - meteora_deployer_pool_lp: self - .meteora_deployer_pool_lp - .expect("meteora_deployer_pool_lp is not set"), - protocol_virtuals_fee: self - .protocol_virtuals_fee - .expect("protocol_virtuals_fee is not set"), - protocol_token_fee: self - .protocol_token_fee - .expect("protocol_token_fee is not set"), - payer: self.payer.expect("payer is not set"), - token_metadata: self.token_metadata.expect("token_metadata is not set"), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - mint_metadata: self.mint_metadata.expect("mint_metadata is not set"), - metadata_program: self.metadata_program.unwrap_or(solana_pubkey::pubkey!( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - )), - vault_program: self.vault_program.unwrap_or(solana_pubkey::pubkey!( - "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" - )), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - dynamic_amm_program: self.dynamic_amm_program.unwrap_or(solana_pubkey::pubkey!( - "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" - )), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `initialize_meteora_accounts` CPI accounts. -pub struct InitializeMeteoraAccountsCpiAccounts<'a, 'b> { - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub pool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub pool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_virtuals_fee: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_fee: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub token_metadata: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub dynamic_amm_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `initialize_meteora_accounts` CPI instruction. -pub struct InitializeMeteoraAccountsCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub lock_escrow: &'b solana_account_info::AccountInfo<'a>, - - pub escrow_vault: &'b solana_account_info::AccountInfo<'a>, - - pub pool: &'b solana_account_info::AccountInfo<'a>, - - pub config: &'b solana_account_info::AccountInfo<'a>, - - pub lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub token_token_vault: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub token_vault_lp: &'b solana_account_info::AccountInfo<'a>, - - pub pool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub pool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub meteora_deployer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_virtuals_fee: &'b solana_account_info::AccountInfo<'a>, - - pub protocol_token_fee: &'b solana_account_info::AccountInfo<'a>, - - pub payer: &'b solana_account_info::AccountInfo<'a>, - - pub token_metadata: &'b solana_account_info::AccountInfo<'a>, - /// Rent account. - pub rent: &'b solana_account_info::AccountInfo<'a>, - - pub mint_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub vault_program: &'b solana_account_info::AccountInfo<'a>, - /// Token program. - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// Associated token program. - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - /// System program. - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub dynamic_amm_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> InitializeMeteoraAccountsCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: InitializeMeteoraAccountsCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - vpool: accounts.vpool, - meteora_deployer: accounts.meteora_deployer, - meteora_deployer_virtuals_ata: accounts.meteora_deployer_virtuals_ata, - meteora_deployer_token_ata: accounts.meteora_deployer_token_ata, - vpool_virtuals_ata: accounts.vpool_virtuals_ata, - vpool_token_ata: accounts.vpool_token_ata, - lock_escrow: accounts.lock_escrow, - escrow_vault: accounts.escrow_vault, - pool: accounts.pool, - config: accounts.config, - lp_mint: accounts.lp_mint, - virtuals_mint: accounts.virtuals_mint, - token_mint: accounts.token_mint, - virtuals_vault: accounts.virtuals_vault, - token_vault: accounts.token_vault, - virtuals_token_vault: accounts.virtuals_token_vault, - token_token_vault: accounts.token_token_vault, - virtuals_vault_lp_mint: accounts.virtuals_vault_lp_mint, - token_vault_lp_mint: accounts.token_vault_lp_mint, - virtuals_vault_lp: accounts.virtuals_vault_lp, - token_vault_lp: accounts.token_vault_lp, - pool_virtuals_ata: accounts.pool_virtuals_ata, - pool_token_ata: accounts.pool_token_ata, - meteora_deployer_pool_lp: accounts.meteora_deployer_pool_lp, - protocol_virtuals_fee: accounts.protocol_virtuals_fee, - protocol_token_fee: accounts.protocol_token_fee, - payer: accounts.payer, - token_metadata: accounts.token_metadata, - rent: accounts.rent, - mint_metadata: accounts.mint_metadata, - metadata_program: accounts.metadata_program, - vault_program: accounts.vault_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - dynamic_amm_program: accounts.dynamic_amm_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(36 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(*self.vpool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.meteora_deployer.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.meteora_deployer_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.meteora_deployer_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lock_escrow.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.escrow_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.config.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.virtuals_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_token_vault.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_lp_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.virtuals_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_vault_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.pool_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.meteora_deployer_pool_lp.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_virtuals_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.protocol_token_fee.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.mint_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vault_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.dynamic_amm_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&InitializeMeteoraAccountsInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(37 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.vpool.clone()); - account_infos.push(self.meteora_deployer.clone()); - account_infos.push(self.meteora_deployer_virtuals_ata.clone()); - account_infos.push(self.meteora_deployer_token_ata.clone()); - account_infos.push(self.vpool_virtuals_ata.clone()); - account_infos.push(self.vpool_token_ata.clone()); - account_infos.push(self.lock_escrow.clone()); - account_infos.push(self.escrow_vault.clone()); - account_infos.push(self.pool.clone()); - account_infos.push(self.config.clone()); - account_infos.push(self.lp_mint.clone()); - account_infos.push(self.virtuals_mint.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.virtuals_vault.clone()); - account_infos.push(self.token_vault.clone()); - account_infos.push(self.virtuals_token_vault.clone()); - account_infos.push(self.token_token_vault.clone()); - account_infos.push(self.virtuals_vault_lp_mint.clone()); - account_infos.push(self.token_vault_lp_mint.clone()); - account_infos.push(self.virtuals_vault_lp.clone()); - account_infos.push(self.token_vault_lp.clone()); - account_infos.push(self.pool_virtuals_ata.clone()); - account_infos.push(self.pool_token_ata.clone()); - account_infos.push(self.meteora_deployer_pool_lp.clone()); - account_infos.push(self.protocol_virtuals_fee.clone()); - account_infos.push(self.protocol_token_fee.clone()); - account_infos.push(self.payer.clone()); - account_infos.push(self.token_metadata.clone()); - account_infos.push(self.rent.clone()); - account_infos.push(self.mint_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.vault_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.dynamic_amm_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `InitializeMeteoraAccounts` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable]` vpool -/// 1. `[writable]` meteora_deployer -/// 2. `[writable]` meteora_deployer_virtuals_ata -/// 3. `[writable]` meteora_deployer_token_ata -/// 4. `[writable]` vpool_virtuals_ata -/// 5. `[writable]` vpool_token_ata -/// 6. `[writable]` lock_escrow -/// 7. `[writable]` escrow_vault -/// 8. `[writable]` pool -/// 9. `[]` config -/// 10. `[writable]` lp_mint -/// 11. `[]` virtuals_mint -/// 12. `[]` token_mint -/// 13. `[writable]` virtuals_vault -/// 14. `[writable]` token_vault -/// 15. `[writable]` virtuals_token_vault -/// 16. `[writable]` token_token_vault -/// 17. `[writable]` virtuals_vault_lp_mint -/// 18. `[writable]` token_vault_lp_mint -/// 19. `[writable]` virtuals_vault_lp -/// 20. `[writable]` token_vault_lp -/// 21. `[writable]` pool_virtuals_ata -/// 22. `[writable]` pool_token_ata -/// 23. `[writable]` meteora_deployer_pool_lp -/// 24. `[writable]` protocol_virtuals_fee -/// 25. `[writable]` protocol_token_fee -/// 26. `[writable, signer]` payer -/// 27. `[writable]` token_metadata -/// 28. `[]` rent -/// 29. `[writable]` mint_metadata -/// 30. `[]` metadata_program -/// 31. `[]` vault_program -/// 32. `[]` token_program -/// 33. `[]` associated_token_program -/// 34. `[]` system_program -/// 35. `[]` dynamic_amm_program -#[derive(Clone, Debug)] -pub struct InitializeMeteoraAccountsCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> InitializeMeteoraAccountsCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(InitializeMeteoraAccountsCpiBuilderInstruction { - __program: program, - vpool: None, - meteora_deployer: None, - meteora_deployer_virtuals_ata: None, - meteora_deployer_token_ata: None, - vpool_virtuals_ata: None, - vpool_token_ata: None, - lock_escrow: None, - escrow_vault: None, - pool: None, - config: None, - lp_mint: None, - virtuals_mint: None, - token_mint: None, - virtuals_vault: None, - token_vault: None, - virtuals_token_vault: None, - token_token_vault: None, - virtuals_vault_lp_mint: None, - token_vault_lp_mint: None, - virtuals_vault_lp: None, - token_vault_lp: None, - pool_virtuals_ata: None, - pool_token_ata: None, - meteora_deployer_pool_lp: None, - protocol_virtuals_fee: None, - protocol_token_fee: None, - payer: None, - token_metadata: None, - rent: None, - mint_metadata: None, - metadata_program: None, - vault_program: None, - token_program: None, - associated_token_program: None, - system_program: None, - dynamic_amm_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn meteora_deployer( - &mut self, - meteora_deployer: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.meteora_deployer = Some(meteora_deployer); - self - } - - #[inline(always)] - pub fn meteora_deployer_virtuals_ata( - &mut self, - meteora_deployer_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.meteora_deployer_virtuals_ata = Some(meteora_deployer_virtuals_ata); - self - } - - #[inline(always)] - pub fn meteora_deployer_token_ata( - &mut self, - meteora_deployer_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.meteora_deployer_token_ata = Some(meteora_deployer_token_ata); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata( - &mut self, - vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata( - &mut self, - vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_token_ata = Some(vpool_token_ata); - self - } - - #[inline(always)] - pub fn lock_escrow( - &mut self, - lock_escrow: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.lock_escrow = Some(lock_escrow); - self - } - - #[inline(always)] - pub fn escrow_vault( - &mut self, - escrow_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.escrow_vault = Some(escrow_vault); - self - } - - #[inline(always)] - pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.pool = Some(pool); - self - } - - #[inline(always)] - pub fn config(&mut self, config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.config = Some(config); - self - } - - #[inline(always)] - pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.lp_mint = Some(lp_mint); - self - } - - #[inline(always)] - pub fn virtuals_mint( - &mut self, - virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_mint = Some(virtuals_mint); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn virtuals_vault( - &mut self, - virtuals_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_vault = Some(virtuals_vault); - self - } - - #[inline(always)] - pub fn token_vault( - &mut self, - token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault = Some(token_vault); - self - } - - #[inline(always)] - pub fn virtuals_token_vault( - &mut self, - virtuals_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_token_vault = Some(virtuals_token_vault); - self - } - - #[inline(always)] - pub fn token_token_vault( - &mut self, - token_token_vault: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_token_vault = Some(token_token_vault); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp_mint( - &mut self, - virtuals_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_vault_lp_mint = Some(virtuals_vault_lp_mint); - self - } - - #[inline(always)] - pub fn token_vault_lp_mint( - &mut self, - token_vault_lp_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_lp_mint = Some(token_vault_lp_mint); - self - } - - #[inline(always)] - pub fn virtuals_vault_lp( - &mut self, - virtuals_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_vault_lp = Some(virtuals_vault_lp); - self - } - - #[inline(always)] - pub fn token_vault_lp( - &mut self, - token_vault_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_vault_lp = Some(token_vault_lp); - self - } - - #[inline(always)] - pub fn pool_virtuals_ata( - &mut self, - pool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_virtuals_ata = Some(pool_virtuals_ata); - self - } - - #[inline(always)] - pub fn pool_token_ata( - &mut self, - pool_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.pool_token_ata = Some(pool_token_ata); - self - } - - #[inline(always)] - pub fn meteora_deployer_pool_lp( - &mut self, - meteora_deployer_pool_lp: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.meteora_deployer_pool_lp = Some(meteora_deployer_pool_lp); - self - } - - #[inline(always)] - pub fn protocol_virtuals_fee( - &mut self, - protocol_virtuals_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_virtuals_fee = Some(protocol_virtuals_fee); - self - } - - #[inline(always)] - pub fn protocol_token_fee( - &mut self, - protocol_token_fee: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.protocol_token_fee = Some(protocol_token_fee); - self - } - - #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.payer = Some(payer); - self - } - - #[inline(always)] - pub fn token_metadata( - &mut self, - token_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_metadata = Some(token_metadata); - self - } - - /// Rent account. - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn mint_metadata( - &mut self, - mint_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.mint_metadata = Some(mint_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - #[inline(always)] - pub fn vault_program( - &mut self, - vault_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vault_program = Some(vault_program); - self - } - - /// Token program. - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - /// Associated token program. - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - /// System program. - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn dynamic_amm_program( - &mut self, - dynamic_amm_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.dynamic_amm_program = Some(dynamic_amm_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = InitializeMeteoraAccountsCpi { - __program: self.instruction.__program, - - vpool: self.instruction.vpool.expect("vpool is not set"), - - meteora_deployer: self - .instruction - .meteora_deployer - .expect("meteora_deployer is not set"), - - meteora_deployer_virtuals_ata: self - .instruction - .meteora_deployer_virtuals_ata - .expect("meteora_deployer_virtuals_ata is not set"), - - meteora_deployer_token_ata: self - .instruction - .meteora_deployer_token_ata - .expect("meteora_deployer_token_ata is not set"), - - vpool_virtuals_ata: self - .instruction - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - - vpool_token_ata: self - .instruction - .vpool_token_ata - .expect("vpool_token_ata is not set"), - - lock_escrow: self - .instruction - .lock_escrow - .expect("lock_escrow is not set"), - - escrow_vault: self - .instruction - .escrow_vault - .expect("escrow_vault is not set"), - - pool: self.instruction.pool.expect("pool is not set"), - - config: self.instruction.config.expect("config is not set"), - - lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"), - - virtuals_mint: self - .instruction - .virtuals_mint - .expect("virtuals_mint is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - virtuals_vault: self - .instruction - .virtuals_vault - .expect("virtuals_vault is not set"), - - token_vault: self - .instruction - .token_vault - .expect("token_vault is not set"), - - virtuals_token_vault: self - .instruction - .virtuals_token_vault - .expect("virtuals_token_vault is not set"), - - token_token_vault: self - .instruction - .token_token_vault - .expect("token_token_vault is not set"), - - virtuals_vault_lp_mint: self - .instruction - .virtuals_vault_lp_mint - .expect("virtuals_vault_lp_mint is not set"), - - token_vault_lp_mint: self - .instruction - .token_vault_lp_mint - .expect("token_vault_lp_mint is not set"), - - virtuals_vault_lp: self - .instruction - .virtuals_vault_lp - .expect("virtuals_vault_lp is not set"), - - token_vault_lp: self - .instruction - .token_vault_lp - .expect("token_vault_lp is not set"), - - pool_virtuals_ata: self - .instruction - .pool_virtuals_ata - .expect("pool_virtuals_ata is not set"), - - pool_token_ata: self - .instruction - .pool_token_ata - .expect("pool_token_ata is not set"), - - meteora_deployer_pool_lp: self - .instruction - .meteora_deployer_pool_lp - .expect("meteora_deployer_pool_lp is not set"), - - protocol_virtuals_fee: self - .instruction - .protocol_virtuals_fee - .expect("protocol_virtuals_fee is not set"), - - protocol_token_fee: self - .instruction - .protocol_token_fee - .expect("protocol_token_fee is not set"), - - payer: self.instruction.payer.expect("payer is not set"), - - token_metadata: self - .instruction - .token_metadata - .expect("token_metadata is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - - mint_metadata: self - .instruction - .mint_metadata - .expect("mint_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - vault_program: self - .instruction - .vault_program - .expect("vault_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - dynamic_amm_program: self - .instruction - .dynamic_amm_program - .expect("dynamic_amm_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct InitializeMeteoraAccountsCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - vpool: Option<&'b solana_account_info::AccountInfo<'a>>, - meteora_deployer: Option<&'b solana_account_info::AccountInfo<'a>>, - meteora_deployer_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - meteora_deployer_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - lock_escrow: Option<&'b solana_account_info::AccountInfo<'a>>, - escrow_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - pool: Option<&'b solana_account_info::AccountInfo<'a>>, - config: Option<&'b solana_account_info::AccountInfo<'a>>, - lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - token_token_vault: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - token_vault_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - pool_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - meteora_deployer_pool_lp: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_virtuals_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - protocol_token_fee: Option<&'b solana_account_info::AccountInfo<'a>>, - payer: Option<&'b solana_account_info::AccountInfo<'a>>, - token_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - mint_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - vault_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - dynamic_amm_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/virtuals-parser/src/generated_sdk/instructions/launch.rs b/crates/virtuals-parser/src/generated_sdk/instructions/launch.rs deleted file mode 100644 index c416b294..00000000 --- a/crates/virtuals-parser/src/generated_sdk/instructions/launch.rs +++ /dev/null @@ -1,815 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Launch { - pub creator: solana_pubkey::Pubkey, - - pub creator_virtuals_ata: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub platform_prototype: solana_pubkey::Pubkey, - - pub platform_prototype_virtuals_ata: solana_pubkey::Pubkey, - - pub vpool: solana_pubkey::Pubkey, - - pub token_metadata: solana_pubkey::Pubkey, - - pub metadata_program: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, - - pub rent: solana_pubkey::Pubkey, -} - -impl Launch { - pub fn instruction(&self, args: LaunchInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: LaunchInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.creator, true)); - accounts.push(solana_instruction::AccountMeta::new( - self.creator_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.token_mint, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_prototype, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_prototype_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(self.vpool, false)); - accounts.push(solana_instruction::AccountMeta::new( - self.token_metadata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.metadata_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.rent, false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&LaunchInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LaunchInstructionData { - discriminator: [u8; 8], -} - -impl LaunchInstructionData { - pub fn new() -> Self { - Self { - discriminator: [153, 241, 93, 225, 22, 69, 74, 61], - } - } -} - -impl Default for LaunchInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LaunchInstructionArgs { - pub symbol: String, - pub name: String, - pub uri: String, -} - -/// Instruction builder for `Launch`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[writable]` creator_virtuals_ata -/// 2. `[writable]` token_mint -/// 3. `[writable, optional]` platform_prototype (default to `933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL`) -/// 4. `[writable]` platform_prototype_virtuals_ata -/// 5. `[writable]` vpool -/// 6. `[writable]` token_metadata -/// 7. `[optional]` metadata_program (default to `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s`) -/// 8. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 9. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 10. `[optional]` system_program (default to `11111111111111111111111111111111`) -/// 11. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct LaunchBuilder { - creator: Option, - creator_virtuals_ata: Option, - token_mint: Option, - platform_prototype: Option, - platform_prototype_virtuals_ata: Option, - vpool: Option, - token_metadata: Option, - metadata_program: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - rent: Option, - symbol: Option, - name: Option, - uri: Option, - __remaining_accounts: Vec, -} - -impl LaunchBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn creator_virtuals_ata( - &mut self, - creator_virtuals_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.creator_virtuals_ata = Some(creator_virtuals_ata); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - /// `[optional account, default to '933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL']` - #[inline(always)] - pub fn platform_prototype(&mut self, platform_prototype: solana_pubkey::Pubkey) -> &mut Self { - self.platform_prototype = Some(platform_prototype); - self - } - - #[inline(always)] - pub fn platform_prototype_virtuals_ata( - &mut self, - platform_prototype_virtuals_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.platform_prototype_virtuals_ata = Some(platform_prototype_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: solana_pubkey::Pubkey) -> &mut Self { - self.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn token_metadata(&mut self, token_metadata: solana_pubkey::Pubkey) -> &mut Self { - self.token_metadata = Some(token_metadata); - self - } - - /// `[optional account, default to 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s']` - #[inline(always)] - pub fn metadata_program(&mut self, metadata_program: solana_pubkey::Pubkey) -> &mut Self { - self.metadata_program = Some(metadata_program); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` - #[inline(always)] - pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - - #[inline(always)] - pub fn symbol(&mut self, symbol: String) -> &mut Self { - self.symbol = Some(symbol); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.name = Some(name); - self - } - - #[inline(always)] - pub fn uri(&mut self, uri: String) -> &mut Self { - self.uri = Some(uri); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Launch { - creator: self.creator.expect("creator is not set"), - creator_virtuals_ata: self - .creator_virtuals_ata - .expect("creator_virtuals_ata is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - platform_prototype: self.platform_prototype.unwrap_or(solana_pubkey::pubkey!( - "933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL" - )), - platform_prototype_virtuals_ata: self - .platform_prototype_virtuals_ata - .expect("platform_prototype_virtuals_ata is not set"), - vpool: self.vpool.expect("vpool is not set"), - token_metadata: self.token_metadata.expect("token_metadata is not set"), - metadata_program: self.metadata_program.unwrap_or(solana_pubkey::pubkey!( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" - )), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - rent: self.rent.unwrap_or(solana_pubkey::pubkey!( - "SysvarRent111111111111111111111111111111111" - )), - }; - let args = LaunchInstructionArgs { - symbol: self.symbol.clone().expect("symbol is not set"), - name: self.name.clone().expect("name is not set"), - uri: self.uri.clone().expect("uri is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `launch` CPI accounts. -pub struct LaunchCpiAccounts<'a, 'b> { - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub creator_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, -} - -/// `launch` CPI instruction. -pub struct LaunchCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub creator_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_metadata: &'b solana_account_info::AccountInfo<'a>, - - pub metadata_program: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, - - pub rent: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: LaunchInstructionArgs, -} - -impl<'a, 'b> LaunchCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: LaunchCpiAccounts<'a, 'b>, - args: LaunchInstructionArgs, - ) -> Self { - Self { - __program: program, - creator: accounts.creator, - creator_virtuals_ata: accounts.creator_virtuals_ata, - token_mint: accounts.token_mint, - platform_prototype: accounts.platform_prototype, - platform_prototype_virtuals_ata: accounts.platform_prototype_virtuals_ata, - vpool: accounts.vpool, - token_metadata: accounts.token_metadata, - metadata_program: accounts.metadata_program, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - rent: accounts.rent, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_prototype.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_prototype_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.vpool.key, false)); - accounts.push(solana_instruction::AccountMeta::new( - *self.token_metadata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.metadata_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.rent.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&LaunchInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.creator_virtuals_ata.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.platform_prototype.clone()); - account_infos.push(self.platform_prototype_virtuals_ata.clone()); - account_infos.push(self.vpool.clone()); - account_infos.push(self.token_metadata.clone()); - account_infos.push(self.metadata_program.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - account_infos.push(self.rent.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Launch` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[writable]` creator_virtuals_ata -/// 2. `[writable]` token_mint -/// 3. `[writable]` platform_prototype -/// 4. `[writable]` platform_prototype_virtuals_ata -/// 5. `[writable]` vpool -/// 6. `[writable]` token_metadata -/// 7. `[]` metadata_program -/// 8. `[]` token_program -/// 9. `[]` associated_token_program -/// 10. `[]` system_program -/// 11. `[]` rent -#[derive(Clone, Debug)] -pub struct LaunchCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> LaunchCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(LaunchCpiBuilderInstruction { - __program: program, - creator: None, - creator_virtuals_ata: None, - token_mint: None, - platform_prototype: None, - platform_prototype_virtuals_ata: None, - vpool: None, - token_metadata: None, - metadata_program: None, - token_program: None, - associated_token_program: None, - system_program: None, - rent: None, - symbol: None, - name: None, - uri: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn creator_virtuals_ata( - &mut self, - creator_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.creator_virtuals_ata = Some(creator_virtuals_ata); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn platform_prototype( - &mut self, - platform_prototype: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_prototype = Some(platform_prototype); - self - } - - #[inline(always)] - pub fn platform_prototype_virtuals_ata( - &mut self, - platform_prototype_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_prototype_virtuals_ata = Some(platform_prototype_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn token_metadata( - &mut self, - token_metadata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_metadata = Some(token_metadata); - self - } - - #[inline(always)] - pub fn metadata_program( - &mut self, - metadata_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.metadata_program = Some(metadata_program); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - - #[inline(always)] - pub fn symbol(&mut self, symbol: String) -> &mut Self { - self.instruction.symbol = Some(symbol); - self - } - - #[inline(always)] - pub fn name(&mut self, name: String) -> &mut Self { - self.instruction.name = Some(name); - self - } - - #[inline(always)] - pub fn uri(&mut self, uri: String) -> &mut Self { - self.instruction.uri = Some(uri); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = LaunchInstructionArgs { - symbol: self.instruction.symbol.clone().expect("symbol is not set"), - name: self.instruction.name.clone().expect("name is not set"), - uri: self.instruction.uri.clone().expect("uri is not set"), - }; - let instruction = LaunchCpi { - __program: self.instruction.__program, - - creator: self.instruction.creator.expect("creator is not set"), - - creator_virtuals_ata: self - .instruction - .creator_virtuals_ata - .expect("creator_virtuals_ata is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - platform_prototype: self - .instruction - .platform_prototype - .expect("platform_prototype is not set"), - - platform_prototype_virtuals_ata: self - .instruction - .platform_prototype_virtuals_ata - .expect("platform_prototype_virtuals_ata is not set"), - - vpool: self.instruction.vpool.expect("vpool is not set"), - - token_metadata: self - .instruction - .token_metadata - .expect("token_metadata is not set"), - - metadata_program: self - .instruction - .metadata_program - .expect("metadata_program is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - - rent: self.instruction.rent.expect("rent is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct LaunchCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - creator_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_prototype: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_prototype_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_metadata: Option<&'b solana_account_info::AccountInfo<'a>>, - metadata_program: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - rent: Option<&'b solana_account_info::AccountInfo<'a>>, - symbol: Option, - name: Option, - uri: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/virtuals-parser/src/generated_sdk/instructions/mod.rs b/crates/virtuals-parser/src/generated_sdk/instructions/mod.rs deleted file mode 100644 index 5ceda8e5..00000000 --- a/crates/virtuals-parser/src/generated_sdk/instructions/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#buy; -pub(crate) mod r#claim_fees; -pub(crate) mod r#create_meteora_pool; -pub(crate) mod r#initialize; -pub(crate) mod r#initialize_meteora_accounts; -pub(crate) mod r#launch; -pub(crate) mod r#sell; -pub(crate) mod r#update_pool_creator; - -pub use self::{ - r#buy::*, r#claim_fees::*, r#create_meteora_pool::*, r#initialize::*, - r#initialize_meteora_accounts::*, r#launch::*, r#sell::*, r#update_pool_creator::*, -}; diff --git a/crates/virtuals-parser/src/generated_sdk/instructions/sell.rs b/crates/virtuals-parser/src/generated_sdk/instructions/sell.rs deleted file mode 100644 index 3619be28..00000000 --- a/crates/virtuals-parser/src/generated_sdk/instructions/sell.rs +++ /dev/null @@ -1,716 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct Sell { - pub user: solana_pubkey::Pubkey, - - pub vpool: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub user_virtuals_ata: solana_pubkey::Pubkey, - - pub user_token_ata: solana_pubkey::Pubkey, - - pub vpool_token_ata: solana_pubkey::Pubkey, - - pub platform_prototype: solana_pubkey::Pubkey, - - pub platform_prototype_virtuals_ata: solana_pubkey::Pubkey, - - pub vpool_virtuals_ata: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, -} - -impl Sell { - pub fn instruction(&self, args: SellInstructionArgs) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(args, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - args: SellInstructionArgs, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.user, true, - )); - accounts.push(solana_instruction::AccountMeta::new(self.vpool, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.user_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_prototype, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.platform_prototype_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.vpool_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&SellInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); - data.append(&mut args); - - solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellInstructionData { - discriminator: [u8; 8], -} - -impl SellInstructionData { - pub fn new() -> Self { - Self { - discriminator: [51, 230, 133, 164, 1, 127, 131, 173], - } - } -} - -impl Default for SellInstructionData { - fn default() -> Self { Self::new() } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellInstructionArgs { - pub amount: u64, - pub min_amount_out: u64, -} - -/// Instruction builder for `Sell`. -/// -/// ### Accounts: -/// -/// 0. `[signer]` user -/// 1. `[writable]` vpool -/// 2. `[]` token_mint -/// 3. `[writable]` user_virtuals_ata -/// 4. `[writable]` user_token_ata -/// 5. `[writable]` vpool_token_ata -/// 6. `[writable, optional]` platform_prototype (default to `933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL`) -/// 7. `[writable]` platform_prototype_virtuals_ata -/// 8. `[writable]` vpool_virtuals_ata -/// 9. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -#[derive(Clone, Debug, Default)] -pub struct SellBuilder { - user: Option, - vpool: Option, - token_mint: Option, - user_virtuals_ata: Option, - user_token_ata: Option, - vpool_token_ata: Option, - platform_prototype: Option, - platform_prototype_virtuals_ata: Option, - vpool_virtuals_ata: Option, - token_program: Option, - amount: Option, - min_amount_out: Option, - __remaining_accounts: Vec, -} - -impl SellBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self { - self.user = Some(user); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: solana_pubkey::Pubkey) -> &mut Self { - self.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn user_virtuals_ata(&mut self, user_virtuals_ata: solana_pubkey::Pubkey) -> &mut Self { - self.user_virtuals_ata = Some(user_virtuals_ata); - self - } - - #[inline(always)] - pub fn user_token_ata(&mut self, user_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.user_token_ata = Some(user_token_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata(&mut self, vpool_token_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_token_ata = Some(vpool_token_ata); - self - } - - /// `[optional account, default to '933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL']` - #[inline(always)] - pub fn platform_prototype(&mut self, platform_prototype: solana_pubkey::Pubkey) -> &mut Self { - self.platform_prototype = Some(platform_prototype); - self - } - - #[inline(always)] - pub fn platform_prototype_virtuals_ata( - &mut self, - platform_prototype_virtuals_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.platform_prototype_virtuals_ata = Some(platform_prototype_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata(&mut self, vpool_virtuals_ata: solana_pubkey::Pubkey) -> &mut Self { - self.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); - self - } - - #[inline(always)] - pub fn min_amount_out(&mut self, min_amount_out: u64) -> &mut Self { - self.min_amount_out = Some(min_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = Sell { - user: self.user.expect("user is not set"), - vpool: self.vpool.expect("vpool is not set"), - token_mint: self.token_mint.expect("token_mint is not set"), - user_virtuals_ata: self - .user_virtuals_ata - .expect("user_virtuals_ata is not set"), - user_token_ata: self.user_token_ata.expect("user_token_ata is not set"), - vpool_token_ata: self.vpool_token_ata.expect("vpool_token_ata is not set"), - platform_prototype: self.platform_prototype.unwrap_or(solana_pubkey::pubkey!( - "933jV351WDG23QTcHPqLFJxyYRrEPWRTR3qoPWi3jwEL" - )), - platform_prototype_virtuals_ata: self - .platform_prototype_virtuals_ata - .expect("platform_prototype_virtuals_ata is not set"), - vpool_virtuals_ata: self - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - }; - let args = SellInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), - min_amount_out: self - .min_amount_out - .clone() - .expect("min_amount_out is not set"), - }; - - accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) - } -} - -/// `sell` CPI accounts. -pub struct SellCpiAccounts<'a, 'b> { - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `sell` CPI instruction. -pub struct SellCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub user: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub user_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub user_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype: &'b solana_account_info::AccountInfo<'a>, - - pub platform_prototype_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - /// The arguments for the instruction. - pub __args: SellInstructionArgs, -} - -impl<'a, 'b> SellCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: SellCpiAccounts<'a, 'b>, - args: SellInstructionArgs, - ) -> Self { - Self { - __program: program, - user: accounts.user, - vpool: accounts.vpool, - token_mint: accounts.token_mint, - user_virtuals_ata: accounts.user_virtuals_ata, - user_token_ata: accounts.user_token_ata, - vpool_token_ata: accounts.vpool_token_ata, - platform_prototype: accounts.platform_prototype, - platform_prototype_virtuals_ata: accounts.platform_prototype_virtuals_ata, - vpool_virtuals_ata: accounts.vpool_virtuals_ata, - token_program: accounts.token_program, - __args: args, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.user.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new(*self.vpool.key, false)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.user_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_prototype.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.platform_prototype_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.vpool_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let mut data = borsh::to_vec(&SellInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); - data.append(&mut args); - - let instruction = solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.user.clone()); - account_infos.push(self.vpool.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.user_virtuals_ata.clone()); - account_infos.push(self.user_token_ata.clone()); - account_infos.push(self.vpool_token_ata.clone()); - account_infos.push(self.platform_prototype.clone()); - account_infos.push(self.platform_prototype_virtuals_ata.clone()); - account_infos.push(self.vpool_virtuals_ata.clone()); - account_infos.push(self.token_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `Sell` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[signer]` user -/// 1. `[writable]` vpool -/// 2. `[]` token_mint -/// 3. `[writable]` user_virtuals_ata -/// 4. `[writable]` user_token_ata -/// 5. `[writable]` vpool_token_ata -/// 6. `[writable]` platform_prototype -/// 7. `[writable]` platform_prototype_virtuals_ata -/// 8. `[writable]` vpool_virtuals_ata -/// 9. `[]` token_program -#[derive(Clone, Debug)] -pub struct SellCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> SellCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(SellCpiBuilderInstruction { - __program: program, - user: None, - vpool: None, - token_mint: None, - user_virtuals_ata: None, - user_token_ata: None, - vpool_token_ata: None, - platform_prototype: None, - platform_prototype_virtuals_ata: None, - vpool_virtuals_ata: None, - token_program: None, - amount: None, - min_amount_out: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.user = Some(user); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn user_virtuals_ata( - &mut self, - user_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_virtuals_ata = Some(user_virtuals_ata); - self - } - - #[inline(always)] - pub fn user_token_ata( - &mut self, - user_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.user_token_ata = Some(user_token_ata); - self - } - - #[inline(always)] - pub fn vpool_token_ata( - &mut self, - vpool_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_token_ata = Some(vpool_token_ata); - self - } - - #[inline(always)] - pub fn platform_prototype( - &mut self, - platform_prototype: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_prototype = Some(platform_prototype); - self - } - - #[inline(always)] - pub fn platform_prototype_virtuals_ata( - &mut self, - platform_prototype_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.platform_prototype_virtuals_ata = Some(platform_prototype_virtuals_ata); - self - } - - #[inline(always)] - pub fn vpool_virtuals_ata( - &mut self, - vpool_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.vpool_virtuals_ata = Some(vpool_virtuals_ata); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); - self - } - - #[inline(always)] - pub fn min_amount_out(&mut self, min_amount_out: u64) -> &mut Self { - self.instruction.min_amount_out = Some(min_amount_out); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let args = SellInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), - min_amount_out: self - .instruction - .min_amount_out - .clone() - .expect("min_amount_out is not set"), - }; - let instruction = SellCpi { - __program: self.instruction.__program, - - user: self.instruction.user.expect("user is not set"), - - vpool: self.instruction.vpool.expect("vpool is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - user_virtuals_ata: self - .instruction - .user_virtuals_ata - .expect("user_virtuals_ata is not set"), - - user_token_ata: self - .instruction - .user_token_ata - .expect("user_token_ata is not set"), - - vpool_token_ata: self - .instruction - .vpool_token_ata - .expect("vpool_token_ata is not set"), - - platform_prototype: self - .instruction - .platform_prototype - .expect("platform_prototype is not set"), - - platform_prototype_virtuals_ata: self - .instruction - .platform_prototype_virtuals_ata - .expect("platform_prototype_virtuals_ata is not set"), - - vpool_virtuals_ata: self - .instruction - .vpool_virtuals_ata - .expect("vpool_virtuals_ata is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - __args: args, - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct SellCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - user: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - user_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - user_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_prototype: Option<&'b solana_account_info::AccountInfo<'a>>, - platform_prototype_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, - min_amount_out: Option, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/virtuals-parser/src/generated_sdk/instructions/update_pool_creator.rs b/crates/virtuals-parser/src/generated_sdk/instructions/update_pool_creator.rs deleted file mode 100644 index 5429b369..00000000 --- a/crates/virtuals-parser/src/generated_sdk/instructions/update_pool_creator.rs +++ /dev/null @@ -1,667 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -/// Accounts. -#[derive(Debug)] -pub struct UpdatePoolCreator { - pub creator: solana_pubkey::Pubkey, - - pub new_creator: solana_pubkey::Pubkey, - - pub virtuals_mint: solana_pubkey::Pubkey, - - pub token_mint: solana_pubkey::Pubkey, - - pub new_creator_virtuals_ata: solana_pubkey::Pubkey, - - pub new_creator_token_ata: solana_pubkey::Pubkey, - - pub vpool: solana_pubkey::Pubkey, - - pub token_program: solana_pubkey::Pubkey, - - pub associated_token_program: solana_pubkey::Pubkey, - - pub system_program: solana_pubkey::Pubkey, -} - -impl UpdatePoolCreator { - pub fn instruction(&self) -> solana_instruction::Instruction { - self.instruction_with_remaining_accounts(&[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::vec_init_then_push)] - pub fn instruction_with_remaining_accounts( - &self, - remaining_accounts: &[solana_instruction::AccountMeta], - ) -> solana_instruction::Instruction { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new(self.creator, true)); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.new_creator, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.virtuals_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_mint, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.new_creator_virtuals_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - self.new_creator_token_ata, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.vpool, false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.associated_token_program, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - self.system_program, - false, - )); - accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&UpdatePoolCreatorInstructionData::new()).unwrap(); - - solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - } - } -} - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct UpdatePoolCreatorInstructionData { - discriminator: [u8; 8], -} - -impl UpdatePoolCreatorInstructionData { - pub fn new() -> Self { - Self { - discriminator: [113, 225, 166, 185, 94, 231, 96, 28], - } - } -} - -impl Default for UpdatePoolCreatorInstructionData { - fn default() -> Self { Self::new() } -} - -/// Instruction builder for `UpdatePoolCreator`. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[]` new_creator -/// 2. `[optional]` virtuals_mint (default to `3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y`) -/// 3. `[]` token_mint -/// 4. `[writable]` new_creator_virtuals_ata -/// 5. `[writable]` new_creator_token_ata -/// 6. `[]` vpool -/// 7. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`) -/// 8. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`) -/// 9. `[optional]` system_program (default to `11111111111111111111111111111111`) -#[derive(Clone, Debug, Default)] -pub struct UpdatePoolCreatorBuilder { - creator: Option, - new_creator: Option, - virtuals_mint: Option, - token_mint: Option, - new_creator_virtuals_ata: Option, - new_creator_token_ata: Option, - vpool: Option, - token_program: Option, - associated_token_program: Option, - system_program: Option, - __remaining_accounts: Vec, -} - -impl UpdatePoolCreatorBuilder { - pub fn new() -> Self { Self::default() } - - #[inline(always)] - pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self { - self.creator = Some(creator); - self - } - - #[inline(always)] - pub fn new_creator(&mut self, new_creator: solana_pubkey::Pubkey) -> &mut Self { - self.new_creator = Some(new_creator); - self - } - - /// `[optional account, default to '3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y']` - #[inline(always)] - pub fn virtuals_mint(&mut self, virtuals_mint: solana_pubkey::Pubkey) -> &mut Self { - self.virtuals_mint = Some(virtuals_mint); - self - } - - #[inline(always)] - pub fn token_mint(&mut self, token_mint: solana_pubkey::Pubkey) -> &mut Self { - self.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn new_creator_virtuals_ata( - &mut self, - new_creator_virtuals_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.new_creator_virtuals_ata = Some(new_creator_virtuals_ata); - self - } - - #[inline(always)] - pub fn new_creator_token_ata( - &mut self, - new_creator_token_ata: solana_pubkey::Pubkey, - ) -> &mut Self { - self.new_creator_token_ata = Some(new_creator_token_ata); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: solana_pubkey::Pubkey) -> &mut Self { - self.vpool = Some(vpool); - self - } - - /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` - #[inline(always)] - pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self { - self.token_program = Some(token_program); - self - } - - /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: solana_pubkey::Pubkey, - ) -> &mut Self { - self.associated_token_program = Some(associated_token_program); - self - } - - /// `[optional account, default to '11111111111111111111111111111111']` - #[inline(always)] - pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self { - self.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { - self.__remaining_accounts.push(account); - self - } - - /// Add additional accounts to the instruction. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[solana_instruction::AccountMeta], - ) -> &mut Self { - self.__remaining_accounts.extend_from_slice(accounts); - self - } - - #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = UpdatePoolCreator { - creator: self.creator.expect("creator is not set"), - new_creator: self.new_creator.expect("new_creator is not set"), - virtuals_mint: self.virtuals_mint.unwrap_or(solana_pubkey::pubkey!( - "3iQL8BFS2vE7mww4ehAqQHAsbmRNCrPxizWAT2Zfyr9y" - )), - token_mint: self.token_mint.expect("token_mint is not set"), - new_creator_virtuals_ata: self - .new_creator_virtuals_ata - .expect("new_creator_virtuals_ata is not set"), - new_creator_token_ata: self - .new_creator_token_ata - .expect("new_creator_token_ata is not set"), - vpool: self.vpool.expect("vpool is not set"), - token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - )), - associated_token_program: self.associated_token_program.unwrap_or( - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), - ), - system_program: self - .system_program - .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")), - }; - - accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) - } -} - -/// `update_pool_creator` CPI accounts. -pub struct UpdatePoolCreatorCpiAccounts<'a, 'b> { - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub new_creator: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub new_creator_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub new_creator_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -/// `update_pool_creator` CPI instruction. -pub struct UpdatePoolCreatorCpi<'a, 'b> { - /// The program to invoke. - pub __program: &'b solana_account_info::AccountInfo<'a>, - - pub creator: &'b solana_account_info::AccountInfo<'a>, - - pub new_creator: &'b solana_account_info::AccountInfo<'a>, - - pub virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - - pub token_mint: &'b solana_account_info::AccountInfo<'a>, - - pub new_creator_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - - pub new_creator_token_ata: &'b solana_account_info::AccountInfo<'a>, - - pub vpool: &'b solana_account_info::AccountInfo<'a>, - - pub token_program: &'b solana_account_info::AccountInfo<'a>, - - pub associated_token_program: &'b solana_account_info::AccountInfo<'a>, - - pub system_program: &'b solana_account_info::AccountInfo<'a>, -} - -impl<'a, 'b> UpdatePoolCreatorCpi<'a, 'b> { - pub fn new( - program: &'b solana_account_info::AccountInfo<'a>, - accounts: UpdatePoolCreatorCpiAccounts<'a, 'b>, - ) -> Self { - Self { - __program: program, - creator: accounts.creator, - new_creator: accounts.new_creator, - virtuals_mint: accounts.virtuals_mint, - token_mint: accounts.token_mint, - new_creator_virtuals_ata: accounts.new_creator_virtuals_ata, - new_creator_token_ata: accounts.new_creator_token_ata, - vpool: accounts.vpool, - token_program: accounts.token_program, - associated_token_program: accounts.associated_token_program, - system_program: accounts.system_program, - } - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], &[]) - } - - #[inline(always)] - pub fn invoke_with_remaining_accounts( - &self, - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) - } - - #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) - } - - #[allow(clippy::arithmetic_side_effects)] - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed_with_remaining_accounts( - &self, - signers_seeds: &[&[&[u8]]], - remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> solana_program_entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); - accounts.push(solana_instruction::AccountMeta::new( - *self.creator.key, - true, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.new_creator.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.virtuals_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_mint.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.new_creator_virtuals_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new( - *self.new_creator_token_ata.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.vpool.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.associated_token_program.key, - false, - )); - accounts.push(solana_instruction::AccountMeta::new_readonly( - *self.system_program.key, - false, - )); - remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_instruction::AccountMeta { - pubkey: *remaining_account.0.key, - is_signer: remaining_account.1, - is_writable: remaining_account.2, - }) - }); - let data = borsh::to_vec(&UpdatePoolCreatorInstructionData::new()).unwrap(); - - let instruction = solana_instruction::Instruction { - program_id: crate::VIRTUALS_PROGRAM_ID, - accounts, - data, - }; - let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len()); - account_infos.push(self.__program.clone()); - account_infos.push(self.creator.clone()); - account_infos.push(self.new_creator.clone()); - account_infos.push(self.virtuals_mint.clone()); - account_infos.push(self.token_mint.clone()); - account_infos.push(self.new_creator_virtuals_ata.clone()); - account_infos.push(self.new_creator_token_ata.clone()); - account_infos.push(self.vpool.clone()); - account_infos.push(self.token_program.clone()); - account_infos.push(self.associated_token_program.clone()); - account_infos.push(self.system_program.clone()); - remaining_accounts - .iter() - .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); - - if signers_seeds.is_empty() { - solana_cpi::invoke(&instruction, &account_infos) - } else { - solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) - } - } -} - -/// Instruction builder for `UpdatePoolCreator` via CPI. -/// -/// ### Accounts: -/// -/// 0. `[writable, signer]` creator -/// 1. `[]` new_creator -/// 2. `[]` virtuals_mint -/// 3. `[]` token_mint -/// 4. `[writable]` new_creator_virtuals_ata -/// 5. `[writable]` new_creator_token_ata -/// 6. `[]` vpool -/// 7. `[]` token_program -/// 8. `[]` associated_token_program -/// 9. `[]` system_program -#[derive(Clone, Debug)] -pub struct UpdatePoolCreatorCpiBuilder<'a, 'b> { - instruction: Box>, -} - -impl<'a, 'b> UpdatePoolCreatorCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(UpdatePoolCreatorCpiBuilderInstruction { - __program: program, - creator: None, - new_creator: None, - virtuals_mint: None, - token_mint: None, - new_creator_virtuals_ata: None, - new_creator_token_ata: None, - vpool: None, - token_program: None, - associated_token_program: None, - system_program: None, - __remaining_accounts: Vec::new(), - }); - Self { instruction } - } - - #[inline(always)] - pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.creator = Some(creator); - self - } - - #[inline(always)] - pub fn new_creator( - &mut self, - new_creator: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_creator = Some(new_creator); - self - } - - #[inline(always)] - pub fn virtuals_mint( - &mut self, - virtuals_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.virtuals_mint = Some(virtuals_mint); - self - } - - #[inline(always)] - pub fn token_mint( - &mut self, - token_mint: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_mint = Some(token_mint); - self - } - - #[inline(always)] - pub fn new_creator_virtuals_ata( - &mut self, - new_creator_virtuals_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_creator_virtuals_ata = Some(new_creator_virtuals_ata); - self - } - - #[inline(always)] - pub fn new_creator_token_ata( - &mut self, - new_creator_token_ata: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.new_creator_token_ata = Some(new_creator_token_ata); - self - } - - #[inline(always)] - pub fn vpool(&mut self, vpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vpool = Some(vpool); - self - } - - #[inline(always)] - pub fn token_program( - &mut self, - token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.token_program = Some(token_program); - self - } - - #[inline(always)] - pub fn associated_token_program( - &mut self, - associated_token_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.associated_token_program = Some(associated_token_program); - self - } - - #[inline(always)] - pub fn system_program( - &mut self, - system_program: &'b solana_account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.system_program = Some(system_program); - self - } - - /// Add an additional account to the instruction. - #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: &'b solana_account_info::AccountInfo<'a>, - is_writable: bool, - is_signer: bool, - ) -> &mut Self { - self.instruction - .__remaining_accounts - .push((account, is_writable, is_signer)); - self - } - - /// Add additional accounts to the instruction. - /// - /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, - /// and a `bool` indicating whether the account is a signer or not. - #[inline(always)] - pub fn add_remaining_accounts( - &mut self, - accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], - ) -> &mut Self { - self.instruction - .__remaining_accounts - .extend_from_slice(accounts); - self - } - - #[inline(always)] - pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult { self.invoke_signed(&[]) } - - #[allow(clippy::clone_on_copy)] - #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program_entrypoint::ProgramResult { - let instruction = UpdatePoolCreatorCpi { - __program: self.instruction.__program, - - creator: self.instruction.creator.expect("creator is not set"), - - new_creator: self - .instruction - .new_creator - .expect("new_creator is not set"), - - virtuals_mint: self - .instruction - .virtuals_mint - .expect("virtuals_mint is not set"), - - token_mint: self.instruction.token_mint.expect("token_mint is not set"), - - new_creator_virtuals_ata: self - .instruction - .new_creator_virtuals_ata - .expect("new_creator_virtuals_ata is not set"), - - new_creator_token_ata: self - .instruction - .new_creator_token_ata - .expect("new_creator_token_ata is not set"), - - vpool: self.instruction.vpool.expect("vpool is not set"), - - token_program: self - .instruction - .token_program - .expect("token_program is not set"), - - associated_token_program: self - .instruction - .associated_token_program - .expect("associated_token_program is not set"), - - system_program: self - .instruction - .system_program - .expect("system_program is not set"), - }; - instruction.invoke_signed_with_remaining_accounts( - signers_seeds, - &self.instruction.__remaining_accounts, - ) - } -} - -#[derive(Clone, Debug)] -struct UpdatePoolCreatorCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_account_info::AccountInfo<'a>, - creator: Option<&'b solana_account_info::AccountInfo<'a>>, - new_creator: Option<&'b solana_account_info::AccountInfo<'a>>, - virtuals_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - token_mint: Option<&'b solana_account_info::AccountInfo<'a>>, - new_creator_virtuals_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - new_creator_token_ata: Option<&'b solana_account_info::AccountInfo<'a>>, - vpool: Option<&'b solana_account_info::AccountInfo<'a>>, - token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>, - system_program: Option<&'b solana_account_info::AccountInfo<'a>>, - /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, -} diff --git a/crates/virtuals-parser/src/generated_sdk/mod.rs b/crates/virtuals-parser/src/generated_sdk/mod.rs deleted file mode 100644 index e0d740ad..00000000 --- a/crates/virtuals-parser/src/generated_sdk/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub mod accounts; -pub mod errors; -pub mod instructions; -pub mod programs; -pub mod shared; -pub mod types; - -pub(crate) use programs::*; diff --git a/crates/virtuals-parser/src/generated_sdk/programs.rs b/crates/virtuals-parser/src/generated_sdk/programs.rs deleted file mode 100644 index 9a43703e..00000000 --- a/crates/virtuals-parser/src/generated_sdk/programs.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use solana_pubkey::{pubkey, Pubkey}; - -/// `virtuals_program` program ID. -pub const VIRTUALS_PROGRAM_ID: Pubkey = pubkey!("5U3EU2ubXtK84QcRjWVmYt9RaDyA8gKxdUrPFXmZyaki"); diff --git a/crates/virtuals-parser/src/generated_sdk/shared.rs b/crates/virtuals-parser/src/generated_sdk/shared.rs deleted file mode 100644 index 71b906d0..00000000 --- a/crates/virtuals-parser/src/generated_sdk/shared.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub struct DecodedAccount { - pub address: solana_pubkey::Pubkey, - pub account: solana_account::Account, - pub data: T, -} - -#[cfg(feature = "fetch")] -#[derive(Debug, Clone)] -pub enum MaybeAccount { - Exists(DecodedAccount), - NotFound(solana_pubkey::Pubkey), -} diff --git a/crates/virtuals-parser/src/generated_sdk/types/buy_event.rs b/crates/virtuals-parser/src/generated_sdk/types/buy_event.rs deleted file mode 100644 index 5134cefb..00000000 --- a/crates/virtuals-parser/src/generated_sdk/types/buy_event.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct BuyEvent { - pub buy_amount: u64, - pub virtuals_amount: u64, -} diff --git a/crates/virtuals-parser/src/generated_sdk/types/graduation_event.rs b/crates/virtuals-parser/src/generated_sdk/types/graduation_event.rs deleted file mode 100644 index 178a8446..00000000 --- a/crates/virtuals-parser/src/generated_sdk/types/graduation_event.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct GraduationEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vpool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - pub balance: u64, -} diff --git a/crates/virtuals-parser/src/generated_sdk/types/launch_event.rs b/crates/virtuals-parser/src/generated_sdk/types/launch_event.rs deleted file mode 100644 index 260781e1..00000000 --- a/crates/virtuals-parser/src/generated_sdk/types/launch_event.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use solana_pubkey::Pubkey; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LaunchEvent { - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub vpool: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub mint: Pubkey, - #[cfg_attr( - feature = "serde", - serde(with = "serde_with::As::") - )] - pub creator: Pubkey, -} diff --git a/crates/virtuals-parser/src/generated_sdk/types/mod.rs b/crates/virtuals-parser/src/generated_sdk/types/mod.rs deleted file mode 100644 index 0101143f..00000000 --- a/crates/virtuals-parser/src/generated_sdk/types/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -pub(crate) mod r#buy_event; -pub(crate) mod r#graduation_event; -pub(crate) mod r#launch_event; -pub(crate) mod r#pool_state; -pub(crate) mod r#sell_event; - -pub use self::{ - r#buy_event::*, r#graduation_event::*, r#launch_event::*, r#pool_state::*, r#sell_event::*, -}; diff --git a/crates/virtuals-parser/src/generated_sdk/types/pool_state.rs b/crates/virtuals-parser/src/generated_sdk/types/pool_state.rs deleted file mode 100644 index 7abd0180..00000000 --- a/crates/virtuals-parser/src/generated_sdk/types/pool_state.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; -use num_derive::FromPrimitive; - -#[derive( - BorshSerialize, - BorshDeserialize, - Clone, - Debug, - Eq, - PartialEq, - Copy, - PartialOrd, - Hash, - FromPrimitive, -)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum PoolState { - Initialized, - Active, - Graduated, - Migrated, -} diff --git a/crates/virtuals-parser/src/generated_sdk/types/sell_event.rs b/crates/virtuals-parser/src/generated_sdk/types/sell_event.rs deleted file mode 100644 index 0f08f0f0..00000000 --- a/crates/virtuals-parser/src/generated_sdk/types/sell_event.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This code was AUTOGENERATED using the codama library. -//! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun codama to update it. -//! -//! -//! - -use borsh::{BorshDeserialize, BorshSerialize}; - -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct SellEvent { - pub sell_amount: u64, - pub virtuals_amount: u64, -} diff --git a/crates/virtuals-parser/src/lib.rs b/crates/virtuals-parser/src/lib.rs deleted file mode 100644 index 1876f730..00000000 --- a/crates/virtuals-parser/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod generated_parser; -mod generated_sdk; -pub use generated::*; -pub use generated_parser::*; -use generated_sdk as generated; -use solana_pubkey::Pubkey; - -pub const ID: Pubkey = VIRTUALS_PROGRAM_ID; - -// #[cfg(feature = "proto")] -pub mod proto_def { - #![allow(clippy::large_enum_variant)] - - tonic::include_proto!("vixen.parser.virtuals"); - - pub const DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor"); -} diff --git a/examples/filtered-pipeline/Cargo.toml b/examples/filtered-pipeline/Cargo.toml index 640eb9d9..67ee95ea 100644 --- a/examples/filtered-pipeline/Cargo.toml +++ b/examples/filtered-pipeline/Cargo.toml @@ -7,14 +7,12 @@ license = "MIT" repository = "https://github.com/rpcpool/yellowstone-vixen" [dependencies] -clap = { version = "4.5.4", features = ["derive", "cargo", "wrap_help"] } -toml = "0.8.12" -tracing = "0.1.40" +clap = { workspace = true, features = ["derive", "cargo", "wrap_help"] } +toml = { workspace = true } +tracing = { workspace = true } +rustls = { workspace = true } yellowstone-vixen = { workspace = true } -yellowstone-vixen-raydium-amm-v4-parser = { workspace = true, features = [ - "shared-data", -] } -yellowstone-vixen-meteora-amm-parser = { workspace = true } +yellowstone-vixen-spl-token-parser = { workspace = true } yellowstone-vixen-yellowstone-grpc-source = { workspace = true } yellowstone-vixen-solana-rpc-source = { workspace = true } diff --git a/examples/filtered-pipeline/src/main.rs b/examples/filtered-pipeline/src/main.rs index 77bfb87d..7fb5703b 100644 --- a/examples/filtered-pipeline/src/main.rs +++ b/examples/filtered-pipeline/src/main.rs @@ -14,12 +14,8 @@ use yellowstone_vixen::{ self as vixen, filter_pipeline::FilterPipeline, vixen_core::{Prefilter, Pubkey}, - Pipeline, -}; -use yellowstone_vixen_raydium_amm_v4_parser::{ - accounts_parser::AccountParser as RaydiumAmmV4AccParser, - instructions_parser::InstructionParser as RaydiumAmmV4IxParser, }; +use yellowstone_vixen_spl_token_parser::InstructionParser; use yellowstone_vixen_yellowstone_grpc_source::YellowstoneGrpcSource; #[derive(clap::Parser)] @@ -33,31 +29,28 @@ pub struct Opts { pub struct Logger; impl vixen::Handler for Logger { - async fn handle(&self, _value: &V, _raw: &R) -> vixen::HandlerResult<()> { Ok(()) } + async fn handle(&self, value: &V, _raw: &R) -> vixen::HandlerResult<()> { + println!("{value:?}"); + Ok(()) + } } fn main() { + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .expect("Fialed to install rustls crypto provider"); + let Opts { config } = Opts::parse(); let config = std::fs::read_to_string(config).expect("Error reading config file"); let config = toml::from_str(&config).expect("Error parsing config"); vixen::Runtime::::builder() - .account(Pipeline::new(RaydiumAmmV4AccParser, [Logger])) - .instruction(Pipeline::new( - yellowstone_vixen_meteora_amm_parser::instructions_parser::InstructionParser, - [Logger], - )) .instruction(FilterPipeline::new( - RaydiumAmmV4IxParser, + InstructionParser, [Logger], - Prefilter::builder() - .transaction_accounts_include([ - Pubkey::from_str("GH8Ers4yzKR3UKDvgVu8cqJfGzU4cU62mTeg9bcJ7ug6").unwrap(), - Pubkey::from_str("4xxM4cdb6MEsCxM52xvYqkNbzvdeWWsPDZrBcTqVGUar").unwrap(), - ]) - .transaction_accounts([Pubkey::from_str( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - ) - .unwrap()]), + Prefilter::builder().transaction_accounts_include([Pubkey::from_str( + "So11111111111111111111111111111111111111112", + ) + .unwrap()]), )) .build(config) .run(); diff --git a/examples/prometheus/Cargo.toml b/examples/prometheus/Cargo.toml index acd268da..760b84b9 100644 --- a/examples/prometheus/Cargo.toml +++ b/examples/prometheus/Cargo.toml @@ -13,5 +13,11 @@ tracing = "0.1.40" yellowstone-vixen = { workspace = true, features = ["prometheus"] } prometheus = { version = "0.14.0", features = ["push"] } tokio = { version = "1.39.3", features = ["rt", "rt-multi-thread"] } -yellowstone-vixen-parser = { workspace = true, features = ["token-program"] } +yellowstone-vixen-parser = { workspace = true } +yellowstone-vixen-proc-macro = { workspace = true } +borsh = { workspace = true, features = ["derive"] } yellowstone-vixen-yellowstone-grpc-source = { workspace = true } +yellowstone-vixen-spl-token-parser = { workspace = true } +yellowstone-vixen-spl-token-extensions-parser = { workspace = true } +rustls = { workspace = true } +prost = { workspace = true, features = ["derive"] } diff --git a/examples/prometheus/src/main.rs b/examples/prometheus/src/main.rs index f99544f4..17c9353a 100644 --- a/examples/prometheus/src/main.rs +++ b/examples/prometheus/src/main.rs @@ -11,7 +11,7 @@ use std::{path::PathBuf, time::Duration}; use clap::Parser; use yellowstone_vixen::Pipeline; -use yellowstone_vixen_parser::token_program::{AccountParser, InstructionParser}; +use yellowstone_vixen_spl_token_parser::{AccountParser, InstructionParser}; use yellowstone_vixen_yellowstone_grpc_source::YellowstoneGrpcSource; #[derive(clap::Parser)] @@ -25,11 +25,18 @@ pub struct Opts { pub struct Logger; impl yellowstone_vixen::Handler for Logger { - async fn handle(&self, _value: &V, _raw: &R) -> yellowstone_vixen::HandlerResult<()> { Ok(()) } + async fn handle(&self, value: &V, _raw: &R) -> yellowstone_vixen::HandlerResult<()> { + println!("{value:?}"); + Ok(()) + } } #[tokio::main] async fn main() { + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .expect("Fialed to install rustls crypto provider"); + let Opts { config } = Opts::parse(); let config = std::fs::read_to_string(config).expect("Error reading config file"); let config = toml::from_str(&config).expect("Error parsing config"); diff --git a/examples/stream/Cargo.toml b/examples/stream/Cargo.toml deleted file mode 100644 index 75466690..00000000 --- a/examples/stream/Cargo.toml +++ /dev/null @@ -1,37 +0,0 @@ -[package] -name = "yellowstone-vixen-example-stream" -description = "Test bed for integrating yellowstone-vixen-parser with Vixen program streams" -publish = false -edition.workspace = true -license = "MIT" -repository = "https://github.com/rpcpool/yellowstone-vixen" - -[dependencies] -clap = { version = "4.5.4", features = ["derive", "cargo", "wrap_help"] } -toml = "0.8.12" -tracing = "0.1.40" -tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } -yellowstone-vixen = { workspace = true } -yellowstone-vixen-proto = { workspace = true } -yellowstone-vixen-stream = { workspace = true } -yellowstone-vixen-parser = { workspace = true, features = [ - "proto", - "token-extensions", - "token-program", -] } -yellowstone-vixen-yellowstone-grpc-source = { workspace = true } - -yellowstone-vixen-meteora-parser = { workspace = true } -yellowstone-vixen-pumpfun-parser = { workspace = true } -yellowstone-vixen-jupiter-swap-parser = { workspace = true } -yellowstone-vixen-meteora-amm-parser = { workspace = true } -yellowstone-vixen-moonshot-parser = { workspace = true } -yellowstone-vixen-orca-whirlpool-parser = { workspace = true } -yellowstone-vixen-raydium-cpmm-parser = { workspace = true } -yellowstone-vixen-pump-swaps-parser = { workspace = true } -yellowstone-vixen-raydium-amm-v4-parser = { workspace = true } -yellowstone-vixen-raydium-clmm-parser = { workspace = true } -yellowstone-vixen-kamino-limit-orders-parser = { workspace = true } - -[build-dependencies] -prost-build = "0.13.1" diff --git a/examples/stream/README.md b/examples/stream/README.md deleted file mode 100644 index 05221cce..00000000 --- a/examples/stream/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# Vixen Stream Example - -This example shows how vixen-streams operates. It starts a gRPC server that provides a continuous stream of parsed account and transaction updates. - -To run the example, navigate to [`examples/stream-parser`](/examples/stream-parser/) and execute the following command: - -### Server - -```bash -RUST_LOG=info cargo run -- --config "$(pwd)/../../Vixen.toml" -``` - -### Client - -To list all available services, execute the following command - -```bash -grpcurl -plaintext 127.0.0.1:3030 list -``` - -To introspect the program stream service, execute the following command - -```bash -grpcurl -plaintext 127.0.0.1:3030 describe vixen.stream.ProgramStreams.Subscribe -``` - -To subcribe to the stream and receive parsed accounts and ixs, execute the following command - -```bash -# Subscribing to Token extension program stream (replace this pubkey with the desired program pubkey that is supported by vixen) -grpcurl -plaintext -d '{"program": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"}' 127.0.0.1:3030 vixen.stream.ProgramStreams/Subscribe -``` - -This example is using Token extensions program to parse Account updates. -replace this with other program pubkeys that are supported by vixen. diff --git a/examples/stream/src/main.rs b/examples/stream/src/main.rs deleted file mode 100644 index 651ce7f3..00000000 --- a/examples/stream/src/main.rs +++ /dev/null @@ -1,139 +0,0 @@ -#![deny( - clippy::disallowed_methods, - clippy::suspicious, - clippy::style, - clippy::clone_on_ref_ptr -)] -#![warn(clippy::pedantic)] -#![allow(clippy::module_name_repetitions)] - -use std::path::PathBuf; - -use clap::Parser as _; -use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; -use yellowstone_vixen::vixen_core::proto::Proto; -use yellowstone_vixen_jupiter_swap_parser::{ - accounts_parser::AccountParser as JupiterSwapAccParser, - instructions_parser::InstructionParser as JupiterSwapIxParser, - proto_def::DESCRIPTOR_SET as JUPITER_SWAP_DESCRIPTOR_SET, -}; -use yellowstone_vixen_kamino_limit_orders_parser::{ - accounts_parser::AccountParser as KaminoLimitOrdersAccParser, - instructions_parser::InstructionParser as KaminoLimitOrdersIxParser, - proto_def::DESCRIPTOR_SET as KAMINO_LIMIT_ORDERS_DESCRIPTOR_SET, -}; -use yellowstone_vixen_meteora_amm_parser::{ - accounts_parser::AccountParser as MeteoraAmmAccParser, - instructions_parser::InstructionParser as MeteoraAmmIxParser, - proto_def::DESCRIPTOR_SET as METEORA_AMM_DESCRIPTOR_SET, -}; -use yellowstone_vixen_meteora_parser::{ - accounts_parser::AccountParser as MeteoraAccParser, - instructions_parser::InstructionParser as MeteoraIxParser, - proto_def::DESCRIPTOR_SET as METEORA_DESCRIPTOR_SET, -}; -use yellowstone_vixen_moonshot_parser::{ - accounts_parser::AccountParser as MoonshotAccParser, - instructions_parser::InstructionParser as MoonshotIxParser, - proto_def::DESCRIPTOR_SET as MOONSHOT_DESCRIPTOR_SET, -}; -use yellowstone_vixen_orca_whirlpool_parser::{ - accounts_parser::AccountParser as OrcaWhirlpoolAccParser, - instructions_parser::InstructionParser as OrcaWhirlpoolIxParser, - proto_def::DESCRIPTOR_SET as ORCA_WHIRLPOOL_DESCRIPTOR_SET, -}; -use yellowstone_vixen_parser::{ - token_extension_program::{ - AccountParser as TokenExtensionProgramAccParser, - InstructionParser as TokenExtensionProgramIxParser, - }, - token_program::{ - AccountParser as TokenProgramAccParser, InstructionParser as TokenProgramIxParser, - }, -}; -use yellowstone_vixen_proto::parser; -use yellowstone_vixen_pump_swaps_parser::{ - accounts_parser::AccountParser as PumpAmmAccParser, - instructions_parser::InstructionParser as PumpAmmIxParser, - proto_def::DESCRIPTOR_SET as PUMP_AMM_DESCRIPTOR_SET, -}; -use yellowstone_vixen_pumpfun_parser::{ - accounts_parser::AccountParser as PumpfunAccParser, - instructions_parser::InstructionParser as PumpfunIxParser, - proto_def::DESCRIPTOR_SET as PUMP_DESCRIPTOR_SET, -}; -use yellowstone_vixen_raydium_amm_v4_parser::{ - accounts_parser::AccountParser as RaydiumAmmV4AccParser, - proto_def::DESCRIPTOR_SET as RAYDIUM_AMM_V4_DESCRIPTOR_SET, -}; -use yellowstone_vixen_raydium_clmm_parser::{ - accounts_parser::AccountParser as RaydiumClmmAccParser, - instructions_parser::InstructionParser as RaydiumClmmIxParser, - proto_def::DESCRIPTOR_SET as RAYDIUM_CLMM_DESCRIPTOR_SET, -}; -use yellowstone_vixen_raydium_cpmm_parser::{ - accounts_parser::AccountParser as RaydiumCpmmAccParser, - instructions_parser::InstructionParser as RaydiumCpmmIxParser, - proto_def::DESCRIPTOR_SET as RAYDIUM_CPMM_DESCRIPTOR_SET, -}; -use yellowstone_vixen_yellowstone_grpc_source::YellowstoneGrpcSource; - -#[derive(clap::Parser)] -#[command(version, author, about)] -pub struct Opts { - #[arg(long, short)] - config: PathBuf, -} - -fn main() { - tracing_subscriber::registry() - .with(tracing_subscriber::EnvFilter::from_default_env()) - .with(tracing_subscriber::fmt::layer()) - .init(); - - let Opts { config } = Opts::parse(); - let config = std::fs::read_to_string(config).expect("Error reading config file"); - let config = toml::from_str(&config).expect("Error parsing config"); - - yellowstone_vixen_stream::Server::::builder() - .descriptor_set(parser::token::DESCRIPTOR_SET) - .descriptor_set(parser::token_extensions::DESCRIPTOR_SET) - .descriptor_set(METEORA_DESCRIPTOR_SET) - .descriptor_set(PUMP_DESCRIPTOR_SET) - .descriptor_set(JUPITER_SWAP_DESCRIPTOR_SET) - .descriptor_set(PUMP_AMM_DESCRIPTOR_SET) - .descriptor_set(RAYDIUM_CPMM_DESCRIPTOR_SET) - .descriptor_set(ORCA_WHIRLPOOL_DESCRIPTOR_SET) - .descriptor_set(MOONSHOT_DESCRIPTOR_SET) - .descriptor_set(METEORA_AMM_DESCRIPTOR_SET) - .descriptor_set(RAYDIUM_AMM_V4_DESCRIPTOR_SET) - .descriptor_set(RAYDIUM_CLMM_DESCRIPTOR_SET) - .descriptor_set(KAMINO_LIMIT_ORDERS_DESCRIPTOR_SET) - .account(Proto::new(MeteoraAccParser)) - .account(Proto::new(PumpfunAccParser)) - .account(Proto::new(TokenExtensionProgramAccParser)) - .account(Proto::new(TokenProgramAccParser)) - .account(Proto::new(JupiterSwapAccParser)) - .account(Proto::new(PumpAmmAccParser)) - .account(Proto::new(RaydiumCpmmAccParser)) - .account(Proto::new(OrcaWhirlpoolAccParser)) - .account(Proto::new(MoonshotAccParser)) - .account(Proto::new(MeteoraAmmAccParser)) - .account(Proto::new(RaydiumAmmV4AccParser)) - .account(Proto::new(RaydiumClmmAccParser)) - .account(Proto::new(KaminoLimitOrdersAccParser)) - .instruction(Proto::new(MeteoraIxParser)) - .instruction(Proto::new(PumpfunIxParser)) - .instruction(Proto::new(TokenProgramIxParser)) - .instruction(Proto::new(TokenExtensionProgramIxParser)) - .instruction(Proto::new(JupiterSwapIxParser)) - .instruction(Proto::new(PumpAmmIxParser)) - .instruction(Proto::new(RaydiumCpmmIxParser)) - .instruction(Proto::new(OrcaWhirlpoolIxParser)) - .instruction(Proto::new(MoonshotIxParser)) - .instruction(Proto::new(MeteoraAmmIxParser)) - .instruction(Proto::new(RaydiumClmmIxParser)) - .instruction(Proto::new(KaminoLimitOrdersIxParser)) - .build(config) - .run(); -} diff --git a/examples/tracing/Cargo.toml b/examples/tracing/Cargo.toml index 3b8f6ed2..f7290d16 100644 --- a/examples/tracing/Cargo.toml +++ b/examples/tracing/Cargo.toml @@ -12,7 +12,11 @@ toml = "0.8.12" tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } yellowstone-vixen = { workspace = true } -yellowstone-vixen-parser = { workspace = true, features = ["token-program"] } +rustls = { workspace = true } +tracing-opentelemetry = "0.30.0" +opentelemetry-appender-tracing = "0.29.0" +tokio = { version = "1.39.3", features = ["rt", "rt-multi-thread"] } +yellowstone-vixen-spl-token-parser = { workspace = true } # OTEL opentelemetry = "0.29.1" @@ -30,9 +34,6 @@ opentelemetry-otlp = { version = "0.29.0", features = [ ] } opentelemetry-stdout = "0.29.0" -tracing-opentelemetry = "0.30.0" -opentelemetry-appender-tracing = "0.29.0" -tokio = { version = "1.39.3", features = ["rt", "rt-multi-thread"] } # Sources yellowstone-vixen-yellowstone-grpc-source = { workspace = true } diff --git a/examples/tracing/src/main.rs b/examples/tracing/src/main.rs index ca4359e5..82961104 100644 --- a/examples/tracing/src/main.rs +++ b/examples/tracing/src/main.rs @@ -13,7 +13,7 @@ use clap::Parser as _; use opentelemetry::trace::TracerProvider; use tracing_subscriber::layer::SubscriberExt; use yellowstone_vixen::{Handler, HandlerResult, Pipeline, Runtime}; -use yellowstone_vixen_parser::token_program::{AccountParser, InstructionParser}; +use yellowstone_vixen_spl_token_parser::{AccountParser, InstructionParser}; use yellowstone_vixen_yellowstone_grpc_source::YellowstoneGrpcSource; #[derive(clap::Parser)] @@ -27,12 +27,19 @@ pub struct Opts { pub struct Logger; impl Handler for Logger { - async fn handle(&self, _value: &V, _raw: &R) -> HandlerResult<()> { Ok(()) } + async fn handle(&self, value: &V, _raw: &R) -> HandlerResult<()> { + println!("{value:?}"); + Ok(()) + } } #[rustfmt::skip] #[allow(clippy::too_many_lines)] fn main() { + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .expect("Fialed to install rustls crypto provider"); + let span_exporter = opentelemetry_otlp::SpanExporter::builder() .with_tonic() .build() @@ -81,8 +88,8 @@ fn main() { let config = toml::from_str(&config).expect("Error parsing config"); Runtime::::builder() - .instruction(Pipeline::new(InstructionParser, [Logger])) .account(Pipeline::new(AccountParser, [Logger])) + .instruction(Pipeline::new(InstructionParser, [Logger])) .build(config) .run(); } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c4d27007..2dc0dae3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.89.0" +channel = "1.90.0" components = ["rustfmt", "clippy"] targets = [] profile = "minimal"